swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.93k stars 6.03k forks source link

[Go] Travis CI failure with Go API client's concurrency test #5102

Open wing328 opened 7 years ago

wing328 commented 7 years ago
Description

Sometimes, we may get the following test failure in 2.3.0 branch with the Go API client for Petstore:

=== RUN TestDeletePet
--- PASS: TestDeletePet (0.00s)
=== RUN TestConcurrency
--- FAIL: TestConcurrency (1.02s)
    Error Trace:    pet_api_test.go:193
            pet_api_test.go:165
    Error:          Not equal: 
                    expected: 0
                    received: 12348
    Messages:       Pet id should be equal
    Error Trace:    pet_api_test.go:194
            pet_api_test.go:165
    Error:          Not equal: 
                    expected: ""
                    received: "gopherJohn"
    Messages:       Pet name should be gopherJohn
    Error Trace:    pet_api_test.go:195
            pet_api_test.go:165
    Error:          Not equal: 
                    expected: ""
                    received: "dead"
    Messages:       Pet status should be dead
    pet_api_test.go:200: &{404 Not Found 404 HTTP/1.1 1 1 map[Content-Type:[application/json] Server:[Jetty(9.2.9.v20150224)] Date:[Fri, 17 Mar 2017 11:05:59 GMT] Access-Control-Allow-Origin:[*] Access-Control-Allow-Methods:[GET, POST, DELETE, PUT] Access-Control-Allow-Headers:[Content-Type, api_key, Authorization]] 0xc208120440 -1 [chunked] false map[] 0xc20801f790 <nil>}
    pet_api_test.go:182: &{404 Not Found 404 HTTP/1.1 1 1 map[Date:[Fri, 17 Mar 2017 11:05:59 GMT] Access-Control-Allow-Origin:[*] Access-Control-Allow-Methods:[GET, POST, DELETE, PUT] Access-Control-Allow-Headers:[Content-Type, api_key, Authorization] Content-Length:[0] Server:[Jetty(9.2.9.v20150224)]] 0xc208120a00 0 [] false map[] 0xc20801f110 <nil>}
=== RUN TestCreateUser
--- PASS: TestCreateUser (0.00s)
=== RUN TestCreateUsersWithArrayInput
--- PASS: TestCreateUsersWithArrayInput (0.00s)
=== RUN TestGetUserByName
--- PASS: TestGetUserByName (0.00s)
=== RUN TestGetUserByNameWithInvalidID
--- PASS: TestGetUserByNameWithInvalidID (0.00s)
    user_api_test.go:109: &{0       0}
    user_api_test.go:112: &{404 Not Found 404 HTTP/1.1 1 1 map[Access-Control-Allow-Methods:[GET, POST, DELETE, PUT] Access-Control-Allow-Headers:[Content-Type, api_key, Authorization] Content-Type:[application/json] Server:[Jetty(9.2.9.v20150224)] Date:[Fri, 17 Mar 2017 11:05:59 GMT] Access-Control-Allow-Origin:[*]] 0xc208121680 -1 [chunked] false map[] 0xc20801fba0 <nil>}
=== RUN TestUpdateUser
--- PASS: TestUpdateUser (0.01s)
=== RUN TestDeleteUser
--- PASS: TestDeleteUser (0.02s)`

Ref: https://api.travis-ci.org/jobs/212060955/log.txt?deansi=true

Seems like the Go API client has issues with concurrent requests.

Swagger-codegen version

2.3.0

Command line used for generation
Steps to reproduce

Submit a PR and the CI (travis) might failed

Related issues
Suggest a Fix

The issue might be addressed by https://github.com/swagger-api/swagger-codegen/pull/5037 but I'm not entirely sure.

cc @antihax

antihax commented 7 years ago

Not addressed by #5037 yet. May have to remove that test, the code is correct but the endpoints do not seem to handle rapid requests well.

I thought it was an issue on my end since it always passed travis for me.

Where is the code for the endpoint server located? Maybe I can figure out what is causing this.

wing328 commented 7 years ago

@antihax I'll comment out the test for the time being.

The Pestore server can be found in https://github.com/swagger-api/swagger-samples under java/java-jersey-jaxrs. Thanks for looking into the issue.

antihax commented 7 years ago

Check https://github.com/swagger-api/swagger-samples/pull/74. Looks like data races in the sample, but i am not familiar with the latest Java.