Chrome crashing when launched by Karma executed from MSBuild - google-chrome

My build server service is executing the following command from an msbuild file:
Exec Command="karma start $(LandscapeExplorerProjectFolder)karma.conf.js -- log-level debug
This then launches a Karma instance running on Node.js
Karma is configured to launch Chrome to run my Jasmine tests. When I execute the above command manually by logging on to the server and typing into the command prompt, the tests run as I would expect.
However when Karma is started by my build service, Chrome is initially launched but then crashes.
From the output of the console when running a build I get the following:
WARN [launcher]: [39mChrome have not captured in 60000 ms, killing.
DEBUG [launcher]: [39mProcess Chrome exited with code 0
When looking in the Chrome log I see:
[6888:2988:1105/162913:ERROR:child_process_launcher.cc(444)] Failed to launch child process
[6888:2988:1105/162913:WARNING:sad_tab_view.cc(105)] Tab Killed: http://localhost:9876/
The exact same console command works fine when executed manually, but there is something about the way the build service is executing things that is causing Chrome to crash. Does anyone have any ideas about this?

I've seen this issue before.
I was not able to resolve it, but was able to workaround it.
This seems to be related to running Jenkins as SYSTEM account on Windows - if this is the case, try changing the service to run as a service account.
I worked around this with PSexec - you can download the tool at:
https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
And then use it in the job to exec Karma:
C:\Path\to\pexec.exe -s -i -accepteula karma start $(LandscapeExplorerProjectFolder)karma.conf.js -- log-level debug
Again this seems to be related to spawning child processes with SYSTEM.

Related

Running "google-chrome" on WSL Ubuntu as --headless --no sandbox gives multiple errors - how do I take screenshot using headless in WSL?

I'm running Windows 10 and I have been using an Ubuntu Linux distro under the Windows Linux Subsystem.
I want to be able to use Chrome.exe or google-chrome to run headless and take screenshots, generate pdfs etc... as part of library calls, but can't see to do that (e.g. to use jupyter_to_medium library launches chrome in the background to take screenshot).
I have tried multiple things to debug it with google-chrome independently of the library or programme I'm using.
Here's what I've tried:
I can launch Chrome (Windows executable) via the Ubuntu terminal, having redirected it to the Windows executable:
/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe
When I do that, a new tab opens in my Windows Chrome browser so no issues here.
When I try to use google-chrome headless in ubuntu terminal I get MULTIPLE ISSUES e.g.
2a) Trying to get a screenshot - FAILs showing Network service crashed, restarting service endless loop - had to CTRL^C to stop it
(base) etzimopoulos#DESKTOP-HI9P6E4:~$ google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
[0626/055458.471044:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/055458.612113:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
[0626/055458.696014:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
...
2b) Trying to get a screenshot using a different parameters --no-sandbox --disable-setuid-sandbox , getting different error this time.
$ sudo google-chrome --no-sandbox --disable-setuid-sandbox --headless --screenshot https://www.chromestatus.com/
[0626/061854.348849:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/061855.311675:ERROR:platform_shared_memory_region_posix.cc(46)] Descriptor access mode (0) differs from expected (2)
[0626/061855.312483:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
[0626/061855.474617:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
--2020-06-26 06:18:55-- https://clients2.google.com/cr/report
Resolving clients2.google.com (clients2.google.com)... 216.58.210.46, 2a00:1450:4009:800::200e
Connecting to clients2.google.com (clients2.google.com)|216.58.210.46|:443... connected.
HTTP request sent, awaiting response... [0626/061855.655013:ERROR:headless_shell.cc(399)] Abnormal renderer termination.
429 Too Many Requests
2020-06-26 06:18:55 ERROR 429: Too Many Requests.
Unexpected crash report id length
Failed to get crash dump id.
Report Id: ```
Trying to run the Windows executable Chrome.exe with same parameters, seems to run but not screenshot is being taken (no new files in my directory)
Trying to run google-chrome without elevated privilages in WSL I get a different error:
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/ Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Permission denied Failed to generate minidump.Illegal instruction (core dumped)
Any help or direction would be hugely appreciated. My other option would be to run a VM on windows 10 with native Linux UI and terminal, which would probably work.
But is there a way to have it all setup in WSL?
Thank you.
Try this (tested in wsl2)
In your wsl2 ubuntu console enter the following commands:
#install packages
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4 fonts-liberation
#get latest chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
#install it
sudo apt install ./google-chrome-stable_current_amd64.deb
#test a screenshot
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/

WebStorm debug mode not working and get message Process finished with exit code -1073741819 (0xC0000005)

I have recently downloaded WebStorm 11.0.3 to run my Protractor test cases. My test cases run fine when run normally (i.e. run from run configurations) but when I try to run my test cases in debug mode nothing really happens and I get the following in the console:
"C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=58467 --nolazy c:\Users\daobrien15\AppData\Roaming\npm\node_modules\protractor\lib\cli.js conf.js
Debugger listening on port 58467
Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Process finished with exit code -1073741819 (0xC0000005)
When I run debug against Firefox it just launches the first run Firefox screen and does nothing. When I run it against Chrome it just loads a blank page with data:, in the URL bar and also does nothing.
I am using the following:
OS: Win 7 (64 bit)
Protractor: 3.0.0
Selenium webdriver: 2.48.2
Firefox: 35 as the latest was not working with my tests when run normally
Chrome: 47.0.2526.111 m (Latest)
Also I am running my selenium webmanager through the console. I get pretty much the same result if I use the directConnect option in my conf.js file:
directConnect: true,
Any help would be greatly appreciated.
I have had same problem.
Check version of node.js in your webstorm terminal: node --version
My version was 5.2 and I had this bug.
Today I update node to 5.5.0(last stable) and this problem gone.
NOTE: If you use Webstorm 9 or 10 go to
C:\Program Files (x86)\JetBrains\WebStorm 9.0\bin
and open WebStorm64.exe.vmoptions and WebStorm.exe.vmoptions and in the end set
-Dnodejs.debugger.use.jb.support=false
this will help to stop on your breakpoint.
If you use Webstorm 11 you will not have this problem, but if you will - use fix for WebStorm 9/10.
Hope this will help you.
I have had some problem. I was tried #user3552 solution but not worked for me second time. I checked my node params and removed this param from my node params. This is working now.
--debug-brk=8081
Before removing one param my exec code was like this
/home/veysel/.nave/installed/5.0.0/bin/node --debug-brk=37621 -debug-brk=8081 --expose_debug_as=v8debug /opt/lampp/htdocs/kart/server.js 8080
After removing the last exec code like this.
/home/veysel/.nave/installed/5.0.0/bin/node --debug-brk=37621 --expose_debug_as=v8debug /opt/lampp/htdocs/kart/server.js 8080

Jenkins doesn't launch the application under test on chromebrowser

I ran into an issue with Jenkins which I've never seen before and I thought I'll get some advice. Jenkins wouldn’t launch the AUT on the chrome browser for running selenium tests.
Steps that I followed:
A Jenkins Master and Slave are setup on the same machine. Not as a windows service, but I launch them manually via command prompt
I setup a project on the Slave node with 2 build steps. One for the MSBuild (I dowloaded the plugin) to build the solution and the second step for executing the windows batch command that will start the tests
I also have a TFS plugin to fetch the server version of the solution to build on Jenkins
So when I build the job on Jenkins Slave,
The solution gets built successfully without any errors
Then for the next build step, Jenkins executes the windows batch command and loads the .dll file. Says “starting execution..”
Chromedriver launches. It opens up the chrome browser
But the chrome browser wouldn’t launch the AUT. It just tries to load it and stays intact indefinitely until my Jenkins job times out
With all this happening, my CPU utilization is at 100%. The browser that runs the Jenkins UI on the local host and Java.exe*32 consumes it to the fullest
I ran the exact same MSTest.exe command (that I entered in the build step) in command prompt when Jenkins is not running and it launches the AUT successfully and tests ran
I ran the exact same MSTest.exe command (that I entered in the build step) in command prompt when Jenkins is running. It again spikes the CPU to 100% and AUT never launches
Any thoughts?
I was also running into this issue and solved it as follows.
Basically the jenkins slave has to be started from the startup through a batch job.
Here is the step by step process.
Node URL : http://host:port/computer/nodeName/
Go to the node "Node URL"
Click on "Mark this node temporarily offline"
Go the the machine where slave is running.
Open command prompt in admin mode.
cd to the location where jenkins is installed
Execute jenkins-slave uninstall
Go to services (type services in run) and stop the jenkins slave running
Restart the machine.
cd C:\Users\myUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Create a new batch job (name say LaunchJenkinsSlave.bat) with following content
>
java -jar C:/Jenkins/slave.jar -jnlpUrl http://host:port/computer/nodeName/slave-agent.jnlp -secret yourSecret
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
<<
fyi : You can refer jenkins-slave.xml in your Jenkins install location for yourSecret, nodeName, host ect if you forgot.
Restart your machine.
Observation : Jenkins slave will be started automatically
12. Go to the "Node URL"
and bring the node back online.
Hope this helps.

Jenkins started selenium, but can't access chrome localStorage

I use Jenkins to start a selenium standalone serve with chrome driver. It starts OK. But when I use it with intern tests, the chrome tests don't start. I got this in the log:
org.openqa.selenium.WebDriverException:
unknown error: Runtime.evaluate threw exception:
DOMException: Failed to read the 'localStorage' property from 'Window':
Access is denied for this document.
If I start selenium locally, everything works fine. Note Jenkins slave service uses the same user as the local login.
Ther batch script I used to start Jenkins is this:
start cmd /c java -jar C:\Jenkins\workspace\app\util\selenium-server-standalone-2.44.0.jar -Dwebdriver.chrome.driver=C:\Jenkins\workspace\app\util\chromedriver.exe 2^> seleniumLog.txt
Why does it not work when I start selenium from Jenkins?
If you use Jenkins as a service standalone server can't create real window.
You can use workaround. Create Node and run from usual user (auto startup). Run your Job on that node
P.S.
For normal screenshot (not black screen) you can put session to Console "tscon RDP-tcp#0 /dest:console" (set screen resolution by QRes tool).

How to deploy on a remote machine using hudson's WAS Builder Plugin?

I have a hudson build server (Windows) that does not have Websphere installed. I created a Hudson node that I connect to via SSH. I also installed the WAS Builder Plugin to run jython scripts on the AIX machine. The job that uses the WAS Builder Plugin is tied to the AIX box.
I run into errors. Does anybody know, whether that setup might work or if a different setup will work for the WAS Builder Plugin?
EDIT:
I get following Error Message:
[test] $ cmd /c call /tmp/hudson9035964108103168395.bat
FATAL: command execution failed
java.io.IOException: cmd: not found
at java.lang.UNIXProcess.fullPath(UNIXProcess.java:372)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:178)
at java.lang.ProcessImpl.start(ProcessImpl.java:114)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:466)
at hudson.Proc$LocalProc.<init>(Proc.java:149)
at hudson.Proc$LocalProc.<init>(Proc.java:121)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:633)
at hudson.Launcher$ProcStarter.start(Launcher.java:268)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:778)
at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:754)
at hudson.remoting.UserRequest.perform(UserRequest.java:114)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:270)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:284)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:810)
Finished: FAILURE
I am wondering whether that plugin can be executed on a slave, especially in my case where the master is on Windows and the slave on AIX.
Check Here Hudson Deploy Websphere Plugin
Why dont you remotely trigger builds on Hudson via the hudsonurl:8080/jobs/jobname/build?token=TOKEN url. That way you dont have to depend on BAT files.
Finally I got it to work. I upgraded the plugin to Version 1.4 and to the newest Hudson server 1.355. That seemed to do the trick.