Unable to run functional tests on server. [geb spock] - grails

Hi I am running my functional tests using geb.
I am able to run tests on my local computer correctly. but as I deploy my application to server. the build for functional tests fails.
Here is my console output
|Running 10 spock tests... 1 of 10
Failure: |
sign in with voucher
|
geb.driver.DriverCreationException: failed to create driver from callback 'script14007213321291157436758$_run_closure1#77068fce'
at geb.driver.CallbackDriverFactory.getDriver(CallbackDriverFactory.groovy:35)
at geb.driver.CachingDriverFactory.getDriver_closure3(CachingDriverFactory.groovy:80)
at geb.driver.CachingDriverFactory$SimpleCache.get(CachingDriverFactory.groovy:30)
at geb.driver.CachingDriverFactory.getDriver(CachingDriverFactory.groovy:79)
at geb.Configuration.createDriver(Configuration.groovy:346)
at geb.Configuration.getDriver(Configuration.groovy:335)
at geb.Browser.getDriver(Browser.groovy:105)
at geb.Browser.go(Browser.groovy:377)
at geb.Page.to(Page.groovy:171)
at geb.Browser.via(Browser.groovy:454)
at geb.Browser.to(Browser.groovy:413)
at geb.Browser.to(Browser.groovy:391)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at VoucherSpec.sign in with voucher(VoucherSpec.groovy:14)
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/local/bin/firefox) on port 7056; process output follows:
Error: no display specified
Error: no display specified
Can anyone guide me to solve this issue.

The server you're running the tests on is 'headless' so doesn't have a display to start Firefox on to run the tests. You've got a couple of options:
Switch from Firefox to a headless browser such as HTMLUnit.
Configure a virtual display on the server.
Use a remote browser service such as SauceLabs.
If you need to test directly on Firefox then HTMLUnit isn't an option for you.
Using a remote browser service such as SauceLabs or BrowserStack has a couple of advantages, for example they record a video of the session and take screenshots, but we found the overhead of passing commands & traffic over the network made the tests unacceptably slow. If you need to test a wide variety of browsers then the overhead diminishes because you can run in parallel...
Option 2, using a virtual display, is the simplest to configure on most servers. If you're using Linux the X Virtual Frame Buffer (XVFB) will get you up and running quickly. It's worth reading up on what's going on but the short answer is:
Install XVFB (sudo apt-get install xvfb)
Install Firefox (sudo apt-get install firefox)
Start XVFB (sudo Xvfb :10 -ac -screen 0 1024x768x8 &). You may want to add an init script so this happens every time the server starts
In your CI server add export DISPLAY=:10 as a step before the tests are run
Run your tests
The XVFB creates a virtual display on :10, which you then set as the default display. When you start Firefox it's completely unaware that it's on a virtual display, so things like getting Geb to take screenshots of failing tests will work as normal.
For more information about the steps see:
http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/
https://github.com/tomaslin/grails-test-recipes
http://www.semicomplete.com/blog/geekery/xvfb-firefox.html
http://www.labelmedia.co.uk/blog/setting-up-selenium-server-on-a-headless-jenkins-ci-build-machine.html
http://manpages.ubuntu.com/manpages/lucid/man1/xvfb-run.1.html
If you need an init script to get it to start/stop, then there are quite a few to choose from, such as this one.

Related

Why does upgrading chome and chrome driver stop web application from loading

Im Running E2E testing on a web application in Jenkins using a centos node with webdriver IO.
Chrome :google-chrome-stable-96.0.4664.110-1.x86_64.rpm
Chrome driver:
sh 'sudo yum info google-chrome-stable | grep Version > chromeOutFile'
def CHROME_VERSION = readFile('chromeOutFile')
def Version = CHROME_VERSION.split('Version :')
def VersionNumber = Version[1].trim()
sh "./src/main/web/node_modules/protractor/bin/webdriver-manager update --versions.chrome=${VersionNumber}"
Id like to update this to user the latest version of chrome with a corresponding chrome driver.
Webdriver IO config:
services: [['chromedriver', {
chromedriverCustomPath: '../node_modules/webdriver-manager/selenium/chromedriver_96.0.4664.110'
}]],
Problem: when I try to use a more upto date version, even if its chromedriver_97.0.4692.99, my web application no longer starts up in Jenkins. When I try to visit the url, the screen shot just shows a blank screen. Im not sure the application is even loading.
Why does it only work with 96 but not others?
I tried to map the version of chrome with an appropriate version of chrome driver using https://chromedriver.storage.googleapis.com/LATEST_RELEASE_97.0.4692 but that still doesnt work for me.
Running tests:
cd e2e && wdio run wdio.ci.conf.ts --suite access --logLevel=info
+ lsb_release -d
Description: CentOS Linux release 7.9.2009 (Core)
Thanks
Have you tried to check memory limits? I had a similar problem with automated testing and had to change memory limits to either 1) limit chrome's memory or 2) pre allocate a set amount of memory ahead of time from my webserver if you are testing on the same device.

Repast Java: how to run model directly in Eclipse without GUI and how to run it in headless mode without even Eclipse

I am wondering how to
1) how to run model directly in Eclipse without GUI - just run the model like run other java codes in Eclipse and print out something i am interested.
2) how to run it in headless mode without even Eclipse - I plan to deploy my model in a remote server, which the server or my own PC could run the model automatically at a specific time of the day.
3) Every time when I change the code, I have to launch a new GUI in order to reflect the code changes. It takes at least 5 seconds to open the GUI. This is very inefficient way of model development and debugging. What is the better strategy available?
For headless, or batch, running of models, take a look at the Repast Batch Getting Started Guide. This can either allow you to run multiple runs without a GUI, as in (1), or if you look at section 9.2, it will allow you to run from the command line without invoking Eclipse, as in your case (2). If you want more control, I'd suggest looking at the InstanceRunner class and utilize the complete_model.jar payload that is generated by the Batch GUI or batch_runner.jar.
Unarchive the complete_model.jar
Then use the InstanceRunner class from the command line, like so from within the complete_model directory
java -Xmx512m -cp "../lib/*" repast.simphony.batch.InstanceRunner \
-pxml ../scenario.rs/batch_params.xml \
-scenario ../scenario.rs \
-id $instance \
-pinput localParamFile.txt
where the localParamFile.txt is an unrolled parameter file specifying the combination(s) of parameters to run (see the unrolledParamFile.txt within the payload for an example) and if you're running just one instance this would just be one line.

Chef stuck at "Recipe: java::openjdk"

I'm currently using knife zero to help me provision the servers and the commands are executed through Jenkins.
But recently I noticed that the process will stuck halfway through without any error and it is always at the part where it start executing the Java recipe.
So every time the process got stuck, I will have to reboot my system to get it running again.
The Java cookbook i'm using is from Chef supermarket.
https://supermarket.chef.io/cookbooks/java/versions/1.50.0
How should I debug this issue?
I would agree with #coderanger that this sounds like a symptom of a process that is waiting for user input before it can continue. Is it possible that you're trying to install Java 7 and haven't included the attribute accept_oracle_download_terms?
From the docs for that cookbook, this is explicitly noted as being required:
To install Oracle Java 7 (note that when installing Oracle JDK,
accept_oracle_download_terms attribute must be set
After much investigation, I found out that this is due to the lack of available ram in the system when chef is running.
I use the sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches' command to clear up the caches at the start of each run and my script no longer get stuck anymore.
http://linuxinsight.com/proc_sys_vm_drop_caches.html

how to place and use headless chrome binary on jenkins (linux) instance

actually i am struggling with absence of bigger picture on how to proceed , here is the case :
I have protractor test suite running headless using Chrome 60 (beta) binary by giving binary location in chrome options in windows environment.
I want to port this to available CI CD Jenkins instance (linux) and run headless there. I can think of two approaches :
Approach 1 :
Install chrome plugin in jenkins , so chrome becomes available to be driven by chrome driver < webdriver modules .so that i can use jenkins job as shown below :
npm install
npm run start (from script , runs webdriver-manager start )
npm run update (from script , runs webdriver-manager update )
npm run test (from script , runs protractor protactor.conf.js )
Approach 2 : install chrome as module like other npm modules .then
npm install
npm run start (from script , runs webdriver-manager start )
npm run update (from script , runs webdriver-manager update )
npm run test (from script , runs protractor protactor.conf.js )
I have looked into simple-headless-chrome , headless-chromium , chrome-runner npm modules , but not able to understand how these will work .
My understanding is to somehow have chrome binaries in node_modules and give path for chrome binaries in chrome options so that chrome driver can find it .
Can anyone enlighten me a little bit about bigger picture and how things will workout for Second approach .As i want dont have access to get chrome plugin installed on jenkins server and want to keep my setup independent.(nodejs and npm , java etc are available in jenkins)
About "using Chrome 60 (beta) binary by giving binary location in chrome options in windows environment.", you don't really need to, protractor gives you a way to specify tags to run the chrome binary:
https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-headless-chrome
I don't think you have a node module to install chrome, or at least something reliable as the google chrome itself, so what I've done was installing google chrome on my ubuntu server that runs the jenkins slave, and you now have a google-chrome binary you can run with --headless.
Previously my jenkins slave was running on a CentOS but I had a really hard time setting up chrome on it so changed to ubuntu.

Jenkins unable to run Calabash-iOS in the simulator

I am trying to run some test in the emulator using Jenkins, but whenever I start Cucumber, the script stop trying to launch UIAutomation.
Here are some facts:
I am using the last version of Cucumber, Calabash-ios and Run Loop
Jenkins is running as local LaunchAgent (~jenkins/Library/LaunchAgents/org.jenkins-ci.plist)
I already added jenkins user to _developer group, turn it in an admin
I set DevToolsSecurity -enable
I am not able to set security authorizationdb write system.privilege.taskport is-developer as it always return an error
Running the same test from the console over SSH works fine
Running the same test from Jenkins on a real device, works fine
I am running Jenkins into a VirtualBox machine
I have already tried to increase the timeout for Calabash (#calabash_launcher.relaunch({timout: 120, :uia_timeout => 30})
I have run out of idea about what to try to fix the issue.
Any suggestion is more than welcome.
UPDATE
I have been able to run the simulator by removing the SessionCreate property from org.jenkins-ci.plist, but now, I have to enter my password to unlock the keychain everytime I run a test.
I had a similar problem. To solve this I only need to export language:
export LC_ALL=en_US.UTF-8

Resources