mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 18:02:01 +00:00
Merge pull request #108592 from claudiubelu/tests/enable-etc-hosts
tests: Enables a few Conformance tests for Windows (part 2)
This commit is contained in:
commit
4f469e63f4
18
test/conformance/testdata/conformance.yaml
vendored
18
test/conformance/testdata/conformance.yaml
vendored
@ -1873,16 +1873,6 @@
|
|||||||
as RestartAlways.
|
as RestartAlways.
|
||||||
release: v1.12
|
release: v1.12
|
||||||
file: test/e2e/common/node/init_container.go
|
file: test/e2e/common/node/init_container.go
|
||||||
- testname: Kubelet, hostAliases
|
|
||||||
codename: '[sig-node] Kubelet when scheduling a busybox Pod with hostAliases should
|
|
||||||
write entries to /etc/hosts [LinuxOnly] [NodeConformance] [Conformance]'
|
|
||||||
description: Create a Pod with hostAliases and a container with command to output
|
|
||||||
/etc/hosts entries. Pod's logs MUST have matching entries of specified hostAliases
|
|
||||||
to the output of /etc/hosts entries. Kubernetes mounts the /etc/hosts file into
|
|
||||||
its containers, however, mounting individual files is not supported on Windows
|
|
||||||
Containers. For this reason, this test is marked LinuxOnly.
|
|
||||||
release: v1.13
|
|
||||||
file: test/e2e/common/node/kubelet.go
|
|
||||||
- testname: Kubelet, log output, default
|
- testname: Kubelet, log output, default
|
||||||
codename: '[sig-node] Kubelet when scheduling a busybox command in a pod should
|
codename: '[sig-node] Kubelet when scheduling a busybox command in a pod should
|
||||||
print the output to logs [NodeConformance] [Conformance]'
|
print the output to logs [NodeConformance] [Conformance]'
|
||||||
@ -1913,6 +1903,14 @@
|
|||||||
Windows does not support creating containers with read-only access.
|
Windows does not support creating containers with read-only access.
|
||||||
release: v1.13
|
release: v1.13
|
||||||
file: test/e2e/common/node/kubelet.go
|
file: test/e2e/common/node/kubelet.go
|
||||||
|
- testname: Kubelet, hostAliases
|
||||||
|
codename: '[sig-node] Kubelet when scheduling an agnhost Pod with hostAliases should
|
||||||
|
write entries to /etc/hosts [NodeConformance] [Conformance]'
|
||||||
|
description: Create a Pod with hostAliases and a container with command to output
|
||||||
|
/etc/hosts entries. Pod's logs MUST have matching entries of specified hostAliases
|
||||||
|
to the output of /etc/hosts entries.
|
||||||
|
release: v1.13
|
||||||
|
file: test/e2e/common/node/kubelet.go
|
||||||
- testname: Kubelet, managed etc hosts
|
- testname: Kubelet, managed etc hosts
|
||||||
codename: '[sig-node] KubeletManagedEtcHosts should test kubelet managed /etc/hosts
|
codename: '[sig-node] KubeletManagedEtcHosts should test kubelet managed /etc/hosts
|
||||||
file [LinuxOnly] [NodeConformance] [Conformance]'
|
file [LinuxOnly] [NodeConformance] [Conformance]'
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
admissionapi "k8s.io/pod-security-admission/api"
|
admissionapi "k8s.io/pod-security-admission/api"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
@ -136,55 +137,39 @@ var _ = SIGDescribe("Kubelet", func() {
|
|||||||
gomega.Expect(err).To(gomega.BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
|
gomega.Expect(err).To(gomega.BeNil(), fmt.Sprintf("Error deleting Pod %v", err))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
ginkgo.Context("when scheduling a busybox Pod with hostAliases", func() {
|
ginkgo.Context("when scheduling an agnhost Pod with hostAliases", func() {
|
||||||
podName := "busybox-host-aliases" + string(uuid.NewUUID())
|
podName := "agnhost-host-aliases" + string(uuid.NewUUID())
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Release: v1.13
|
Release: v1.13
|
||||||
Testname: Kubelet, hostAliases
|
Testname: Kubelet, hostAliases
|
||||||
Description: Create a Pod with hostAliases and a container with command to output /etc/hosts entries. Pod's logs MUST have matching entries of specified hostAliases to the output of /etc/hosts entries.
|
Description: Create a Pod with hostAliases and a container with command to output /etc/hosts entries. Pod's logs MUST have matching entries of specified hostAliases to the output of /etc/hosts entries.
|
||||||
Kubernetes mounts the /etc/hosts file into its containers, however, mounting individual files is not supported on Windows Containers. For this reason, this test is marked LinuxOnly.
|
|
||||||
*/
|
*/
|
||||||
framework.ConformanceIt("should write entries to /etc/hosts [LinuxOnly] [NodeConformance]", func() {
|
framework.ConformanceIt("should write entries to /etc/hosts [NodeConformance]", func() {
|
||||||
podClient.CreateSync(&v1.Pod{
|
pod := e2epod.NewAgnhostPod(f.Namespace.Name, podName, nil, nil, nil, "etc-hosts")
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: podName,
|
|
||||||
},
|
|
||||||
Spec: v1.PodSpec{
|
|
||||||
// Don't restart the Pod since it is expected to exit
|
// Don't restart the Pod since it is expected to exit
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
pod.Spec.RestartPolicy = v1.RestartPolicyNever
|
||||||
Containers: []v1.Container{
|
pod.Spec.HostAliases = []v1.HostAlias{
|
||||||
{
|
|
||||||
Image: framework.BusyBoxImage,
|
|
||||||
Name: podName,
|
|
||||||
Command: []string{"/bin/sh", "-c", "cat /etc/hosts; sleep 6000"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
HostAliases: []v1.HostAlias{
|
|
||||||
{
|
{
|
||||||
IP: "123.45.67.89",
|
IP: "123.45.67.89",
|
||||||
Hostnames: []string{"foo", "bar"},
|
Hostnames: []string{"foo", "bar"},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
gomega.Eventually(func() error {
|
|
||||||
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream(context.TODO())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pod = podClient.Create(pod)
|
||||||
|
ginkgo.By("Waiting for pod completion")
|
||||||
|
err := e2epod.WaitForPodNoLongerRunningInNamespace(f.ClientSet, pod.Name, f.Namespace.Name)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
rc, err := podClient.GetLogs(podName, &v1.PodLogOptions{}).Stream(context.TODO())
|
||||||
|
framework.ExpectNoError(err)
|
||||||
defer rc.Close()
|
defer rc.Close()
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
buf.ReadFrom(rc)
|
buf.ReadFrom(rc)
|
||||||
hostsFileContent := buf.String()
|
hostsFileContent := buf.String()
|
||||||
|
|
||||||
if !strings.Contains(hostsFileContent, "123.45.67.89\tfoo\tbar") {
|
errMsg := fmt.Sprintf("expected hosts file to contain entries from HostAliases. Got:\n%+v", hostsFileContent)
|
||||||
return fmt.Errorf("expected hosts file to contain entries from HostAliases. Got:\n%+v", hostsFileContent)
|
framework.ExpectEqual(true, strings.Contains(hostsFileContent, "123.45.67.89\tfoo\tbar"), errMsg)
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}, time.Minute, time.Second*4).Should(gomega.BeNil())
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
ginkgo.Context("when scheduling a read only busybox container", func() {
|
ginkgo.Context("when scheduling a read only busybox container", func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user