Skip to content

Commit c453a40

Browse files
Update suit_test.go
Signed-off-by: Dharmendra solanki <[email protected]>
1 parent 002be06 commit c453a40

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ VERSION ?= 0.0.1
88
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
99
BIN_DIR := $(PROJECT_DIR)/bin
1010

11-
ENVTEST_K8S_VERSION = 1.29.3
11+
ENVTEST_K8S_VERSION ?= 1.29.3
1212
# CHANNELS define the bundle channels used in the bundle.
1313
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
1414
# To re-generate a bundle for other specific channels without changing the standard setup, you can:
@@ -116,8 +116,8 @@ tidy: ## Run go mod tidy against code.
116116
go mod tidy
117117

118118
.PHONY: test
119-
test: manifests generate fmt vet ## Run tests.
120-
go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic
119+
test: test-env manifests generate fmt vet ## Run tests.
120+
ENVTEST_K8S_VERSION=$(ENVTEST_K8S_VERSION) go test --short ./... -race -coverprofile=coverage.txt -covermode=atomic
121121

122122
##@ Build
123123

controllers/suit_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ package controllers
1919
import (
2020
"os"
2121
"path/filepath"
22+
"runtime"
2223
"testing"
2324
"time"
2425

2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
2728
apiv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
28-
runtime "k8s.io/apimachinery/pkg/runtime"
29+
k8sruntime "k8s.io/apimachinery/pkg/runtime"
2930
types "k8s.io/apimachinery/pkg/types"
3031
"k8s.io/client-go/kubernetes"
3132
k8sscheme "k8s.io/client-go/kubernetes/scheme"
@@ -59,6 +60,12 @@ var _ = BeforeSuite(func(ctx SpecContext) {
5960

6061
By("bootstrapping test environment")
6162
timeout := 2 * time.Minute
63+
// Get K8s version from environment variable, default to 1.29.3
64+
k8sVersion := os.Getenv("ENVTEST_K8S_VERSION")
65+
if k8sVersion == "" {
66+
k8sVersion = "1.29.3"
67+
}
68+
binaryAssetsDir := filepath.Join("..", "bin", "k8s", k8sVersion+"-"+runtime.GOOS+"-"+runtime.GOARCH)
6269
testEnv = &envtest.Environment{
6370
ErrorIfCRDPathMissing: true,
6471
CRDDirectoryPaths: []string{
@@ -67,7 +74,7 @@ var _ = BeforeSuite(func(ctx SpecContext) {
6774
ControlPlaneStartTimeout: timeout,
6875
ControlPlaneStopTimeout: timeout,
6976
AttachControlPlaneOutput: false,
70-
BinaryAssetsDirectory: filepath.Join("..", "bin", "k8s", "1.30.0-linux-amd64"),
77+
BinaryAssetsDirectory: binaryAssetsDir,
7178
}
7279

7380
var cfg *rest.Config
@@ -82,7 +89,7 @@ var _ = BeforeSuite(func(ctx SpecContext) {
8289
Expect(err).NotTo(HaveOccurred())
8390
Expect(cfg).NotTo(BeNil())
8491

85-
scheme := runtime.NewScheme()
92+
scheme := k8sruntime.NewScheme()
8693

8794
Expect(mesheryv1alpha1.AddToScheme(scheme)).To(Succeed())
8895
Expect(k8sscheme.AddToScheme(scheme)).To(Succeed())

pkg/broker/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ACSU3Q6LTLBVLGAQUONAGXJHVNWGSKKAUA7IY5TB4Z7PLEKSR5O6JTGR: eyJ0eXAiOiJqd3QiLCJhbG
171171
Containers: []corev1.Container{
172172
{
173173
Name: "nats",
174-
Image: "nats:2.8.2-alpine3.15",
174+
Image: "nats:2.10.29-alpine3.22",
175175
ImagePullPolicy: corev1.PullIfNotPresent,
176176
Ports: []corev1.ContainerPort{
177177
{

pkg/broker/suit_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ package broker
1919
import (
2020
"os"
2121
"path/filepath"
22+
"runtime"
2223
"testing"
2324
"time"
2425

2526
. "github.com/onsi/ginkgo/v2"
2627
. "github.com/onsi/gomega"
2728
apiv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
28-
runtime "k8s.io/apimachinery/pkg/runtime"
29+
k8sruntime "k8s.io/apimachinery/pkg/runtime"
2930
types "k8s.io/apimachinery/pkg/types"
3031
"k8s.io/client-go/kubernetes"
3132
k8sscheme "k8s.io/client-go/kubernetes/scheme"
@@ -55,6 +56,12 @@ var _ = BeforeSuite(func(ctx SpecContext) {
5556

5657
By("bootstrapping test environment")
5758
timeout := 3 * time.Minute
59+
// Get K8s version from environment variable, default to 1.29.3
60+
k8sVersion := os.Getenv("ENVTEST_K8S_VERSION")
61+
if k8sVersion == "" {
62+
k8sVersion = "1.29.3"
63+
}
64+
binaryAssetsDir := filepath.Join("..", "..", "bin", "k8s", k8sVersion+"-"+runtime.GOOS+"-"+runtime.GOARCH)
5865
testEnv = &envtest.Environment{
5966
ErrorIfCRDPathMissing: true,
6067
CRDDirectoryPaths: []string{
@@ -63,7 +70,7 @@ var _ = BeforeSuite(func(ctx SpecContext) {
6370
ControlPlaneStartTimeout: timeout,
6471
ControlPlaneStopTimeout: timeout,
6572
AttachControlPlaneOutput: false,
66-
BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", "1.24.2-linux-amd64"),
73+
BinaryAssetsDirectory: binaryAssetsDir,
6774
}
6875

6976
var cfg *rest.Config
@@ -78,7 +85,7 @@ var _ = BeforeSuite(func(ctx SpecContext) {
7885
Expect(err).NotTo(HaveOccurred())
7986
Expect(cfg).NotTo(BeNil())
8087

81-
scheme := runtime.NewScheme()
88+
scheme := k8sruntime.NewScheme()
8289

8390
Expect(mesheryv1alpha1.AddToScheme(scheme)).To(Succeed())
8491
Expect(k8sscheme.AddToScheme(scheme)).To(Succeed())

0 commit comments

Comments
 (0)