Skip to content

Commit 1eadd08

Browse files
E2E: Improvements to chart-upgrade suite tests (#1917)
Signed-off-by: Furkat Gofurov <[email protected]>
1 parent 88ec804 commit 1eadd08

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

scripts/build-local-rancher-charts.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ RANCHER_CHART_DEV_VERSION=${RANCHER_CHART_DEV_VERSION}
2121
RANCHER_CHARTS_BASE_BRANCH=${RANCHER_CHARTS_BASE_BRANCH}
2222
CHART_RELEASE_DIR=${CHART_RELEASE_DIR}
2323
HELM=${HELM}
24-
# Optional: Override image repository and tag in the chart (useful for e2e tests with preloaded images)
25-
TURTLES_IMAGE_OVERRIDE_REPO=${TURTLES_IMAGE_OVERRIDE_REPO:-}
26-
TURTLES_IMAGE_OVERRIDE_TAG=${TURTLES_IMAGE_OVERRIDE_TAG:-}
2724

2825
# Cleanup
2926
rm -rf $RANCHER_CHARTS_REPO_DIR
@@ -36,11 +33,6 @@ cp -r $CHART_RELEASE_DIR/* $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANC
3633
yq -i '.version = "'$RANCHER_CHART_DEV_VERSION'"' $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/Chart.yaml
3734
yq -i '.appVersion = "dev"' $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/Chart.yaml
3835
yq -i '.urls[0] += "assets/rancher-turtles/rancher-turtles-'$RANCHER_CHART_DEV_VERSION'.tgz"' $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/Chart.yaml
39-
# Optionally override image repository and tag if environment variables are set (e.g., for e2e tests with preloaded images)
40-
if [ -n "$TURTLES_IMAGE_OVERRIDE_REPO" ] && [ -n "$TURTLES_IMAGE_OVERRIDE_TAG" ]; then
41-
yq -i '.image.repository = "'$TURTLES_IMAGE_OVERRIDE_REPO'"' $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/values.yaml
42-
yq -i '.image.tag = "'$TURTLES_IMAGE_OVERRIDE_TAG'"' $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/values.yaml
43-
fi
4436
# Populate release.yaml and index.yaml
4537
yq -i '.rancher-turtles += "'$RANCHER_CHART_DEV_VERSION'"' $RANCHER_CHARTS_REPO_DIR/release.yaml
4638
index_entry=$(yq -o=j -I=0 $RANCHER_CHARTS_REPO_DIR/charts/rancher-turtles/$RANCHER_CHART_DEV_VERSION/Chart.yaml)

test/e2e/suites/chart-upgrade/chart_upgrade_test.go

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ var _ = Describe("Chart upgrade functionality should work", Ordered, Label(e2e.S
172172
By("Upgrading Rancher to 2.13.x with Gitea chart repository (enables system chart controller)")
173173
testenv.UpgradeRancherWithGitea(ctx, testenv.UpgradeRancherWithGiteaInput{
174174
BootstrapClusterProxy: bootstrapClusterProxy,
175-
// at the time of adding this test, there's no stable chart in `rancher-latest` for v2.13.0, so we use a release candidate
176-
RancherVersion: "2.13.0-rc2",
177-
ChartRepoURL: chartsResult.ChartRepoHTTPURL,
178-
ChartRepoBranch: chartsResult.Branch,
179-
ChartVersion: chartsResult.ChartVersion,
180-
RancherWaitInterval: e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-rancher"),
175+
ChartRepoURL: chartsResult.ChartRepoHTTPURL,
176+
ChartRepoBranch: chartsResult.Branch,
177+
ChartVersion: chartsResult.ChartVersion,
178+
TurtlesImageRepo: "ghcr.io/rancher/turtles-e2e",
179+
TurtlesImageTag: "v0.0.1",
180+
RancherWaitInterval: e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-rancher"),
181181
})
182182

183183
By("Waiting for Rancher to be ready after upgrade")
@@ -209,36 +209,39 @@ var _ = Describe("Chart upgrade functionality should work", Ordered, Label(e2e.S
209209
UseLegacyCAPINamespace: false, // v0.25.x uses new cattle-capi-system namespace
210210
RancherTurtlesNamespace: e2e.NewRancherTurtlesNamespace,
211211
ProviderList: "docker,aws,gcp",
212-
AdditionalValues: map[string]string{
213-
"providers.infrastructureDocker.enabled": "true",
214-
"providers.infrastructureAWS.enabled": "true",
215-
"providers.infrastructureGCP.enabled": "true",
216-
},
217212
})
218213

219214
By("Verifying all CAPI providers are running after upgrade")
220-
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
221-
Getter: bootstrapClusterProxy.GetClient(),
222-
Name: "cluster-api",
223-
Namespace: "cattle-capi-system",
215+
capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{
216+
Getter: bootstrapClusterProxy.GetClient(),
217+
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
218+
Name: "capi-controller-manager",
219+
Namespace: "cattle-capi-system",
220+
}},
224221
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
225222

226-
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
227-
Getter: bootstrapClusterProxy.GetClient(),
228-
Name: "docker",
229-
Namespace: "cattle-capi-system",
223+
capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{
224+
Getter: bootstrapClusterProxy.GetClient(),
225+
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
226+
Name: "capd-controller-manager",
227+
Namespace: "capd-system",
228+
}},
230229
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
231230

232-
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
233-
Getter: bootstrapClusterProxy.GetClient(),
234-
Name: "aws",
235-
Namespace: "cattle-capi-system",
231+
capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{
232+
Getter: bootstrapClusterProxy.GetClient(),
233+
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
234+
Name: "capa-controller-manager",
235+
Namespace: "capa-system",
236+
}},
236237
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
237238

238-
framework.WaitForCAPIProviderRollout(ctx, framework.WaitForCAPIProviderRolloutInput{
239-
Getter: bootstrapClusterProxy.GetClient(),
240-
Name: "gcp",
241-
Namespace: "cattle-capi-system",
239+
capiframework.WaitForDeploymentsAvailable(ctx, capiframework.WaitForDeploymentsAvailableInput{
240+
Getter: bootstrapClusterProxy.GetClient(),
241+
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
242+
Name: "capg-controller-manager",
243+
Namespace: "capg-system",
244+
}},
242245
}, e2eConfig.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...)
243246

244247
By("Verifying workload cluster survived the upgrade (zero-downtime validated)")

test/e2e/suites/chart-upgrade/suite_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ var _ = SynchronizedBeforeSuite(
107107
RancherChartsBaseBranch: "dev-v2.13",
108108
GiteaServerAddress: giteaResult.GitAddress,
109109
GiteaRepoName: "charts",
110-
// Use preloaded e2e image from kind cluster
111-
TurtlesImageRepo: "ghcr.io/rancher/turtles-e2e",
112-
TurtlesImageTag: "v0.0.1",
113110
// ChartVersion will be auto-populated from RANCHER_CHART_DEV_VERSION env var or Makefile default
114111
})
115112

test/testenv/rancher_system_chart.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type UpgradeRancherWithGiteaInput struct {
126126
RancherNamespace string `env:"RANCHER_NAMESPACE" envDefault:"cattle-system"`
127127

128128
// RancherVersion is the version to upgrade to.
129-
RancherVersion string
129+
RancherVersion string `env:"RANCHER_VERSION"`
130130

131131
// ChartRepoURL is the URL of the Gitea chart repository (e.g., http://gitea.address/git/charts).
132132
ChartRepoURL string
@@ -137,6 +137,12 @@ type UpgradeRancherWithGiteaInput struct {
137137
// ChartVersion is the Turtles chart version (e.g., "108.0.0+up99.99.99").
138138
ChartVersion string
139139

140+
// TurtlesImageRepo is the image repository to override in rancher-config ConfigMap (optional, for e2e with preloaded images).
141+
TurtlesImageRepo string
142+
143+
// TurtlesImageTag is the image tag to override in rancher-config ConfigMap (optional, for e2e with preloaded images).
144+
TurtlesImageTag string
145+
140146
// RancherWaitInterval is the wait interval for Rancher.
141147
RancherWaitInterval []interface{} `envDefault:"15m,30s"`
142148
}
@@ -191,6 +197,21 @@ func UpgradeRancherWithGitea(ctx context.Context, input UpgradeRancherWithGiteaI
191197
},
192198
},
193199
}, input.RancherWaitInterval...)
200+
201+
// Optionally configure image overrides via rancher-config ConfigMap for e2e tests with preloaded images
202+
if input.TurtlesImageRepo != "" && input.TurtlesImageTag != "" {
203+
By("Patching rancher-config ConfigMap to override Turtles image")
204+
patchCmd := exec.Command(
205+
"kubectl",
206+
"patch", "configmap", "rancher-config",
207+
"-n", e2e.RancherNamespace,
208+
"--type", "merge",
209+
"--patch", fmt.Sprintf(`{"data":{"rancher-turtles": "image:\n repository: %s\n tag: %s\n"}}`, input.TurtlesImageRepo, input.TurtlesImageTag),
210+
)
211+
patchCmd.Env = append(os.Environ(), fmt.Sprintf("KUBECONFIG=%s", input.BootstrapClusterProxy.GetKubeconfigPath()))
212+
patchOutput, patchErr := patchCmd.CombinedOutput()
213+
Expect(patchErr).ToNot(HaveOccurred(), "Failed to patch rancher-config ConfigMap: %s", string(patchOutput))
214+
}
194215
}
195216

196217
// BuildAndPushRancherChartsToGiteaInput represents the input parameters for building and pushing Rancher charts to Gitea.
@@ -223,12 +244,6 @@ type BuildAndPushRancherChartsToGiteaInput struct {
223244
// ChartVersion is the version string for the Turtles chart.
224245
// If not provided, will use RANCHER_CHART_DEV_VERSION from environment or Makefile default.
225246
ChartVersion string `env:"RANCHER_CHART_DEV_VERSION" envDefault:"108.0.0+up99.99.99"`
226-
227-
// TurtlesImageRepo is the image repository to use in the chart (optional, for e2e with preloaded images).
228-
TurtlesImageRepo string `env:"TURTLES_IMAGE_OVERRIDE_REPO"`
229-
230-
// TurtlesImageTag is the image tag to use in the chart (optional, for e2e with preloaded images).
231-
TurtlesImageTag string `env:"TURTLES_IMAGE_OVERRIDE_TAG"`
232247
}
233248

234249
// BuildAndPushRancherChartsToGiteaResult represents the result of building and pushing charts.
@@ -288,13 +303,6 @@ func BuildAndPushRancherChartsToGitea(ctx context.Context, input BuildAndPushRan
288303
fmt.Sprintf("RANCHER_CHARTS_BASE_BRANCH=%s", input.RancherChartsBaseBranch),
289304
fmt.Sprintf("RANCHER_CHART_DEV_VERSION=%s", input.ChartVersion),
290305
}
291-
// Optionally override image repository and tag for e2e tests with preloaded images
292-
if input.TurtlesImageRepo != "" {
293-
envVars = append(envVars, fmt.Sprintf("TURTLES_IMAGE_OVERRIDE_REPO=%s", input.TurtlesImageRepo))
294-
}
295-
if input.TurtlesImageTag != "" {
296-
envVars = append(envVars, fmt.Sprintf("TURTLES_IMAGE_OVERRIDE_TAG=%s", input.TurtlesImageTag))
297-
}
298306
makeCmd.Env = append(os.Environ(), envVars...)
299307
output, err := makeCmd.CombinedOutput()
300308
Expect(err).ToNot(HaveOccurred(), "Failed to run make build-local-rancher-charts: %s", string(output))

0 commit comments

Comments
 (0)