mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #84255 from oomichi/move-CreatePodOrFail
Move CreatePodOrFail() to e2e network test
This commit is contained in:
commit
176929a72a
@ -488,32 +488,6 @@ func CreateExecPodOrFail(client clientset.Interface, ns, generateName string, tw
|
|||||||
return execPod
|
return execPod
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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: " "}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
_, err := c.CoreV1().Pods(ns).Create(pod)
|
|
||||||
expectNoError(err, "failed to create pod %s in namespace %s", name, ns)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckPodsRunningReady returns whether all pods whose names are listed in
|
// CheckPodsRunningReady returns whether all pods whose names are listed in
|
||||||
// podNames in namespace ns are running and ready, using c and waiting at most
|
// podNames in namespace ns are running and ready, using c and waiting at most
|
||||||
// timeout.
|
// timeout.
|
||||||
|
@ -148,12 +148,12 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
name1 := "pod1"
|
name1 := "pod1"
|
||||||
name2 := "pod2"
|
name2 := "pod2"
|
||||||
|
|
||||||
e2epod.CreatePodOrFail(cs, ns, name1, jig.Labels, []v1.ContainerPort{{ContainerPort: 80}})
|
createPodOrFail(cs, ns, name1, jig.Labels, []v1.ContainerPort{{ContainerPort: 80}})
|
||||||
names[name1] = true
|
names[name1] = true
|
||||||
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{name1: {80}})
|
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{name1: {80}})
|
||||||
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
||||||
|
|
||||||
e2epod.CreatePodOrFail(cs, ns, name2, jig.Labels, []v1.ContainerPort{{ContainerPort: 80}})
|
createPodOrFail(cs, ns, name2, jig.Labels, []v1.ContainerPort{{ContainerPort: 80}})
|
||||||
names[name2] = true
|
names[name2] = true
|
||||||
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{name1: {80}, name2: {80}})
|
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{name1: {80}, name2: {80}})
|
||||||
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
||||||
@ -234,12 +234,12 @@ var _ = SIGDescribe("Services", func() {
|
|||||||
podname1 := "pod1"
|
podname1 := "pod1"
|
||||||
podname2 := "pod2"
|
podname2 := "pod2"
|
||||||
|
|
||||||
e2epod.CreatePodOrFail(cs, ns, podname1, jig.Labels, containerPorts1)
|
createPodOrFail(cs, ns, podname1, jig.Labels, containerPorts1)
|
||||||
names[podname1] = true
|
names[podname1] = true
|
||||||
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{podname1: {port1}})
|
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{podname1: {port1}})
|
||||||
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
||||||
|
|
||||||
e2epod.CreatePodOrFail(cs, ns, podname2, jig.Labels, containerPorts2)
|
createPodOrFail(cs, ns, podname2, jig.Labels, containerPorts2)
|
||||||
names[podname2] = true
|
names[podname2] = true
|
||||||
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{podname1: {port1}, podname2: {port2}})
|
err = e2eendpoints.ValidateEndpointsPorts(cs, ns, serviceName, e2eendpoints.PortsByPodName{podname1: {port1}, podname2: {port2}})
|
||||||
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
framework.ExpectNoError(err, "failed to validate endpoints for service %s in namespace: %s", serviceName, ns)
|
||||||
@ -2562,6 +2562,32 @@ func createPausePodDeployment(cs clientset.Interface, name, ns string, replicas
|
|||||||
return deployment
|
return deployment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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: " "}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_, err := c.CoreV1().Pods(ns).Create(pod)
|
||||||
|
framework.ExpectNoError(err, "failed to create pod %s in namespace %s", name, ns)
|
||||||
|
}
|
||||||
|
|
||||||
// launchHostExecPod launches a hostexec pod in the given namespace and waits
|
// launchHostExecPod launches a hostexec pod in the given namespace and waits
|
||||||
// until it's Running
|
// until it's Running
|
||||||
func launchHostExecPod(client clientset.Interface, ns, name string) *v1.Pod {
|
func launchHostExecPod(client clientset.Interface, ns, name string) *v1.Pod {
|
||||||
|
Loading…
Reference in New Issue
Block a user