Skip to content

Commit

Permalink
test: allow running functional tests for different k8s versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer committed Apr 3, 2024
1 parent 86f5c14 commit 9279e98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
20 changes: 19 additions & 1 deletion test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (

"k8s.io/minikube/pkg/drivers/kic/oci"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/detect"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/reason"
Expand Down Expand Up @@ -70,9 +71,27 @@ var mitm *StartSession

var runCorpProxy = detect.GithubActionRunner() && runtime.GOOS == "linux" && !arm64Platform()

// k8s version string for functional test.
// When this variable is set, minikube will be started with the specified version for functional test
var k8sVersionString = ""

// TestFunctional are functionality tests which can safely share a profile in parallel
func TestFunctional(t *testing.T) {
testFunctional(t)
}

// TestFunctionalNewestKuberentes are functionality run functional tests using NewestKubernetesVersion
func TestFunctionalNewestKuberentes(t *testing.T) {
if strings.Contains(*startArgs, "--kubernetes-version") {
t.Skip()
}
k8sVersionString = constants.NewestKubernetesVersion
t.Run("Version"+k8sVersionString, func(t *testing.T) {
testFunctional(t)
})
}

func testFunctional(t *testing.T) {
profile := UniqueProfileName("functional")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(40))
defer func() {
Expand All @@ -86,7 +105,6 @@ func TestFunctional(t *testing.T) {

Cleanup(t, profile, cancel)
}()

// Serial tests
t.Run("serial", func(t *testing.T) {
tests := []struct {
Expand Down
6 changes: 5 additions & 1 deletion test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ func setMaxParallelism() {

// StartArgs returns the arguments normally used for starting minikube
func StartArgs() []string {
return strings.Split(*startArgs, " ")
res := strings.Split(*startArgs, " ")
if k8sVersionString != "" {
res = append(res, fmt.Sprintf("--kubernetes-version=%s", k8sVersionString))
}
return res
}

// Target returns where the minikube binary can be found
Expand Down

0 comments on commit 9279e98

Please sign in to comment.