Skip to content

Commit

Permalink
Tests: apply embedded capi ff after rancher install
Browse files Browse the repository at this point in the history
Signed-off-by: Danil Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Oct 4, 2023
1 parent e2c2adb commit dd50762
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ vendor-clean:

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: generate-modules
generate-modules: ## Run go mod tidy to ensure modules are up to date
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ var (
//go:embed data/rancher/rancher-setting-patch.yaml
RancherSettingPatch []byte

//go:embed data/rancher/embedded-capi-feature.yaml
RancherEmbeddedFeatureFlag []byte

//go:embed data/rancher/nginx-ingress.yaml
NginxIngress []byte

Expand Down
6 changes: 6 additions & 0 deletions test/e2e/data/rancher/embedded-capi-feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: management.cattle.io/v3
kind: Feature
metadata:
name: embedded-cluster-api
spec:
value: false
3 changes: 1 addition & 2 deletions test/e2e/suites/import-gitops/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ var _ = BeforeSuite(func() {
RancherHost: hostName,
RancherNamespace: e2e.RancherNamespace,
RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar),
RancherFeatures: e2eConfig.GetVariable(e2e.RancherFeaturesVar),
RancherSettingsPatch: e2e.RancherSettingPatch,
RancherPatches: [][]byte{e2e.RancherSettingPatch, e2e.RancherEmbeddedFeatureFlag},
RancherWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-rancher"),
ControllerWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"),
IsolatedMode: flagVals.IsolatedMode,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/suites/v2prov/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var _ = BeforeSuite(func() {
RancherNamespace: e2e.RancherNamespace,
RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar),
RancherFeatures: e2eConfig.GetVariable(e2e.RancherFeaturesVar),
RancherSettingsPatch: e2e.RancherSettingPatch,
RancherPatches: [][]byte{e2e.RancherSettingPatch},
RancherWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-rancher"),
ControllerWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"),
IsolatedMode: flagVals.IsolatedMode,
Expand Down
28 changes: 15 additions & 13 deletions test/testenv/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
turtlesframework "github.com/rancher-sandbox/rancher-turtles/test/framework"

"github.com/drone/envsubst/v2"
"github.com/rancher-sandbox/rancher-turtles/test/e2e"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
opframework "sigs.k8s.io/cluster-api-operator/test/framework"
"sigs.k8s.io/cluster-api/test/framework"
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
)

type DeployRancherInput struct {
BootstrapClusterProxy framework.ClusterProxy
E2EConfig *clusterctl.E2EConfig
HelmBinaryPath string
RancherChartRepoName string
RancherChartURL string
Expand All @@ -45,7 +49,7 @@ type DeployRancherInput struct {
RancherHost string
RancherPassword string
RancherFeatures string
RancherSettingsPatch []byte
RancherPatches [][]byte
RancherWaitInterval []interface{}
ControllerWaitInterval []interface{}
IsolatedMode bool
Expand Down Expand Up @@ -131,18 +135,16 @@ func DeployRancher(ctx context.Context, input DeployRancherInput) {
_, err = chart.Run(values)
Expect(err).ToNot(HaveOccurred())

if len(input.RancherSettingsPatch) > 0 {
By("Updating rancher settings")
settingPatch, err := envsubst.Eval(string(input.RancherSettingsPatch), func(s string) string {
switch s {
case "RANCHER_HOSTNAME":
return input.RancherHost
default:
return os.Getenv(s)
}
})
Expect(err).ToNot(HaveOccurred())
Expect(input.BootstrapClusterProxy.Apply(ctx, []byte(settingPatch))).To(Succeed())
By("Updating rancher configuration")
for _, patch := range input.RancherPatches {
Expect(turtlesframework.ApplyFromTemplate(ctx, turtlesframework.ApplyFromTemplateInput{
Proxy: input.BootstrapClusterProxy,
Template: patch,
Getter: input.E2EConfig.GetVariable,
AddtionalEnvironmentVariables: map[string]string{
e2e.RancherHostnameVar: input.RancherHost,
},
})).To(Succeed())
}

if !input.IsolatedMode {
Expand Down

0 comments on commit dd50762

Please sign in to comment.