Skip to content

Commit 887ddcb

Browse files
authored
Merge pull request #256 from davidz627/feature/featureGates
Add feature gate setting & required test focus flag to integration tests
2 parents 1d8de6e + fc073c4 commit 887ddcb

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

test/k8s-integration/main.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ var (
4343
doDriverBuild = flag.Bool("do-driver-build", true, "building the driver from source")
4444
boskosResourceType = flag.String("boskos-resource-type", "gce-project", "name of the boskos resource type to reserve")
4545
storageClassFile = flag.String("storageclass-file", "", "name of storageclass yaml file to use for test relative to test/k8s-integration/config")
46+
kubeFeatureGates = flag.String("kube-feature-gates", "", "feature gates to set on new kubernetes cluster")
47+
testFocus = flag.String("test-focus", "", "test focus for Kubernetes e2e")
4648
)
4749

4850
const (
@@ -72,6 +74,14 @@ func main() {
7274
glog.Fatalf("storageclass-file is a required flag")
7375
}
7476

77+
if !*bringupCluster && len(*kubeFeatureGates) > 0 {
78+
glog.Fatalf("kube-feature-gates set but not bringing up new cluster")
79+
}
80+
81+
if len(*testFocus) == 0 {
82+
glog.Fatalf("test-focus is a required flag")
83+
}
84+
7585
err := handle()
7686
if err != nil {
7787
glog.Fatalf("Failed to run integration test: %v", err)
@@ -161,6 +171,14 @@ func handle() error {
161171
glog.Errorf("could not find cluster kubectl at %s, falling back to default kubectl", kshPath)
162172
}
163173

174+
if len(*kubeFeatureGates) != 0 {
175+
err = os.Setenv("KUBE_FEATURE_GATES", *kubeFeatureGates)
176+
if err != nil {
177+
return fmt.Errorf("failed to set kubernetes feature gates: %v", err)
178+
}
179+
glog.V(4).Infof("Set Kubernetes feature gates: %v", *kubeFeatureGates)
180+
}
181+
164182
err = clusterUp(k8sDir)
165183
if err != nil {
166184
return fmt.Errorf("failed to cluster up: %v", err)
@@ -192,7 +210,7 @@ func handle() error {
192210
if len(*localK8sDir) != 0 {
193211
k8sDir = *localK8sDir
194212
}
195-
err = runTests(pkgDir, k8sDir, *storageClassFile)
213+
err = runTests(pkgDir, k8sDir, *storageClassFile, *testFocus)
196214
if err != nil {
197215
return fmt.Errorf("failed to run tests: %v", err)
198216
}
@@ -213,7 +231,7 @@ func setEnvProject(project string) error {
213231
return nil
214232
}
215233

216-
func runTests(pkgDir, k8sDir, storageClassFile string) error {
234+
func runTests(pkgDir, k8sDir, storageClassFile, testFocus string) error {
217235
testDriverConfigFile, err := generateDriverConfigFile(pkgDir, storageClassFile)
218236
if err != nil {
219237
return err
@@ -231,10 +249,11 @@ func runTests(pkgDir, k8sDir, storageClassFile string) error {
231249
reportArg := fmt.Sprintf("-report-dir=%s", artifactsDir)
232250

233251
driverConfigArg := fmt.Sprintf("-storage.testdriver=%s", testDriverConfigFile)
252+
testFocusArg := fmt.Sprintf("-focus=%s", testFocus)
234253

235254
cmd := exec.Command(filepath.Join(k8sBuildBinDir, "ginkgo"),
236255
"-p",
237-
"-focus=External.Storage",
256+
testFocusArg,
238257
"-skip=\\[Disruptive\\]|\\[Serial\\]|\\[Feature:.+\\]",
239258
filepath.Join(k8sBuildBinDir, "e2e.test"),
240259
"--",

test/run-k8s-integration-local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ensure_var GCE_PD_CSI_STAGING_IMAGE
1010
ensure_var GCE_PD_SA_DIR
1111

1212
make -C ${PKGDIR} test-k8s-integration
13-
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false --staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json --deploy-overlay-name=dev --storageclass-file=sc-standard.yaml
13+
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=false --staging-image=${GCE_PD_CSI_STAGING_IMAGE} --service-account-file=${GCE_PD_SA_DIR}/cloud-sa.json --deploy-overlay-name=dev --storageclass-file=sc-standard.yaml --test-focus="External.Storage"
1414

1515
# This version of the command does not build the driver or K8s, points to a
1616
# local K8s repo to get the e2e.test binary, and does not bring up or down the cluster

test/run-k8s-integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ readonly do_driver_build="${GCE_PD_DO_DRIVER_BUILD:-true}"
1616
export GCE_PD_VERBOSITY=9
1717

1818
make -C ${PKGDIR} test-k8s-integration
19-
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=true --deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} --do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} --storageclass-file=sc-standard.yaml
19+
${PKGDIR}/bin/k8s-integration-test --kube-version=master --run-in-prow=true --deploy-overlay-name=${overlay_name} --service-account-file=${E2E_GOOGLE_APPLICATION_CREDENTIALS} --do-driver-build=${do_driver_build} --boskos-resource-type=${boskos_resource_type} --storageclass-file=sc-standard.yaml --test-focus="External.Storage"

0 commit comments

Comments
 (0)