Alfresco / Aikau

Aikau UI framework
GNU Lesser General Public License v3.0
81 stars 61 forks source link

100% node.js CPU usage during grunt local_tests without any progress #1185

Open AFaust opened 8 years ago

AFaust commented 8 years ago

After another attempt to set up a Linux-based VM for testing Aikau following https://github.com/Alfresco/Aikau/wiki/Aikau%20Setup%20%28Linux%29 I am again stumped about how unstable the node.js based setup is. (Although, nothing with regards to "quality" or "professionalism" of node.js or its ecosystem is capable of disappointing me much further at this point.)

I basically executed every step almost to the letter up to "Running the tests". Instead of Mint 17.1 I used the newer 17.3. Since google-chrome-stable could not be found via "apt-cache search" I opted for chromium-browser instead. The node.js version installed by nvm is 6.3.1.

When the first "grunt local_tests" is executed as listed under "Running the tests" (no changes made to Suites.js), the node.js process initially runs fine until the intern task is being processed. After clearing the console screen it remains empty. "top" reports continuous 100% CPU usage by the node.js process from then on until I Ctrl-c the grunt process and then kill the still-running node.js process. The only indication that a test might actually be attempted to be run is in a single log line output from the Jetty test server run via "mvn clean install jetty:run" in another shell. The line reads: ERROR [extensions.surf.DependencyAggregator] Could not find compressed file: js/aikau/testing/RequireEverything.js

When I previously attempted to set up a test VM on the same Mint version about 4 months ago, I at least got some tests to run intermittently (most tests though would fail to be properly opened in the browser, some reported seemingly trivial/stupid issues though tests were run against unaltered master or develop), albeit at some point the same 100% CPU usage situation settled in. Before that I attempted to set up on my local Windows 7 environment, but the intern NPM module failed to be installed with cryptic/unspecific internal errors from associated installation scripts (support/fixdeps.js).

draperd commented 8 years ago

OK, thanks for such a detailed explanation of the problems. I'll see if I can get to the bottom of the situation. I know that the unit tests can be quite intensive - what resources are you giving to your VM (number of CPUS, memory, etc)?

AFaust commented 8 years ago

4 CPUs, 8 GiB memory (you snooze - you loose). 100% CPU reported by "top" means 1 of 4 CPU is occupied. No other processes (i.e. Java / Jetty) seemed to take any resources while I observed the state via "top"

draperd commented 8 years ago

OK... I've created a similar VM with Mint and will attempt to step through the setup instructions we've provided and see what happens. I probably won't get around to this until tomorrow though.

draperd commented 8 years ago

I've updated the Linux instructions with how to install Chrome.

draperd commented 8 years ago

So it looks like the issue is that the unit test framework isn't working with Node v6.3.0 (which is the current "stable" release). We do see things like this quite frequently with Node unfortunately, so rather than installing the latest stable version you'll need to specifically install Node v6.0.0 (which is fortunately quite easy using nvm

nvm install v6.0.0

...Although you'll need to re-install grunt-cli again !!

I'll update the instructions for this - I've already added some additional information on installing a JDK and exporting JAVA_HOME. Otherwise I've managed to get this working.

One other thing - from time to time (and now is one such time) ... a release of Firefox stops working with Selenium - so you'll want to comment out Firefox from the intern_local.js config and just use Chome.

Hopefully this will get you going though. I won't close this until all the instructions are up-to-date and I've run through them again from scratch with a clean VM image.

AFaust commented 8 years ago

Nothing has really changed after downgrading Node to v6.0.0, disabling Firefox, reinstalling Grunt AND Selenium. I even explicitly uninstalled the v6.3.1 to make sure it isn't somehow used accidentally. Still 100% CPU usage by Node. Only difference so far: The error message from the DependencyAggregator is not shown anymore.

draperd commented 8 years ago

Are the unit tests actually running though?

AFaust commented 8 years ago

Nothing is happening (no unit tests, only the 100% CPU use by Node) and after waiting 15-20 minutes, I typically Ctrl+C the Grunt CLI and kill the Node process...

draperd commented 8 years ago

OK... then that's not what I am seeing... I'm seeing the tests actually running, I'm going to run through all the steps from scratch again with a clean VM as soon as I get the chance and record it for clarity - but at the moment I'm having to look at some other stuff.

draperd commented 8 years ago

I've now gone through the whole process with a clean VM (recording it as I went)... I hit the issues that you hit, it would appear to be down to the incompatibility with the latest Firefox release and the Selenium drivers (which usually get resolved in time). I've currently down-graded Firefox to version 44.0.2 (which does work with the Selenium drivers)... this is just one of the frustrations with automated UI testing and evergreen browsers.

So to resolve the problem you need to remove the Firefox environment from the intern_local.js file...

// Environments to run integration testing against
environments: [{
   browserName: "chrome"
}, {
   browserName: "firefox"
}],

... this then gets everything running. Hopefully I'll get the video up online soon, but I need to edit out the bits of Maven downloading the internet, etc !!

AFaust commented 8 years ago

I had already commented the firefox section in the environments based on your previous compatibility statement. Since I started to look into #958 again I checked out my branch (Aikau 1.0.61), and at least on that old branch I can run some unit tests.

Switching back to the 1.0.80 develop branch, doing a npm install and triggering grunt again, I am back to 100% CPU. Using node --prof to run grunt without the shortcut, I can only see that the majority of ticks are spent in syscalls without any indication what kind of C++ syscalls these are.

Are you using Mint 17.1 as outlined in the wiki or 17.3 which I mentioned I use in the first post?

AFaust commented 8 years ago

I just found out that while grunt test_local and node node_modules/grunt/bin/grunt test_local hang with 100% CPU, node debug node_modules/grunt/bin/grunt test_local works just fine (I only have to tell the debugger to cont once). Chrome is opened almost immediately and the test cases run. Unfortunately, running in debug mode means output is very much unusable...

draperd commented 8 years ago

I actually ended up using Mint 18... although I don't think it should make much difference, I'm on a patched Mint 17 on my main machine.

draperd commented 8 years ago

I've uploaded this video showing setting up a Linux VM from scratch.

draperd commented 8 years ago

I'm not sure what else I can do with this issue now... I don't want to close it whilst you're still having issues, but I'm not sure what the next step is? Perhaps you can review the video when you get a chance to see if there is anything obvious that you might have missed.

AFaust commented 8 years ago

Sigh... well, it likely is something very obscure or node-esque. I just created a new VM from scratch following the updated documentation (and using Mint 18 as a starting point). Same issue as before. I will likely come back to this when my new machine is here and I set up a completely fresh system - who's to say that this isn't somehow related to virtualization support or what-not?

AFaust commented 7 years ago

My new development machine has been here for a while now and I decided to give this another try. But even with a fresh system and setting up another VM from scratch following your video / documentation, the same issue still persists. I tried to fall back on the vagrant-based test execution, but virtualbox-4.3 is no longer available via APT and grunt vcreate fails when I try to use it with virtualbox 5 while installing the guest plugins for vagrant ("undefined method 'group_by' for nil:NilClass" in vagrant/bundler.rb:275).