From b319406c8f51aeace4b652299cc4c72ba717b5c5 Mon Sep 17 00:00:00 2001 From: weizhichen Date: Wed, 29 Mar 2023 08:33:25 +0000 Subject: [PATCH] fix BeforeSuite and AfterSuite --- test/e2e/suite_test.go | 80 ++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index fd574f4e3..ae5aea38d 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -61,7 +61,7 @@ type testCmd struct { endLog string } -var _ = ginkgo.BeforeSuite(func() { +var _ = ginkgo.SynchronizedBeforeSuite(func() { // k8s.io/kubernetes/test/e2e/framework requires env KUBECONFIG to be set // it does not fall back to defaults if os.Getenv(kubeconfigEnvVar) == "" { @@ -106,7 +106,7 @@ var _ = ginkgo.BeforeSuite(func() { endLog: "metrics service created", } execTestCmd([]testCmd{e2eBootstrap, createMetricsSVC}) - +}, func() { kubeconfig := os.Getenv(kubeconfigEnvVar) _, useBlobfuseProxy := os.LookupEnv("ENABLE_BLOBFUSE_PROXY") driverOptions := blob.DriverOptions{ @@ -117,6 +117,7 @@ var _ = ginkgo.BeforeSuite(func() { BlobfuseProxyConnTimout: 5, EnableBlobMockMount: false, } + blobDriver = blob.NewDriver(&driverOptions) go func() { os.Setenv("AZURE_CREDENTIAL_FILE", credentials.TempAzureCredentialFilePath) @@ -124,43 +125,44 @@ var _ = ginkgo.BeforeSuite(func() { }() }) -var _ = ginkgo.AfterSuite(func() { - createExampleDeployment := testCmd{ - command: "bash", - args: []string{"hack/verify-examples.sh"}, - startLog: "create example deployments", - endLog: "example deployments created", - } - execTestCmd([]testCmd{createExampleDeployment}) - - e2eTeardown := testCmd{ - command: "make", - args: []string{"e2e-teardown"}, - startLog: "Uninstalling Azure Blob Storage CSI driver...", - endLog: "Azure Blob Storage CSI driver uninstalled", - } - execTestCmd([]testCmd{e2eTeardown}) - - // install/uninstall CSI Driver deployment scripts test - installDriver := testCmd{ - command: "bash", - args: []string{"deploy/install-driver.sh", "master", "local,enable-blobfuse-proxy"}, - startLog: "===================install CSI Driver deployment scripts test===================", - endLog: "===================================================", - } - uninstallDriver := testCmd{ - command: "bash", - args: []string{"deploy/uninstall-driver.sh", "master", "local,enable-blobfuse-proxy"}, - startLog: "===================uninstall CSI Driver deployment scripts test===================", - endLog: "===================================================", - } - execTestCmd([]testCmd{installDriver, uninstallDriver}) - - checkAccountCreationLeak() - - err := credentials.DeleteAzureCredentialFile() - gomega.Expect(err).NotTo(gomega.HaveOccurred()) -}) +var _ = ginkgo.SynchronizedAfterSuite(func() {}, + func() { + createExampleDeployment := testCmd{ + command: "bash", + args: []string{"hack/verify-examples.sh"}, + startLog: "create example deployments", + endLog: "example deployments created", + } + execTestCmd([]testCmd{createExampleDeployment}) + + e2eTeardown := testCmd{ + command: "make", + args: []string{"e2e-teardown"}, + startLog: "Uninstalling Azure Blob Storage CSI driver...", + endLog: "Azure Blob Storage CSI driver uninstalled", + } + execTestCmd([]testCmd{e2eTeardown}) + + // install/uninstall CSI Driver deployment scripts test + installDriver := testCmd{ + command: "bash", + args: []string{"deploy/install-driver.sh", "master", "local,enable-blobfuse-proxy"}, + startLog: "===================install CSI Driver deployment scripts test===================", + endLog: "===================================================", + } + uninstallDriver := testCmd{ + command: "bash", + args: []string{"deploy/uninstall-driver.sh", "master", "local,enable-blobfuse-proxy"}, + startLog: "===================uninstall CSI Driver deployment scripts test===================", + endLog: "===================================================", + } + execTestCmd([]testCmd{installDriver, uninstallDriver}) + + checkAccountCreationLeak() + + err := credentials.DeleteAzureCredentialFile() + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + }) func TestE2E(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail)