Validating the OpenAPI schema in the CI pipeline #8438

Closed
opened 2025-12-29 20:36:41 +01:00 by adam · 6 comments
Owner

Originally created by @commonism on GitHub (Aug 9, 2023).

NetBox version

v3.5.7

Feature type

New functionality

Proposed functionality

Unit testing assist in validating changes.
The GitHub CI can be used to create a docker-compose environment to test with.
I propose to create a GitHub CI using the existing netbox-docker container - extending it, overriding the netbox sources to match the commit.
And run tests towards this environment.
It'll help to validate the API matches the OpenAPI description document for requests and responses, and allow testing combinations of parameters.

Use case

Unit testing helps finding bugs and prevent regressions due to changes (in dependencies).

Database changes

No response

External dependencies

No response

Originally created by @commonism on GitHub (Aug 9, 2023). ### NetBox version v3.5.7 ### Feature type New functionality ### Proposed functionality Unit testing assist in validating changes. The GitHub CI can be used to create a docker-compose environment [to test with](https://gist.github.com/cecilemuller/437d7340b9f095cf5635dc9780a05092). I propose to create a GitHub CI using the existing netbox-docker container - extending it, overriding the netbox sources to match the commit. And run tests towards this environment. It'll help to validate the API matches the OpenAPI description document for requests and responses, and allow testing combinations of parameters. ### Use case Unit testing helps finding bugs and prevent regressions due to changes (in dependencies). ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurepending closurestatus: revisions needed labels 2025-12-29 20:36:41 +01:00
adam closed this issue 2025-12-29 20:36:42 +01:00
Author
Owner

@kkthxbye-code commented on GitHub (Aug 9, 2023):

I think the base idea is decent, but the FR is not detailed enough to be actionable.

The GitHub CI can be used to create a docker-compose environment to test with.

We already run the normal tests in the CI pipeline, where we spin up both postgres and redis. What would using docker-in-docker provide of benefits?

I propose to create a GitHub CI using the existing netbox-docker container - extending it, overriding the netbox sources to match the commit.

My gut feeling is that this is a no-go. Making netbox dependent on netbox-docker would be a pretty large burden on both projects and I'm not sure I see what the benefit would be.

And run tests towards this environment.

This needs a lot of elaboration to be actionable. What types of tests, with which tools, does it have to be a running instance or can we just use the testing systems we already have in place, these already tests the API.

It'll help to validate the API matches the OpenAPI description document for requests and responses, and allow testing combinations of parameters.

Performance of the CI pipeline would also need to be taken into account. There's also a question of how do we get to the point where we can actually fail the pipeline, as the schema is not in a place now where that is possible. It would probably need to be a seperate test, which doesn't block merging in the beginning.

Again, I'm not saying this is a bad idea. It just needs a whole lot of elaboration.

@kkthxbye-code commented on GitHub (Aug 9, 2023): I think the base idea is decent, but the FR is not detailed enough to be actionable. > The GitHub CI can be used to create a docker-compose environment [to test with](https://gist.github.com/cecilemuller/437d7340b9f095cf5635dc9780a05092). We already run the normal tests in the CI pipeline, where we spin up both postgres and redis. What would using docker-in-docker provide of benefits? > I propose to create a GitHub CI using the existing netbox-docker container - extending it, overriding the netbox sources to match the commit. My gut feeling is that this is a no-go. Making netbox dependent on netbox-docker would be a pretty large burden on both projects and I'm not sure I see what the benefit would be. > And run tests towards this environment. This needs a lot of elaboration to be actionable. What types of tests, with which tools, does it have to be a running instance or can we just use the testing systems we already have in place, these already tests the API. > It'll help to validate the API matches the OpenAPI description document for requests and responses, and allow testing combinations of parameters. Performance of the CI pipeline would also need to be taken into account. There's also a question of how do we get to the point where we can actually fail the pipeline, as the schema is not in a place now where that is possible. It would probably need to be a seperate test, which doesn't block merging in the beginning. Again, I'm not saying this is a bad idea. It just needs a whole lot of elaboration.
Author
Owner

@jeremystretch commented on GitHub (Aug 9, 2023):

My gut feeling is that this is a no-go. Making netbox dependent on netbox-docker would be a pretty large burden on both projects and I'm not sure I see what the benefit would be.

Agreed. Any tests we introduce, for any purpose, must be fully contained within this repository and not rely on external images or deployments.

@jeremystretch commented on GitHub (Aug 9, 2023): > My gut feeling is that this is a no-go. Making netbox dependent on netbox-docker would be a pretty large burden on both projects and I'm not sure I see what the benefit would be. Agreed. Any tests we introduce, for any purpose, _must_ be fully contained within this repository and not rely on external images or deployments.
Author
Owner

@commonism commented on GitHub (Aug 9, 2023):

Okay, you have a CI to test with already, great.
So adding API test is basically creating the environment and running the tests.

How about adding something similar to

python3 -m venv /tmp/nbu
/tmp/nbu/bin/pip install git+https://github.com/commonism/aiopenapi3.git@8df35fab904b821998bde6410fb9a847183a370b
/tmp/nbu/bin/pip install pytest pytest_asyncio
/tmp/nbu/bin/pytest thefile.py

thefile.py

as a test about here?
f5a1f83f9f/.github/workflows/ci.yml (L80-L81)

Could even contribute to coverage.

@commonism commented on GitHub (Aug 9, 2023): Okay, you have a CI to test with already, great. So adding API test is basically creating the environment and running the tests. How about adding something similar to ```shell python3 -m venv /tmp/nbu /tmp/nbu/bin/pip install git+https://github.com/commonism/aiopenapi3.git@8df35fab904b821998bde6410fb9a847183a370b /tmp/nbu/bin/pip install pytest pytest_asyncio /tmp/nbu/bin/pytest thefile.py ``` [thefile.py](https://gist.github.com/commonism/18bd0a13dee523c47f5453f3f8b587cf) as a test about here? https://github.com/netbox-community/netbox/blob/f5a1f83f9fa9d98c945d21eb0f7ccb8cd37fbf59/.github/workflows/ci.yml#L80-L81 Could even contribute to coverage.
Author
Owner

@tobiasge commented on GitHub (Aug 9, 2023):

From the point of view of netbox-docker I also have to say, that making tests of Netbox dependent on the Docker images is a bad idea.
We use the Netbox unit test to verify the images we build in our GitHub actions. So this would produce a circular dependency.

@tobiasge commented on GitHub (Aug 9, 2023): From the point of view of `netbox-docker` I also have to say, that making tests of Netbox dependent on the Docker images is a bad idea. We use the Netbox unit test to verify the images we build in our GitHub actions. So this would produce a circular dependency.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 8, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Nov 8, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Dec 9, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Dec 9, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8438