mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
fix ReplicaSet and Deployment tests for DeploymentReplicaSetTerminatingReplicas FG enablement
This commit is contained in:
@@ -42,6 +42,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
@@ -53,6 +54,7 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/controller"
|
||||
. "k8s.io/kubernetes/pkg/controller/testutil"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/securitycontext"
|
||||
"k8s.io/kubernetes/test/utils/ktesting"
|
||||
"k8s.io/utils/ptr"
|
||||
@@ -334,6 +336,7 @@ func TestSyncReplicaSetDormancy(t *testing.T) {
|
||||
rsSpec.Status.Replicas = 1
|
||||
rsSpec.Status.ReadyReplicas = 1
|
||||
rsSpec.Status.AvailableReplicas = 1
|
||||
rsSpec.Status.TerminatingReplicas = ptr.To[int32](0)
|
||||
manager.syncReplicaSet(ctx, GetKey(rsSpec, t))
|
||||
err := validateSyncReplicaSet(&fakePodControl, 1, 0, 0)
|
||||
if err != nil {
|
||||
@@ -1235,6 +1238,14 @@ func TestExpectationsOnRecreate(t *testing.T) {
|
||||
t.Fatal("queue is shutting down")
|
||||
}
|
||||
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DeploymentReplicaSetTerminatingReplicas) {
|
||||
// DeploymentReplicaSetTerminatingReplicas feature results in the "terminatingReplicas nil->0" update, so we need to do empty sync.
|
||||
ok = manager.processNextWorkItem(tCtx)
|
||||
if !ok {
|
||||
t.Fatal("queue is shutting down")
|
||||
}
|
||||
}
|
||||
|
||||
err = validateSyncReplicaSet(&fakePodControl, 1, 0, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -929,6 +929,8 @@ func TestSpecReplicasChange(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeploymentAvailableCondition(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.DeploymentReplicaSetTerminatingReplicas, true)
|
||||
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
@@ -968,7 +970,7 @@ func TestDeploymentAvailableCondition(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify all replicas fields of DeploymentStatus have desired counts
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 0, 0, 10, nil); err != nil {
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 0, 0, 10, ptr.To[int32](0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -988,7 +990,7 @@ func TestDeploymentAvailableCondition(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify all replicas fields of DeploymentStatus have desired counts
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 10, 0, 10, nil); err != nil {
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 10, 0, 10, ptr.To[int32](0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -1011,7 +1013,7 @@ func TestDeploymentAvailableCondition(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify all replicas fields of DeploymentStatus have desired counts
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 10, 10, 0, nil); err != nil {
|
||||
if err = tester.checkDeploymentStatusReplicasFields(10, 10, 10, 10, 0, ptr.To[int32](0)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user