Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI/CD] Integration-Tests / Samples execution/generation on CI env #9823

Open
hypery2k opened this issue Oct 31, 2019 · 1 comment
Open

[CI/CD] Integration-Tests / Samples execution/generation on CI env #9823

hypery2k opened this issue Oct 31, 2019 · 1 comment
Assignees

Comments

@hypery2k
Copy link

hypery2k commented Oct 31, 2019

Description

Currently to me the testing approach seems a little bit weired:

  • The generated samples are checked in
  • There are scripts within bin which use latest version
  • Not all samples are executed
Swagger-codegen version

latest 3.0.0 branch

Swagger declaration file content or url

N/A

Command line used for generation

N/A

Steps to reproduce
 mvn -q --batch-mode verify -Psamples

;)

Related issues/PRs

e.g. this error would have been found before releasing: #9822

Suggest a fix/enhancement
  1. I think the samples folder should just hold the pom.xml
  2. For the rest the scripts should run on CI
  3. All samples should be executed on travis
@HugoMario HugoMario self-assigned this May 8, 2020
@kaibra
Copy link

kaibra commented Sep 25, 2020

I recently spend some thoughts and time on this topic.
I came up with a different solution for integration tests which is based on testcontainers, it works like this:

  • All integration-tests are part of the test-code base (Java)
  • An integration Test generates sources based on some test-data (e.g. petstore, ...) into a temporary directory
  • After this a testcontainer (https://www.testcontainers.org/) is started
  • the temporary directory is mounted into the container as well as caches for dependencies (e.g. m2 cache)
  • within the container itself the generated code is compiled and tests are run

Benefits of this:

  • you can use a docker container of your choice for each language supported. the environment is isolated / separated from others
  • propper test-results can be written (junit)
  • run integration tests easily within your IDE without having to understand a complex workflow (git commit + push / samples dir / mvn profile / pom module wrapper around others languages / ....)
  • tests can also be parallelized

I put a small example on how this can be done into a repo: https://github.com/kaibra/swagger-codegen-integration/blob/master/src/test/java/de/kaibra/swaggercodegenintegration/languages/java/JavaCodegenITest.java

@HugoMario what do you think about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants