Skip to content

Commit

Permalink
Merge pull request #6632 from danfengliu/make-cls-worker-node-count-c…
Browse files Browse the repository at this point in the history
…onfigurable

[E2E Test] The minimum worker node count of workload cluster should be 2
  • Loading branch information
danfengliu authored Aug 10, 2023
2 parents 7311fb4 + c637057 commit a88cb46
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 17 deletions.
5 changes: 4 additions & 1 deletion test/e2e/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"flag"
"fmt"
"time"

"github.com/google/uuid"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -68,7 +69,9 @@ func BackupRestoreTest(useVolumeSnapshots bool) {
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
})
if veleroCfg.InstallVelero {
err = VeleroUninstall(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
err = VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)
Expect(err).To(Succeed())
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/backups/sync_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func BackupsSyncTest() {
DeleteBackups(context.Background(), *VeleroCfg.ClientToInstallVelero)
})
if VeleroCfg.InstallVelero {
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/e2e/backups/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ func TTLTest() {
By("Clean backups after test", func() {
DeleteBackups(context.Background(), *veleroCfg.ClientToInstallVelero)
})
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
if veleroCfg.InstallVelero {
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
}
ctx, ctxCancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer ctxCancel()
Expect(DeleteNamespace(ctx, client, test.testNS, false)).To(Succeed(), fmt.Sprintf("Failed to delete the namespace %s", test.testNS))
}
})
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/basic/api-group/enable_api_group_extentions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ func APIExtensionsVersionsTest() {
})
if veleroCfg.InstallVelero {
By("Uninstall Velero and delete CRD ", func() {
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultCluster)).To(Succeed())
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())

Expect(KubectlConfigUseContext(context.Background(), veleroCfg.StandbyCluster)).To(Succeed())
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())
})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/basic/api-group/enable_api_group_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@ var veleroCfg VeleroConfig

type apiGropuVersionsTest struct {
name string
namespaces []string
srcCrdYaml string
srcCRs map[string]string
tgtCrdYaml string
tgtVer string
cm *corev1api.ConfigMap
gvs map[string][]string
want map[string]map[string]string
}

Expand Down Expand Up @@ -108,6 +106,8 @@ func APIGropuVersionsTest() {

Context("When EnableAPIGroupVersions flag is set", func() {
It("Should back up API group version and restore by version priority", func() {
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*60)
defer ctxCancel()
Expect(runEnableAPIGroupVersionsTests(
ctx,
*veleroCfg.ClientToInstallVelero,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/basic/pvc-selected-node-changing.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
By("Prepare ConfigMap data", func() {
nodeNameList, err := GetWorkerNodes(p.Ctx)
Expect(err).To(Succeed())
Expect(len(nodeNameList) > 2).To(Equal(true))
Expect(len(nodeNameList) >= 2).To(Equal(true))
for _, nodeName := range nodeNameList {
if nodeName != p.oldNodeName {
p.newNodeName = nodeName
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"testing"
"time"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
Expand Down Expand Up @@ -205,6 +206,8 @@ var _ = BeforeSuite(func() {
var _ = AfterSuite(func() {
if VeleroCfg.InstallVelero && !VeleroCfg.Debug {
By("release test resources after testing")
Expect(VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)).To(Succeed())
}
})
10 changes: 7 additions & 3 deletions test/e2e/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
// need to uninstall Velero first in case of the affection of the existing global velero installation
if veleroCfg.InstallVelero {
By("Uninstall Velero", func() {
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
})
}
Expand All @@ -86,13 +88,15 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
// })
if veleroCfg.InstallVelero {
By(fmt.Sprintf("Uninstall Velero and delete sample workload namespace %s", migrationNamespace), func() {
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultCluster)).To(Succeed())
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
DeleteNamespace(context.Background(), *veleroCfg.DefaultClient, migrationNamespace, true)

Expect(KubectlConfigUseContext(context.Background(), veleroCfg.StandbyCluster)).To(Succeed())
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
DeleteNamespace(context.Background(), *veleroCfg.StandbyClient, migrationNamespace, true)
})
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
// need to uninstall Velero first in case of the affection of the existing global velero installation
if veleroCfg.InstallVelero {
By("Uninstall Velero", func() {
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
})
}
Expand All @@ -92,7 +94,9 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
})
if veleroCfg.InstallVelero {
By("Uninstall Velero", func() {
Expect(VeleroUninstall(context.Background(), veleroCfg.VeleroCLI,
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI,
veleroCfg.VeleroNamespace)).To(Succeed())
})
}
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/util/velero/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func VeleroInstall(ctx context.Context, veleroCfg *VeleroConfig, isStandbyCluste
RestoreHelperImage: veleroCfg.RestoreHelperImage,
VeleroServerDebugMode: veleroCfg.VeleroServerDebugMode,
})

if err != nil {
RunDebug(context.Background(), veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace, "", "")
return errors.WithMessagef(err, "Failed to install Velero in the cluster")
Expand Down Expand Up @@ -536,7 +537,9 @@ func PrepareVelero(ctx context.Context, caseName string) error {
ready, err := IsVeleroReady(context.Background(), VeleroCfg.VeleroNamespace, VeleroCfg.UseNodeAgent)
if err != nil {
fmt.Printf("error in checking velero status with %v", err)
VeleroUninstall(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
defer ctxCancel()
VeleroUninstall(ctx, VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace)
ready = false
}
if ready {
Expand Down

0 comments on commit a88cb46

Please sign in to comment.