From 9dad8c4aae704e8c9c14b03f5114b03e63931ac7 Mon Sep 17 00:00:00 2001 From: Igor Braginsky Date: Thu, 17 Aug 2023 14:16:53 +0300 Subject: [PATCH 1/2] Fixed patching of tackle CR Signed-off-by: Igor Braginsky --- cypress/utils/utils.ts | 55 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index d6dda2199..24b52190f 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -1683,31 +1683,38 @@ export function isRwxEnabled(): boolean { // This method is patching export function configureRWX(isEnabled = true): void { // Patching CR to set value - let value: string; - if (isEnabled) { - value = "true"; - } else { - value = "false"; - } - let command = ""; - let tackleCr = "tackle=$(oc get tackle --all-namespaces|grep -iv name|awk '{print $2}'); "; - let namespace = - 'namespace=$(oc get tackle --all-namespaces|egrep "tackle|mta"|cut -d " " -f 1); '; - command += tackleCr; - command += namespace; - command += "oc patch tackle "; - command += "$tackle "; - command += "-n$namespace "; - command += "--type merge "; - command += `--patch '{"spec":{"rwx_supported": ${value}}}'`; - cy.log(command); - cy.exec(command).then((result) => { - cy.log(result.stderr); - }); + cy.url().then(($url) => { + const pattern = /-(.*?)\./; + let namespace: string; + const match = $url.match(pattern); + let value: string; + if (isEnabled) { + value = "true"; + } else { + value = "false"; + } + let command = ""; + if (match && match[1]) { + namespace = match[1].toString(); + } else { + namespace = "konveyor-tackle"; + } + let tackleCr = `tackle=$(oc get tackle -n${namespace}|grep -iv name|awk '{print $2}'); `; + command += "oc patch tackle "; + command += "$tackle "; + command += `-n${namespace} `; + command += "--type merge "; + command += `--patch '{"spec":{"rwx_supported": ${value}}}'`; + cy.log(command); + cy.pause(); + cy.exec(command).then((result) => { + cy.log(result.stderr); + }); - // Timeout as it takes time until pods are starting to reboot - cy.wait(180 * SEC); - cy.reload(); + // Timeout as it takes time until pods are starting to reboot + cy.wait(180 * SEC); + cy.reload(); + }); } export function isEnabled(selector: string, toBeEnabled?: boolean): void { From 8a0ea7d857dce035be6c7ece3296c22ca2c5d6e7 Mon Sep 17 00:00:00 2001 From: Igor Braginsky Date: Thu, 17 Aug 2023 22:41:16 +0300 Subject: [PATCH 2/2] Align changes with mta_6.2.0 Signed-off-by: Igor Braginsky --- cypress/utils/utils.ts | 69 +++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/cypress/utils/utils.ts b/cypress/utils/utils.ts index 24b52190f..26b8809cf 100644 --- a/cypress/utils/utils.ts +++ b/cypress/utils/utils.ts @@ -1680,41 +1680,48 @@ export function isRwxEnabled(): boolean { return Cypress.env("rwx_enabled"); } +export function getUrl(): string { + return window.location.href; +} + +export function getNamespace(): string { + // This is regexp pattern to search between first `-` and first `.` + const namespacePattern = /-(.*?)\./; + // First match, means `-` + const match = getUrl().match(namespacePattern); + if (match && match[1]) { + return match[1].toString(); + } else { + return "konveyor-tackle"; + } +} + // This method is patching export function configureRWX(isEnabled = true): void { // Patching CR to set value - cy.url().then(($url) => { - const pattern = /-(.*?)\./; - let namespace: string; - const match = $url.match(pattern); - let value: string; - if (isEnabled) { - value = "true"; - } else { - value = "false"; - } - let command = ""; - if (match && match[1]) { - namespace = match[1].toString(); - } else { - namespace = "konveyor-tackle"; - } - let tackleCr = `tackle=$(oc get tackle -n${namespace}|grep -iv name|awk '{print $2}'); `; - command += "oc patch tackle "; - command += "$tackle "; - command += `-n${namespace} `; - command += "--type merge "; - command += `--patch '{"spec":{"rwx_supported": ${value}}}'`; - cy.log(command); - cy.pause(); - cy.exec(command).then((result) => { - cy.log(result.stderr); - }); - - // Timeout as it takes time until pods are starting to reboot - cy.wait(180 * SEC); - cy.reload(); + let value = ""; + if (isEnabled) { + value = "true"; + } else { + value = "false"; + } + let command = ""; + let namespace = getNamespace(); + let tackleCr = `tackle=$(oc get tackle -n${namespace}|grep -iv name|awk '{print $1}'); `; + command += tackleCr; + command += "oc patch tackle "; + command += "$tackle "; + command += `-n${namespace} `; + command += "--type merge "; + command += `--patch '{"spec":{"rwx_supported": ${value}}}'`; + cy.log(command); + cy.exec(command).then((result) => { + cy.log(result.stderr); }); + + // Timeout as it takes time until pods are starting to reboot + cy.wait(180 * SEC); + cy.reload(); } export function isEnabled(selector: string, toBeEnabled?: boolean): void {