2017-11-21 04:43:22 +00:00
|
|
|
/*
|
2018-04-13 01:21:59 +00:00
|
|
|
Copyright 2018 The Kubernetes Authors.
|
2017-11-21 04:43:22 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2019-03-02 18:53:44 +00:00
|
|
|
v1 "k8s.io/api/core/v1"
|
2018-08-28 13:27:41 +00:00
|
|
|
storagev1 "k8s.io/api/storage/v1"
|
2017-11-21 04:43:22 +00:00
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2018-11-07 15:42:58 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/storage/drivers"
|
2018-10-22 16:04:43 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/storage/testsuites"
|
2017-11-21 04:43:22 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/storage/utils"
|
2018-08-28 13:27:41 +00:00
|
|
|
|
2017-11-21 04:43:22 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
2018-03-09 18:57:50 +00:00
|
|
|
. "github.com/onsi/gomega"
|
2018-11-12 03:10:49 +00:00
|
|
|
"k8s.io/apimachinery/pkg/util/rand"
|
2017-11-21 04:43:22 +00:00
|
|
|
)
|
|
|
|
|
2018-11-07 15:42:58 +00:00
|
|
|
// List of testDrivers to be executed in below loop
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
var csiTestDrivers = []func() testsuites.TestDriver{
|
2018-11-07 15:42:58 +00:00
|
|
|
drivers.InitHostPathCSIDriver,
|
2019-03-02 18:53:44 +00:00
|
|
|
drivers.InitGcePDCSIDriver,
|
2018-11-07 15:42:58 +00:00
|
|
|
drivers.InitGcePDExternalCSIDriver,
|
2018-11-30 14:10:23 +00:00
|
|
|
drivers.InitHostPathV0CSIDriver,
|
2019-01-02 15:11:41 +00:00
|
|
|
// Don't run tests with mock driver (drivers.InitMockCSIDriver), it does not provide persistent storage.
|
2017-11-21 04:43:22 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 15:42:58 +00:00
|
|
|
// List of testSuites to be executed in below loop
|
|
|
|
var csiTestSuites = []func() testsuites.TestSuite{
|
|
|
|
testsuites.InitVolumesTestSuite,
|
|
|
|
testsuites.InitVolumeIOTestSuite,
|
|
|
|
testsuites.InitVolumeModeTestSuite,
|
|
|
|
testsuites.InitSubPathTestSuite,
|
|
|
|
testsuites.InitProvisioningTestSuite,
|
2019-01-13 10:15:59 +00:00
|
|
|
testsuites.InitSnapshottableTestSuite,
|
2019-02-28 01:31:37 +00:00
|
|
|
testsuites.InitMultiVolumeTestSuite,
|
2018-03-29 00:00:34 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 15:42:58 +00:00
|
|
|
// This executes testSuites for csi volumes.
|
2018-10-02 21:46:58 +00:00
|
|
|
var _ = utils.SIGDescribe("CSI Volumes", func() {
|
2018-11-07 15:42:58 +00:00
|
|
|
for _, initDriver := range csiTestDrivers {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
curDriver := initDriver()
|
2018-04-13 01:21:59 +00:00
|
|
|
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
Context(testsuites.GetDriverNameWithFeatureTags(curDriver), func() {
|
2019-02-13 19:46:49 +00:00
|
|
|
testsuites.DefineTestSuite(curDriver, csiTestSuites)
|
2017-11-21 04:43:22 +00:00
|
|
|
})
|
2018-04-13 01:21:59 +00:00
|
|
|
}
|
2018-08-28 13:27:41 +00:00
|
|
|
|
2019-03-06 23:11:50 +00:00
|
|
|
// TODO: PD CSI driver needs to be serial because it uses a fixed name. Address as part of #71289
|
|
|
|
Context("CSI Topology test using GCE PD driver [Serial]", func() {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
f := framework.NewDefaultFramework("csitopology")
|
2019-03-02 18:53:44 +00:00
|
|
|
driver := drivers.InitGcePDCSIDriver().(testsuites.DynamicPVTestDriver) // TODO (#71289) eliminate by moving this test to common test suite.
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
var (
|
|
|
|
config *testsuites.PerTestConfig
|
|
|
|
testCleanup func()
|
|
|
|
)
|
2018-11-12 03:10:49 +00:00
|
|
|
BeforeEach(func() {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
config, testCleanup = driver.PrepareTest(f)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
if testCleanup != nil {
|
|
|
|
testCleanup()
|
|
|
|
}
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should provision zonal PD with immediate volume binding and AllowedTopologies set and mount the volume to a pod", func() {
|
|
|
|
suffix := "topology-positive"
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
testTopologyPositive(config.Framework.ClientSet, suffix, config.Framework.Namespace.GetName(), false /* delayBinding */, true /* allowedTopologies */)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should provision zonal PD with delayed volume binding and mount the volume to a pod", func() {
|
|
|
|
suffix := "delayed"
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
testTopologyPositive(config.Framework.ClientSet, suffix, config.Framework.Namespace.GetName(), true /* delayBinding */, false /* allowedTopologies */)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should provision zonal PD with delayed volume binding and AllowedTopologies set and mount the volume to a pod", func() {
|
|
|
|
suffix := "delayed-topology-positive"
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
testTopologyPositive(config.Framework.ClientSet, suffix, config.Framework.Namespace.GetName(), true /* delayBinding */, true /* allowedTopologies */)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should fail to schedule a pod with a zone missing from AllowedTopologies; PD is provisioned with immediate volume binding", func() {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
framework.SkipUnlessMultizone(config.Framework.ClientSet)
|
2018-11-12 03:10:49 +00:00
|
|
|
suffix := "topology-negative"
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
testTopologyNegative(config.Framework.ClientSet, suffix, config.Framework.Namespace.GetName(), false /* delayBinding */)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should fail to schedule a pod with a zone missing from AllowedTopologies; PD is provisioned with delayed volume binding", func() {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
framework.SkipUnlessMultizone(config.Framework.ClientSet)
|
2018-11-12 03:10:49 +00:00
|
|
|
suffix := "delayed-topology-negative"
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
testTopologyNegative(config.Framework.ClientSet, suffix, config.Framework.Namespace.GetName(), true /* delayBinding */)
|
2018-11-12 03:10:49 +00:00
|
|
|
})
|
|
|
|
})
|
2018-04-13 01:21:59 +00:00
|
|
|
})
|
2017-11-21 04:43:22 +00:00
|
|
|
|
2018-11-12 03:10:49 +00:00
|
|
|
func testTopologyPositive(cs clientset.Interface, suffix, namespace string, delayBinding, allowedTopologies bool) {
|
|
|
|
test := createGCEPDStorageClassTest()
|
|
|
|
test.DelayBinding = delayBinding
|
|
|
|
|
|
|
|
class := newStorageClass(test, namespace, suffix)
|
|
|
|
if allowedTopologies {
|
|
|
|
topoZone := getRandomClusterZone(cs)
|
|
|
|
addSingleCSIZoneAllowedTopologyToStorageClass(cs, class, topoZone)
|
|
|
|
}
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
test.Client = cs
|
|
|
|
test.Claim = newClaim(test, namespace, suffix)
|
|
|
|
test.Claim.Spec.StorageClassName = &class.Name
|
|
|
|
test.Class = class
|
2018-11-12 03:10:49 +00:00
|
|
|
|
|
|
|
if delayBinding {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
_, node := test.TestBindingWaitForFirstConsumer(nil /* node selector */, false /* expect unschedulable */)
|
2018-11-12 03:10:49 +00:00
|
|
|
Expect(node).ToNot(BeNil(), "Unexpected nil node found")
|
|
|
|
} else {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
test.TestDynamicProvisioning()
|
2018-11-12 03:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testTopologyNegative(cs clientset.Interface, suffix, namespace string, delayBinding bool) {
|
|
|
|
framework.SkipUnlessMultizone(cs)
|
|
|
|
|
|
|
|
// Use different zones for pod and PV
|
|
|
|
zones, err := framework.GetClusterZones(cs)
|
2019-04-02 16:10:56 +00:00
|
|
|
framework.ExpectNoError(err)
|
2018-11-12 03:10:49 +00:00
|
|
|
Expect(zones.Len()).To(BeNumerically(">=", 2))
|
|
|
|
zonesList := zones.UnsortedList()
|
|
|
|
podZoneIndex := rand.Intn(zones.Len())
|
|
|
|
podZone := zonesList[podZoneIndex]
|
|
|
|
pvZone := zonesList[(podZoneIndex+1)%zones.Len()]
|
|
|
|
|
|
|
|
test := createGCEPDStorageClassTest()
|
|
|
|
test.DelayBinding = delayBinding
|
2019-01-16 11:26:38 +00:00
|
|
|
nodeSelector := map[string]string{v1.LabelZoneFailureDomain: podZone}
|
2018-11-12 03:10:49 +00:00
|
|
|
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
test.Client = cs
|
|
|
|
test.Class = newStorageClass(test, namespace, suffix)
|
|
|
|
addSingleCSIZoneAllowedTopologyToStorageClass(cs, test.Class, pvZone)
|
|
|
|
test.Claim = newClaim(test, namespace, suffix)
|
|
|
|
test.Claim.Spec.StorageClassName = &test.Class.Name
|
2018-11-12 03:10:49 +00:00
|
|
|
if delayBinding {
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
test.TestBindingWaitForFirstConsumer(nodeSelector, true /* expect unschedulable */)
|
2018-11-12 03:10:49 +00:00
|
|
|
} else {
|
2019-03-28 01:40:36 +00:00
|
|
|
test.PvCheck = func(claim *v1.PersistentVolumeClaim) {
|
2019-01-16 11:26:38 +00:00
|
|
|
// Ensure that a pod cannot be scheduled in an unsuitable zone.
|
|
|
|
pod := testsuites.StartInPodWithVolume(cs, namespace, claim.Name, "pvc-tester-unschedulable", "sleep 100000",
|
2019-02-28 01:31:37 +00:00
|
|
|
framework.NodeSelection{Selector: nodeSelector})
|
2019-01-16 11:26:38 +00:00
|
|
|
defer testsuites.StopPod(cs, pod)
|
|
|
|
framework.ExpectNoError(framework.WaitForPodNameUnschedulableInNamespace(cs, pod.Name, pod.Namespace), "pod should be unschedulable")
|
|
|
|
}
|
e2e/storage: speed up skipping, simplify APIs and test definition
CreateDriver (now called SetupTest) is a potentially expensive
operation, depending on the driver. Creating and tearing down a
framework instance also takes time (measured at 6 seconds on a fast
machine) and produces quite a bit of log output.
Both can be avoided for tests that skip based on static
information (like for instance the current OS, vendor, driver and test
pattern) by making the test suite responsible for creating framework
and driver.
The lifecycle of the TestConfig instance was confusing because it was
stored inside the DriverInfo, a struct which conceptually is static,
while the TestConfig is dynamic. It is cleaner to separate the two,
even if that means that an additional pointer must be passed into some
functions. Now CreateDriver is responsible for initializing the
PerTestConfig that is to be used by the test.
To make this approach simpler to implement (= less functions which
need the pointer) and the tests easier to read, the entire setup and
test definition is now contained in a single function. This is how it
is normally done in Ginkgo. This is easier to read because one can see
at a glance where variables are set, instead of having to trace values
though two additional structs (TestResource and TestInput).
Because we are changing the API already, also other changes are made:
- some function prototypes get simplified
- the naming of functions is changed to match their purpose
(tests aren't executed by the test suite, they only get defined
for later execution)
- unused methods get removed (TestSuite.skipUnsupportedTest is redundant)
2018-12-29 16:08:34 +00:00
|
|
|
test.TestDynamicProvisioning()
|
2018-11-12 03:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func addSingleCSIZoneAllowedTopologyToStorageClass(c clientset.Interface, sc *storagev1.StorageClass, zone string) {
|
|
|
|
term := v1.TopologySelectorTerm{
|
|
|
|
MatchLabelExpressions: []v1.TopologySelectorLabelRequirement{
|
|
|
|
{
|
|
|
|
Key: drivers.GCEPDCSIZoneTopologyKey,
|
|
|
|
Values: []string{zone},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
sc.AllowedTopologies = append(sc.AllowedTopologies, term)
|
|
|
|
}
|
|
|
|
|
|
|
|
func createGCEPDStorageClassTest() testsuites.StorageClassTest {
|
|
|
|
return testsuites.StorageClassTest{
|
|
|
|
Name: drivers.GCEPDCSIProvisionerName,
|
|
|
|
Provisioner: drivers.GCEPDCSIProvisionerName,
|
|
|
|
Parameters: map[string]string{"type": "pd-standard"},
|
|
|
|
ClaimSize: "5Gi",
|
|
|
|
ExpectedSize: "5Gi",
|
|
|
|
}
|
|
|
|
}
|