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

Makefile: add env var controls to make test targets configurable #1489

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ HOSTMOUNT_PREFIX ?= /
KUBECONFIG ?= ${HOME}/.kube/config
E2E_TEST_CONFIG ?=
E2E_PULL_IF_NOT_PRESENT ?= false
E2E_TEST_FULL_IMAGE ?= false
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
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)"
Expand Down Expand Up @@ -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\]" \
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
-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)
Expand Down
16 changes: 12 additions & 4 deletions docs/developer-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ 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:

Expand Down Expand Up @@ -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* |
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
| 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
Expand Down
1 change: 1 addition & 0 deletions scripts/test-infra/test-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
ArangoGutierrez marked this conversation as resolved.
Show resolved Hide resolved
func NFDDescribe(args ...interface{}) bool {
return ginkgo.Describe("[k8s-sigs/node-feature-discovery]", append(args, ginkgo.Label("nfd-all"))...)
}
6 changes: 3 additions & 3 deletions test/e2e/nfd_gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()}
Expand Down Expand Up @@ -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()}
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/node_feature_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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())

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/topology_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down