Skip to content

Commit 9964b37

Browse files
committed
Refactor the E2E framework. Add migration framework.
Signed-off-by: Xun Jiang <[email protected]>
1 parent 78c97d9 commit 9964b37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1004
-666
lines changed

Diff for: test/e2e/basic/api-group/enable_api_group_extentions.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ func APIExtensionsVersionsTest() {
3939
label := "for=backup"
4040
srcCrdYaml := "testdata/enable_api_group_versions/case-a-source-v1beta1.yaml"
4141
BeforeEach(func() {
42-
if veleroCfg.DefaultClusterContext == "" && veleroCfg.StandbyClusterContext == "" {
42+
if veleroCfg.ActiveClusterContext == "" && veleroCfg.StandbyClusterContext == "" {
4343
Skip("CRD with apiextension versions migration test needs 2 clusters")
4444
}
4545
veleroCfg = VeleroCfg
46-
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
47-
srcVersions, err := GetAPIVersions(veleroCfg.DefaultClient, resourceName)
46+
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.ActiveClusterContext)).To(Succeed())
47+
srcVersions, err := GetAPIVersions(veleroCfg.ActiveClient, resourceName)
4848
Expect(err).ShouldNot(HaveOccurred())
4949
dstVersions, err := GetAPIVersions(veleroCfg.StandbyClient, resourceName)
5050
Expect(err).ShouldNot(HaveOccurred())
@@ -67,9 +67,9 @@ func APIExtensionsVersionsTest() {
6767
})
6868
})
6969
AfterEach(func() {
70-
By(fmt.Sprintf("Switch to default kubeconfig context %s", veleroCfg.DefaultClusterContext), func() {
71-
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
72-
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
70+
By(fmt.Sprintf("Switch to default kubeconfig context %s", veleroCfg.ActiveClusterContext), func() {
71+
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.ActiveClusterContext)).To(Succeed())
72+
veleroCfg.ClientToInstallVelero = veleroCfg.ActiveClient
7373
})
7474

7575
if CurrentSpecReport().Failed() && veleroCfg.FailFast {
@@ -82,7 +82,7 @@ func APIExtensionsVersionsTest() {
8282
By("Uninstall Velero and delete CRD ", func() {
8383
ctx, ctxCancel := context.WithTimeout(context.Background(), time.Minute*5)
8484
defer ctxCancel()
85-
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
85+
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.ActiveClusterContext)).To(Succeed())
8686
Expect(VeleroUninstall(ctx, veleroCfg)).To(Succeed())
8787
Expect(DeleteCRDByName(context.Background(), crdName)).To(Succeed())
8888

@@ -98,14 +98,14 @@ func APIExtensionsVersionsTest() {
9898
backupName = "backup-" + UUIDgen.String()
9999
restoreName = "restore-" + UUIDgen.String()
100100

101-
By(fmt.Sprintf("Install Velero in cluster-A (%s) to backup workload", veleroCfg.DefaultClusterContext), func() {
102-
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
101+
By(fmt.Sprintf("Install Velero in cluster-A (%s) to backup workload", veleroCfg.ActiveClusterContext), func() {
102+
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.ActiveClusterContext)).To(Succeed())
103103
veleroCfg.Features = "EnableAPIGroupVersions"
104104
veleroCfg.UseVolumeSnapshots = false
105105
Expect(VeleroInstall(context.Background(), &veleroCfg, false)).To(Succeed())
106106
})
107107

108-
By(fmt.Sprintf("Install CRD of apiextenstions v1beta1 in cluster-A (%s)", veleroCfg.DefaultClusterContext), func() {
108+
By(fmt.Sprintf("Install CRD of apiextenstions v1beta1 in cluster-A (%s)", veleroCfg.ActiveClusterContext), func() {
109109
Expect(InstallCRD(context.Background(), srcCrdYaml)).To(Succeed())
110110
Expect(CRDShouldExist(context.Background(), crdName)).To(Succeed())
111111
Expect(WaitForCRDEstablished(crdName)).To(Succeed())

Diff for: test/e2e/basic/backup-volume-info/base.go

+22-24
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,39 @@ import (
2828
v1 "k8s.io/api/core/v1"
2929

3030
. "github.com/vmware-tanzu/velero/test"
31-
. "github.com/vmware-tanzu/velero/test/e2e/test"
31+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
3232
. "github.com/vmware-tanzu/velero/test/util/common"
3333
. "github.com/vmware-tanzu/velero/test/util/k8s"
3434
)
3535

3636
type BackupVolumeInfo struct {
37-
TestCase
37+
BRCase
3838
SnapshotVolumes bool
3939
DefaultVolumesToFSBackup bool
4040
SnapshotMoveData bool
4141
TimeoutDuration time.Duration
4242
}
4343

4444
func (v *BackupVolumeInfo) Init() error {
45-
v.TestCase.Init()
45+
v.BRCase.Init()
46+
47+
if v.VeleroCfg.CloudProvider == Vsphere && (!strings.Contains(v.CaseBaseName, "fs-upload") && !strings.Contains(v.CaseBaseName, "skipped")) {
48+
fmt.Printf("Skip snapshot case %s for vsphere environment.\n", v.CaseBaseName)
49+
Skip("Skip snapshot case due to vsphere environment doesn't cover the CSI test, and it doesn't have a Velero native snapshot plugin.")
50+
}
51+
52+
if strings.Contains(v.VeleroCfg.Features, FeatureCSI) {
53+
if strings.Contains(v.CaseBaseName, "native-snapshot") {
54+
fmt.Printf("Skip native snapshot case %s when the CSI feature is enabled.\n", v.CaseBaseName)
55+
Skip("Skip native snapshot case due to CSI feature is enabled.")
56+
}
57+
} else {
58+
if strings.Contains(v.CaseBaseName, "csi") {
59+
fmt.Printf("Skip CSI related case %s when the CSI feature is not enabled.\n", v.CaseBaseName)
60+
Skip("Skip CSI cases due to CSI feature is not enabled.")
61+
}
62+
}
63+
4664
v.CaseBaseName = v.CaseBaseName + v.UUIDgen
4765
v.BackupName = "backup-" + v.CaseBaseName
4866
v.RestoreName = "restore-" + v.CaseBaseName
@@ -76,26 +94,6 @@ func (v *BackupVolumeInfo) Init() error {
7694
return nil
7795
}
7896

79-
func (v *BackupVolumeInfo) Start() error {
80-
if v.VeleroCfg.CloudProvider == Vsphere && (!strings.Contains(v.CaseBaseName, "fs-upload") && !strings.Contains(v.CaseBaseName, "skipped")) {
81-
fmt.Printf("Skip snapshot case %s for vsphere environment.\n", v.CaseBaseName)
82-
Skip("Skip snapshot case due to vsphere environment doesn't cover the CSI test, and it doesn't have a Velero native snapshot plugin.")
83-
}
84-
85-
if strings.Contains(v.VeleroCfg.Features, FeatureCSI) {
86-
if strings.Contains(v.CaseBaseName, "native-snapshot") {
87-
fmt.Printf("Skip native snapshot case %s when the CSI feature is enabled.\n", v.CaseBaseName)
88-
Skip("Skip native snapshot case due to CSI feature is enabled.")
89-
}
90-
} else {
91-
if strings.Contains(v.CaseBaseName, "csi") {
92-
fmt.Printf("Skip CSI related case %s when the CSI feature is not enabled.\n", v.CaseBaseName)
93-
Skip("Skip CSI cases due to CSI feature is not enabled.")
94-
}
95-
}
96-
v.TestCase.Start()
97-
return nil
98-
}
9997
func (v *BackupVolumeInfo) CreateResources() error {
10098
labels := map[string]string{
10199
"volume-info": "true",
@@ -147,7 +145,7 @@ func (v *BackupVolumeInfo) CreateResources() error {
147145
return nil
148146
}
149147

150-
func (v *BackupVolumeInfo) Destroy() error {
148+
func (v *BackupVolumeInfo) DeleteResources() error {
151149
err := CleanupNamespaces(v.Ctx, v.Client, v.CaseBaseName)
152150
if err != nil {
153151
return errors.Wrap(err, "Could cleanup retrieve namespaces")

Diff for: test/e2e/basic/backup-volume-info/csi_data_mover.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
. "github.com/onsi/gomega"
2323

24-
. "github.com/vmware-tanzu/velero/test/e2e/test"
24+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2525
. "github.com/vmware-tanzu/velero/test/util/providers"
2626
. "github.com/vmware-tanzu/velero/test/util/velero"
2727
)
@@ -30,7 +30,7 @@ var CSIDataMoverVolumeInfoTest func() = TestFunc(&CSIDataMoverVolumeInfo{
3030
BackupVolumeInfo{
3131
SnapshotMoveData: true,
3232
SnapshotVolumes: true,
33-
TestCase: TestCase{
33+
BRCase: BRCase{
3434
CaseBaseName: "csi-data-mover-volumeinfo",
3535
TestMsg: &TestMSG{
3636
Desc: "Test backup's VolumeInfo metadata content for CSI data mover case.",

Diff for: test/e2e/basic/backup-volume-info/csi_snapshot.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121

2222
. "github.com/onsi/gomega"
2323

24-
. "github.com/vmware-tanzu/velero/test/e2e/test"
24+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2525
. "github.com/vmware-tanzu/velero/test/util/providers"
2626
. "github.com/vmware-tanzu/velero/test/util/velero"
2727
)
2828

2929
var CSISnapshotVolumeInfoTest func() = TestFunc(&CSISnapshotVolumeInfo{
3030
BackupVolumeInfo{
3131
SnapshotVolumes: true,
32-
TestCase: TestCase{
32+
BRCase: BRCase{
3333
CaseBaseName: "csi-snapshot-volumeinfo",
3434
TestMsg: &TestMSG{
3535
Desc: "Test backup's VolumeInfo metadata content for CSI snapshot case.",

Diff for: test/e2e/basic/backup-volume-info/filesystem_upload.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121

2222
. "github.com/onsi/gomega"
2323

24-
. "github.com/vmware-tanzu/velero/test/e2e/test"
24+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2525
. "github.com/vmware-tanzu/velero/test/util/providers"
2626
. "github.com/vmware-tanzu/velero/test/util/velero"
2727
)
2828

2929
var FilesystemUploadVolumeInfoTest func() = TestFunc(&FilesystemUploadVolumeInfo{
3030
BackupVolumeInfo{
3131
DefaultVolumesToFSBackup: true,
32-
TestCase: TestCase{
32+
BRCase: BRCase{
3333
CaseBaseName: "fs-upload-volumeinfo",
3434
TestMsg: &TestMSG{
3535
Desc: "Test backup's VolumeInfo metadata content for filesystem upload case.",

Diff for: test/e2e/basic/backup-volume-info/native_snapshot.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121

2222
. "github.com/onsi/gomega"
2323

24-
. "github.com/vmware-tanzu/velero/test/e2e/test"
24+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2525
. "github.com/vmware-tanzu/velero/test/util/providers"
2626
. "github.com/vmware-tanzu/velero/test/util/velero"
2727
)
2828

2929
var NativeSnapshotVolumeInfoTest func() = TestFunc(&NativeSnapshotVolumeInfo{
3030
BackupVolumeInfo{
3131
SnapshotVolumes: true,
32-
TestCase: TestCase{
32+
BRCase: BRCase{
3333
UseVolumeSnapshots: true,
3434
CaseBaseName: "native-snapshot-volumeinfo",
3535
TestMsg: &TestMSG{

Diff for: test/e2e/basic/backup-volume-info/skipped_volumes.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121

2222
. "github.com/onsi/gomega"
2323

24-
. "github.com/vmware-tanzu/velero/test/e2e/test"
24+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2525
. "github.com/vmware-tanzu/velero/test/util/providers"
2626
. "github.com/vmware-tanzu/velero/test/util/velero"
2727
)
2828

2929
var SkippedVolumeInfoTest func() = TestFunc(&SkippedVolumeInfo{
3030
BackupVolumeInfo{
3131
SnapshotVolumes: false,
32-
TestCase: TestCase{
32+
BRCase: BRCase{
3333
CaseBaseName: "skipped-volumes-volumeinfo",
3434
TestMsg: &TestMSG{
3535
Desc: "Test backup's VolumeInfo metadata content for volume-skipped case.",

Diff for: test/e2e/basic/namespace-mapping.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import (
88
. "github.com/onsi/ginkgo/v2"
99
. "github.com/onsi/gomega"
1010

11-
. "github.com/vmware-tanzu/velero/test/e2e/test"
11+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
1212
. "github.com/vmware-tanzu/velero/test/util/k8s"
1313
. "github.com/vmware-tanzu/velero/test/util/kibishii"
1414
)
1515

1616
type NamespaceMapping struct {
17-
TestCase
17+
BRCase
1818
MappedNamespaceList []string
1919
kibishiiData *KibishiiData
2020
}
2121

2222
const NamespaceBaseName string = "ns-mp-"
2323

24-
var OneNamespaceMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: false}})
25-
var MultiNamespacesMappingResticTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: false}})
26-
var OneNamespaceMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 1, UseVolumeSnapshots: true}})
27-
var MultiNamespacesMappingSnapshotTest func() = TestFunc(&NamespaceMapping{TestCase: TestCase{NamespacesTotal: 2, UseVolumeSnapshots: true}})
24+
var OneNamespaceMappingResticTest func() = TestFunc(&NamespaceMapping{BRCase: BRCase{NamespacesTotal: 1, UseVolumeSnapshots: false}})
25+
var MultiNamespacesMappingResticTest func() = TestFunc(&NamespaceMapping{BRCase: BRCase{NamespacesTotal: 2, UseVolumeSnapshots: false}})
26+
var OneNamespaceMappingSnapshotTest func() = TestFunc(&NamespaceMapping{BRCase: BRCase{NamespacesTotal: 1, UseVolumeSnapshots: true}})
27+
var MultiNamespacesMappingSnapshotTest func() = TestFunc(&NamespaceMapping{BRCase: BRCase{NamespacesTotal: 2, UseVolumeSnapshots: true}})
2828

2929
func (n *NamespaceMapping) Init() error {
30-
n.TestCase.Init()
30+
n.BRCase.Init()
3131
n.CaseBaseName = "ns-mp-" + n.UUIDgen
3232
n.BackupName = "backup-" + n.CaseBaseName
3333
n.RestoreName = "restore-" + n.CaseBaseName
@@ -128,7 +128,7 @@ func (n *NamespaceMapping) Clean() error {
128128
}
129129
}
130130

131-
return n.GetTestCase().Clean()
131+
return n.BRCase.Clean()
132132
}
133133

134134
return nil

Diff for: test/e2e/basic/nodeport.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import (
1111
"k8s.io/apimachinery/pkg/util/intstr"
1212

1313
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
14-
. "github.com/vmware-tanzu/velero/test/e2e/test"
14+
"github.com/vmware-tanzu/velero/test"
15+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
1516
. "github.com/vmware-tanzu/velero/test/util/k8s"
1617
. "github.com/vmware-tanzu/velero/test/util/velero"
1718
)
1819

1920
type NodePort struct {
20-
TestCase
21+
BRCase
2122
labels map[string]string
2223
serviceName string
2324
namespaceToCollision []string
@@ -29,7 +30,12 @@ const NodeportBaseName string = "nodeport-"
2930
var NodePortTest func() = TestFunc(&NodePort{})
3031

3132
func (n *NodePort) Init() error {
32-
n.TestCase.Init()
33+
n.BRCase.Init()
34+
35+
if n.VeleroCfg.CloudProvider == test.Azure || n.VeleroCfg.CloudProvider == test.AWS {
36+
Skip("Skip due to issue https://github.com/kubernetes/kubernetes/issues/114384 on AKS")
37+
}
38+
3339
n.CaseBaseName = NodeportBaseName + n.UUIDgen
3440
n.BackupName = "backup-" + n.CaseBaseName
3541
n.RestoreName = "restore-" + n.CaseBaseName
@@ -77,7 +83,7 @@ func (n *NodePort) CreateResources() error {
7783
return nil
7884
}
7985

80-
func (n *NodePort) Destroy() error {
86+
func (n *NodePort) DeleteResources() error {
8187
for i, ns := range *n.NSIncluded {
8288
By(fmt.Sprintf("Start to destroy namespace %s......", n.CaseBaseName), func() {
8389
Expect(CleanupNamespacesWithPoll(n.Ctx, n.Client, NodeportBaseName)).To(Succeed(),

Diff for: test/e2e/basic/pvc-selected-node-changing.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import (
99

1010
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
1111
. "github.com/vmware-tanzu/velero/test"
12-
. "github.com/vmware-tanzu/velero/test/e2e/test"
12+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
1313
. "github.com/vmware-tanzu/velero/test/util/k8s"
1414
. "github.com/vmware-tanzu/velero/test/util/velero"
1515
)
1616

1717
type PVCSelectedNodeChanging struct {
18-
TestCase
18+
BRCase
1919
labels map[string]string
2020
data map[string]string
2121
configmaptName string
@@ -32,7 +32,7 @@ type PVCSelectedNodeChanging struct {
3232
var PVCSelectedNodeChangingTest func() = TestFunc(&PVCSelectedNodeChanging{})
3333

3434
func (p *PVCSelectedNodeChanging) Init() error {
35-
p.TestCase.Init()
35+
p.BRCase.Init()
3636
p.CaseBaseName = "psnc-" + p.UUIDgen
3737
p.namespace = p.CaseBaseName
3838
p.mappedNS = p.namespace + "-mapped"
@@ -104,7 +104,7 @@ func (p *PVCSelectedNodeChanging) CreateResources() error {
104104
return nil
105105
}
106106

107-
func (p *PVCSelectedNodeChanging) Destroy() error {
107+
func (p *PVCSelectedNodeChanging) DeleteResources() error {
108108
By(fmt.Sprintf("Start to destroy namespace %s......", p.CaseBaseName), func() {
109109
Expect(CleanupNamespacesWithPoll(p.Ctx, p.Client, p.CaseBaseName)).To(Succeed(),
110110
fmt.Sprintf("Failed to delete namespace %s", p.CaseBaseName))
@@ -144,7 +144,7 @@ func (p *PVCSelectedNodeChanging) Clean() error {
144144
if CurrentSpecReport().Failed() && p.VeleroCfg.FailFast {
145145
fmt.Println("Test case failed and fail fast is enabled. Skip resource clean up.")
146146
} else {
147-
p.TestCase.Clean()
147+
p.BRCase.Clean()
148148
By(fmt.Sprintf("Clean namespace with prefix %s after test", p.mappedNS), func() {
149149
CleanupNamespaces(p.Ctx, p.Client, p.mappedNS)
150150
})

Diff for: test/e2e/basic/resources-check/namespaces.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ import (
2525
"github.com/pkg/errors"
2626
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727

28-
. "github.com/vmware-tanzu/velero/test/e2e/test"
28+
. "github.com/vmware-tanzu/velero/test/e2e/framework"
2929
. "github.com/vmware-tanzu/velero/test/util/k8s"
3030
)
3131

3232
type MultiNSBackup struct {
33-
TestCase
33+
BRCase
3434
IsScalTest bool
3535
NSExcluded *[]string
3636
TimeoutDuration time.Duration
3737
}
3838

3939
func (m *MultiNSBackup) Init() error {
40-
m.TestCase.Init()
40+
m.BRCase.Init()
4141
m.CaseBaseName = "nstest-" + m.UUIDgen
4242
m.BackupName = "backup-" + m.CaseBaseName
4343
m.RestoreName = "restore-" + m.CaseBaseName
@@ -111,7 +111,7 @@ func (m *MultiNSBackup) Verify() error {
111111
return nil
112112
}
113113

114-
func (m *MultiNSBackup) Destroy() error {
114+
func (m *MultiNSBackup) DeleteResources() error {
115115
err := CleanupNamespaces(m.Ctx, m.Client, m.CaseBaseName)
116116
if err != nil {
117117
return errors.Wrap(err, "Could cleanup retrieve namespaces")

0 commit comments

Comments
 (0)