Working with a machine executor

Hi Team,

I have an issue when working in a workflow for a machine executor. Mine is a maven project. The test job is not recognising the build machine which is present in the build job. I don’t want to invoke my mvn package again for test, as this is a headache and increases the my pipeline time. I want to run it in a workflow so that I can distinguish both build and test separately. Could you please help me in that how I can do that in a workflow.

Could you please check that and suggest how this can be possible.

version: 2
jobs:
 container_build:
   machine: true
   working_directory: ~/rbsmicroservices/services/productservice
   environment:
     TEST_REPORTS: /tmp/test-reports
     HOST_PORT: 8190
     CONTAINER_PORT: 8190
     SERVICE_NAME: productservice
     URL: localhost:8190/productIds?id=1
   steps:
     - checkout:
         path: ~/rbsmicroservices
     - add_ssh_keys:
         fingerprints:
           - "3e:06:2b:c5:fa:81:f9:be:94:6e:b1:dc:3e:87:01:68"
     - run: mvn -DskipTests package
     - run: |
         docker image build -t microservices/${SERVICE_NAME} .
         docker run -d -p ${HOST_PORT}:${CONTAINER_PORT} --name ${SERVICE_NAME} microservices/${SERVICE_NAME}
         docker ps -all
         sleep 30
     - run: |
         chmod +x testendpoints.sh
         bash testendpoints.sh $URL

 container_api_testing:
   docker:
     - image: circleci/openjdk:8-jdk
   environment:
     SERVICE_NAME: productservice
     KARATE_ENV: pipeline
     KARATE_TAG: pipelineTest
     HOST_PORT: 8190
   working_directory: ~/rbsmicroservices/services/productservice
   steps:
     - checkout:
         path: ~/rbsmicroservices
     - run: echo "container api testing executed here"
     - run: |
          cd ~/rbsmicroservices/services/productservice/test/karate/
          chmod +x environmentSetter.sh
          bash environmentSetter.sh http://localhost ${HOST_PORT}
          mvn test -Dcucumber.options="--tags @${KARATE_TAG}" -DargLine="-Dkarate.env=${KARATE_ENV}"

workflows:
 version: 2
 pipeline:
   jobs:
     - container_build
     - container_api_testing:
         requires:
           - container_build

Error -
T E S T S

Running productServiceTest.ProductServiceTest
15:33:22.155 [main] DEBUG c.i.karate.cucumber.CucumberRunner - init test class: class productServiceTest.ProductServiceTest
15:33:22.315 [main] DEBUG c.i.karate.cucumber.CucumberRunner - loading feature: /home/circleci/rbsmicroservices/services/productservice/test/karate/target/test-classes/productServiceTest/testingEndPoints/basicEndpointTest.feature
15:33:22.501 [main] DEBUG com.intuit.karate.ScriptEnv - obtained ‘karate.env’ from system properties: pipeline
15:33:23.279 [main] INFO com.intuit.karate.ScriptBridge - karate.env system property was: pipeline
Jun 29, 2018 3:33:24 PM org.glassfish.jersey.logging.LoggingInterceptor log
SEVERE: 1 * Sending client request on thread main
1 > GET http://localhost:8190/productIds?id=1

Failed scenarios:
productServiceTest/testingEndPoints/basicEndpointTest.feature:48 # Scenario: 

1 Scenarios (1 failed)
3 Steps (1 failed, 1 skipped, 1 passed)
0m1.654s

javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused (Connection refused)
	at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:287)
	at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:252)
	at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:684)
	at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:681)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
	at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:681)
	at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:411)
	at com.intuit.karate.StepDefs.method(StepDefs.java:318)
	at ✽.When method get(productServiceTest/testingEndPoints/basicEndpointTest.feature:50)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:35

Could someone let me know if you faced this issue, please. Thanks

(The logs in this question needs Markdown formatting repair. I am more likely to answer questions where effort has clearly been expended on making them as readable as possible).

It seems that you are doing a build process in one job and you want the file output of that to be available in the next job in your workflow. Jobs are isolated by default, but I wonder if you need workspaces to save/restore your build output between jobs. Take a look at the docs for this?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.