Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated cherry pick of 87266 93196 94438 94653 95229 95867 96294 96330 96479 96626 96644 96690 96843 #99220

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a0e4ad2
tests: Refactor agnhost image pod usage
claudiubelu Dec 17, 2019
7a12d03
Minor cleanup in snapshot test suite.
Jul 14, 2020
a0ac6ec
Add pre provisioned snapshot tests
Jul 14, 2020
f867a8f
Combine two tests with overlap to reduce overall snapshot test suite …
Jul 17, 2020
74425b8
Remove snapshot class from prepv test because it is not needed.
Jul 23, 2020
f423cbe
Quick commit
Jul 28, 2020
557c506
Stack snapshot tests into one to reuse snapshot resource and reduce t…
Aug 5, 2020
fecd303
Remove custom hash function, generate a random UUID for snapshot and …
Aug 6, 2020
8da39bf
Move common portion of dynamic snapshot out of switch statement
Aug 6, 2020
74cb12e
Ran hack/update-bazel.sh but discarded changes to root build file
Aug 7, 2020
0e12128
Combine switch case into one case
Aug 28, 2020
58d536b
Fix testpattern check
Aug 28, 2020
a89f202
tests: Refactors agnhost image pod usage in tests
claudiubelu Dec 17, 2019
12e682b
Tolerate NotFound errors when deleting snapshots
jsafrane Sep 9, 2020
320bdbb
e2e can't use both pod.Name and pod.GenerateName
Oct 1, 2020
86e674c
Log PodExec stdout + stderr
jsafrane Oct 26, 2020
9b3febc
Separate in-tree gcepd driver for windows
jingxu97 Nov 6, 2020
e2ec769
Modify storage snapshottable and disruptive test for Windows
jingxu97 Nov 7, 2020
5004fd5
Update storage test suits for Windows
jingxu97 Nov 9, 2020
a8a56c4
Update topology tests for windows
jingxu97 Nov 17, 2020
c0201d4
Mark some storage tests as LinuxOnly
jingxu97 Nov 17, 2020
aae0466
Add linuxonly on one multivolume test
jingxu97 Nov 18, 2020
da216e0
Remove unnecessary snapshot ability check
Jiawei0227 Nov 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 6 additions & 21 deletions test/e2e/apimachinery/table_conversion.go
Expand Up @@ -35,8 +35,8 @@ import (
utilversion "k8s.io/apimachinery/pkg/util/version"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
imageutils "k8s.io/kubernetes/test/utils/image"
)

var serverPrintVersion = utilversion.MustParseSemantic("v1.10.0")
Expand All @@ -55,7 +55,7 @@ var _ = SIGDescribe("Servers with support for Table transformation", func() {
podName := "pod-1"
framework.Logf("Creating pod %s", podName)

_, err := c.CoreV1().Pods(ns).Create(context.TODO(), newTablePod(podName), metav1.CreateOptions{})
_, err := c.CoreV1().Pods(ns).Create(context.TODO(), newTablePod(ns, podName), metav1.CreateOptions{})
framework.ExpectNoError(err, "failed to create pod %s in namespace: %s", podName, ns)

table := &metav1beta1.Table{}
Expand Down Expand Up @@ -179,25 +179,10 @@ func printTable(table *metav1beta1.Table) string {
return buf.String()
}

func newTablePod(podName string) *v1.Pod {
containerName := fmt.Sprintf("%s-container", podName)
func newTablePod(ns, podName string) *v1.Pod {
port := 8080
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: containerName,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"porter"},
Env: []v1.EnvVar{{Name: fmt.Sprintf("SERVE_PORT_%d", port), Value: "foo"}},
Ports: []v1.ContainerPort{{ContainerPort: int32(port)}},
},
},
RestartPolicy: v1.RestartPolicyNever,
},
}
pod := e2epod.NewAgnhostPod(ns, podName, nil, nil, []v1.ContainerPort{{ContainerPort: int32(port)}}, "porter")
pod.Spec.Containers[0].Env = []v1.EnvVar{{Name: fmt.Sprintf("SERVE_PORT_%d", port), Value: "foo"}}
pod.Spec.RestartPolicy = v1.RestartPolicyNever
return pod
}
18 changes: 3 additions & 15 deletions test/e2e/auth/node_authn.go
Expand Up @@ -24,11 +24,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/test/e2e/framework"
imageutils "k8s.io/kubernetes/test/utils/image"

"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
)

var _ = SIGDescribe("[Feature:NodeAuthenticator]", func() {
Expand Down Expand Up @@ -93,19 +93,7 @@ var _ = SIGDescribe("[Feature:NodeAuthenticator]", func() {
})

func createNodeAuthTestPod(f *framework.Framework) *v1.Pod {
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-node-authn-",
},
Spec: v1.PodSpec{
Containers: []v1.Container{{
Name: "test-node-authn",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Command: []string{"sleep", "3600"},
}},
RestartPolicy: v1.RestartPolicyNever,
},
}

pod := e2epod.NewAgnhostPod(f.Namespace.Name, "agnhost-pod", nil, nil, nil)
pod.ObjectMeta.GenerateName = "test-node-authn-"
return f.PodClient().CreateSync(pod)
}
60 changes: 34 additions & 26 deletions test/e2e/framework/pod/resource.go
Expand Up @@ -386,49 +386,57 @@ func isNotRestartAlwaysMirrorPod(p *v1.Pod) bool {
return p.Spec.RestartPolicy != v1.RestartPolicyAlways
}

// NewExecPodSpec returns the pod spec of hostexec pod
func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod {
// NewAgnhostPod returns a pod that uses the agnhost image. The image's binary supports various subcommands
// that behave the same, no matter the underlying OS. If no args are given, it defaults to the pause subcommand.
// For more information about agnhost subcommands, see: https://github.com/kubernetes/kubernetes/tree/master/test/images/agnhost#agnhost
func NewAgnhostPod(ns, podName string, volumes []v1.Volume, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) *v1.Pod {
immediate := int64(0)
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Name: podName,
Namespace: ns,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "agnhost",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
ImagePullPolicy: v1.PullIfNotPresent,
},
NewAgnhostContainer("agnhost-container", mounts, ports, args...),
},
HostNetwork: hostNetwork,
Volumes: volumes,
SecurityContext: &v1.PodSecurityContext{},
TerminationGracePeriodSeconds: &immediate,
},
}
return pod
}

// NewAgnhostContainer returns the container Spec of an agnhost container.
func NewAgnhostContainer(containerName string, mounts []v1.VolumeMount, ports []v1.ContainerPort, args ...string) v1.Container {
if len(args) == 0 {
args = []string{"pause"}
}
return v1.Container{
Name: containerName,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: args,
VolumeMounts: mounts,
Ports: ports,
SecurityContext: &v1.SecurityContext{},
ImagePullPolicy: v1.PullIfNotPresent,
}
}

// NewExecPodSpec returns the pod spec of hostexec pod
func NewExecPodSpec(ns, name string, hostNetwork bool) *v1.Pod {
pod := NewAgnhostPod(ns, name, nil, nil, nil)
pod.Spec.HostNetwork = hostNetwork
return pod
}

// newExecPodSpec returns the pod spec of exec pod
func newExecPodSpec(ns, generateName string) *v1.Pod {
immediate := int64(0)
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
GenerateName: generateName,
Namespace: ns,
},
Spec: v1.PodSpec{
TerminationGracePeriodSeconds: &immediate,
Containers: []v1.Container{
{
Name: "agnhost-pause",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"pause"},
},
},
},
}
// GenerateName is an optional prefix, used by the server,
// to generate a unique name ONLY IF the Name field has not been provided
pod := NewAgnhostPod(ns, "", nil, nil, nil)
pod.ObjectMeta.GenerateName = generateName
return pod
}

Expand Down
48 changes: 42 additions & 6 deletions test/e2e/framework/volume/fixtures.go
Expand Up @@ -388,7 +388,7 @@ func runVolumeTesterPod(client clientset.Interface, config TestConfig, podSuffix
Containers: []v1.Container{
{
Name: config.Prefix + "-" + podSuffix,
Image: GetTestImage(framework.BusyBoxImage),
Image: GetDefaultTestImage(),
WorkingDir: "/opt",
// An imperative and easily debuggable container which reads/writes vol contents for
// us to scan in the tests or by eye.
Expand Down Expand Up @@ -466,7 +466,7 @@ func testVolumeContent(f *framework.Framework, pod *v1.Pod, fsGroup *int64, fsTy
} else {
// Filesystem: check content
fileName := fmt.Sprintf("/opt/%d/%s", i, test.File)
commands := generateReadFileCmd(fileName)
commands := GenerateReadFileCmd(fileName)
_, err := framework.LookForStringInPodExec(pod.Namespace, pod.Name, commands, test.ExpectedContent, time.Minute)
framework.ExpectNoError(err, "failed: finding the contents of the mounted file %s.", fileName)

Expand Down Expand Up @@ -608,9 +608,9 @@ func generateWriteBlockCmd(content, fullPath string) []string {
return generateWriteCmd(content, fullPath)
}

// generateReadFileCmd generates the corresponding command lines to read from a file with the given file path.
// GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path.
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
func generateReadFileCmd(fullPath string) []string {
func GenerateReadFileCmd(fullPath string) []string {
var commands []string
if !framework.NodeOSDistroIs("windows") {
commands = []string{"cat", fullPath}
Expand Down Expand Up @@ -654,9 +654,45 @@ func GeneratePodSecurityContext(fsGroup *int64, seLinuxOptions *v1.SELinuxOption
// GetTestImage returns the image name with the given input
// If the Node OS is windows, currently we return Agnhost image for Windows node
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
func GetTestImage(image string) string {
func GetTestImage(id int) string {
if framework.NodeOSDistroIs("windows") {
return imageutils.GetE2EImage(imageutils.Agnhost)
}
return image
return imageutils.GetE2EImage(id)
}

// GetTestImageID returns the image id with the given input
// If the Node OS is windows, currently we return Agnhost image for Windows node
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
func GetTestImageID(id int) int {
if framework.NodeOSDistroIs("windows") {
return imageutils.Agnhost
}
return id
}

// GetDefaultTestImage returns the default test image based on OS.
// If the node OS is windows, currently we return Agnhost image for Windows node
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
// If the node OS is linux, return busybox image
func GetDefaultTestImage() string {
return imageutils.GetE2EImage(GetDefaultTestImageID())
}

// GetDefaultTestImageID returns the default test image id based on OS.
// If the node OS is windows, currently we return Agnhost image for Windows node
// due to the issue of #https://github.com/kubernetes-sigs/windows-testing/pull/35.
// If the node OS is linux, return busybox image
func GetDefaultTestImageID() int {
return GetTestImageID(imageutils.BusyBox)
}

// GetLinuxLabel returns the default SELinuxLabel based on OS.
// If the node OS is windows, it will return nil
func GetLinuxLabel() *v1.SELinuxOptions {
if framework.NodeOSDistroIs("windows") {
return nil
}
return &v1.SELinuxOptions{
Level: "s0:c0,c1"}
}
31 changes: 7 additions & 24 deletions test/e2e/network/service.go
Expand Up @@ -3587,11 +3587,7 @@ func createPausePodDeployment(cs clientset.Interface, name, ns string, replicas
labels := map[string]string{"deployment": "agnhost-pause"}
pauseDeployment := e2edeployment.NewDeployment(name, int32(replicas), labels, "", "", appsv1.RollingUpdateDeploymentStrategyType)

pauseDeployment.Spec.Template.Spec.Containers[0] = v1.Container{
Name: "agnhost-pause",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"pause"},
}
pauseDeployment.Spec.Template.Spec.Containers[0] = e2epod.NewAgnhostContainer("agnhost-pause", nil, nil, "pause")
pauseDeployment.Spec.Template.Spec.Affinity = &v1.Affinity{
PodAntiAffinity: &v1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
Expand All @@ -3612,25 +3608,12 @@ func createPausePodDeployment(cs clientset.Interface, name, ns string, replicas
// createPodOrFail creates a pod with the specified containerPorts.
func createPodOrFail(c clientset.Interface, ns, name string, labels map[string]string, containerPorts []v1.ContainerPort) {
ginkgo.By(fmt.Sprintf("Creating pod %s in namespace %s", name, ns))
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: labels,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "pause",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"pause"},
Ports: containerPorts,
// Add a dummy environment variable to work around a docker issue.
// https://github.com/docker/docker/issues/14203
Env: []v1.EnvVar{{Name: "FOO", Value: " "}},
},
},
},
}
pod := e2epod.NewAgnhostPod(ns, name, nil, nil, containerPorts)
pod.ObjectMeta.Labels = labels
// Add a dummy environment variable to work around a docker issue.
// https://github.com/docker/docker/issues/14203
pod.Spec.Containers[0].Env = []v1.EnvVar{{Name: "FOO", Value: " "}}

_, err := c.CoreV1().Pods(ns).Create(context.TODO(), pod, metav1.CreateOptions{})
framework.ExpectNoError(err, "failed to create pod %s in namespace %s", name, ns)
}
Expand Down
21 changes: 4 additions & 17 deletions test/e2e/node/pods.go
Expand Up @@ -63,23 +63,10 @@ var _ = SIGDescribe("Pods Extended", func() {
ginkgo.By("creating the pod")
name := "pod-submit-remove-" + string(uuid.NewUUID())
value := strconv.Itoa(time.Now().Nanosecond())
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Labels: map[string]string{
"name": "foo",
"time": value,
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "agnhost",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"pause"},
},
},
},
pod := e2epod.NewAgnhostPod(f.Namespace.Name, name, nil, nil, nil)
pod.ObjectMeta.Labels = map[string]string{
"name": "foo",
"time": value,
}

ginkgo.By("setting up selector")
Expand Down
16 changes: 1 addition & 15 deletions test/e2e/node/pre_stop.go
Expand Up @@ -44,21 +44,7 @@ type State struct {

func testPreStop(c clientset.Interface, ns string) {
// This is the server that will receive the preStop notification
podDescr := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "server",
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "server",
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Args: []string{"nettest"},
Ports: []v1.ContainerPort{{ContainerPort: 8080}},
},
},
},
}
podDescr := e2epod.NewAgnhostPod(ns, "server", nil, nil, []v1.ContainerPort{{ContainerPort: 8080}}, "nettest")
ginkgo.By(fmt.Sprintf("Creating server pod %s in namespace %s", podDescr.Name, ns))
podDescr, err := c.CoreV1().Pods(ns).Create(context.TODO(), podDescr, metav1.CreateOptions{})
framework.ExpectNoError(err, fmt.Sprintf("creating pod %s", podDescr.Name))
Expand Down
37 changes: 32 additions & 5 deletions test/e2e/storage/drivers/in_tree.go
Expand Up @@ -1228,17 +1228,12 @@ var _ testsuites.DynamicPVTestDriver = &gcePdDriver{}

// InitGcePdDriver returns gcePdDriver that implements TestDriver interface
func InitGcePdDriver() testsuites.TestDriver {
// In current test structure, it first initialize the driver and then set up
// the new framework, so we cannot get the correct OS here. So here set to
// support all fs types including both linux and windows. We have code to check Node OS later
// during test.
supportedTypes := sets.NewString(
"", // Default fsType
"ext2",
"ext3",
"ext4",
"xfs",
"ntfs",
)
return &gcePdDriver{
driverInfo: testsuites.DriverInfo{
Expand Down Expand Up @@ -1268,6 +1263,38 @@ func InitGcePdDriver() testsuites.TestDriver {
}
}

// InitWindowsGcePdDriver returns gcePdDriver running on Windows cluster that implements TestDriver interface
// In current test structure, it first initialize the driver and then set up
// the new framework, so we cannot get the correct OS here and select which file system is supported.
// So here uses a separate Windows in-tree gce pd driver
func InitWindowsGcePdDriver() testsuites.TestDriver {
supportedTypes := sets.NewString(
"ntfs",
)
return &gcePdDriver{
driverInfo: testsuites.DriverInfo{
Name: "windows-gcepd",
InTreePluginName: "kubernetes.io/gce-pd",
MaxFileSize: testpatterns.FileSizeMedium,
SupportedSizeRange: e2evolume.SizeRange{
Min: "1Gi",
},
SupportedFsType: supportedTypes,
TopologyKeys: []string{v1.LabelZoneFailureDomain},
Capabilities: map[testsuites.Capability]bool{
testsuites.CapControllerExpansion: false,
testsuites.CapPersistence: true,
testsuites.CapExec: true,
testsuites.CapMultiPODs: true,
// GCE supports volume limits, but the test creates large
// number of volumes and times out test suites.
testsuites.CapVolumeLimits: false,
testsuites.CapTopology: true,
},
},
}
}

func (g *gcePdDriver) GetDriverInfo() *testsuites.DriverInfo {
return &g.driverInfo
}
Expand Down