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

Fix flaky test by disabling Prometheus metrics #1341

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

dhwthompson
Copy link
Contributor

The test suites for some of our packages spin up parts of a Kubernetes cluster using the envtest library, so that we have something more solid than mocks to test against. One problem this was causing was that running tests for both the kube and server packages at once would cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more efficiently by spinning up a fake web server to sit on port 8080, for example using Python's built-in web server:

python3 -m http.server 8080

After some digging, I found out that the reason for this is that both environments were trying to spin up a Prometheus metrics handler listening on port 8080. If they both tried to do this at once, one would fail, causing the entire test suite for that package to fail too (including some nil-pointer panics during the clean up, which might be worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for the test clusters (the documentation for which is buried in a comment in the Kubernetes docs), which fixes this particular problem. Testing on my local machine, there didn't seem to be any other fixed port assignments cropping up to take its place.

Closes: #1332

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager
Copy link
Contributor

@jpellizzari jpellizzari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

Copy link
Contributor

@jpellizzari jpellizzari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never would have found this. Nice work!

@dhwthompson dhwthompson merged commit 0d022cc into main Jan 25, 2022
@dhwthompson dhwthompson deleted the fix-double-test-port-failure branch January 25, 2022 18:58
joshri pushed a commit that referenced this pull request Jan 26, 2022
The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager
jpellizzari pushed a commit that referenced this pull request Jan 26, 2022
The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager
jpellizzari pushed a commit that referenced this pull request Jan 26, 2022
The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager
jpellizzari added a commit that referenced this pull request Jan 28, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
jpellizzari added a commit that referenced this pull request Feb 7, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
joshri pushed a commit that referenced this pull request Feb 10, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
joshri pushed a commit that referenced this pull request Feb 16, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
jpellizzari added a commit that referenced this pull request Feb 25, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
jpellizzari added a commit that referenced this pull request Mar 3, 2022
* New proto endpoints

* Added integration tests

* V2 workflow added

* Use controller-runtime client in app server

* Fix whitepace and unused linting errors

* Add kustomization tests

* Fix flaky test by disabling Prometheus metrics (#1341)

The test suites for some of our packages spin up parts of a Kubernetes
cluster using the `envtest` library, so that we have something more
solid than mocks to test against. One problem this was causing was that
running tests for both the `kube` and `server` packages at once would
cause one of those test suites to fail.

Side-note: it's possible to reproduce this problem a little more
efficiently by spinning up a fake web server to sit on port 8080, for
example using Python's built-in web server:

    python3 -m http.server 8080

After some digging, I found out that the reason for this is that both
environments were trying to spin up a Prometheus metrics handler
listening on port 8080. If they both tried to do this at once, one would
fail, causing the entire test suite for that package to fail too
(including some nil-pointer panics during the clean up, which might be
worth tidying up in a future pull request).

Setting the metrics bind address to the string "0" disables metrics for
the test clusters (the documentation for which is buried in a comment in
the Kubernetes docs[1]), which fixes this particular problem. Testing on
my local machine, there didn't seem to be any other fixed port
assignments cropping up to take its place.

[1]: https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.2/pkg/manager

* Use suite test for kubebuilder setup/teardown

* Add more create kustomization test coverage

* Skip acceptance test lint

* Split k8s resources into separate files

* Initial work implementing HelmRepository to the API

* Added weave related labels to helm repository resource

* Use app name to list helm repositories

* Added unit test for ListHelmRepositories

* Added missing namespace parameter when listing helm repositories

Co-authored-by: James Wilson <jwils22@gmail.com>
Co-authored-by: Jordan Pellizzari <jordan@weave.works>
Co-authored-by: David Thompson <32775+dhwthompson@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K8s test environment causes test failures on a clean build
3 participants