You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Alexandr Antonenko <hi...@gmail.com> on 2014/04/09 19:10:26 UTC

Review Request 20171: Karma integration.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/20171/
-----------------------------------------------------------

Review request for Ambari and Oleg Nechiporenko.


Bugs: AMBARI-5411
    https://issues.apache.org/jira/browse/AMBARI-5411


Repository: ambari


Description
-------

Add [Karma|http://karma-runner.github.io/0.12/index.html] as additional tool for running FE tests. Karma provides great functionality and powered with a lot of useful plugins. It can improve testing experience and prevent bugs appearing before pushing your changes to git repository.

h2. Setup

First of all there are no changes to testing with *mocha-phantomjs* and additional packages doesn't break any compatibility with dev and build tools.  
You need *node.js* >= 0.10. I recommend to install node.js by [nvm|https://github.com/creationix/nvm](Unix only).
Install required packages. Run after patch applying:
{noformat}$ npm install {noformat}
Now you have installed Karma in *node_modules/* folder. If you want to install Karma globally run:
{noformat}$ npm i -g karma@0.11.14{noformat}
Run karma from *project_root/ambari-web/* folder:
{noformat}
# for locally installed Karma
$ node_modules/karma/bin/karma start

# for globally installed Karma
$ karma start
{noformat}

This command will run karma server on http://localhost:9876 and repeat tests while files changing.
PhantomJS is default browser for running, but you can open http://localhost:9876 in any browser which will run tests also. 

To generate coverage summary edit *project_root/ambari-web/karma.conf.js*:
{noformat}
...
preprocessors: {
     '!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage', // uncomment this line
      'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
      'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
      'test/**/*.js': ['common-require']
    },
....
reporters: ['progress','coverage']
{noformat}
Look to *project_root/ambari-web/public/coverage/*. You can setup custom path in #coverageReporter config property.

If you have problems with PhantomJS disconnecting, install it from [download page|http://phantomjs.org/download.html] and set shell variable *PHANTOMJS_BIN* with path to executable file (by default is */usr/bin/phantomjs*). You can add this variable to your shell profile file, or make it session only by: {noformat}$ export PHANTOMJS_BIN=/usr/bin/phantomjs{noformat}

h3. Windows Setup

Tested with node.js v 0.10.20
You need to install, if not installed:
- [Visual C++|http://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express]
- [Python 2.6|https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi]
- [Node.js|http://nodejs.org/download/]

h2. Karma plugin for Intellij Platform IDE

Install plugin from ??File -> Settings -> IDE Settings -> Plugins??.
After IDE restart go to ??Run -> Edit Configuration??. 
Add configuration: press *plus* button, select *Karma*. Now fill inputs with path to: *Node.js interpreter*, *Karma node package* and *Configuration file* it should be *project_root/ambari-web/karma.conf.js*.
After setup you can run karma from *Debug panel* and you will see progress in *4: Run* tab. You can set *Auto-test* by pressing ??Toggle auto-test?? button.


Diffs
-----

  ambari-web/app/assets/test/karma_setup.js PRE-CREATION 
  ambari-web/karma.conf.js PRE-CREATION 
  ambari-web/package.json 572e1cb 
  ambari-web/test/installer/step5_test.js a672900 

Diff: https://reviews.apache.org/r/20171/diff/


Testing
-------


Thanks,

Alexandr Antonenko


Re: Review Request 20171: Karma integration.

Posted by Oleg Nechiporenko <on...@apache.org>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/20171/#review39903
-----------------------------------------------------------

Ship it!


Ship It!

- Oleg Nechiporenko


On April 9, 2014, 5:10 p.m., Alexandr Antonenko wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/20171/
> -----------------------------------------------------------
> 
> (Updated April 9, 2014, 5:10 p.m.)
> 
> 
> Review request for Ambari and Oleg Nechiporenko.
> 
> 
> Bugs: AMBARI-5411
>     https://issues.apache.org/jira/browse/AMBARI-5411
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Add [Karma|http://karma-runner.github.io/0.12/index.html] as additional tool for running FE tests. Karma provides great functionality and powered with a lot of useful plugins. It can improve testing experience and prevent bugs appearing before pushing your changes to git repository.
> 
> h2. Setup
> 
> First of all there are no changes to testing with *mocha-phantomjs* and additional packages doesn't break any compatibility with dev and build tools.  
> You need *node.js* >= 0.10. I recommend to install node.js by [nvm|https://github.com/creationix/nvm](Unix only).
> Install required packages. Run after patch applying:
> {noformat}$ npm install {noformat}
> Now you have installed Karma in *node_modules/* folder. If you want to install Karma globally run:
> {noformat}$ npm i -g karma@0.11.14{noformat}
> Run karma from *project_root/ambari-web/* folder:
> {noformat}
> # for locally installed Karma
> $ node_modules/karma/bin/karma start
> 
> # for globally installed Karma
> $ karma start
> {noformat}
> 
> This command will run karma server on http://localhost:9876 and repeat tests while files changing.
> PhantomJS is default browser for running, but you can open http://localhost:9876 in any browser which will run tests also. 
> 
> To generate coverage summary edit *project_root/ambari-web/karma.conf.js*:
> {noformat}
> ...
> preprocessors: {
>      '!(vendor|node_modules|test)/**/!(karma_setup|tests).js': 'coverage', // uncomment this line
>       'app/templates/**/*.hbs': ['ember-precompiler-brunch', 'common-require'],
>       'app!(assets)/**/!(karma_setup|tests).js': ['common-require'],
>       'test/**/*.js': ['common-require']
>     },
> ....
> reporters: ['progress','coverage']
> {noformat}
> Look to *project_root/ambari-web/public/coverage/*. You can setup custom path in #coverageReporter config property.
> 
> If you have problems with PhantomJS disconnecting, install it from [download page|http://phantomjs.org/download.html] and set shell variable *PHANTOMJS_BIN* with path to executable file (by default is */usr/bin/phantomjs*). You can add this variable to your shell profile file, or make it session only by: {noformat}$ export PHANTOMJS_BIN=/usr/bin/phantomjs{noformat}
> 
> h3. Windows Setup
> 
> Tested with node.js v 0.10.20
> You need to install, if not installed:
> - [Visual C++|http://www.visualstudio.com/downloads/download-visual-studio-vs#d-2010-express]
> - [Python 2.6|https://www.python.org/ftp/python/2.6.6/python-2.6.6.msi]
> - [Node.js|http://nodejs.org/download/]
> 
> h2. Karma plugin for Intellij Platform IDE
> 
> Install plugin from ??File -> Settings -> IDE Settings -> Plugins??.
> After IDE restart go to ??Run -> Edit Configuration??. 
> Add configuration: press *plus* button, select *Karma*. Now fill inputs with path to: *Node.js interpreter*, *Karma node package* and *Configuration file* it should be *project_root/ambari-web/karma.conf.js*.
> After setup you can run karma from *Debug panel* and you will see progress in *4: Run* tab. You can set *Auto-test* by pressing ??Toggle auto-test?? button.
> 
> 
> Diffs
> -----
> 
>   ambari-web/app/assets/test/karma_setup.js PRE-CREATION 
>   ambari-web/karma.conf.js PRE-CREATION 
>   ambari-web/package.json 572e1cb 
>   ambari-web/test/installer/step5_test.js a672900 
> 
> Diff: https://reviews.apache.org/r/20171/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Alexandr Antonenko
> 
>