Skip to content

Commit

Permalink
add test for pause eksa
Browse files Browse the repository at this point in the history
  • Loading branch information
tatlat authored and eks-distro-pr-bot committed Feb 21, 2024
1 parent 59a1df0 commit 0ecb937
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions pkg/workflows/management/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ func (c *deleteTestSetup) expectInstallCAPI(err error) {
c.clusterManager.EXPECT().InstallCAPI(c.ctx, gomock.Any(), c.clusterSpec, c.bootstrapCluster, c.provider).Return(err)
}

func (c *deleteTestSetup) expectMoveCAPI(err error) {
c.clusterManager.EXPECT().PauseEKSAControllerReconcile(c.ctx, c.workloadCluster, c.clusterSpec, c.provider)
c.clusterManager.EXPECT().MoveCAPI(c.ctx, c.workloadCluster, c.bootstrapCluster, c.workloadCluster.Name, c.clusterSpec, gomock.Any()).Return(err)
func (c *deleteTestSetup) expectMoveCAPI(err1, err2 error) {
c.clusterManager.EXPECT().PauseEKSAControllerReconcile(c.ctx, c.workloadCluster, c.clusterSpec, c.provider).Return(err1)
if err1 != nil {
return
}
c.clusterManager.EXPECT().MoveCAPI(c.ctx, c.workloadCluster, c.bootstrapCluster, c.workloadCluster.Name, c.clusterSpec, gomock.Any()).Return(err2)
}

func (c *deleteTestSetup) expectInstallEksaComponentsBootstrap(err1, err2, err3, err4, err5 error) {
Expand Down Expand Up @@ -219,7 +222,7 @@ func TestDeleteRunSuccess(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, nil, nil)
test.expectApplyOnBootstrap(nil)
test.expectDeleteCluster(nil, nil, nil, nil)
Expand Down Expand Up @@ -309,6 +312,25 @@ func TestDeleteRunFailInstallCAPI(t *testing.T) {
}
}

func TestDeleteRunFailPauseEksa(t *testing.T) {
features.ClearCache()
os.Setenv(features.UseControllerForCli, "true")
test := newDeleteTest(t)
test.expectSetup(nil)
test.expectBootstrapOpts(nil)
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(fmt.Errorf(""), nil)
test.expectSaveLogsWorkload()
test.expectSaveLogsManagement()

err := test.run()
if err == nil {
t.Fatalf("Delete.Run() err = %v, want err = nil", err)
}
}

func TestDeleteRunFailMoveCAPI(t *testing.T) {
features.ClearCache()
os.Setenv(features.UseControllerForCli, "true")
Expand All @@ -318,7 +340,7 @@ func TestDeleteRunFailMoveCAPI(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(fmt.Errorf(""))
test.expectMoveCAPI(nil, fmt.Errorf(""))
test.expectSaveLogsWorkload()
test.expectSaveLogsManagement()

Expand All @@ -337,7 +359,7 @@ func TestDeleteRunFailResumeReconcile(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(fmt.Errorf(""), nil, nil, nil, nil)
test.expectSaveLogsManagement()
test.expectSaveLogsWorkload()
Expand All @@ -356,7 +378,7 @@ func TestDeleteRunFailAddAnnotation(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, fmt.Errorf(""), nil, nil, nil)
test.expectSaveLogsManagement()
test.expectSaveLogsWorkload()
Expand All @@ -376,7 +398,7 @@ func TestDeleteRunFailProviderInstall(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, fmt.Errorf(""), nil, nil)
test.expectSaveLogsManagement()
test.expectSaveLogsWorkload()
Expand All @@ -396,7 +418,7 @@ func TestDeleteRunFailEksdInstall(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, fmt.Errorf(""), nil)
test.expectSaveLogsManagement()
test.expectSaveLogsWorkload()
Expand All @@ -416,7 +438,7 @@ func TestDeleteRunFailBuildClient(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, nil, fmt.Errorf(""))
test.expectSaveLogsManagement()
test.expectSaveLogsWorkload()
Expand All @@ -436,7 +458,7 @@ func TestDeleteRunFailPostDelete(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, nil, nil)
test.expectCreateNamespace()
test.expectApplyOnBootstrap(nil)
Expand All @@ -458,7 +480,7 @@ func TestDeleteRunFailCleanupGit(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, nil, nil)
test.expectCreateNamespace()
test.expectApplyOnBootstrap(nil)
Expand All @@ -482,7 +504,7 @@ func TestDeleteRunFailDeleteBootstrap(t *testing.T) {
test.expectCreateBootstrap(nil)
test.expectPreCAPI(nil)
test.expectInstallCAPI(nil)
test.expectMoveCAPI(nil)
test.expectMoveCAPI(nil, nil)
test.expectInstallEksaComponentsBootstrap(nil, nil, nil, nil, nil)
test.expectApplyOnBootstrap(nil)
test.expectCreateNamespace()
Expand Down

0 comments on commit 0ecb937

Please sign in to comment.