Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions e2e/nomostest/config_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ var (
//
// All paths must be relative to the test file that is running. There is probably
// a more elegant way to do this.
baseDir = filepath.FromSlash("../..")
outputManifestsDir = filepath.Join(baseDir, ".output", "staging", "oss")
configSyncManifest = filepath.Join(outputManifestsDir, "config-sync-manifest.yaml")
multiConfigMaps = filepath.Join(baseDir, "e2e", "raw-nomos", configSyncManifests, multiConfigMapsName)
baseDir = filepath.FromSlash("../..")
outputManifestsDir = filepath.Join(baseDir, ".output", "staging", "oss")
configSyncManifest = filepath.Join(outputManifestsDir, "config-sync-manifest.yaml")
admissionWebhookManifest = filepath.Join(outputManifestsDir, "admission-webhook.yaml")
multiConfigMaps = filepath.Join(baseDir, "e2e", "raw-nomos", configSyncManifests, multiConfigMapsName)
)

var (
Expand Down Expand Up @@ -245,6 +246,34 @@ func InstallConfigSync(nt *NT) error {
return nil
}

// InstallConfigSyncFromManifest installs ConfigSync on the test cluster by directly
// applying the manifest file using kubectl client-side apply
func InstallConfigSyncFromManifest(nt *NT) error {
nt.T.Log("[SETUP] Installing Config Sync directly from manifest file")

nt.T.Logf("Applying Config Sync manifest directly from %s", configSyncManifest)

out, err := nt.Shell.Kubectl("apply", "--server-side=false", "-f", configSyncManifest)
if err != nil {
return fmt.Errorf("failed to apply Config Sync manifest: %v\n%s", err, out)
}

nt.T.Logf("Applying multi-repo configmaps from %s", multiConfigMaps)
out, err = nt.Shell.Kubectl("apply", "--server-side=false", "-f", multiConfigMaps)
if err != nil {
return fmt.Errorf("failed to apply multi-repo configmaps: %v\n%s", err, out)
}

// Apply the admission webhook manifest
nt.T.Logf("Applying admission webhook manifest from %s", admissionWebhookManifest)
out, err = nt.Shell.Kubectl("apply", "--server-side=false", "-f", admissionWebhookManifest)
if err != nil {
return fmt.Errorf("failed to apply admission webhook manifest: %v\n%s", err, out)
}

return nil
}

// uninstallConfigSync uninstalls ConfigSync on the test cluster
func uninstallConfigSync(nt *NT) error {
nt.T.Log("[CLEANUP] Uninstalling Config Sync")
Expand Down
24 changes: 13 additions & 11 deletions e2e/testcases/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,13 +1297,14 @@ func TestApiResourceFormatting(t *testing.T) {
}

func TestNomosMigrate(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
cmObj := &unstructured.Unstructured{
Expand Down Expand Up @@ -1451,11 +1452,11 @@ func TestNomosMigrate(t *testing.T) {
configmanagement.RGControllerName, configmanagement.RGControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.Deployment(),
return nt.Watcher.WatchForCurrentStatus(kinds.Deployment(),
core.RootReconcilerName(configsync.RootSyncName), configsync.ControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.RootSyncV1Beta1(),
return nt.Watcher.WatchForCurrentStatus(kinds.RootSyncV1Beta1(),
configsync.RootSyncName, configsync.ControllerNamespace)
})
if err := tg.Wait(); err != nil {
Expand All @@ -1464,14 +1465,14 @@ func TestNomosMigrate(t *testing.T) {
}

func TestNomosMigrateMonoRepo(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test.
// This also emulates upgrading to the current version after migrating
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
crds := []string{
Expand Down Expand Up @@ -1707,13 +1708,14 @@ func TestNomosMigrateMonoRepo(t *testing.T) {
// This test case validates the behavior of the uninstall script defined
// at installation/uninstall_configmanagement.sh
func TestACMUninstallScript(t *testing.T) {
nt := nomostest.New(t, nomostesting.NomosCLI, ntopts.SkipConfigSyncInstall)
nt := nomostest.New(t, nomostesting.NomosCLI)

nt.T.Cleanup(func() {
// Restore state of Config Sync installation after test
if err := nomostest.InstallConfigSync(nt); err != nil {
if err := nomostest.InstallConfigSyncFromManifest(nt); err != nil {
nt.T.Fatal(err)
}
nt.Must(nt.WatchForAllSyncs())
})
nt.T.Cleanup(func() {
cmObj := &unstructured.Unstructured{
Expand Down Expand Up @@ -1861,11 +1863,11 @@ func TestACMUninstallScript(t *testing.T) {
configmanagement.RGControllerName, configmanagement.RGControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.Deployment(),
return nt.Watcher.WatchForCurrentStatus(kinds.Deployment(),
core.RootReconcilerName(configsync.RootSyncName), configsync.ControllerNamespace)
})
tg.Go(func() error {
return nt.Watcher.WatchForNotFound(kinds.RootSyncV1Beta1(),
return nt.Watcher.WatchForCurrentStatus(kinds.RootSyncV1Beta1(),
configsync.RootSyncName, configsync.ControllerNamespace)
})
if err := tg.Wait(); err != nil {
Expand Down