From b230714af89225eb46164ed12dd8444092514360 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 5 Dec 2023 16:45:12 +0100 Subject: [PATCH] Makefile: add env var controls to make test targets configurable Signed-off-by: Carlos Eduardo Arango Gutierrez --- Makefile | 22 ++++++++++++++-------- docs/developer-guide/index.md | 15 ++++++++++++--- scripts/test-infra/test-e2e.sh | 1 + test/e2e/framework.go | 7 +++---- test/e2e/nfd_gc_test.go | 6 +++--- test/e2e/node_feature_discovery_test.go | 12 ++++++------ test/e2e/topology_updater_test.go | 2 +- 7 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index ae81f32b95..80604e0607 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,8 @@ HOSTMOUNT_PREFIX ?= / KUBECONFIG ?= ${HOME}/.kube/config E2E_TEST_CONFIG ?= E2E_PULL_IF_NOT_PRESENT ?= false +E2E_TEST_FULL_IMAGE ?= false +E2E_GINKGO_LABEL_FILTER ?= BUILD_FLAGS = -tags osusergo,netgo \ -ldflags "-s -w -extldflags=-static -X sigs.k8s.io/node-feature-discovery/pkg/version.version=$(VERSION) -X sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath.pathPrefix=$(HOSTMOUNT_PREFIX)" @@ -191,16 +193,20 @@ e2e-test: -kubeconfig=$(KUBECONFIG) \ -nfd.e2e-config=$(E2E_TEST_CONFIG) \ -nfd.pull-if-not-present=$(E2E_PULL_IF_NOT_PRESENT) \ - -ginkgo.focus="\[kubernetes-sigs\]" \ - -test.timeout=1h \ - $(if $(OPENSHIFT),-nfd.openshift,) - $(GO_CMD) test -v ./test/e2e/ -args -nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME)-full \ - -kubeconfig=$(KUBECONFIG) \ - -nfd.e2e-config=$(E2E_TEST_CONFIG) \ - -nfd.pull-if-not-present=$(E2E_PULL_IF_NOT_PRESENT) \ - -ginkgo.focus="\[kubernetes-sigs\]" \ + -ginkgo.focus="\[k8s-sigs\/node-feature-discovery\]" \ + -ginkgo.label-filter=$(E2E_GINKGO_LABEL_FILTER) \ -test.timeout=1h \ $(if $(OPENSHIFT),-nfd.openshift,) + @if [ "$(E2E_TEST_FULL_IMAGE)" = "true" ]; then \ + $(GO_CMD) test -v ./test/e2e/ -args -nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME)-full \ + -kubeconfig=$(KUBECONFIG) \ + -nfd.e2e-config=$(E2E_TEST_CONFIG) \ + -nfd.pull-if-not-present=$(E2E_PULL_IF_NOT_PRESENT) \ + -ginkgo.focus="\[k8s-sigs\/node-feature-discovery\]" \ + -ginkgo.label-filter=$(E2E_GINKGO_LABEL_FILTER) \ + -test.timeout=1h \ + $(if $(OPENSHIFT),-nfd.openshift,) + fi push: $(IMAGE_PUSH_CMD) $(IMAGE_TAG) diff --git a/docs/developer-guide/index.md b/docs/developer-guide/index.md index 50473d5c59..27a257b8aa 100644 --- a/docs/developer-guide/index.md +++ b/docs/developer-guide/index.md @@ -122,9 +122,7 @@ makefile overrides. | IMAGE_TAG_NAME | Container image tag name | <nfd version> | | IMAGE_EXTRA_TAG_NAMES | Additional container image tag(s) to create when building image | *empty* | | K8S_NAMESPACE | nfd-master and nfd-worker namespace | node-feature-discovery | -| KUBECONFIG | Kubeconfig for running e2e-tests | *empty* | -| E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *empty* | -| E2E_PULL_IF_NOT_PRESENT | True-ish value makes the image pull policy IfNotPresent (to be used only in e2e tests) | false | + | OPENSHIFT | Non-empty value enables OpenShift specific support (only affects e2e tests) | *empty* | For example, to use a custom registry: @@ -164,6 +162,17 @@ cluster you need to specify the kubeconfig to be used: make e2e-test KUBECONFIG=$HOME/.kube/config ``` +There are several environment variables that can be used to customize the +e2e-tests: + +| Variable | Description | Default value | +| -------------------------- | ----------------------------------------------------------------- | ------------- | +| KUBECONFIG | Kubeconfig for running e2e-tests | *empty* | +| E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *empty* | +| E2E_PULL_IF_NOT_PRESENT | True-ish value makes the image pull policy IfNotPresent (to be used only in e2e tests) | false | +| E2E_TEST_FULL_IMAGE | Run e2e-test also against the Full Image tag | false | +| E2E_GINKGO_LABEL_FILTER | Ginkgo label filter to use for running e2e tests | *empty* | + ## Running locally > ****DEPRECATED**: Running NFD locally is deprecated and will be removed in a diff --git a/scripts/test-infra/test-e2e.sh b/scripts/test-infra/test-e2e.sh index 2aeb95d286..9e384803db 100755 --- a/scripts/test-infra/test-e2e.sh +++ b/scripts/test-infra/test-e2e.sh @@ -11,6 +11,7 @@ chmod a+x /usr/local/bin/kubectl # Configure environment export KUBECONFIG=`pwd`/kubeconfig export E2E_TEST_CONFIG=`pwd`/e2e-test-config +export E2E_TEST_FULL_IMAGE=true echo "$KUBECONFIG_DATA" > "$KUBECONFIG" echo "$E2E_TEST_CONFIG_DATA" > "$E2E_TEST_CONFIG" diff --git a/test/e2e/framework.go b/test/e2e/framework.go index a3e71424b1..e9249db538 100644 --- a/test/e2e/framework.go +++ b/test/e2e/framework.go @@ -1,5 +1,5 @@ /* -Copyright 2021 The Kubernetes Authors. +Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package e2e import "github.com/onsi/ginkgo/v2" -// SIGDescribe annotates the test with the SIG label. -func SIGDescribe(text string, body func()) bool { - return ginkgo.Describe("[kubernetes-sigs] "+text, body) +func NFDDescribe(args ...interface{}) bool { + return ginkgo.Describe("[k8s-sigs/node-feature-discovery]", append(args, ginkgo.Label("nfd-all"))...) } diff --git a/test/e2e/nfd_gc_test.go b/test/e2e/nfd_gc_test.go index c2b21ca038..ac825d91b0 100644 --- a/test/e2e/nfd_gc_test.go +++ b/test/e2e/nfd_gc_test.go @@ -38,7 +38,7 @@ import ( ) // Actual test suite -var _ = SIGDescribe("NFD GC", func() { +var _ = NFDDescribe(Label("nfd-gc"), func() { f := framework.NewDefaultFramework("nfd-gc") Context("when deploying nfd-gc", Ordered, func() { @@ -117,7 +117,7 @@ var _ = SIGDescribe("NFD GC", func() { // Test GC at startup // Context("with pre-existing NodeFeature and NodeResourceTopology objects", func() { - It("it should delete stale objects at startup", func(ctx context.Context) { + It("it should delete stale objects at startup", Label("gc-startup"), func(ctx context.Context) { nodes, err := f.ClientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{}) Expect(err).NotTo(HaveOccurred()) targetNodeNames := []string{nodes.Items[0].GetName()} @@ -153,7 +153,7 @@ var _ = SIGDescribe("NFD GC", func() { // Test periodic GC // Context("with stale NodeFeature and NodeResourceTopology objects appearing", func() { - It("it should remove stale objects", func(ctx context.Context) { + It("it should remove stale objects", Label("gc-periodic"), func(ctx context.Context) { nodes, err := f.ClientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{}) Expect(err).NotTo(HaveOccurred()) targetNodeNames := []string{nodes.Items[0].GetName()} diff --git a/test/e2e/node_feature_discovery_test.go b/test/e2e/node_feature_discovery_test.go index 5493acd754..5d64953aaa 100644 --- a/test/e2e/node_feature_discovery_test.go +++ b/test/e2e/node_feature_discovery_test.go @@ -177,7 +177,7 @@ func cleanupCRs(ctx context.Context, cli *nfdclient.Clientset, namespace string) } // Actual test suite -var _ = SIGDescribe("NFD master and worker", func() { +var _ = NFDDescribe(Label("nfd-master"), func() { f := framework.NewDefaultFramework("node-feature-discovery") nfdTestSuite := func(useNodeFeatureApi bool) { @@ -272,7 +272,7 @@ var _ = SIGDescribe("NFD master and worker", func() { // Simple test with only the fake source enabled // Context("and a single worker pod with fake source enabled", func() { - It("it should decorate the node with the fake feature labels", func(ctx context.Context) { + It("it should decorate the node with the fake feature labels", Label("nfd-worker"), func(ctx context.Context) { nodes, err := getNonControlPlaneNodes(ctx, f.ClientSet) Expect(err).NotTo(HaveOccurred()) @@ -315,7 +315,7 @@ var _ = SIGDescribe("NFD master and worker", func() { // More comprehensive test when --e2e-node-config is enabled // Context("and nfd-workers as a daemonset with default sources enabled", func() { - It("the node labels and annotations listed in the e2e config should be present", func(ctx context.Context) { + It("the node labels and annotations listed in the e2e config should be present", Label("nfd-worker"), func(ctx context.Context) { cfg, err := testutils.GetConfig() Expect(err).ToNot(HaveOccurred()) @@ -407,7 +407,7 @@ var _ = SIGDescribe("NFD master and worker", func() { // Test custom nodename source configured in 2 additional ConfigMaps // Context("and nfd-workers as a daemonset with 2 additional configmaps for the custom source configured", func() { - It("the nodename matching features listed in the configmaps should be present", func(ctx context.Context) { + It("the nodename matching features listed in the configmaps should be present", Label("nfd-worker"), func(ctx context.Context) { By("Getting a worker node") // We need a valid nodename for the configmap @@ -505,7 +505,7 @@ var _ = SIGDescribe("NFD master and worker", func() { ), } }) - It("labels from the NodeFeature objects should be created", func(ctx context.Context) { + It("labels from the NodeFeature objects should be created", Label("nfd-worker"), func(ctx context.Context) { if !useNodeFeatureApi { Skip("NodeFeature API not enabled") } @@ -664,7 +664,7 @@ var _ = SIGDescribe("NFD master and worker", func() { testpod.SpecWithTolerations(testTolerations), } }) - It("custom features from the NodeFeatureRule rules should be created", func(ctx context.Context) { + It("custom features from the NodeFeatureRule rules should be created", Label("nfd-worker"), func(ctx context.Context) { nodes, err := getNonControlPlaneNodes(ctx, f.ClientSet) Expect(err).NotTo(HaveOccurred()) diff --git a/test/e2e/topology_updater_test.go b/test/e2e/topology_updater_test.go index 07c017e792..8b463ed283 100644 --- a/test/e2e/topology_updater_test.go +++ b/test/e2e/topology_updater_test.go @@ -46,7 +46,7 @@ import ( testpod "sigs.k8s.io/node-feature-discovery/test/e2e/utils/pod" ) -var _ = SIGDescribe("NFD topology updater", func() { +var _ = NFDDescribe(Label("nfd-topology-updater"), func() { var ( extClient *extclient.Clientset topologyClient *topologyclientset.Clientset