-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add E2E test for antrea multiclusters
- Loading branch information
Showing
12 changed files
with
985 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package e2e | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func createDirectory(path string) error { | ||
return os.Mkdir(path, 0700) | ||
} | ||
|
||
func (data *TestData) setupLogDirectoryForTest(testName string) error { | ||
path := filepath.Join(testOptions.logsExportDir, testName) | ||
// remove directory if it already exists. This ensures that we start with an empty | ||
// directory | ||
_ = os.RemoveAll(path) | ||
err := createDirectory(path) | ||
if err != nil { | ||
return err | ||
} | ||
data.logsDirForTestCase = path | ||
return nil | ||
} | ||
|
||
func setupTest(tb testing.TB) (*TestData, error) { | ||
if err := testData.setupLogDirectoryForTest(tb.Name()); err != nil { | ||
tb.Errorf("Error creating logs directory '%s': %v", testData.logsDirForTestCase, err) | ||
return nil, err | ||
} | ||
success := false | ||
defer func() { | ||
if !success { | ||
tb.Fail() | ||
} | ||
}() | ||
tb.Logf("Creating '%s' K8s Namespace", multiClusterTestNamespace) | ||
if err := testData.createTestNamespace(); err != nil { | ||
return nil, err | ||
} | ||
|
||
success = true | ||
return testData, nil | ||
} | ||
|
||
func teardownTest(tb testing.TB, data *TestData) { | ||
if empty, _ := IsDirEmpty(data.logsDirForTestCase); empty { | ||
_ = os.Remove(data.logsDirForTestCase) | ||
} | ||
} | ||
|
||
func deletePodWrapper(tb testing.TB, data *TestData, clusterName string, namespace string, name string) { | ||
tb.Logf("Deleting Pod '%s'", name) | ||
if err := data.deletePod(clusterName, namespace, name); err != nil { | ||
tb.Logf("Error when deleting Pod: %v", err) | ||
} | ||
} | ||
|
||
func deleteServiceWrapper(tb testing.TB, data *TestData, clusterName string, namespace string, name string) { | ||
tb.Logf("Deleting Service '%s'", name) | ||
if err := data.deleteService(clusterName, namespace, name); err != nil { | ||
tb.Logf("Error when deleting Service: %v", err) | ||
} | ||
} |
Oops, something went wrong.