mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Added e2e test and fixed existing pod test
This commit is contained in:
parent
94ddb3a98f
commit
f035e37c4b
@ -18,7 +18,6 @@ package pod
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"reflect"
|
||||
@ -52,7 +51,7 @@ func TestPatchPodStatus(t *testing.T) {
|
||||
"no change",
|
||||
func(input v1.PodStatus) v1.PodStatus { return input },
|
||||
true,
|
||||
[]byte(fmt.Sprintf(`{"metadata":{"uid":"myuid"}}`)),
|
||||
[]byte(`{"metadata":{"uid":"myuid"}}`),
|
||||
},
|
||||
{
|
||||
"message change",
|
||||
@ -61,7 +60,7 @@ func TestPatchPodStatus(t *testing.T) {
|
||||
return input
|
||||
},
|
||||
false,
|
||||
[]byte(fmt.Sprintf(`{"metadata":{"uid":"myuid"},"status":{"message":"random message"}}`)),
|
||||
[]byte(`{"metadata":{"uid":"myuid"},"status":{"message":"random message"}}`),
|
||||
},
|
||||
{
|
||||
"pod condition change",
|
||||
@ -70,7 +69,7 @@ func TestPatchPodStatus(t *testing.T) {
|
||||
return input
|
||||
},
|
||||
false,
|
||||
[]byte(fmt.Sprintf(`{"metadata":{"uid":"myuid"},"status":{"$setElementOrder/conditions":[{"type":"Ready"},{"type":"PodScheduled"}],"conditions":[{"status":"False","type":"Ready"}]}}`)),
|
||||
[]byte(`{"metadata":{"uid":"myuid"},"status":{"$setElementOrder/conditions":[{"type":"Ready"},{"type":"PodScheduled"}],"conditions":[{"status":"False","type":"Ready"}]}}`),
|
||||
},
|
||||
{
|
||||
"additional init container condition",
|
||||
@ -84,7 +83,7 @@ func TestPatchPodStatus(t *testing.T) {
|
||||
return input
|
||||
},
|
||||
false,
|
||||
[]byte(fmt.Sprintf(`{"metadata":{"uid":"myuid"},"status":{"initContainerStatuses":[{"image":"","imageID":"","lastState":{},"name":"init-container","ready":true,"restartCount":0,"state":{}}]}}`)),
|
||||
[]byte(`{"metadata":{"uid":"myuid"},"status":{"initContainerStatuses":[{"image":"","imageID":"","lastState":{},"name":"init-container","ready":true,"restartCount":0,"state":{}}]}}`),
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
utilrand "k8s.io/apimachinery/pkg/util/rand"
|
||||
"k8s.io/kubernetes/test/e2e/feature"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||
@ -661,3 +662,43 @@ var _ = SIGDescribe(feature.PodLifecycleSleepActionAllowZero, func() {
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
var _ = SIGDescribe(feature.ContainerStopSignals, func() {
|
||||
f := framework.NewDefaultFramework("container-stop-signals")
|
||||
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
|
||||
var podClient *e2epod.PodClient
|
||||
sigterm := v1.SIGTERM
|
||||
podName := "pod-" + utilrand.String(5)
|
||||
|
||||
ginkgo.Context("when create a pod with a StopSignal lifecycle", func() {
|
||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||
podClient = e2epod.NewPodClient(f)
|
||||
})
|
||||
ginkgo.It("StopSignal defined with pod.OS", func(ctx context.Context) {
|
||||
|
||||
testPod := e2epod.MustMixinRestrictedPodSecurity(&v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: podName,
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
OS: &v1.PodOS{
|
||||
Name: v1.Linux,
|
||||
},
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Name: "test",
|
||||
Image: imageutils.GetPauseImageName(),
|
||||
Lifecycle: &v1.Lifecycle{
|
||||
StopSignal: &sigterm,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
ginkgo.By("submitting the pod to kubernetes")
|
||||
pod := podClient.CreateSync(ctx, testPod)
|
||||
framework.ExpectNoError(e2epod.WaitForPodRunningInNamespace(ctx, f.ClientSet, pod), "Pod didn't start when custom StopSignal was passed in Lifecycle")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -66,6 +66,10 @@ var (
|
||||
// TODO: document the feature (owning SIG, when to use this feature for a test)
|
||||
ComprehensiveNamespaceDraining = framework.WithFeature(framework.ValidFeatures.Add("ComprehensiveNamespaceDraining"))
|
||||
|
||||
// Owner: sig-node
|
||||
// Enables configuring custom stop signals for containers from container lifecycle
|
||||
ContainerStopSignals = framework.WithFeature(framework.ValidFeatures.Add("ContainerStopSignals"))
|
||||
|
||||
// Owner: sig-api-machinery
|
||||
// Marks tests that require coordinated leader election
|
||||
CoordinatedLeaderElection = framework.WithFeature(framework.ValidFeatures.Add("CoordinatedLeaderElection"))
|
||||
|
Loading…
Reference in New Issue
Block a user