Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share test functions between e2e and multicluster e2e package #3424

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions multicluster/test/e2e/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Antrea Authors
// Copyright 2022 Antrea Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -26,7 +26,7 @@ func createDirectory(path string) error {
return os.Mkdir(path, 0700)
}

func (data *TestData) setupLogDirectoryForTest(testName string) error {
func (data *MCTestData) 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
Expand All @@ -39,7 +39,7 @@ func (data *TestData) setupLogDirectoryForTest(testName string) error {
return nil
}

func setupTest(tb testing.TB) (*TestData, error) {
func setupTest(tb testing.TB) (*MCTestData, error) {
if err := testData.setupLogDirectoryForTest(tb.Name()); err != nil {
tb.Errorf("Error creating logs directory '%s': %v", testData.logsDirForTestCase, err)
return nil, err
Expand All @@ -51,21 +51,21 @@ func setupTest(tb testing.TB) (*TestData, error) {
}
}()
tb.Logf("Creating '%s' K8s Namespace", multiClusterTestNamespace)
if err := testData.createTestNamespace(); err != nil {
if err := testData.createTestNamespaces(); err != nil {
return nil, err
}

success = true
return testData, nil
}

func teardownTest(tb testing.TB, data *TestData) {
func teardownTest(tb testing.TB, data *MCTestData) {
if empty, _ := IsDirEmpty(data.logsDirForTestCase); empty {
_ = os.Remove(data.logsDirForTestCase)
}
}

func createPodWrapper(tb testing.TB, data *TestData, cluster string, namespace string, name string, image string, ctr string, command []string,
func createPodWrapper(tb testing.TB, data *MCTestData, cluster string, namespace string, name string, image string, ctr string, command []string,
args []string, env []corev1.EnvVar, ports []corev1.ContainerPort, hostNetwork bool, mutateFunc func(pod *corev1.Pod)) error {
tb.Logf("Creating Pod '%s'", name)
if err := data.createPod(cluster, name, namespace, ctr, image, command, args, env, ports, hostNetwork, mutateFunc); err != nil {
Expand All @@ -79,14 +79,14 @@ func createPodWrapper(tb testing.TB, data *TestData, cluster string, namespace s
return err
}

func deletePodWrapper(tb testing.TB, data *TestData, clusterName string, namespace string, name string) {
func deletePodWrapper(tb testing.TB, data *MCTestData, 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) {
func deleteServiceWrapper(tb testing.TB, data *MCTestData, 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)
Expand Down
Loading