From aafad928bff439171244a548bd6eb869445bb914 Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Wed, 18 Dec 2024 14:28:57 -0300 Subject: [PATCH 1/7] rhidp-5296 e2e - main nightly job failing on runtime configuration change step Signed-off-by: Gustavo Lira --- .../e2e/configuration-test/config-map.spec.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts index 58f57654b1..5930962e66 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -1,6 +1,5 @@ import { test, expect } from "@playwright/test"; import { KubeClient } from "../../utils/kube-client"; -import { LOGGER } from "../../utils/logger"; import { Common } from "../../utils/common"; import { UIhelper } from "../../utils/ui-helper"; @@ -16,14 +15,14 @@ test.describe("Change app-config at e2e test runtime", () => { const dynamicTitle = generateDynamicTitle(); const uiHelper = new UIhelper(page); try { - LOGGER.info(`Updating ConfigMap '${configMapName}' with new title.`); + console.log(`Updating ConfigMap '${configMapName}' with new title.`); await kubeUtils.updateConfigMapTitle( configMapName, namespace, dynamicTitle, ); - LOGGER.info( + console.log( `Restarting deployment '${deploymentName}' to apply ConfigMap changes.`, ); await kubeUtils.restartDeployment(deploymentName, namespace); @@ -31,17 +30,25 @@ test.describe("Change app-config at e2e test runtime", () => { const common = new Common(page); await page.context().clearCookies(); await page.context().clearPermissions(); - await page.reload({ waitUntil: "domcontentloaded" }); + await page.reload({ waitUntil: "domcontentloaded" }) await common.loginAsGuest(); await new UIhelper(page).openSidebar("Home"); await uiHelper.verifyHeading("Welcome back!"); await uiHelper.verifyText("Quick Access"); await expect(page.locator("#search-bar-text-field")).toBeVisible(); - LOGGER.info("Verifying new title in the UI..."); - expect(await page.title()).toContain(dynamicTitle); - LOGGER.info("Title successfully verified in the UI."); + console.log("Verifying new title in the UI..."); + + const title = await page.evaluate(() => document.title); + console.log(title); + console.log(page.title()); + const title2 = await page.locator('title').textContent(); + console.log(title2); + + expect(title2).toContain(dynamicTitle); + + console.log("Title successfully verified in the UI."); } catch (error) { - LOGGER.error( + console.error( `Test failed during ConfigMap update or deployment restart:`, error, ); From 8fa19f98428517073842ad7ff1a7f4ad47e8e3ae Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Wed, 18 Dec 2024 14:36:35 -0300 Subject: [PATCH 2/7] rhidp-5296 e2e - main nightly job failing on runtime configuration change step Signed-off-by: Gustavo Lira --- .../playwright/e2e/configuration-test/config-map.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts index 5930962e66..b731efcd3e 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -30,7 +30,7 @@ test.describe("Change app-config at e2e test runtime", () => { const common = new Common(page); await page.context().clearCookies(); await page.context().clearPermissions(); - await page.reload({ waitUntil: "domcontentloaded" }) + await page.reload({ waitUntil: "domcontentloaded" }); await common.loginAsGuest(); await new UIhelper(page).openSidebar("Home"); await uiHelper.verifyHeading("Welcome back!"); @@ -41,7 +41,7 @@ test.describe("Change app-config at e2e test runtime", () => { const title = await page.evaluate(() => document.title); console.log(title); console.log(page.title()); - const title2 = await page.locator('title').textContent(); + const title2 = await page.locator("title").textContent(); console.log(title2); expect(title2).toContain(dynamicTitle); From 2a705ebf1dbdd9a72eb9725f202819cd3ad36d68 Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Dec 2024 13:16:42 -0300 Subject: [PATCH 3/7] test Signed-off-by: Gustavo Lira --- .ibm/pipelines/jobs/main.sh | 11 +++++++++++ .ibm/pipelines/jobs/periodic.sh | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.ibm/pipelines/jobs/main.sh b/.ibm/pipelines/jobs/main.sh index f37b47e367..e3892bdc35 100644 --- a/.ibm/pipelines/jobs/main.sh +++ b/.ibm/pipelines/jobs/main.sh @@ -13,4 +13,15 @@ handle_main() { check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${url}" local rbac_url="https://${RELEASE_NAME_RBAC}-backstage-${NAME_SPACE_RBAC}.${K8S_CLUSTER_ROUTER_BASE}" check_and_test "${RELEASE_NAME_RBAC}" "${NAME_SPACE_RBAC}" "${rbac_url}" + + # Deploy `showcase-runtime` to run tests that require configuration changes at runtime + configure_namespace "${NAME_SPACE_RUNTIME}" + uninstall_helmchart "${NAME_SPACE_RUNTIME}" "${RELEASE_NAME}" + oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE_RUNTIME}" + + local runtime_url="https://${RELEASE_NAME}-backstage-${NAME_SPACE_RUNTIME}.${K8S_CLUSTER_ROUTER_BASE}" + + apply_yaml_files "${DIR}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" + helm upgrade -i "${RELEASE_NAME}" -n "${NAME_SPACE_RUNTIME}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" --version "${CHART_VERSION}" -f "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" --set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" --set upstream.backstage.image.repository="${QUAY_REPO}" --set upstream.backstage.image.tag="${TAG_NAME}" + check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" } diff --git a/.ibm/pipelines/jobs/periodic.sh b/.ibm/pipelines/jobs/periodic.sh index 23fdd7138d..5b10a410f6 100644 --- a/.ibm/pipelines/jobs/periodic.sh +++ b/.ibm/pipelines/jobs/periodic.sh @@ -18,14 +18,14 @@ handle_nightly() { local rds_url="https://${RELEASE_NAME}-backstage-${NAME_SPACE_RDS}.${K8S_CLUSTER_ROUTER_BASE}" check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RDS}" "${rds_url}" - # Deploy `showcase-runtime` to run tests that require configuration changes at runtime - configure_namespace "${NAME_SPACE_RUNTIME}" - uninstall_helmchart "${NAME_SPACE_RUNTIME}" "${RELEASE_NAME}" - oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE_RUNTIME}" - - local runtime_url="https://${RELEASE_NAME}-backstage-${NAME_SPACE_RUNTIME}.${K8S_CLUSTER_ROUTER_BASE}" - - apply_yaml_files "${DIR}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" - helm upgrade -i "${RELEASE_NAME}" -n "${NAME_SPACE_RUNTIME}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" --version "${CHART_VERSION}" -f "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" --set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" --set upstream.backstage.image.repository="${QUAY_REPO}" --set upstream.backstage.image.tag="${TAG_NAME}" - check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" +# # Deploy `showcase-runtime` to run tests that require configuration changes at runtime +# configure_namespace "${NAME_SPACE_RUNTIME}" +# uninstall_helmchart "${NAME_SPACE_RUNTIME}" "${RELEASE_NAME}" +# oc apply -f "$DIR/resources/redis-cache/redis-deployment.yaml" --namespace="${NAME_SPACE_RUNTIME}" +# +# local runtime_url="https://${RELEASE_NAME}-backstage-${NAME_SPACE_RUNTIME}.${K8S_CLUSTER_ROUTER_BASE}" +# +# apply_yaml_files "${DIR}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" +# helm upgrade -i "${RELEASE_NAME}" -n "${NAME_SPACE_RUNTIME}" "${HELM_REPO_NAME}/${HELM_IMAGE_NAME}" --version "${CHART_VERSION}" -f "${DIR}/value_files/${HELM_CHART_VALUE_FILE_NAME}" --set global.clusterRouterBase="${K8S_CLUSTER_ROUTER_BASE}" --set upstream.backstage.image.repository="${QUAY_REPO}" --set upstream.backstage.image.tag="${TAG_NAME}" +# check_and_test "${RELEASE_NAME}" "${NAME_SPACE_RUNTIME}" "${runtime_url}" } From 3f9016cce6eba8255f3541dae32ff062d78b1a1c Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Dec 2024 17:26:02 -0300 Subject: [PATCH 4/7] test Signed-off-by: Gustavo Lira --- .../e2e/configuration-test/config-map.spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts index b731efcd3e..c2820f6cda 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -2,6 +2,7 @@ import { test, expect } from "@playwright/test"; import { KubeClient } from "../../utils/kube-client"; import { Common } from "../../utils/common"; import { UIhelper } from "../../utils/ui-helper"; +import * as yaml from "js-yaml"; test.describe("Change app-config at e2e test runtime", () => { test("Verify title change after ConfigMap modification", async ({ page }) => { @@ -27,6 +28,16 @@ test.describe("Change app-config at e2e test runtime", () => { ); await kubeUtils.restartDeployment(deploymentName, namespace); + console.log(`Verifying ConfigMap '${configMapName}' contains the new title.`); + const updatedConfigMap = await kubeUtils.getConfigMap(configMapName, namespace); + const appConfigYaml = updatedConfigMap.body.data[`${configMapName}.yaml`]; + + const appConfig = yaml.load(appConfigYaml) as any; + const updatedTitle = appConfig?.app?.title; + + console.log(`Updated title in ConfigMap: ${updatedTitle}`); + expect(updatedTitle).toBe(dynamicTitle); + const common = new Common(page); await page.context().clearCookies(); await page.context().clearPermissions(); From eac3d98234a96cea5b275532ff46e83a9524f3e2 Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Dec 2024 19:14:44 -0300 Subject: [PATCH 5/7] test Signed-off-by: Gustavo Lira --- .../playwright/e2e/configuration-test/config-map.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts index c2820f6cda..161333b970 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -57,6 +57,10 @@ test.describe("Change app-config at e2e test runtime", () => { expect(title2).toContain(dynamicTitle); + await expect(page.locator("title")).toHaveText(new RegExp(dynamicTitle), { + timeout: 60000, + }); + console.log("Title successfully verified in the UI."); } catch (error) { console.error( From 6cb659986c95396e8a25cbe141ac4c0990ca0d4c Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Dec 2024 19:21:56 -0300 Subject: [PATCH 6/7] test Signed-off-by: Gustavo Lira --- e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts index 161333b970..11ce5a5af2 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -26,7 +26,8 @@ test.describe("Change app-config at e2e test runtime", () => { console.log( `Restarting deployment '${deploymentName}' to apply ConfigMap changes.`, ); - await kubeUtils.restartDeployment(deploymentName, namespace); + // await kubeUtils.restartDeployment(deploymentName, namespace); + await kubeUtils.restartDeploymentWithAnnotation(deploymentName, namespace); console.log(`Verifying ConfigMap '${configMapName}' contains the new title.`); const updatedConfigMap = await kubeUtils.getConfigMap(configMapName, namespace); From 0f8d53ba7ee5cb7cfec7d68d34eab9bff47b93cf Mon Sep 17 00:00:00 2001 From: Gustavo Lira Date: Thu, 19 Dec 2024 19:22:32 -0300 Subject: [PATCH 7/7] test Signed-off-by: Gustavo Lira --- e2e-tests/playwright/utils/kube-client.ts | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/e2e-tests/playwright/utils/kube-client.ts b/e2e-tests/playwright/utils/kube-client.ts index 2bac334e24..436d68c7a5 100644 --- a/e2e-tests/playwright/utils/kube-client.ts +++ b/e2e-tests/playwright/utils/kube-client.ts @@ -350,6 +350,41 @@ export class KubeClient { } } + async restartDeploymentWithAnnotation(deploymentName: string, namespace: string) { + try { + console.log(`Adding annotation to deployment '${deploymentName}' for redeploy.`); + + const patch = [ + { + op: "add", + path: "/spec/template/metadata/annotations/restartTime", + value: new Date().toISOString(), + }, + ]; + + const options = { + headers: { "Content-Type": k8s.PatchUtils.PATCH_FORMAT_JSON_PATCH }, + }; + + await this.appsApi.patchNamespacedDeployment( + deploymentName, + namespace, + patch, + undefined, + undefined, + undefined, + undefined, + undefined, + options, + ); + + console.log(`Annotation added to deployment '${deploymentName}'.`); + } catch (error) { + console.error(`Error adding annotation to deployment '${deploymentName}':`, error); + throw error; + } + } + async logPodConditions(namespace: string, labelSelector?: string) { const selector = labelSelector ||