tests: allow integration tests in minimal config to run on multiple versions
When the tests run in a PR, they can only run against a single version of K8s by default. If more than five k8s versions are supported in hte CI, we will need to run some of the suites on multiple versions. The versions are comma-separated in the list. Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
This commit is contained in:
2 files changed
+18
-6
No files matched your search
@@ -101,10 +101,11 @@ func (k8sh *K8sHelper) VersionAtLeast(minVersion string) bool {
|
||||
return v.AtLeast(version.MustParseSemantic(minVersion))
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) VersionMinorMatches(minVersion string) bool {
|
||||
v := version.MustParseSemantic(k8sh.GetK8sServerVersion())
|
||||
func (k8sh *K8sHelper) VersionMinorMatches(minVersion string) (string, bool) {
|
||||
kubeVersion := k8sh.GetK8sServerVersion()
|
||||
v := version.MustParseSemantic(kubeVersion)
|
||||
requestedVersion := version.MustParseSemantic(minVersion)
|
||||
return v.Major() == requestedVersion.Major() && v.Minor() == requestedVersion.Minor()
|
||||
return kubeVersion, v.Major() == requestedVersion.Major() && v.Minor() == requestedVersion.Minor()
|
||||
}
|
||||
|
||||
func (k8sh *K8sHelper) MakeContext() *clusterd.Context {
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
// UPDATE these versions when the integration test matrix changes
|
||||
// These versions are for running a minimal test suite for more efficient tests across different versions of K8s
|
||||
// instead of running all suites on all versions
|
||||
// To run on multiple versions, add a comma separate list such as 1.16.0,1.17.0
|
||||
blockMinimalTestVersion = "1.13.0"
|
||||
multiClusterMinimalTestVersion = "1.14.0"
|
||||
helmMinimalTestVersion = "1.15.0"
|
||||
@@ -113,11 +114,21 @@ func checkIfShouldRunForMinimalTestMatrix(t func() *testing.T, k8sh *utils.K8sHe
|
||||
logger.Infof("running all tests")
|
||||
return
|
||||
}
|
||||
if !k8sh.VersionMinorMatches(version) {
|
||||
logger.Infof("Skipping test suite since kube version is not minor version %s", version)
|
||||
versions := strings.Split(version, ",")
|
||||
logger.Infof("checking if tests are running on k8s %q", version)
|
||||
matchedVersion := false
|
||||
kubeVersion := ""
|
||||
for _, v := range versions {
|
||||
kubeVersion, matchedVersion = k8sh.VersionMinorMatches(v)
|
||||
if matchedVersion {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !matchedVersion {
|
||||
logger.Infof("Skipping test suite since kube version %q does not match", kubeVersion)
|
||||
t().Skip()
|
||||
}
|
||||
logger.Infof("Running test suite since kube version is minor version %s", version)
|
||||
logger.Infof("Running test suite since kube version is %q", kubeVersion)
|
||||
}
|
||||
|
||||
// StartTestCluster creates new instance of TestCluster struct
|
||||
|
||||
Reference in new issue
Block a user