chore(test/autoscaling): replace RC with ReplicaSet and update deprecated API versions in HPA e2e

Signed-off-by: atilsensalduz <atil.sensalduz@gmail.com>
This commit is contained in:
atilsensalduz 2026-02-17 14:01:02 +03:00
parent f9c9f03b05
commit 7e3bd4cfa5
3 changed files with 34 additions and 41 deletions

View file

@ -91,16 +91,16 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (scale resource: CP
})
// These tests take ~20 minutes each.
f.Describe("ReplicationController", func() {
f.Describe("ReplicaSet", func() {
ginkgo.It(titleUp+" and verify decision stability", func(ctx context.Context) {
scaleUp(ctx, "rc", e2eautoscaling.KindRC, cpuResource, utilizationMetricType, true, f)
scaleUp(ctx, "rs", e2eautoscaling.KindReplicaSet, cpuResource, utilizationMetricType, true, f)
})
ginkgo.It(titleDown+" and verify decision stability", func(ctx context.Context) {
scaleDown(ctx, "rc", e2eautoscaling.KindRC, cpuResource, utilizationMetricType, true, f)
scaleDown(ctx, "rs", e2eautoscaling.KindReplicaSet, cpuResource, utilizationMetricType, true, f)
})
})
f.Describe("ReplicationController light", func() {
f.Describe("ReplicaSet light", func() {
ginkgo.It("Should scale from 1 pod to 2 pods", func(ctx context.Context) {
st := &HPAScaleTest{
initPods: 1,
@ -113,7 +113,7 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (scale resource: CP
resourceType: cpuResource,
metricTargetType: utilizationMetricType,
}
st.run(ctx, "rc-light", e2eautoscaling.KindRC, f)
st.run(ctx, "rs-light", e2eautoscaling.KindReplicaSet, f)
})
f.It("Should scale from 2 pods to 1 pod", func(ctx context.Context) {
st := &HPAScaleTest{
@ -127,7 +127,7 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (scale resource: CP
resourceType: cpuResource,
metricTargetType: utilizationMetricType,
}
st.run(ctx, "rc-light", e2eautoscaling.KindRC, f)
st.run(ctx, "rs-light", e2eautoscaling.KindReplicaSet, f)
})
})

View file

@ -51,7 +51,6 @@ import (
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
e2eendpointslice "k8s.io/kubernetes/test/e2e/framework/endpointslice"
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
e2eresource "k8s.io/kubernetes/test/e2e/framework/resource"
e2eservice "k8s.io/kubernetes/test/e2e/framework/service"
testutils "k8s.io/kubernetes/test/utils"
@ -88,12 +87,10 @@ const (
)
var (
// KindRC is the GVK for ReplicationController
KindRC = schema.GroupVersionKind{Version: "v1", Kind: "ReplicationController"}
// KindDeployment is the GVK for Deployment
KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "Deployment"}
KindDeployment = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
// KindReplicaSet is the GVK for ReplicaSet
KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1beta2", Kind: "ReplicaSet"}
KindReplicaSet = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "ReplicaSet"}
// KindCRD is the GVK for CRD for test purposes
KindCRD = schema.GroupVersionKind{Group: crdGroup, Version: crdVersion, Kind: crdKind}
)
@ -640,12 +637,6 @@ func (rc *ResourceConsumer) sendConsumeCustomMetric(ctx context.Context, delta i
// GetReplicas get the replicas
func (rc *ResourceConsumer) GetReplicas(ctx context.Context) (int, error) {
switch rc.kind {
case KindRC:
replicationController, err := rc.clientSet.CoreV1().ReplicationControllers(rc.nsName).Get(ctx, rc.name, metav1.GetOptions{})
if err != nil {
return 0, err
}
return int(replicationController.Status.ReadyReplicas), nil
case KindDeployment:
deployment, err := rc.clientSet.AppsV1().Deployments(rc.nsName).Get(ctx, rc.name, metav1.GetOptions{})
if err != nil {
@ -758,7 +749,7 @@ func (rc *ResourceConsumer) CleanUp(ctx context.Context) {
}
framework.ExpectNoError(rc.clientSet.CoreV1().Services(rc.nsName).Delete(ctx, rc.name, metav1.DeleteOptions{}))
framework.ExpectNoError(e2eresource.DeleteResourceAndWaitForGC(ctx, rc.clientSet, schema.GroupKind{Kind: "ReplicationController"}, rc.nsName, rc.controllerName))
framework.ExpectNoError(e2eresource.DeleteResourceAndWaitForGC(ctx, rc.clientSet, schema.GroupKind{Group: "apps", Kind: "ReplicaSet"}, rc.nsName, rc.controllerName))
framework.ExpectNoError(rc.clientSet.CoreV1().Services(rc.nsName).Delete(ctx, rc.name+"-ctrl", metav1.DeleteOptions{}))
// Cleanup sidecar related resources
if rc.sidecarStatus == Enable && rc.sidecarType == Busy {
@ -862,18 +853,20 @@ func runServiceAndSidecarForResourceConsumer(ctx context.Context, c clientset.In
framework.ExpectNoError(err)
dnsClusterFirst := v1.DNSClusterFirst
controllerRcConfig := testutils.RCConfig{
Client: c,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Name: controllerName,
Namespace: ns,
Timeout: timeoutRC,
Replicas: 1,
Command: []string{"/agnhost", "resource-consumer-controller", "--consumer-service-name=" + sidecarName, "--consumer-service-namespace=" + ns, "--consumer-port=80"},
DNSPolicy: &dnsClusterFirst,
controllerRsConfig := testutils.ReplicaSetConfig{
RCConfig: testutils.RCConfig{
Client: c,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Name: controllerName,
Namespace: ns,
Timeout: timeoutRC,
Replicas: 1,
Command: []string{"/agnhost", "resource-consumer-controller", "--consumer-service-name=" + sidecarName, "--consumer-service-namespace=" + ns, "--consumer-port=80"},
DNSPolicy: &dnsClusterFirst,
},
}
framework.ExpectNoError(e2erc.RunRC(ctx, controllerRcConfig))
framework.ExpectNoError(runReplicaSet(ctx, controllerRsConfig))
// Wait for endpoints to propagate for the controller service.
framework.ExpectNoError(e2eendpointslice.WaitForEndpointCount(
ctx, c, ns, controllerName, 1))
@ -909,8 +902,6 @@ func runServiceAndWorkloadForResourceConsumer(ctx context.Context, c clientset.I
dpConfig.ContainerDumpFunc = e2ekubectl.LogFailedContainers
switch kind {
case KindRC:
framework.ExpectNoError(e2erc.RunRC(ctx, rcConfig))
case KindDeployment:
ginkgo.By(fmt.Sprintf("Creating deployment %s in namespace %s", dpConfig.Name, dpConfig.Namespace))
framework.ExpectNoError(testutils.RunDeployment(ctx, dpConfig))
@ -948,18 +939,20 @@ func runServiceAndWorkloadForResourceConsumer(ctx context.Context, c clientset.I
framework.ExpectNoError(err)
dnsClusterFirst := v1.DNSClusterFirst
controllerRcConfig := testutils.RCConfig{
Client: c,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Name: controllerName,
Namespace: ns,
Timeout: timeoutRC,
Replicas: 1,
Command: []string{"/agnhost", "resource-consumer-controller", "--consumer-service-name=" + name, "--consumer-service-namespace=" + ns, "--consumer-port=80"},
DNSPolicy: &dnsClusterFirst,
controllerRsConfig := testutils.ReplicaSetConfig{
RCConfig: testutils.RCConfig{
Client: c,
Image: imageutils.GetE2EImage(imageutils.Agnhost),
Name: controllerName,
Namespace: ns,
Timeout: timeoutRC,
Replicas: 1,
Command: []string{"/agnhost", "resource-consumer-controller", "--consumer-service-name=" + name, "--consumer-service-namespace=" + ns, "--consumer-port=80"},
DNSPolicy: &dnsClusterFirst,
},
}
framework.ExpectNoError(e2erc.RunRC(ctx, controllerRcConfig))
framework.ExpectNoError(runReplicaSet(ctx, controllerRsConfig))
// Wait for endpoints to propagate for the controller service.
framework.ExpectNoError(e2eendpointslice.WaitForEndpointCount(
ctx, c, ns, controllerName, 1))

View file

@ -42,7 +42,7 @@ func (t *HPAUpgradeTest) Setup(ctx context.Context, f *framework.Framework) {
t.rc = e2eautoscaling.NewDynamicResourceConsumer(ctx,
"res-cons-upgrade",
f.Namespace.Name,
e2eautoscaling.KindRC,
e2eautoscaling.KindReplicaSet,
1, /* replicas */
250, /* initCPUTotal */
0,