Skip to content

Commit b93791b

Browse files
committed
test: Add client side install method for restoring Config Sync
To guarantee the e2e client claims ownership of all fields for objects that might have drifted, use client-side apply when reinstalling Config Sync after ConfigManagement was previously installed and removed.
1 parent 1a8f8ee commit b93791b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

e2e/nomostest/config_sync.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,21 @@ func InstallConfigSync(nt *NT) error {
245245
return nil
246246
}
247247

248+
// InstallConfigSyncFromManifest installs ConfigSync on the test cluster by directly
249+
// applying the manifest file using kubectl client-side apply
250+
func InstallConfigSyncFromManifest(nt *NT) error {
251+
nt.T.Log("[SETUP] Installing Config Sync directly from manifest file")
252+
253+
nt.T.Logf("Applying Config Sync manifest directly from %s", configSyncManifest)
254+
255+
out, err := nt.Shell.Kubectl("apply", "-f", configSyncManifest)
256+
if err != nil {
257+
return fmt.Errorf("failed to apply Config Sync manifest: %v\n%s", err, out)
258+
}
259+
260+
return WaitForConfigSyncReady(nt)
261+
}
262+
248263
// uninstallConfigSync uninstalls ConfigSync on the test cluster
249264
func uninstallConfigSync(nt *NT) error {
250265
nt.T.Log("[CLEANUP] Uninstalling Config Sync")

e2e/testcases/cli_test.go

Lines changed: 4 additions & 4 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,7 +1302,7 @@ func TestNomosMigrate(t *testing.T) {
13011302

13021303
nt.T.Cleanup(func() {
13031304
// Restore state of Config Sync installation after test
1304-
if err := nomostest.InstallConfigSync(nt); err != nil {
1305+
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
13051306
nt.T.Fatal(err)
13061307
}
13071308
})
@@ -1468,8 +1469,7 @@ func TestNomosMigrateMonoRepo(t *testing.T) {
14681469

14691470
nt.T.Cleanup(func() {
14701471
// Restore state of Config Sync installation after test.
1471-
// This also emulates upgrading to the current version after migrating
1472-
if err := nomostest.InstallConfigSync(nt); err != nil {
1472+
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
14731473
nt.T.Fatal(err)
14741474
}
14751475
})
@@ -1711,7 +1711,7 @@ func TestACMUninstallScript(t *testing.T) {
17111711

17121712
nt.T.Cleanup(func() {
17131713
// Restore state of Config Sync installation after test
1714-
if err := nomostest.InstallConfigSync(nt); err != nil {
1714+
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
17151715
nt.T.Fatal(err)
17161716
}
17171717
})

0 commit comments

Comments
 (0)