Skip to content

Commit

Permalink
pass project root to e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Mar 31, 2023
1 parent 6b795c6 commit f9638e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ e2e-test: install-ginkgo
if [ ! -z "$(EXTERNAL_E2E_TEST_BLOBFUSE)" ] || [ ! -z "$(EXTERNAL_E2E_TEST_BLOBFUSE_v2)" ] || [ ! -z "$(EXTERNAL_E2E_TEST_NFS)" ]; then \
bash ./test/external-e2e/run.sh;\
else \
ginkgo -p -vv --flake-attempts 2 --fail-fast ./test/e2e;\
ginkgo -p -vv --flake-attempts 2 --fail-fast ./test/e2e -- --project-root=$(shell pwd);\
fi

.PHONY: e2e-bootstrap
Expand Down
10 changes: 6 additions & 4 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,12 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
tsecret.Create()
defer tsecret.Cleanup()

bringKeyStorageClassParameters["csi.storage.k8s.io/provisioner-secret-name"] = secretName
bringKeyStorageClassParameters["csi.storage.k8s.io/node-stage-secret-name"] = secretName
bringKeyStorageClassParameters["csi.storage.k8s.io/provisioner-secret-namespace"] = ns.Name
bringKeyStorageClassParameters["csi.storage.k8s.io/node-stage-secret-namespace"] = ns.Name
var bringKeyStorageClassParameters = map[string]string{
"csi.storage.k8s.io/provisioner-secret-name": secretName,
"csi.storage.k8s.io/node-stage-secret-name": secretName,
"csi.storage.k8s.io/provisioner-secret-namespace": ns.Name,
"csi.storage.k8s.io/node-stage-secret-namespace": ns.Name,
}

pods := []testsuites.PodDetails{
{
Expand Down
36 changes: 18 additions & 18 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/onsi/ginkgo/v2/reporters"
"github.com/onsi/gomega"
"github.com/pborman/uuid"
"k8s.io/klog/v2"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework/config"
"sigs.k8s.io/blob-csi-driver/pkg/blob"
Expand All @@ -50,11 +51,7 @@ const (

var isAzureStackCloud = strings.EqualFold(os.Getenv("AZURE_CLOUD_NAME"), "AZURESTACKCLOUD")
var blobDriver *blob.Driver

var bringKeyStorageClassParameters = map[string]string{
"csi.storage.k8s.io/provisioner-secret-namespace": "default",
"csi.storage.k8s.io/node-stage-secret-namespace": "default",
}
var projectRoot string

type testCmd struct {
command string
Expand All @@ -65,7 +62,7 @@ type testCmd struct {

func TestMain(m *testing.M) {
handleFlags()
framework.AfterReadingAllFlags(&framework.TestContext)

os.Exit(m.Run())
}

Expand Down Expand Up @@ -201,24 +198,13 @@ func execTestCmd(cmds []testCmd) {
// This allows you to build reusable test helpers and trust that the location presented to the user will always be in the spec that called the helper, and not the helper itself.
ginkgo.GinkgoHelper()

err := os.Chdir("../..")
gomega.Expect(err).NotTo(gomega.HaveOccurred())
defer func() {
err := os.Chdir("test/e2e")
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}()

projectRoot, err := os.Getwd()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(strings.HasSuffix(projectRoot, "blob-csi-driver")).To(gomega.Equal(true))

for _, cmd := range cmds {
log.Println(cmd.startLog)
cmdSh := exec.Command(cmd.command, cmd.args...)
cmdSh.Dir = projectRoot
cmdSh.Stdout = os.Stdout
cmdSh.Stderr = os.Stderr
err = cmdSh.Run()
err := cmdSh.Run()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
log.Println(cmd.endLog)
}
Expand All @@ -240,8 +226,22 @@ func checkAccountCreationLeak() {

// handleFlags sets up all flags and parses the command line.
func handleFlags() {
registerFlags()
handleFramworkFlags()
}

func registerFlags() {
flag.StringVar(&projectRoot, "project-root", "", "path to the blob csi driver project root, used for script execution")
flag.Parse()
if projectRoot == "" {
klog.Fatal("project-root must be set")
}
}

func handleFramworkFlags() {
config.CopyFlags(config.Flags, flag.CommandLine)
framework.RegisterCommonFlags(flag.CommandLine)
framework.RegisterClusterFlags(flag.CommandLine)
flag.Parse()
framework.AfterReadingAllFlags(&framework.TestContext)
}

0 comments on commit f9638e2

Please sign in to comment.