Skip to content

Commit ab3731e

Browse files
committed
Cleanup legacy controller deployments in test teardown
Improve test reliability by deleting legacy reconciler-manager and resource-group-controller deployments in test cleanup. Legacy ConfigManagement sets readiness on these controllers, which isn’t reliably cleaned up after tests. Removing both deployments ensures a fresh Config Sync install instead of patching, reducing flakiness and side effects between tests.
1 parent 1a8f8ee commit ab3731e

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

e2e/testcases/cli_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"kpt.dev/configsync/e2e/nomostest/ntopts"
4444
"kpt.dev/configsync/e2e/nomostest/policy"
4545
"kpt.dev/configsync/e2e/nomostest/syncsource"
46+
4647
"kpt.dev/configsync/e2e/nomostest/taskgroup"
4748
nomostesting "kpt.dev/configsync/e2e/nomostest/testing"
4849
"kpt.dev/configsync/e2e/nomostest/testpredicates"
@@ -1301,6 +1302,23 @@ func TestNomosMigrate(t *testing.T) {
13011302

13021303
nt.T.Cleanup(func() {
13031304
// Restore state of Config Sync installation after test
1305+
// Legacy ConfigManagement sets readiness on reconciler-manager and resource-group-controller,
1306+
// which isn't reliably cleaned up after tests. Delete both to ensure a fresh
1307+
// install instead of patching.
1308+
rmDeployment := k8sobjects.DeploymentObject(
1309+
core.Name(reconcilermanager.ManagerName),
1310+
core.Namespace(configsync.ControllerNamespace),
1311+
)
1312+
rgDeployment := k8sobjects.DeploymentObject(
1313+
core.Name(configmanagement.RGControllerName),
1314+
core.Namespace(configmanagement.RGControllerNamespace),
1315+
)
1316+
if err := nt.KubeClient.Delete(rmDeployment); err != nil && !apierrors.IsNotFound(err) {
1317+
nt.T.Error(err)
1318+
}
1319+
if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
1320+
nt.T.Error(err)
1321+
}
13041322
if err := nomostest.InstallConfigSync(nt); err != nil {
13051323
nt.T.Fatal(err)
13061324
}
@@ -1469,6 +1487,23 @@ func TestNomosMigrateMonoRepo(t *testing.T) {
14691487
nt.T.Cleanup(func() {
14701488
// Restore state of Config Sync installation after test.
14711489
// This also emulates upgrading to the current version after migrating
1490+
// Legacy ConfigManagement sets readiness on reconciler-manager and resource-group-controller,
1491+
// which isn’t reliably cleaned up after tests. Delete both to ensure a fresh
1492+
// install instead of patching.
1493+
rmDeployment := k8sobjects.DeploymentObject(
1494+
core.Name(reconcilermanager.ManagerName),
1495+
core.Namespace(configsync.ControllerNamespace),
1496+
)
1497+
rgDeployment := k8sobjects.DeploymentObject(
1498+
core.Name(configmanagement.RGControllerName),
1499+
core.Namespace(configmanagement.RGControllerNamespace),
1500+
)
1501+
if err := nt.KubeClient.Delete(rmDeployment); err != nil && !apierrors.IsNotFound(err) {
1502+
nt.T.Error(err)
1503+
}
1504+
if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
1505+
nt.T.Error(err)
1506+
}
14721507
if err := nomostest.InstallConfigSync(nt); err != nil {
14731508
nt.T.Fatal(err)
14741509
}
@@ -1711,6 +1746,23 @@ func TestACMUninstallScript(t *testing.T) {
17111746

17121747
nt.T.Cleanup(func() {
17131748
// Restore state of Config Sync installation after test
1749+
// Legacy ConfigManagement sets readiness on reconciler-manager and resource-group-controller,
1750+
// which isn’t reliably cleaned up after tests. Delete both to ensure a fresh
1751+
// install instead of patching.
1752+
rmDeployment := k8sobjects.DeploymentObject(
1753+
core.Name(reconcilermanager.ManagerName),
1754+
core.Namespace(configsync.ControllerNamespace),
1755+
)
1756+
rgDeployment := k8sobjects.DeploymentObject(
1757+
core.Name(configmanagement.RGControllerName),
1758+
core.Namespace(configmanagement.RGControllerNamespace),
1759+
)
1760+
if err := nt.KubeClient.Delete(rmDeployment); err != nil && !apierrors.IsNotFound(err) {
1761+
nt.T.Error(err)
1762+
}
1763+
if err := nt.KubeClient.Delete(rgDeployment); err != nil && !apierrors.IsNotFound(err) {
1764+
nt.T.Error(err)
1765+
}
17141766
if err := nomostest.InstallConfigSync(nt); err != nil {
17151767
nt.T.Fatal(err)
17161768
}

0 commit comments

Comments
 (0)