1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Makefile: add env var controls to make test targets configurable

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
This commit is contained in:
Carlos Eduardo Arango Gutierrez 2023-12-05 16:45:12 +01:00
parent bdfef6df18
commit f9195ef6a4
No known key found for this signature in database
GPG key ID: 42D9CB42F300A852
7 changed files with 40 additions and 26 deletions

View file

@ -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)

View file

@ -122,10 +122,6 @@ makefile overrides.
| IMAGE_TAG_NAME | Container image tag name | &lt;nfd version&gt; |
| 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 +160,18 @@ 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* |
| OPENSHIFT | Non-empty value enables OpenShift specific support (only affects e2e tests) | *empty* |
## Running locally
> ****DEPRECATED**: Running NFD locally is deprecated and will be removed in a

View file

@ -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"

View file

@ -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"))...)
}

View file

@ -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()}

View file

@ -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())

View file

@ -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