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}" } 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..11ce5a5af2 100644 --- a/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts +++ b/e2e-tests/playwright/e2e/configuration-test/config-map.spec.ts @@ -1,8 +1,8 @@ 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"; +import * as yaml from "js-yaml"; test.describe("Change app-config at e2e test runtime", () => { test("Verify title change after ConfigMap modification", async ({ page }) => { @@ -16,17 +16,28 @@ 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); + // 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); + 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(); @@ -37,11 +48,23 @@ test.describe("Change app-config at e2e test runtime", () => { 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); + + await expect(page.locator("title")).toHaveText(new RegExp(dynamicTitle), { + timeout: 60000, + }); + + console.log("Title successfully verified in the UI."); } catch (error) { - LOGGER.error( + console.error( `Test failed during ConfigMap update or deployment restart:`, error, ); 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 ||