Skip to content

Commit 540a208

Browse files
committed
chore: minor cleanup tasks
1 parent 3c8feb8 commit 540a208

File tree

8 files changed

+34
-27
lines changed

8 files changed

+34
-27
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- "**.go"
3131
- "!**_test.go" # exclude test files to ignore unit test changes
3232
- "test/**" # include test files in e2e again
33-
- "e2e-next/**" #include e2e-next tests
33+
- "!e2e-next/**" # exclude e2e-next tests
3434
- "!**.md"
3535
- "Dockerfile.release"
3636
- ".github/workflows/e2e.yaml"

e2e-next/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,32 @@
66
4. If you created a new folder, make sure to add the import in `e2e_suite_test.go`.
77

88
### Preparations
9-
* Install [vcluster cli](https://www.vcluster.com/docs/vcluster)
10-
* Install ginkgo cli via `go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4`
9+
* Install ginkgo cli via `go install github.com/onsi/ginkgo/v2/ginkgo`
1110
* Install [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
1211
```
1312
13+
### Setup an environment for manual testing
14+
If you only want an environment that matches a test, you can create the environment without running the tests:
15+
1. Run `just build-snapshot`
16+
2. Run `just build-cli-snapshot`
17+
3. Run `just setup [LABEL]`
18+
4. Perform any manual testing using the deployed virtual cluster environment
19+
1420
### Develop a test
1521
If you want to iterate over a test, you can do:
1622
1. Run `just build-snapshot`
17-
2. Run `just setup [LABEL]` and it will do the following:
18-
* Create a kind cluster
19-
* Load vcluster image into kind cluster
20-
21-
Then iterate via:
22-
1. Run `just iterate-e2e [LABEL]`
23-
2. Change things, then rerun above command
23+
2. Run `just build-cli-snapshot`
24+
3. Run `just iterate-e2e [LABEL]`
25+
4. Rerun step 1 if you modify the vCluster code
26+
5. Rerun step 2 if you modify the vCluster CLI code
27+
6. Rerun step 2 as you modify the tests
2428
2529
### Run a test
2630
If you just want to run a test, you can do:
2731
1. Run `just build-snapshot`
28-
2. Run `just iterate-e2e [LABEL]`
32+
2. Run `just build-cli-snapshot`
33+
3. Run `just iterate-e2e [LABEL]`
2934
3035
### Destroy the kind cluster
31-
If you want to cleanup the state, you can do:
32-
1. Run `just teardown my-feature`
36+
If you want to cleanup test environment you can do:
37+
1. Run `just teardown [LABEL]`

e2e-next/clusters/clusters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
providervcluster.WithPath(filepath.Join(os.Getenv("GOBIN"), "vcluster")),
3737
providervcluster.WithLocalChartDir("../chart"),
3838
providervcluster.WithUpgrade(true),
39-
providervcluster.WithBackgroundProxyImage(constants.GetVclusterImage()),
39+
providervcluster.WithBackgroundProxyImage(constants.GetVClusterImage()),
4040
}
4141
)
4242
var (

e2e-next/constants/cluster.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package constants
22

3+
import "os"
4+
35
var hostCluster string
46

57
func GetHostClusterName() string {
68
if hostCluster == "" {
9+
if kindName, ok := os.LookupEnv("KIND_NAME"); ok && kindName != "" {
10+
return kindName
11+
}
12+
713
return "kind-cluster"
814
}
915
return hostCluster

e2e-next/constants/image.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var (
99
tag string
1010
)
1111

12-
func GetVclusterImage() string {
12+
func GetVClusterImage() string {
1313
if repository == "" && tag == "" {
1414
return "ghcr.io/loft-sh/vcluster:dev-next"
1515
}
@@ -33,7 +33,7 @@ func GetTag() string {
3333
return tag
3434
}
3535

36-
func SetVclusterImage(image string) {
36+
func SetVClusterImage(image string) {
3737
if strings.Contains(image, "@") {
3838
// Handle digest format: repo@sha256:xxx
3939
parts := strings.SplitN(image, "@", 2)

e2e-next/e2e_suite_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var (
3838

3939
// Register your flags in an init function. This ensures they are registered _before_ `go test` calls flag.Parse().
4040
func handleFlags() {
41-
flag.StringVar(&vclusterImage, "vcluster-image", constants.GetVclusterImage(), "vCluster image to test")
41+
flag.StringVar(&vclusterImage, "vcluster-image", constants.GetVClusterImage(), "vCluster image to test")
4242
flag.StringVar(&clusterName, "cluster-name", constants.GetHostClusterName(), "The kind cluster to run test against. Optional.")
4343
flag.BoolVar(&setupOnly, "setup-only", false, "Skip tests and setup the environment")
4444
flag.BoolVar(&teardown, "teardown", true, "Disables [e2e.AfterSuite] [e2e.AfterAll] to leave environment in place.")
@@ -52,7 +52,7 @@ func handleFlags() {
5252
}
5353

5454
constants.SetHostClusterName(clusterName)
55-
constants.SetVclusterImage(vclusterImage)
55+
constants.SetVClusterImage(vclusterImage)
5656

5757
e2e.SetSetupOnly(setupOnly)
5858
e2e.SetTeardown(!setupOnly && teardown)

e2e-next/test_core/sync/test_node.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package test_core
22

33
import (
44
"context"
5-
"os"
65

76
"github.com/loft-sh/e2e-framework/pkg/setup/cluster"
87
"github.com/loft-sh/vcluster/e2e-next/clusters"
@@ -37,9 +36,6 @@ var _ = Describe("Node sync",
3736
It("Sync nodes using label selector", func(ctx context.Context) {
3837

3938
hostname := constants.GetHostClusterName() + "-control-plane"
40-
if kindName, ok := os.LookupEnv("KIND_NAME"); ok && kindName != "" {
41-
hostname = kindName + "-control-plane"
42-
}
4339
Eventually(func(g Gomega) {
4440
hostNodes, err := hostClient.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
4541
g.Expect(err).NotTo(HaveOccurred(), "Failed to list host nodes")

e2e-next/test_deploy/test_helm_charts.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
"github.com/loft-sh/e2e-framework/pkg/setup/cluster"
99
"github.com/loft-sh/vcluster/e2e-next/clusters"
1010
"github.com/loft-sh/vcluster/e2e-next/constants"
11-
e2eLabels "github.com/loft-sh/vcluster/e2e-next/labels"
11+
"github.com/loft-sh/vcluster/e2e-next/labels"
1212
"github.com/loft-sh/vcluster/pkg/controllers/deploy"
1313
. "github.com/onsi/ginkgo/v2"
1414
. "github.com/onsi/gomega"
1515
appsv1 "k8s.io/api/apps/v1"
1616
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17-
"k8s.io/apimachinery/pkg/labels"
17+
k8slabels "k8s.io/apimachinery/pkg/labels"
1818
"k8s.io/client-go/kubernetes"
1919
)
2020

@@ -28,7 +28,7 @@ const (
2828

2929
var _ = Describe("Helm charts (regular and OCI) are synced and applied as expected",
3030
Ordered,
31-
e2eLabels.Deploy,
31+
labels.Deploy,
3232
cluster.Use(clusters.HelmChartsVCluster),
3333
func() {
3434
var (
@@ -69,7 +69,7 @@ var _ = Describe("Helm charts (regular and OCI) are synced and applied as expect
6969
It("Test nginx release secret existence in vcluster (regular chart)", func(ctx context.Context) {
7070
Eventually(func(g Gomega) {
7171
secList, err := vClusterClient.CoreV1().Secrets(ChartNamespace).List(ctx, metav1.ListOptions{
72-
LabelSelector: labels.SelectorFromSet(HelmSecretLabels).String(),
72+
LabelSelector: k8slabels.SelectorFromSet(HelmSecretLabels).String(),
7373
})
7474
g.Expect(err).NotTo(HaveOccurred(), "Should be able to list secrets")
7575
g.Expect(secList.Items).To(HaveLen(1), "Should have exactly one helm secret")
@@ -84,7 +84,7 @@ var _ = Describe("Helm charts (regular and OCI) are synced and applied as expect
8484
It("Test fluent-bit release deployment existence in vcluster (OCI chart)", func(ctx context.Context) {
8585
Eventually(func(g Gomega) []appsv1.Deployment {
8686
deployList, err := vClusterClient.AppsV1().Deployments(ChartOCINamespace).List(ctx, metav1.ListOptions{
87-
LabelSelector: labels.SelectorFromSet(HelmOCIDeploymentLabels).String(),
87+
LabelSelector: k8slabels.SelectorFromSet(HelmOCIDeploymentLabels).String(),
8888
})
8989
g.Expect(err).NotTo(HaveOccurred(), "Should be able to list deployments")
9090
return deployList.Items

0 commit comments

Comments
 (0)