Skip to content

Commit

Permalink
fix BeforeSuite and AfterSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Mar 29, 2023
1 parent 1496638 commit b319406
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) == "" {
Expand Down Expand Up @@ -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{
Expand All @@ -117,50 +117,52 @@ var _ = ginkgo.BeforeSuite(func() {
BlobfuseProxyConnTimout: 5,
EnableBlobMockMount: false,
}

blobDriver = blob.NewDriver(&driverOptions)
go func() {
os.Setenv("AZURE_CREDENTIAL_FILE", credentials.TempAzureCredentialFilePath)
blobDriver.Run(fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String()), kubeconfig, false)
}()
})

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)
Expand Down

0 comments on commit b319406

Please sign in to comment.