-
Notifications
You must be signed in to change notification settings - Fork 123
test: Rename test names to follow a well defined pattern #2540
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
base: main
Are you sure you want to change the base?
Conversation
Tests are named using the pattern Test<Category><Provider><TestName> This helps to filter tests and run specific categories as needed. Signed-off-by: Pradipta Banerjee <[email protected]>
|
Folks, ptal a look and let me know if this approach sounds good. With the current code, it's really hard to run specific set of tests on need basis so I'm starting with a well-defined and opinionated patter for the names. |
Thanks for this - I think it's good, but I wonder how you are considering the aim of our to have a "BVT" suite for running on the nightly as I think we'd want to cross-cut multiple of these categories, but not run all the tests within these? |
One approach I am thinking is to have separate labels for each categories and then triggering a suite (say nightly or bvt etc) via grouping the labels. Do you think this approach will work with GHA ? |
Sorry, I don't understand this proposal? What do you mean by labels? |
I meant the labels that you use today to trigger the e2e tests. Like |
Magnus' proposal is that we run a cut down version of the e2e tests on nightly to improve the reliability (what I'm calling the BVT), but run the full e2e tests on PRs. It sounds like you are working on an orthogonal idea and you don't want to run the full e2e tests on PRs, but only selective tests driven by a label? What's the reason behind this as it feels like we run full tests on PRs to try and ensure that we don't break the |
Sorry for the confusion. In this PR, my only intention is to make it easier to run group of tests via regular expression (via setting the RUN_TESTS variable) which is not possible today. However we do need a way to run some specific tests for some PR so as to not overload the runners. This is where I was thinking we can have GH labels which can be mapped to specific regular expressions to allow a subset of tests to run. Does this help ? |
api/types ContainerListOptions is moved to api/types/container Ref: moby/moby#47148 Signed-off-by: Pradipta Banerjee <[email protected]>
Not really - I don't understand when we would use the labels? However, my naive approach for the BVT was going to be a relabel that clashes with what you did e.g. |
Can you run the following as part of bvt.yaml GHA workflow for example ? |
|
Looks like the docker e2e is broken due to some recent changes :-(. I'm looking into it. Will send PR soon. |
I don't think your definition of the labels matches with what we'd want in the BVT. I'd expect us to have some of BTW - thanks for the starting this conversation - it's really important! |
Let's ignore the labels for now and see how we can run specific set of tests. I think that's the real issue. Or am I missing something? If not, then may be we can think about naming the tests in a way to include the category like BVT, Nightly etc. ? |
Yeah, AFAIK the regex is in the only way to do it, so I figured we just have a list of the tests and rename the cut down version TestBVT and then in the nightly gha with just set RUN_TESTS to be |
When you get time, can you list down the tests you would want to run for BVT? I'll have a sample pattern and then we can iterate to see if it makes sense. |
|
I created #2542 to cover this discuss and as a starting point. I hope this helps |
Ensure configured API version is used for the provider and the related tests Signed-off-by: Pradipta Banerjee <[email protected]>
486cd2a to
f1d7d99
Compare
|
Hi @bpradipt @stevenhorsman ! Sorry, late for the party. The problem with having the category (or grouping) in the test's name is you cannot easily share tests among different categories. The standard go For example, split in // libvirt_basic_test.go
//go:build libvirt && basic
package e2e
import (
"testing"
_ "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/libvirt"
)
func TestLibvirtCreateSimplePod(t *testing.T) {
assert := LibvirtAssert{}
DoTestCreateSimplePod(t, testEnv, assert)
}
...
...
...// libvirt_bvt_test.go
//go:build libvirt && bvt
package e2e
import (
"testing"
_ "github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/test/provisioner/libvirt"
)
func TestLibvirtCreateSimplePod(t *testing.T) {
assert := LibvirtAssert{}
DoTestCreateSimplePod(t, testEnv, assert)
}
...
...
...
func TestLibvirtKbsKeyRelease(t *testing.T) {
if !isTestWithKbs() {
t.Skip("Skipping kbs related test as kbs is not deployed")
}
testSecret := envconf.RandomName("coco-pp-e2e-secret", 25)
resourcePath := "caa/workload_key/test_key.bin"
err := keyBrokerService.SetSecret(resourcePath, []byte(testSecret))
if err != nil {
t.Fatalf("SetSecret failed with: %v", err)
}
err = keyBrokerService.EnableKbsCustomizedResourcePolicy("deny_all.rego")
if err != nil {
t.Fatalf("EnableKbsCustomizedResourcePolicy failed with: %v", err)
}
kbsEndpoint, err := keyBrokerService.GetCachedKbsEndpoint()
if err != nil {
t.Fatalf("GetCachedKbsEndpoint failed with: %v", err)
}
assert := LibvirtAssert{}
t.Parallel()
DoTestKbsKeyReleaseForFailure(t, testEnv, assert, kbsEndpoint, resourcePath, testSecret)
if isTestWithKbsIBMSE() {
t.Log("KBS with ibmse cases")
// the allow_*_.rego file is created by follow document
// https://github.com/confidential-containers/trustee/blob/main/deps/verifier/src/se/README.md#set-attestation-policy
err = keyBrokerService.EnableKbsCustomizedAttestationPolicy("allow_with_wrong_image_tag.rego")
if err != nil {
t.Fatalf("EnableKbsCustomizedAttestationPolicy failed with: %v", err)
}
DoTestKbsKeyReleaseForFailure(t, testEnv, assert, kbsEndpoint, resourcePath, testSecret)
err = keyBrokerService.EnableKbsCustomizedAttestationPolicy("allow_with_correct_claims.rego")
if err != nil {
t.Fatalf("EnableKbsCustomizedAttestationPolicy failed with: %v", err)
}
DoTestKbsKeyRelease(t, testEnv, assert, kbsEndpoint, resourcePath, testSecret)
} else {
t.Log("KBS normal cases")
err = keyBrokerService.EnableKbsCustomizedResourcePolicy("allow_all.rego")
if err != nil {
t.Fatalf("EnableKbsCustomizedResourcePolicy failed with: %v", err)
}
DoTestKbsKeyRelease(t, testEnv, assert, kbsEndpoint, resourcePath, testSecret)
}
}And we tweak the Makefile so that the categories (list of go build labels) are passed in the call: RUN_TEST_CATEGORIES ?= basic,net,security
.PHONY: test-e2e
test-e2e: ## Run end-to-end tests for single provider.
ifneq ($(CLOUD_PROVIDER),)
go test -v -tags=$(CLOUD_PROVIDER),$(RUN_TEST_CATEGORIES) -timeout $(TEST_E2E_TIMEOUT) -count=1 -run $(RUN_TESTS) ./test/e2e
else
$(error CLOUD_PROVIDER is not set)
endifIf I only want to run bvt ones One clear cons of that approach is that test function definitions are duplicated on many files and this can easily get out of sync. Some functions like |
Tests are named using the pattern Test This helps to filter tests and run specific categories as needed.