How to connect to localhost

In CircleCI I run an app that I would like to run the tests against:

    # run app
    - ./gradlew bootRun -Dgrails.env=dev:
        background: true
    - sleep 40
    - ./gradlew test 

On localhost the app is accessible on http://localhost:8080. I can see the app startup on CircleCI.

I thought that I would change the host localhost:

  # Override /etc/hosts

My tests work locally correctly. On CircleCI they always end up without connection when calling new HttpPost("http://localhost:8080/api"); with this error:

org.apache.http.conn.HttpHostConnectException at SendMessageSpec.groovy:44
Caused by: at SendMessageSpec.groovy:44

I’ve also asked a question on StackOverflow.

I had to increase the sleep time to something unreasonably big. - sleep 480

I think I’ll have a look at how to block tests until the app is started.

I’m having the same issue. Did you find a better solution?

You can try starting the app in dependencies:post and use wget to check for when it’s up and serving.