From 0e6eb95fd2e525281619a6e199e3286fee9e9acc Mon Sep 17 00:00:00 2001 From: Mitali Paygude Date: Tue, 16 Jan 2024 11:20:50 -0800 Subject: [PATCH] m --- pkg/workflows/management/create_test.go | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/pkg/workflows/management/create_test.go b/pkg/workflows/management/create_test.go index ee63477de7bb7..7ea9bb0910e3c 100644 --- a/pkg/workflows/management/create_test.go +++ b/pkg/workflows/management/create_test.go @@ -408,6 +408,90 @@ func TestCreatePostWorkloadInitFailure(t *testing.T) { } } +func TestCreateInstallComponentsFailure(t *testing.T) { + c := newCreateTest(t) + c.expectSetup() + c.expectCreateBootstrap() + c.expectPreflightValidationsToPass() + c.expectCAPIInstall() + + gomock.InOrder( + c.clusterManager.EXPECT().InstallCustomComponents( + c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider), + + c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster).Return(errors.New("test")), + ) + + c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster) + c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil) + + c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any()) + + err := c.run() + if err == nil { + t.Fatalf("Create.Run() expected to return an error %v", err) + } +} + +func TestCreateEKSAReleaseBundleFailure(t *testing.T) { + c := newCreateTest(t) + c.expectSetup() + c.expectCreateBootstrap() + c.expectPreflightValidationsToPass() + c.expectCAPIInstall() + + gomock.InOrder( + c.clusterManager.EXPECT().InstallCustomComponents( + c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider), + + c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster), + + c.clusterManager.EXPECT().CreateEKSAReleaseBundle( + c.ctx, c.bootstrapCluster, c.clusterSpec).Return(errors.New("test")), + ) + + c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster) + c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil) + + c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any()) + + err := c.run() + if err == nil { + t.Fatalf("Create.Run() expected to return an error %v", err) + } +} + +func TestCreateInstallEksdManifestFailure(t *testing.T) { + c := newCreateTest(t) + c.expectSetup() + c.expectCreateBootstrap() + c.expectPreflightValidationsToPass() + c.expectCAPIInstall() + + gomock.InOrder( + c.clusterManager.EXPECT().InstallCustomComponents( + c.ctx, c.clusterSpec, c.bootstrapCluster, c.provider), + + c.eksdInstaller.EXPECT().InstallEksdCRDs(c.ctx, c.clusterSpec, c.bootstrapCluster), + + c.clusterManager.EXPECT().CreateEKSAReleaseBundle( + c.ctx, c.bootstrapCluster, c.clusterSpec), + + c.eksdInstaller.EXPECT().InstallEksdManifest( + c.ctx, c.clusterSpec, c.bootstrapCluster).Return(errors.New("test")), + ) + + c.clusterManager.EXPECT().SaveLogsManagementCluster(c.ctx, c.clusterSpec, c.bootstrapCluster) + c.clusterManager.EXPECT().SaveLogsWorkloadCluster(c.ctx, c.provider, c.clusterSpec, nil) + + c.writer.EXPECT().Write(fmt.Sprintf("%s-checkpoint.yaml", c.clusterSpec.Cluster.Name), gomock.Any()) + + err := c.run() + if err == nil { + t.Fatalf("Create.Run() expected to return an error %v", err) + } +} + func TestCreateMoveCAPIFailure(t *testing.T) { c := newCreateTest(t) c.expectSetup()