Karate UI-based tests run successfully locally with karate-chrome (steps here) which starts a container with an exposed port.
Now, I am trying to run the tests within the karate-chrome container in CI. I have started the karate-chrome container with KARATE_SOCAT_START=trueand then executed the java -jar (standalone jar) command to run the tests. Non-UI based tests pass but the UI tests are throwing the following exception:
ERROR com.intuit.karate - http request failed:
15:26:09 DOCKER: org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
Note that driverTarget with docker has not been configured. Only the following driver's configuration:
* configure driver = { type: 'chrome', start: false, showDriverLog: true, port:9222 ,pollAttempts: 5}
Is it possible to make it work this way or should a custom docker image be set up?
I was not able to run UI-based tests directly on karate-chrome. Therefore, I ended up creating a new docker image (docker-openjdk8) to run the tests with driverTarget:
* configure driverTarget = { docker: 'ptrthomas/karate-chrome', showDriverLog: true}
This basically runs the tests with Docker-in-Docker (DIND) process. Would be happy to know if anybody else has got a better solution.
I know this question is old, but today I stumbled upon this very same issue where I had to configure Karate UI tests for automation. The solution I found was to configure the chrome driver as follows:
* configure driver = { type: 'chrome', showDriverLog: true, port: 9222, pollAttempts: 5, addOptions:['--no-sandbox'], headless: true }
Then the karate standalone jar was able to launch the browser and all tests passed.
Hope this helps!
Sorry, your setup is not clear. But to use configure driverTarget = { docker: 'ptrthomas/karate-chrome' } means Docker should be installed on the machine where you are running the test.
I suggest you start looking at the 1.0 release, and we have a reference test that uses the Docker container a little differently, without using driverTarget. You can find details here: https://stackoverflow.com/a/66005331/143475
It would be great if after you get this working, you post your solution as another answer here so that it helps others and helps us improve the documentation if needed.
Related
Karate UI-based tests run successfully locally with karate-chrome (steps here) which starts a container with an exposed port.
Now, I am trying to run the tests within the karate-chrome container in CI. I have started the karate-chrome container with KARATE_SOCAT_START=trueand then executed the java -jar (standalone jar) command to run the tests. Non-UI based tests pass but the UI tests are throwing the following exception:
ERROR com.intuit.karate - http request failed:
15:26:09 DOCKER: org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
Note that driverTarget with docker has not been configured. Only the following driver's configuration:
* configure driver = { type: 'chrome', start: false, showDriverLog: true, port:9222 ,pollAttempts: 5}
Is it possible to make it work this way or should a custom docker image be set up?
I was not able to run UI-based tests directly on karate-chrome. Therefore, I ended up creating a new docker image (docker-openjdk8) to run the tests with driverTarget:
* configure driverTarget = { docker: 'ptrthomas/karate-chrome', showDriverLog: true}
This basically runs the tests with Docker-in-Docker (DIND) process. Would be happy to know if anybody else has got a better solution.
I know this question is old, but today I stumbled upon this very same issue where I had to configure Karate UI tests for automation. The solution I found was to configure the chrome driver as follows:
* configure driver = { type: 'chrome', showDriverLog: true, port: 9222, pollAttempts: 5, addOptions:['--no-sandbox'], headless: true }
Then the karate standalone jar was able to launch the browser and all tests passed.
Hope this helps!
Sorry, your setup is not clear. But to use configure driverTarget = { docker: 'ptrthomas/karate-chrome' } means Docker should be installed on the machine where you are running the test.
I suggest you start looking at the 1.0 release, and we have a reference test that uses the Docker container a little differently, without using driverTarget. You can find details here: https://stackoverflow.com/a/66005331/143475
It would be great if after you get this working, you post your solution as another answer here so that it helps others and helps us improve the documentation if needed.
I am new to Cypress, I am trying to run a simple test on a docker container but I get this error:
cy.visit() failed trying to load:
http://bp.localhost:84/
We attempted to make an http request to this URL but the request failed without a response.
We received this error at the network level:
> Error: getaddrinfo ENOTFOUND bp.localhost
Common situations why this would fail:
- you don't have internet access
- you forgot to run / boot your web server
- your web server isn't accessible
- you have weird network configuration settings on your computer
But my container is running and I can access to the test website from my browser
I have been looking around for a solution, but most of the ones I've found are related to Cypress being inside the same docker image.
I have installed it locally with npm install since I cannot modify the image itself.
How do I access the above URL then?
I am running SonarQube on both java and javascript code inside a CentOS VM. I pulled the sonarqube docker image and am running the container. I exposed port 9000 and am able to open up localhost:9000 and interact with the sonarqube gui. When I run the sonar-scanner from the command line on the JavaScript code using this command:
sonar-scanner -Dsonar.projectKey=javascript_code -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin
I get a fully analyzed project. As well as the JavaScript code I can run it on the Java code using the maven build. Both work correctly from the command line.
When I add it into a Jenkins Pipeline I do the exact same commands and get the following:
Error: SonarQube server [http://localhost:9000] can not be reached
Caused by: Fail to get bootstrap index from server
Caused by: Failed to connect to localhost:9000
Caused by: Connection refused (Connection refused)
I also tried when starting the container to use --network="host" instead of publishing port 9000, but it still does not connect from the Jenkins Pipeline. Everything works correctly when I am running the commands from the Command Line, just when I try to put it into a Jenkins Pipeline.
Any suggestions on how to fix this? Thanks.
*Edit: Using the sonarqube plugin I was able to get my analysis to run as a Jenkins Job. However, when I try to add the analysis into the pipeline I get the same SonarQube server cannot be reached error. It says it skips my project because the project has been banned form the build due to previous failures and gives me this error message:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project sonarqubeproj:
Unable to execute SonarQube: Fail to get bootstrap index from server: unexpected end of stream on Connection{localhost:9000, proxy=DIRECT hostAddress=localhost/127.0.0.1:9000 cipherSuite=none protocol=http/1.1}: \n not found: limit=0 content=… -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.5.0.1254:sonar (default-cli) on project feedback-tool-ui: Unable to execute SonarQube
The problem you are facing is most likely related to how you run jenkins.
I assume you also run jenkins via docker. this means that in the context of jenkins, localhost is not your host system, but the jenkins container. This means you need to adapt your sonarqube-url to reference the host system.
Therefore you have multiple options:
use the public ip of the host system
use the docker ip of the host system
resolve the ip via dns. docker has an internal DNS and if those container run in the same network, you can normally reach them by containername.
sidenote:
i am not sure if you are using docker-compose or kubernetes, but if you are not using it, you might also want to dive into docker-compose as it is just a simple yaml-config in which you can easily start up servers.
I've just installed moodle-docker in my computer and I'm trying to run some behat tests. The tests are running and passing. I'm trying now to actually see those test through VNC, following the Using VNC to view behat tests section. However, when I try to connect from VNC I get an error:
connect: the requested direction is not valid in this context (10049)
How can I fix this?
I was able to fix it by setting port to 127.0.0.1:PI instead of 0.0.0.0:PI as the guide suggests.
I am using jenkins-test-harness to run some tests on my jenkins library code, but when it executes the tests I get the following error for each test :
hudson.UDPBroadcastThread#run: Cannot listen to UDP port 33,848, skipping: java.net.SocketException: Can't assign requested address
The test will pass (if it should pass), but it then takes about 75 seconds for the jenkins server to shut down. I believe that these two are related, but I can't work out why I am getting this error. I have nothing else running on this port.
When I run the tests within a gradle docker container, rather than locally on the command line or inside the IDE (IntelliJ). This is very frustrating. While it does not change the result of the tests, it takes the running from about 10 minutes to over 1 hour and 15 minutes.
Am I missing a setting which is making this fail?
For me this was caused by Jenkins assuming that the default IP address it would be provided with would be IPv4 when in fact my machine was dual stack, preferring IPv6. I resolved it by ensuring that the integrationTest section of my build.gradle file had systemProperties 'java.net.preferIPv4Stack' : true. A bit like this:
integrationTest: {
/* other statements */
systemProperties 'java.net.preferIPv4Stack' : true
}
I must confess I saw no significant difference to my Jenkins shutdown time. I'd be interested to know if this resolves the error message, and if that resolves your overall issue.