mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Remove dependency on kubelet related flags.
This commit is contained in:
parent
08204bea62
commit
090809d8ad
@ -23,6 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/onsi/ginkgo/config"
|
"github.com/onsi/ginkgo/config"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/componentconfig"
|
||||||
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
|
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
|
||||||
"k8s.io/kubernetes/pkg/cloudprovider"
|
"k8s.io/kubernetes/pkg/cloudprovider"
|
||||||
)
|
)
|
||||||
@ -125,6 +126,9 @@ type NodeTestContextType struct {
|
|||||||
ContainerRuntimeEndpoint string
|
ContainerRuntimeEndpoint string
|
||||||
// MounterPath is the path to the program to run to perform a mount
|
// MounterPath is the path to the program to run to perform a mount
|
||||||
MounterPath string
|
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 {
|
type CloudConfig struct {
|
||||||
|
@ -54,7 +54,7 @@ func makePodToVerifyCgroups(cgroupNames []cm.CgroupName) *api.Pod {
|
|||||||
// convert the names to their literal cgroupfs forms...
|
// convert the names to their literal cgroupfs forms...
|
||||||
cgroupFsNames := []string{}
|
cgroupFsNames := []string{}
|
||||||
for _, cgroupName := range cgroupNames {
|
for _, cgroupName := range cgroupNames {
|
||||||
if framework.TestContext.CgroupDriver == "systemd" {
|
if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" {
|
||||||
cgroupFsNames = append(cgroupFsNames, cm.ConvertCgroupNameToSystemd(cgroupName, true))
|
cgroupFsNames = append(cgroupFsNames, cm.ConvertCgroupNameToSystemd(cgroupName, true))
|
||||||
} else {
|
} else {
|
||||||
cgroupFsNames = append(cgroupFsNames, string(cgroupName))
|
cgroupFsNames = append(cgroupFsNames, string(cgroupName))
|
||||||
@ -103,7 +103,7 @@ func makePodToVerifyCgroups(cgroupNames []cm.CgroupName) *api.Pod {
|
|||||||
// makePodToVerifyCgroupRemoved verfies the specified cgroup does not exist.
|
// makePodToVerifyCgroupRemoved verfies the specified cgroup does not exist.
|
||||||
func makePodToVerifyCgroupRemoved(cgroupName cm.CgroupName) *api.Pod {
|
func makePodToVerifyCgroupRemoved(cgroupName cm.CgroupName) *api.Pod {
|
||||||
cgroupFsName := string(cgroupName)
|
cgroupFsName := string(cgroupName)
|
||||||
if framework.TestContext.CgroupDriver == "systemd" {
|
if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" {
|
||||||
cgroupFsName = cm.ConvertCgroupNameToSystemd(cm.CgroupName(cgroupName), true)
|
cgroupFsName = cm.ConvertCgroupNameToSystemd(cm.CgroupName(cgroupName), true)
|
||||||
}
|
}
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
@ -143,7 +143,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() {
|
|||||||
Describe("QOS containers", func() {
|
Describe("QOS containers", func() {
|
||||||
Context("On enabling QOS cgroup hierarchy", func() {
|
Context("On enabling QOS cgroup hierarchy", func() {
|
||||||
It("Top level QoS containers should have been created", func() {
|
It("Top level QoS containers should have been created", func() {
|
||||||
if !framework.TestContext.CgroupsPerQOS {
|
if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cgroupsToVerify := []cm.CgroupName{cm.CgroupName(qos.Burstable), cm.CgroupName(qos.BestEffort)}
|
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() {
|
Describe("Pod containers", func() {
|
||||||
Context("On scheduling a Guaranteed Pod", func() {
|
Context("On scheduling a Guaranteed Pod", func() {
|
||||||
It("Pod containers should have been created under the cgroup-root", func() {
|
It("Pod containers should have been created under the cgroup-root", func() {
|
||||||
if !framework.TestContext.CgroupsPerQOS {
|
if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
@ -202,7 +202,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() {
|
|||||||
})
|
})
|
||||||
Context("On scheduling a BestEffort Pod", func() {
|
Context("On scheduling a BestEffort Pod", func() {
|
||||||
It("Pod containers should have been created under the BestEffort cgroup", func() {
|
It("Pod containers should have been created under the BestEffort cgroup", func() {
|
||||||
if !framework.TestContext.CgroupsPerQOS {
|
if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
@ -246,7 +246,7 @@ var _ = framework.KubeDescribe("Kubelet Cgroup Manager", func() {
|
|||||||
})
|
})
|
||||||
Context("On scheduling a Burstable Pod", func() {
|
Context("On scheduling a Burstable Pod", func() {
|
||||||
It("Pod containers should have been created under the Burstable cgroup", func() {
|
It("Pod containers should have been created under the Burstable cgroup", func() {
|
||||||
if !framework.TestContext.CgroupsPerQOS {
|
if !framework.TestContext.KubeletConfig.ExperimentalCgroupsPerQOS {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
|
@ -223,7 +223,7 @@ func nodeHasDiskPressure(cs clientset.Interface) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func evictionOptionIsSet() 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.
|
// TODO(random-liu): Use OSImage in node status to do the check.
|
||||||
|
@ -20,7 +20,6 @@ package e2e_node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -151,15 +150,8 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
|||||||
// Reference common test to make the import valid.
|
// Reference common test to make the import valid.
|
||||||
commontest.CurrentSuite = commontest.NodeE2E
|
commontest.CurrentSuite = commontest.NodeE2E
|
||||||
|
|
||||||
data, err := json.Marshal(&framework.TestContext.NodeTestContextType)
|
return nil
|
||||||
Expect(err).NotTo(HaveOccurred(), "should be able to serialize node test context.")
|
}, func([]byte) {
|
||||||
|
|
||||||
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.")
|
|
||||||
|
|
||||||
// update test context with node configuration.
|
// update test context with node configuration.
|
||||||
Expect(updateTestContext()).To(Succeed(), "update test context with node config.")
|
Expect(updateTestContext()).To(Succeed(), "update test context with node config.")
|
||||||
})
|
})
|
||||||
@ -235,12 +227,20 @@ func updateTestContext() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get apiserver client: %v", err)
|
return fmt.Errorf("failed to get apiserver client: %v", err)
|
||||||
}
|
}
|
||||||
|
// Update test context with current node object.
|
||||||
node, err := getNode(client)
|
node, err := getNode(client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get node: %v", err)
|
return fmt.Errorf("failed to get node: %v", err)
|
||||||
}
|
}
|
||||||
// Initialize the node name
|
framework.TestContext.NodeName = node.Name // Set node name.
|
||||||
framework.TestContext.NodeName = 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,14 +37,16 @@ import (
|
|||||||
var _ = framework.KubeDescribe("MirrorPod", func() {
|
var _ = framework.KubeDescribe("MirrorPod", func() {
|
||||||
f := framework.NewDefaultFramework("mirror-pod")
|
f := framework.NewDefaultFramework("mirror-pod")
|
||||||
Context("when create a mirror pod ", func() {
|
Context("when create a mirror pod ", func() {
|
||||||
var ns, staticPodName, mirrorPodName string
|
var ns, manifestPath, staticPodName, mirrorPodName string
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
ns = f.Namespace.Name
|
ns = f.Namespace.Name
|
||||||
staticPodName = "static-pod-" + string(uuid.NewUUID())
|
staticPodName = "static-pod-" + string(uuid.NewUUID())
|
||||||
mirrorPodName = staticPodName + "-" + framework.TestContext.NodeName
|
mirrorPodName = staticPodName + "-" + framework.TestContext.NodeName
|
||||||
|
|
||||||
|
manifestPath = framework.TestContext.KubeletConfig.PodManifestPath
|
||||||
|
|
||||||
By("create the static pod")
|
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)
|
"gcr.io/google_containers/nginx-slim:0.7", api.RestartPolicyAlways)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ var _ = framework.KubeDescribe("MirrorPod", func() {
|
|||||||
|
|
||||||
By("update the static pod container image")
|
By("update the static pod container image")
|
||||||
image := framework.GetPauseImageNameForHostArch()
|
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())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
By("wait for the mirror pod to be updated")
|
By("wait for the mirror pod to be updated")
|
||||||
@ -107,7 +109,7 @@ var _ = framework.KubeDescribe("MirrorPod", func() {
|
|||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
By("delete the static pod")
|
By("delete the static pod")
|
||||||
err := deleteStaticPod(framework.TestContext.ManifestPath, staticPodName, ns)
|
err := deleteStaticPod(manifestPath, staticPodName, ns)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
|
||||||
By("wait for the mirror pod to disappear")
|
By("wait for the mirror pod to disappear")
|
||||||
|
@ -209,7 +209,6 @@ func (e *E2EServices) startKubelet() (*server, error) {
|
|||||||
"--eviction-pressure-transition-period", "30s",
|
"--eviction-pressure-transition-period", "30s",
|
||||||
"--feature-gates", framework.TestContext.FeatureGates,
|
"--feature-gates", framework.TestContext.FeatureGates,
|
||||||
"--v", LOG_VERBOSITY_LEVEL, "--logtostderr",
|
"--v", LOG_VERBOSITY_LEVEL, "--logtostderr",
|
||||||
|
|
||||||
"--experimental-mounter-path", framework.TestContext.MounterPath,
|
"--experimental-mounter-path", framework.TestContext.MounterPath,
|
||||||
)
|
)
|
||||||
if framework.TestContext.NodeName != "" { // If node name is specified, set hostname override.
|
if framework.TestContext.NodeName != "" { // If node name is specified, set hostname override.
|
||||||
|
Loading…
Reference in New Issue
Block a user