OpenPOWER-BigData / HDP2.5-ambari

Apache License 2.0
0 stars 1 forks source link

Ambari-web mocha-phantomjs tests hang using PhantomJS 2.1.1 #1

Open pravin-dsilva opened 7 years ago

pravin-dsilva commented 7 years ago

In the Ambari-web project, On running the mocha-phantomjs tests using Phantomjs version 2.1.1 on ppc64le and x86, the tests do not run but get hanged and do not show any error message as well.

Console output:

[INFO] --- exec-maven-plugin:1.2.1:exec (ambari-web unit tests) @ ambari-web ---

> Ambari@2.4.0 test /home/pravin/HDP25-openpower/ambari-release/ambari-web
> mocha-phantomjs -p /home/pravin/ibm/node/bin/phantomjs  -R min public/test/test.html
pravin-dsilva commented 7 years ago

The issue occurs because the mocha and mocha-phantomjs versions are not compatible with Phantomjs 2.1.1

To resolve the issue, changed the versions of "mocha" from "1.9.0" to "1.21.5" and "mocha-phantomjs" from"~3.1.6" to "~4.1.0" in package.json

On running the tests, another error is seen:

 Error loading resource file:///img/logo-white.png (203). Details: Error opening /img/logo-white.png: No such file or directory
Likely due to external resource loading and timing, your tests require calling `window.initMochaPhantomJS()` before calling any mocha setup functions. See https://github.com/nathanboktae/mocha-phantomjs-core/issues/12

To resolve this, added code to call 'window.initMochaPhantomJS()' before calling 'mocha.ui('bdd')' method in ambari-web/app/assets/test/test.html file.


diff --git a/ambari-web/app/assets/test/test.html b/ambari-web/app/assets/test/test.html
--- a/ambari-web/app/assets/test/test.html
+++ b/ambari-web/app/assets/test/test.html
@@ -41,6 +41,7 @@
 <script>
     $.mocho = true;
     $.hostName = 'localhost:3333';
+    window.initMochaPhantomJS && window.initMochaPhantomJS();
     mocha.ui('bdd');
     mocha.reporter('html');
     expect = chai.expect;

On making the above changes and running the tests, the tests completed without failures:

29088 passing (47s)
154 pending

This result appears on both Power and x86