Issue with migration from 1.0 to 2.0


#1

For the tests, we start a local server (petstore) for testing API calls. Here is how we start it in 1.0 config:

- docker pull swaggerapi/petstore
- docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore

Things are working fine with the 1.0 config.

We try to migrate the config to 2.0 and here is one of the builds (failure): https://circleci.com/gh/OpenAPITools/openapi-generator/606

Basically all API calls/tests failed.

If I comment out the following to use the public petstore server instead:

- run:
    working_directory: ~/OpenAPITools/openapi-generator
    command: |-
      printf '127.0.0.1       petstore.swagger.io
      ' | sudo tee -a /etc/hosts

Then all tests in “openapi-scala-client” passed without issues.

It seems to me there’s an issue running “swaggerapi/petstore” but there’s no error/warning. “docker ps -a” looks good in both 1.0 and 2.0 config.

Does anyone have a clue on what may have caused the issue after the migration to 2.0?


#2

I wonder if this is related to the way working_directory is being set multiple times with no global working_directory – could you try configuring one working_directory globally, and then define directories inside of that directory as working_directory on each run step? A little more info available on this here.

I’m thinking this because of the following error:

[ERROR] Error fetching link: /home/ubuntu/OpenAPITools/openapi-generator/modules/openapi-generator/home/ubuntu/OpenAPITools/openapi-generator/modules/openapi-generator-cli/target/apidocs/package-list. Ignored it.


#3

Thanks. I’ll give that a try.

For the error message you mentioned, it also presents in a successful build: https://circleci.com/gh/OpenAPITools/openapi-generator/636 so I don’t think it’s related (and we’ll clean it up later as the error may cause confusion)


#4

UPDATE: I’ve cleaned up the working_directory and only kept one but still got the same errors: https://circleci.com/gh/OpenAPITools/openapi-generator/644


#5

I’ve tried the following but still failed

  • use mvn jetty:run instead of docker
  • add 120 seconds to let the server start
  • listen at port 8080 instead of 80

From the error message, the API client is correctly hitting the server at 127.0.01 (localhost):

--- FAIL: TestOAuth2 (0.00s)
	auth_test.go:47: Error while adding pet
	auth_test.go:48: Post http://petstore.swagger.io:80/v2/pet: dial tcp 127.0.0.1:80: getsockopt: connection refused

Ref: https://circleci.com/gh/OpenAPITools/openapi-generator/673

Does anyone encounter similar issue in making a connection to servers (Database, Redis, etc) that run locally?


#6

Does anyone have a clue on why the API (HTTP) calls from local client to local sever failed?


#7

As this is some kind of internal network issue, I would probably recommend trying out the machine executor as this has a lot more ‘freedom’ inside of the Circle infrastructure.

Failing that, I would suggest that it might simplify things to try starting a new 2.0 config from one of the templates available on our site – the config translation endpoint can be a useful tool, but it can also complicate matters, just by virtue of being an automatic tool.

If any assistance is needed on either point, add a reply and I’ll assist however I can.


#8

Thanks for the tips. I’ll try it out over the weekend.


#9

Using the machine executor resolves the problem :+1:


#10