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

Refactor Kubernetes E2E test definition for ease of use #9581

Merged
merged 40 commits into from
Jun 17, 2024

Conversation

jbohanon
Copy link
Contributor

@jbohanon jbohanon commented Jun 5, 2024

Description

Introduces abstractions over the test cases for Ordered and Unordered sets of tests within a suite. This allows us to define the run behavior of the tests separate from the suite that runs them.

Also refactors the tests out into an importable tests package (*_test packages cannot be imported). This will allow us to run the tests in the same way in EE, and also make sure the test suites in OSS and EE stay in lockstep.

Any tests which did not have a comment about needing to be ordered were assumed to be unordered. There is a non-zero risk that this introduces some flakes if the test order was in fact important.

Context

Tests added to these suites in OSS had to be added in the same manner in EE. By exporting the entire pack of tests to run, the EE suites can import them to run on their bespoke e2e.TestInstallation.

Code changes

  • New types and interface to abstract the concept of Ordered and Unordered groups of tests
  • Tests actually run in the suite were separated from the suite. This adds a little unnecessary code distance, but in order to import them they could not be in a *_test package and it seemed cleaner to me (and possibly necessary for testify but not sure) to leave the suites in *_test package.

Testing steps

I manually verified behavior by opening https://github.com/solo-io/solo-projects/pull/6314 and running nightlies off of that branch to see that the expected suite ran (at that time just the k8s_gw_tests had been migrated).

Interesting decisions

In order to reduce verbosity of defining a new test, we strip back some of the injection to the actual Run function. This means that we cannot need to reference the three things we need injected (ctx, t, testInstallation) when we are registering tests. To reconcile with this, what is registered is actually the feature suite construction function. We have enforced this by defining a new typedef for that signature and making a compiler assertion at the top of each feature suite for its construction function.

A side-effect of this is that nested test structures such as used for Glooctl in k8s_gw_test.go no longer work since we don't have access to the injected values at registration time. To resolve this, nested test structures must be defined as suites. An example of this can be found in the same Glooctl test, now located in k8s_gw_tests.go.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@github-actions github-actions bot added the keep pr updated signals bulldozer to keep pr up to date with base branch label Jun 5, 2024
@jbohanon jbohanon added the work in progress signals bulldozer to keep pr open (don't auto-merge) label Jun 5, 2024
Copy link

github-actions bot commented Jun 5, 2024

Visit the preview URL for this PR (updated for commit 3d86031):

https://gloo-edge--pr9581-jbohanon-e2e-tests-c-f5lfdmel.web.app

(expires Thu, 20 Jun 2024 14:45:20 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 77c2b86e287749579b7ff9cadb81e099042ef677

@solo-changelog-bot
Copy link

Issues linked to changelog:
#9353

@jbohanon
Copy link
Contributor Author

/skip-ci Kube tests only

@jbohanon jbohanon changed the title make tests runnable with injection Refactor Kubernetes E2E test definition for ease of use Jun 13, 2024
@jbohanon jbohanon removed the work in progress signals bulldozer to keep pr open (don't auto-merge) label Jun 13, 2024
@jbohanon
Copy link
Contributor Author

/skip-ci Kube tests only

@jbohanon
Copy link
Contributor Author

Had to kick cluster one due to this error which looks like the validation flakiness being worked on elsewhere in this repo now

Error from server: error when creating "/home/runner/work/gloo/gloo/test/kubernetes/e2e/features/glooctl/testdata/edge-gateway-gateways.yaml": admission webhook "gloo.k8s-gw-test.svc" denied the request: resource incompatible with current Gloo snapshot: [Validating *v1.Gateway failed: 1 error occurred:
	* Validating *v1.Gateway failed: validating *v1.Gateway name:"gateway1"  namespace:"k8s-gw-test": 1 error occurred:
	* could not render proxy: 2 errors occurred:
	* invalid resource k8s-gw-test.gateway1
	* invalid virtual service ref name:"vs1"  namespace:"default"

@jbohanon
Copy link
Contributor Author

/skip-ci Kube tests only

Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

nice work!

test/kubernetes/e2e/tests/types.go Outdated Show resolved Hide resolved
test/kubernetes/e2e/tests/types.go Outdated Show resolved Hide resolved
test/kubernetes/e2e/tests/types.go Outdated Show resolved Hide resolved
@jbohanon
Copy link
Contributor Author

/skip-ci Kube tests only

Copy link
Contributor

@sam-heilbron sam-heilbron left a comment

Choose a reason for hiding this comment

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

great work!

@jbohanon
Copy link
Contributor Author

/skip-ci Kube tests only

@jbohanon
Copy link
Contributor Author

Dozer?

@jbohanon jbohanon merged commit 6a8bd6b into main Jun 17, 2024
23 checks passed
@jbohanon jbohanon deleted the jbohanon/e2e-tests-cleanup branch June 17, 2024 17:06
npolshakova pushed a commit that referenced this pull request Jun 18, 2024
* make tests runnable with injection

* yoink var into better package

* refactor for un/ordered, convert the rest

* fix a missed merge conflict

* add changelog

* oops wrong skip

* rename and refactor

* clean up and compiler-assert new suite signatures

* documentation

* documentation

* fix my runs

* wrap un/ordered in struct for ease of use

* Adding changelog file to new location

* Deleting changelog file from old location

* move changelog

* Update test/kubernetes/e2e/tests/glooctl_istio_inject_tests.go

* refactor to export less

* move and rename suite runner

* update readme

* rename some more stuff

---------

Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: changelog-bot <changelog-bot>
soloio-bulldozer bot added a commit that referenced this pull request Jun 18, 2024
* make tests runnable with injection

* yoink var into better package

* refactor for un/ordered, convert the rest

* fix a missed merge conflict

* add changelog

* oops wrong skip

* rename and refactor

* clean up and compiler-assert new suite signatures

* documentation

* documentation

* fix my runs

* wrap un/ordered in struct for ease of use

* Adding changelog file to new location

* Deleting changelog file from old location

* move changelog

* Update test/kubernetes/e2e/tests/glooctl_istio_inject_tests.go

* refactor to export less

* move and rename suite runner

* update readme

* rename some more stuff

---------

Co-authored-by: Jacob Bohanon <jacob.bohanon@solo.io>
Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep pr updated signals bulldozer to keep pr up to date with base branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants