Fix E2E backup namespaces test

Signed-off-by: Ming <mqiu@vmware.com>
This commit is contained in:
Ming
2022-02-14 10:12:45 +08:00
parent 0270b96a5f
commit 6a61a418ca
3 changed files with 25 additions and 14 deletions

View File

@@ -48,17 +48,6 @@ func (m *MultiNSBackup) Init() error {
m.Client = TestClientInstance
m.NSExcluded = &[]string{}
// Currently it's hard to build a large list of namespaces to include and wildcards do not work so instead
// we will exclude all of the namespaces that existed prior to the test from the backup
namespaces, err := m.Client.ClientGo.CoreV1().Namespaces().List(context.Background(), v1.ListOptions{})
if err != nil {
return errors.Wrap(err, "Could not retrieve namespaces")
}
for _, excludeNamespace := range namespaces.Items {
*m.NSExcluded = append(*m.NSExcluded, excludeNamespace.Name)
}
if m.IsScalTest {
m.NamespacesTotal = 2500
m.TimeoutDuration = time.Hour * 2
@@ -74,6 +63,20 @@ func (m *MultiNSBackup) Init() error {
FailedMSG: "Failed to successfully backup and restore multiple namespaces",
}
}
return nil
}
func (m *MultiNSBackup) StartRun() error {
// Currently it's hard to build a large list of namespaces to include and wildcards do not work so instead
// we will exclude all of the namespaces that existed prior to the test from the backup
namespaces, err := m.Client.ClientGo.CoreV1().Namespaces().List(context.Background(), v1.ListOptions{})
if err != nil {
return errors.Wrap(err, "Could not retrieve namespaces")
}
for _, excludeNamespace := range namespaces.Items {
*m.NSExcluded = append(*m.NSExcluded, excludeNamespace.Name)
}
m.BackupArgs = []string{
"create", "--namespace", VeleroCfg.VeleroNamespace, "backup", m.BackupName,
@@ -85,7 +88,6 @@ func (m *MultiNSBackup) Init() error {
"create", "--namespace", VeleroCfg.VeleroNamespace, "restore", m.RestoreName,
"--from-backup", m.BackupName, "--wait",
}
return nil
}

View File

@@ -39,6 +39,7 @@ depends on your test patterns.
*/
type VeleroBackupRestoreTest interface {
Init() error
StartRun() error
CreateResources() error
Backup() error
Destroy() error
@@ -137,6 +138,10 @@ func (t *TestCase) CreateResources() error {
return nil
}
func (t *TestCase) StartRun() error {
return nil
}
func (t *TestCase) Backup() error {
if err := VeleroCmdExec(t.Ctx, VeleroCfg.VeleroCLI, t.BackupArgs); err != nil {
RunDebug(context.Background(), VeleroCfg.VeleroCLI, VeleroCfg.VeleroNamespace, t.BackupName, "")
@@ -180,8 +185,11 @@ func RunTestCase(test VeleroBackupRestoreTest) error {
}
defer test.Clean()
err := test.CreateResources()
err := test.StartRun()
if err != nil {
return err
}
err = test.CreateResources()
if err != nil {
return err
}