Remove setting taint during e2e test (#621)

We're in effect testing the K8s scheduler logic in the test
by setting taints, as opposed to the actual VK itself. If we
want to make sure the taint is set, we can just observe the node
object.

Instead, bind to the pod to the VK node explicitly.
This commit is contained in:
Sargun Dhillon
2019-05-17 10:49:37 -07:00
committed by Brian Goff
parent 5b3190acb5
commit 9bf05b525d
4 changed files with 12 additions and 57 deletions

View File

@@ -33,9 +33,6 @@ bin/e2e/virtual-kubelet: bin/e2e
e2e: KUBECONFIG ?= $(HOME)/.kube/config e2e: KUBECONFIG ?= $(HOME)/.kube/config
e2e: NAMESPACE := default e2e: NAMESPACE := default
e2e: NODE_NAME := vkubelet-mock-0 e2e: NODE_NAME := vkubelet-mock-0
e2e: TAINT_KEY := virtual-kubelet.io/provider
e2e: TAINT_VALUE := mock
e2e: TAINT_EFFECT := NoSchedule
e2e: export VK_BUILD_TAGS += mock_provider e2e: export VK_BUILD_TAGS += mock_provider
e2e: e2e.clean bin/e2e/virtual-kubelet skaffold/run e2e: e2e.clean bin/e2e/virtual-kubelet skaffold/run
@echo Running tests... @echo Running tests...
@@ -43,9 +40,6 @@ e2e: e2e.clean bin/e2e/virtual-kubelet skaffold/run
-kubeconfig=$(KUBECONFIG) \ -kubeconfig=$(KUBECONFIG) \
-namespace=$(NAMESPACE) \ -namespace=$(NAMESPACE) \
-node-name=$(NODE_NAME) \ -node-name=$(NODE_NAME) \
-taint-key=$(TAINT_KEY) \
-taint-value=$(TAINT_VALUE) \
-taint-effect=$(TAINT_EFFECT)
.PHONY: e2e.clean .PHONY: e2e.clean
e2e.clean: NODE_NAME ?= vkubelet-mock-0 e2e.clean: NODE_NAME ?= vkubelet-mock-0

View File

@@ -8,23 +8,17 @@ import (
// Framework encapsulates the configuration for the current run, and provides helper methods to be used during testing. // Framework encapsulates the configuration for the current run, and provides helper methods to be used during testing.
type Framework struct { type Framework struct {
KubeClient kubernetes.Interface KubeClient kubernetes.Interface
Namespace string Namespace string
NodeName string NodeName string
TaintKey string
TaintValue string
TaintEffect string
} }
// NewTestingFramework returns a new instance of the testing framework. // NewTestingFramework returns a new instance of the testing framework.
func NewTestingFramework(kubeconfig, namespace, nodeName, taintKey, taintValue, taintEffect string) *Framework { func NewTestingFramework(kubeconfig, namespace, nodeName string) *Framework {
return &Framework{ return &Framework{
KubeClient: createKubeClient(kubeconfig), KubeClient: createKubeClient(kubeconfig),
Namespace: namespace, Namespace: namespace,
NodeName: nodeName, NodeName: nodeName,
TaintKey: taintKey,
TaintValue: taintValue,
TaintEffect: taintEffect,
} }
} }

View File

@@ -15,10 +15,7 @@ import (
podutil "k8s.io/kubernetes/pkg/api/v1/pod" podutil "k8s.io/kubernetes/pkg/api/v1/pod"
) )
const ( const defaultWatchTimeout = 2 * time.Minute
defaultWatchTimeout = 2 * time.Minute
hostnameNodeSelectorLabel = "kubernetes.io/hostname"
)
// CreateDummyPodObjectWithPrefix creates a dujmmy pod object using the specified prefix as the value of .metadata.generateName. // CreateDummyPodObjectWithPrefix creates a dujmmy pod object using the specified prefix as the value of .metadata.generateName.
// A variable number of strings can be provided. // A variable number of strings can be provided.
@@ -33,16 +30,7 @@ func (f *Framework) CreateDummyPodObjectWithPrefix(prefix string, images ...stri
Namespace: f.Namespace, Namespace: f.Namespace,
}, },
Spec: corev1.PodSpec{ Spec: corev1.PodSpec{
NodeSelector: map[string]string{ NodeName: f.NodeName,
hostnameNodeSelectorLabel: f.NodeName,
},
Tolerations: []corev1.Toleration{
{
Key: f.TaintKey,
Value: f.TaintValue,
Effect: corev1.TaintEffect(f.TaintEffect),
},
},
EnableServiceLinks: &enableServiceLink, EnableServiceLinks: &enableServiceLink,
}, },
} }

View File

@@ -13,11 +13,8 @@ import (
) )
const ( const (
defaultNamespace = v1.NamespaceDefault defaultNamespace = v1.NamespaceDefault
defaultNodeName = "vkubelet-mock-0" defaultNodeName = "vkubelet-mock-0"
defaultTaintKey = "virtual-kubelet.io/provider"
defaultTaintValue = "mock"
defaultTaintEffect = string(v1.TaintEffectNoSchedule)
) )
var ( var (
@@ -30,21 +27,12 @@ var (
namespace string namespace string
// nodeName is the name of the virtual-kubelet node to test. // nodeName is the name of the virtual-kubelet node to test.
nodeName string nodeName string
// taintKey is the key of the taint that is expected to be associated with the virtual-kubelet node to test.
taintKey string
// taintValue is the value of the taint that is expected to be associated with the virtual-kubelet node to test.
taintValue string
// taintEffect is the effect of the taint that is expected to be associated with the virtual-kubelet node to test.
taintEffect string
) )
func init() { func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "path to the kubeconfig file to use when running the test suite outside a kubernetes cluster") flag.StringVar(&kubeconfig, "kubeconfig", "", "path to the kubeconfig file to use when running the test suite outside a kubernetes cluster")
flag.StringVar(&namespace, "namespace", defaultNamespace, "the name of the kubernetes namespace to use for running the test suite (i.e. where to create pods)") flag.StringVar(&namespace, "namespace", defaultNamespace, "the name of the kubernetes namespace to use for running the test suite (i.e. where to create pods)")
flag.StringVar(&nodeName, "node-name", defaultNodeName, "the name of the virtual-kubelet node to test") flag.StringVar(&nodeName, "node-name", defaultNodeName, "the name of the virtual-kubelet node to test")
flag.StringVar(&taintKey, "taint-key", defaultTaintKey, "the key of the taint that is expected to be associated with the virtual-kubelet node to test")
flag.StringVar(&taintValue, "taint-value", defaultTaintValue, "the value of the taint that is expected to be associated with the virtual-kubelet node to test")
flag.StringVar(&taintEffect, "taint-effect", defaultTaintEffect, "the effect of the taint that is expected to be associated with the virtual-kubelet node to test")
flag.Parse() flag.Parse()
} }
@@ -52,7 +40,7 @@ func TestMain(m *testing.M) {
// Set sane defaults in case no values (or empty ones) have been provided. // Set sane defaults in case no values (or empty ones) have been provided.
setDefaults() setDefaults()
// Create a new instance of the test framework targeting the specified node. // Create a new instance of the test framework targeting the specified node.
f = framework.NewTestingFramework(kubeconfig, namespace, nodeName, taintKey, taintValue, taintEffect) f = framework.NewTestingFramework(kubeconfig, namespace, nodeName)
// Wait for the virtual-kubelet pod to be ready. // Wait for the virtual-kubelet pod to be ready.
if err := f.WaitUntilPodReady(namespace, nodeName); err != nil { if err := f.WaitUntilPodReady(namespace, nodeName); err != nil {
panic(err) panic(err)
@@ -69,13 +57,4 @@ func setDefaults() {
if nodeName == "" { if nodeName == "" {
nodeName = defaultNodeName nodeName = defaultNodeName
} }
if taintKey == "" {
taintKey = defaultTaintKey
}
if taintValue == "" {
taintValue = defaultTaintValue
}
if taintEffect == "" {
taintEffect = defaultTaintEffect
}
} }