How to connect to localhost


#1

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

test:
  pre:
    # run app
    - ./gradlew bootRun -Dgrails.env=dev:
        background: true
    - sleep 40
  override:        
    - ./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:

machine:
  # Override /etc/hosts
  hosts:
      localhost: 127.0.0.1

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: java.net.ConnectException at SendMessageSpec.groovy:44

I’ve also asked a question on StackOverflow.


#2

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.


#3

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


#4

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


#5