Skip to content

Commit 0488531

Browse files
Add compatibility suite with selected OpenAPI documents (#267)
### Motivation In order to help shape the 1.0 release, we'd like to maintain a public compatibility test suite, with some selected real-world OpenAPI documents. The goal of this is to check that (a) we can run the code generation for the document, and (b) the generated code compiles. We can then use this test as part of CI. However, we may want to gate PRs only on the code generation phase and run the build on main to keep PR feedback timely. ### Modifications - Adds a new test suite `CompatibilityTest` to the `OpenAPIGeneratorReferenceTests` test target. - Adds docker support. ### Result CI runs can check we are still able to handle selected real-world OpenAPI documents. ### Test Plan I have run this many times locally with varying parameters, and intend to tweak the parameters used in CI during this job. The draft PR hijacks an existing CI pipeline (`docc-test`), which will be reverted and replaced with a new pipeline before merging. ### TODO - [x] Determine appropriate params for CI. - [x] Remove commit that hijacks existing CI pipeline for testing. - [x] Enable new pipeline with desired parameters. ### Notes There are a number of decisions to make about how we run this suite: - Do we build the generated code, or just run the code generation? - Do we build the generator and test suite in debug or release? - Do we run the XCTest suite in parallel? - Do we generate the code in parallel? - Do we build the generated code in parallel? The below sections contain some numbers from some local experiments. #### Building the generator and compatibility test | Build configuration | `-j $(($(nproc)-1))` | Time | |---------------------|----------------------|------| | debug | ❌ | 70s | | debug | ✅ | 68s | | release | ❌ | 252s | | release | ✅ | 256s | Conclusion: `-j` has no impact; presumably because it defaults to core count. All following experiments assume no `-j` argument is used when building the generator and the compatibility test suite. #### LLVM flag when building the generator and compatibility test | Build configuration | `-Xllvm -vectorize-slp=false` | Time | |---------------------|-------------------------------|------| | debug | ❌ | 70s | | debug | ✅ | 71s | | release | ❌ | 252s | | release | ✅ | 249s | Conclusion: As expected, this has no impact in debug; but also, not in release. All following experiments do not use this flag when building the generator and the compatibility test suite. #### Test times (only code generation) The following table shows the result of running the compatibility test suite in a mode that only performs code generation, i.e. it does not build the generated code. | Build configuration | Parallel test[^1] | Time[^2] | |---------------------|-------------------|----------| | debug | no | 157s | | debug | yes | 108s | | release | no | 53s | | release | yes | 38s | [^1]: _Parallel test_ implies the test was run with: `--parallel --num-workers $(($(nproc)-1))`. [^2]: This does not include build time; tests are run with `--skip-build`. Conclusion: Probably worth parallelizing the test, up to the cores. #### Building the compatibility test and running codegen The following table combines the results from the previous sections. | Build configuration | Parallel test | Build time | Test time | Total time | | ------------------- | ------------- | ----------- | --------- | ---------- | | debug | no | 70s | 157s | 227s | | debug | yes | 70s | 108s | 178s | | release | no | 252s | 53s | 305s | | release | yes | 252s | 38s | 270s | Conclusion: Given that building the generated code (next section) is unaffected by whether the generator and test are compiled in release mode we can determine that the fastest pipeline that runs the codegen is debug, with parallel test. All further experiments use debug build of the generator and tests. #### Test times (including building generated code) | `--parallel` | Test time[^3] | |--------------|---------------| | ❌ | 21m34s | | ✅ | 29m45s | [^3]: Note, this does _not_ include build time of the generator or the compatibility test suite. Conclusion: using `--parallel`, at the XCTest level, doesn't play too well with the `swift build`, within the test. That is because each of the `swift build` commands in each of the parallel tests will parallelise according to the number of cores. Looking at `top` in the container, we can see that there is an explosion of build processes that compete with each other and with the outstanding `swift-openapi-generator` that are still in flight. ### Disable parallel build of generated code This can be resolved by using `swift build -j 1` within the test, which does allow `--parallel` to provide some speedup: | Parallel test | Parallel build | Time | |--------------|--------|--------| | ❌ | ✅ | 21m34s | | ✅ | ✅ | 29m45s | | ✅ | ❌ | 15m56s | | ❌ | ❌ | ? | #### Conclusions 1. If we want a pipeline that just runs code generation, it will take around 3 minutes, and should: a. Build the generator and compatibility test suite in debug. b. Use `--parallel` when running the test. 2. If we want a pipeline that also builds the generated code, it will take around 17 minutes, and should, additionally: c. Use `swift build -j 1` when building the generated code. #### Potential other directions It might be worth _not_ using XCTest as the harness for the compatibility suite and then we can control the parallelism from within the compatibility test harness itself. That said, this is probably good enough for now. --------- Signed-off-by: Si Beaumont <[email protected]>
1 parent d7da4db commit 0488531

File tree

3 files changed

+504
-0
lines changed

3 files changed

+504
-0
lines changed

NOTICE.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,79 @@ This product contains derivations of examples from the OpenAPI project.
4141
* https://github.com/OAI/OpenAPI-Specification/blob/main/LICENSE
4242
* HOMEPAGE:
4343
* https://github.com/OAI/OpenAPI-Specification
44+
45+
-------------------------------------------------------------------------------
46+
47+
This product contains OpenAPI document(s) for compatibility testing from:
48+
49+
* AWS Lambda for .NET Core
50+
* LICENSE (Apache License 2.0):
51+
* https://www.apache.org/licenses/LICENSE-2.0
52+
* HOMEPAGE:
53+
* https://github.com/aws/aws-lambda-dotnet
54+
55+
* Azure IoT Identity Service
56+
* LICENSE (MIT License):
57+
* https://mit-license.org
58+
* HOMEPAGE:
59+
* https://github.com/Azure/iot-identity-service
60+
61+
* OpenAPI 3.0 Specification for the Box APIs
62+
* LICENSE (Apache License 2.0):
63+
* https://www.apache.org/licenses/LICENSE-2.0
64+
* HOMEPAGE:
65+
* https://github.com/box/box-openapi
66+
67+
* MindMeld Conversational AI Platform
68+
* LICENSE (Apache License 2.0):
69+
* https://www.apache.org/licenses/LICENSE-2.0
70+
* HOMEPAGE:
71+
* https://github.com/cisco/mindmeld
72+
73+
* Cloud Hypervisor
74+
* LICENSE (Apache License 2.0):
75+
* https://www.apache.org/licenses/LICENSE-2.0
76+
* HOMEPAGE:
77+
* https://github.com/cloud-hypervisor/cloud-hypervisor
78+
79+
* Discourse API Documentation
80+
* LICENSE (MIT License):
81+
* https://mit-license.org
82+
* HOMEPAGE:
83+
* https://github.com/discourse/discourse_api_docs
84+
85+
* GitHub's REST API OpenAPI Description
86+
* LICENSE (MIT License):
87+
* https://mit-license.org
88+
* HOMEPAGE:
89+
* https://github.com/github/rest-api-description
90+
91+
* Kubernetes (K8s)
92+
* LICENSE (Apache License 2.0):
93+
* https://www.apache.org/licenses/LICENSE-2.0
94+
* HOMEPAGE:
95+
* https://github.com/kubernetes/kubernetes
96+
97+
* ConsoleMe
98+
* LICENSE (Apache License 2.0):
99+
* https://www.apache.org/licenses/LICENSE-2.0
100+
* HOMEPAGE:
101+
* https://github.com/Netflix/consoleme
102+
103+
* OpenAPI spec for the OpenAI API
104+
* LICENSE (MIT License):
105+
* https://mit-license.org
106+
* HOMEPAGE:
107+
* https://github.com/openai/openai-openapi
108+
109+
* The OpenAPI Specification
110+
* LICENSE (Apache License 2.0):
111+
* https://www.apache.org/licenses/LICENSE-2.0
112+
* HOMEPAGE:
113+
* https://github.com/OAI/OpenAPI-Specification
114+
115+
* Swift Package Manager Project
116+
* LICENSE (Apache License 2.0):
117+
* https://www.apache.org/licenses/LICENSE-2.0
118+
* HOMEPAGE:
119+
* https://github.com/apple/swift-package-manager

0 commit comments

Comments
 (0)