diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 8cfd2be9cc3..b73fd118040 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -23,6 +23,7 @@ import ( "github.com/onsi/ginkgo/config" "github.com/spf13/viper" + "k8s.io/kubernetes/pkg/apis/componentconfig" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd" "k8s.io/kubernetes/pkg/cloudprovider" ) @@ -125,6 +126,9 @@ type NodeTestContextType struct { ContainerRuntimeEndpoint string // MounterPath is the path to the program to run to perform a mount MounterPath string + // KubeletConfig is the kubelet configuration the test is running against. + // TODO(random-liu): Remove kubelet configuration related fields above after removing kubelet start logic out. + KubeletConfig componentconfig.KubeletConfiguration } type CloudConfig struct { diff --git a/test/e2e_node/cgroup_manager_test.go b/test/e2e_node/cgroup_manager_test.go index 362ab22b079..3d4de84085e 100644 --- a/test/e2e_node/cgroup_manager_test.go +++ b/test/e2e_node/cgroup_manager_test.go @@ -54,7 +54,7 @@ func makePodToVerifyCgroups(cgroupNames []cm.CgroupName) *api.Pod { // convert the names to their literal cgroupfs forms... cgroupFsNames := []string{} for _, cgroupName := range cgroupNames { - if framework.TestContext.CgroupDriver == "systemd" { + if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" { cgroupFsNames = append(cgroupFsNames, cm.ConvertCgroupNameToSystemd(cgroupName, true)) } else { cgroupFsNames = append(cgroupFsNames, string(cgroupName)) @@ -103,7 +103,7 @@ func makePodToVerifyCgroups(cgroupNames []cm.CgroupName) *api.Pod { // makePodToVerifyCgroupRemoved verfies the specified cgroup does not exist. func makePodToVerifyCgroupRemoved(cgroupName cm.CgroupName) *api.Pod { cgroupFsName := string(cgroupName) - if framework.TestContext.CgroupDriver == "systemd" { + if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" { cgroupFsName = cm.ConvertCgroupNameToSystemd(cm.CgroupName(cgroupName), true) } pod := &api.Pod{ @@ -143,7 +143,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() { Describe("QOS containers", func() { Context("On enabling QOS cgroup hierarchy", func() { It("Top level QoS containers should have been created", func() { - if !framework.TestContext.CgroupsPerQOS { + if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS { return } cgroupsToVerify := []cm.CgroupName{cm.CgroupName(qos.Burstable), cm.CgroupName(qos.BestEffort)} @@ -158,7 +158,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() { Describe("Pod containers", func() { Context("On scheduling a Guaranteed Pod", func() { It("Pod containers should have been created under the cgroup-root", func() { - if !framework.TestContext.CgroupsPerQOS { + if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS { return } var ( @@ -202,7 +202,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() { }) Context("On scheduling a BestEffort Pod", func() { It("Pod containers should have been created under the BestEffort cgroup", func() { - if !framework.TestContext.CgroupsPerQOS { + if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS { return } var ( @@ -246,7 +246,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() { }) Context("On scheduling a Burstable Pod", func() { It("Pod containers should have been created under the Burstable cgroup", func() { - if !framework.TestContext.CgroupsPerQOS { + if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS { return } var ( diff --git a/test/e2e_node/disk_eviction_test.go b/test/e2e_node/disk_eviction_test.go index b6b14984be0..6200a36c8d6 100644 --- a/test/e2e_node/disk_eviction_test.go +++ b/test/e2e_node/disk_eviction_test.go @@ -223,7 +223,7 @@ func nodeHasDiskPressure(cs clientset.Interface) bool { } func evictionOptionIsSet() bool { - return len(framework.TestContext.EvictionHard) > 0 + return len(framework.TestContext.KubeletConfig.EvictionHard) > 0 } // TODO(random-liu): Use OSImage in node status to do the check. diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index 740f67b2a0e..bffd6d2295c 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -20,7 +20,6 @@ package e2e_node import ( "bytes" - "encoding/json" "flag" "fmt" "io/ioutil" @@ -151,15 +150,8 @@ var _ = SynchronizedBeforeSuite(func() []byte { // Reference common test to make the import valid. commontest.CurrentSuite = commontest.NodeE2E - data, err := json.Marshal(&framework.TestContext.NodeTestContextType) - Expect(err).NotTo(HaveOccurred(), "should be able to serialize node test context.") - - return data -}, func(data []byte) { - // The node test context is updated in the first function, update it on every test node. - err := json.Unmarshal(data, &framework.TestContext.NodeTestContextType) - Expect(err).NotTo(HaveOccurred(), "should be able to deserialize node test context.") - + return nil +}, func([]byte) { // update test context with node configuration. Expect(updateTestContext()).To(Succeed(), "update test context with node config.") }) @@ -235,12 +227,20 @@ func updateTestContext() error { if err != nil { return fmt.Errorf("failed to get apiserver client: %v", err) } + // Update test context with current node object. node, err := getNode(client) if err != nil { return fmt.Errorf("failed to get node: %v", err) } - // Initialize the node name - framework.TestContext.NodeName = node.Name + framework.TestContext.NodeName = node.Name // Set node name. + // Update test context with current kubelet configuration. + // This assumes all tests which dynamically change kubelet configuration + // must: 1) run in serial; 2) restore kubelet configuration after test. + kubeletCfg, err := getCurrentKubeletConfig() + if err != nil { + return fmt.Errorf("failed to get kubelet configuration: %v", err) + } + framework.TestContext.KubeletConfig = *kubeletCfg // Set kubelet config. return nil } diff --git a/test/e2e_node/mirror_pod_test.go b/test/e2e_node/mirror_pod_test.go index db2c1dd9d2d..6cbcebb0126 100644 --- a/test/e2e_node/mirror_pod_test.go +++ b/test/e2e_node/mirror_pod_test.go @@ -37,14 +37,16 @@ import ( var _ = framework.KubeDescribe("MirrorPod", func() { f := framework.NewDefaultFramework("mirror-pod") Context("when create a mirror pod ", func() { - var ns, staticPodName, mirrorPodName string + var ns, manifestPath, staticPodName, mirrorPodName string BeforeEach(func() { ns = f.Namespace.Name staticPodName = "static-pod-" + string(uuid.NewUUID()) mirrorPodName = staticPodName + "-" + framework.TestContext.NodeName + manifestPath = framework.TestContext.KubeletConfig.PodManifestPath + By("create the static pod") - err := createStaticPod(framework.TestContext.ManifestPath, staticPodName, ns, + err := createStaticPod(manifestPath, staticPodName, ns, "gcr.io/google_containers/nginx-slim:0.7", api.RestartPolicyAlways) Expect(err).ShouldNot(HaveOccurred()) @@ -61,7 +63,7 @@ var _ = framework.KubeDescribe("MirrorPod", func() { By("update the static pod container image") image := framework.GetPauseImageNameForHostArch() - err = createStaticPod(framework.TestContext.ManifestPath, staticPodName, ns, image, api.RestartPolicyAlways) + err = createStaticPod(manifestPath, staticPodName, ns, image, api.RestartPolicyAlways) Expect(err).ShouldNot(HaveOccurred()) By("wait for the mirror pod to be updated") @@ -107,7 +109,7 @@ var _ = framework.KubeDescribe("MirrorPod", func() { }) AfterEach(func() { By("delete the static pod") - err := deleteStaticPod(framework.TestContext.ManifestPath, staticPodName, ns) + err := deleteStaticPod(manifestPath, staticPodName, ns) Expect(err).ShouldNot(HaveOccurred()) By("wait for the mirror pod to disappear") diff --git a/test/e2e_node/services/services.go b/test/e2e_node/services/services.go index f678ef35c6a..372044c5089 100644 --- a/test/e2e_node/services/services.go +++ b/test/e2e_node/services/services.go @@ -209,7 +209,6 @@ func (e *E2EServices) startKubelet() (*server, error) { "--eviction-pressure-transition-period", "30s", "--feature-gates", framework.TestContext.FeatureGates, "--v", LOG_VERBOSITY_LEVEL, "--logtostderr", - "--experimental-mounter-path", framework.TestContext.MounterPath, ) if framework.TestContext.NodeName != "" { // If node name is specified, set hostname override.