mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
test/e2e: make openshift bits optional
Only enabled if OPENSHIFT is specified in the environment when running make e2e-test, for example: $ OPENSHIFT=y make e2e-test
This commit is contained in:
parent
3d5c1a18a2
commit
7e6f740c9f
3 changed files with 13 additions and 4 deletions
6
Makefile
6
Makefile
|
@ -39,6 +39,8 @@ IMAGE_EXTRA_TAGS := $(foreach tag,$(IMAGE_EXTRA_TAG_NAMES),$(IMAGE_REPO):$(tag))
|
||||||
|
|
||||||
K8S_NAMESPACE ?= node-feature-discovery
|
K8S_NAMESPACE ?= node-feature-discovery
|
||||||
|
|
||||||
|
OPENSHIFT ?=
|
||||||
|
|
||||||
# We use different mount prefix for local and container builds.
|
# We use different mount prefix for local and container builds.
|
||||||
# Take CONTAINER_HOSTMOUNT_PREFIX from HOSTMOUNT_PREFIX if only the latter is specified
|
# Take CONTAINER_HOSTMOUNT_PREFIX from HOSTMOUNT_PREFIX if only the latter is specified
|
||||||
ifdef HOSTMOUNT_PREFIX
|
ifdef HOSTMOUNT_PREFIX
|
||||||
|
@ -127,7 +129,9 @@ test:
|
||||||
|
|
||||||
e2e-test:
|
e2e-test:
|
||||||
@if [ -z ${KUBECONFIG} ]; then echo "[ERR] KUBECONFIG missing, must be defined"; exit 1; fi
|
@if [ -z ${KUBECONFIG} ]; then echo "[ERR] KUBECONFIG missing, must be defined"; exit 1; fi
|
||||||
$(GO_CMD) test -v ./test/e2e/ -args -nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME) -kubeconfig=$(KUBECONFIG) -nfd.e2e-config=$(E2E_TEST_CONFIG) -ginkgo.focus="\[NFD\]"
|
$(GO_CMD) test -v ./test/e2e/ -args -nfd.repo=$(IMAGE_REPO) -nfd.tag=$(IMAGE_TAG_NAME) \
|
||||||
|
-kubeconfig=$(KUBECONFIG) -nfd.e2e-config=$(E2E_TEST_CONFIG) -ginkgo.focus="\[NFD\]" \
|
||||||
|
$(if $(OPENSHIFT),-nfd.openshift,)
|
||||||
|
|
||||||
push:
|
push:
|
||||||
$(IMAGE_PUSH_CMD) $(IMAGE_TAG)
|
$(IMAGE_PUSH_CMD) $(IMAGE_TAG)
|
||||||
|
|
|
@ -110,6 +110,7 @@ makefile overrides.
|
||||||
| K8S_NAMESPACE | nfd-master and nfd-worker namespace | kube-system
|
| K8S_NAMESPACE | nfd-master and nfd-worker namespace | kube-system
|
||||||
| KUBECONFIG | Kubeconfig for running e2e-tests | *empty*
|
| KUBECONFIG | Kubeconfig for running e2e-tests | *empty*
|
||||||
| E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *empty*
|
| E2E_TEST_CONFIG | Parameterization file of e2e-tests (see [example][e2e-config-sample]) | *empty*
|
||||||
|
| OPENSHIFT | Non-empty value enables OpenShift specific support (currently only effective in e2e tests) | *empty*
|
||||||
|
|
||||||
For example, to use a custom registry:
|
For example, to use a custom registry:
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ var (
|
||||||
dockerRepo = flag.String("nfd.repo", "gcr.io/k8s-staging-nfd/node-feature-discovery", "Docker repository to fetch image from")
|
dockerRepo = flag.String("nfd.repo", "gcr.io/k8s-staging-nfd/node-feature-discovery", "Docker repository to fetch image from")
|
||||||
dockerTag = flag.String("nfd.tag", "master", "Docker tag to use")
|
dockerTag = flag.String("nfd.tag", "master", "Docker tag to use")
|
||||||
e2eConfigFile = flag.String("nfd.e2e-config", "", "Configuration parameters for end-to-end tests")
|
e2eConfigFile = flag.String("nfd.e2e-config", "", "Configuration parameters for end-to-end tests")
|
||||||
|
openShift = flag.Bool("nfd.openshift", false, "Enable OpenShift specific bits")
|
||||||
|
|
||||||
conf *e2eConfig
|
conf *e2eConfig
|
||||||
)
|
)
|
||||||
|
@ -168,14 +169,17 @@ func createClusterRole(cs clientset.Interface) (*rbacv1.ClusterRole, error) {
|
||||||
Resources: []string{"nodes"},
|
Resources: []string{"nodes"},
|
||||||
Verbs: []string{"get", "patch", "update"},
|
Verbs: []string{"get", "patch", "update"},
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
|
}
|
||||||
|
if *openShift {
|
||||||
|
cr.Rules = append(cr.Rules,
|
||||||
|
rbacv1.PolicyRule{
|
||||||
// needed on OpenShift clusters
|
// needed on OpenShift clusters
|
||||||
APIGroups: []string{"security.openshift.io"},
|
APIGroups: []string{"security.openshift.io"},
|
||||||
Resources: []string{"securitycontextconstraints"},
|
Resources: []string{"securitycontextconstraints"},
|
||||||
ResourceNames: []string{"hostaccess"},
|
ResourceNames: []string{"hostaccess"},
|
||||||
Verbs: []string{"use"},
|
Verbs: []string{"use"},
|
||||||
},
|
})
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return cs.RbacV1().ClusterRoles().Update(context.TODO(), cr, metav1.UpdateOptions{})
|
return cs.RbacV1().ClusterRoles().Update(context.TODO(), cr, metav1.UpdateOptions{})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue