Skip to content

Commit

Permalink
Added source version validation in 6.2.Z
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Braginsky <[email protected]>
  • Loading branch information
ibragins committed Mar 19, 2024
1 parent d91154b commit 01bb64b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cypress/e2e/tests/upgrade/create_upgrade_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
getRandomApplicationData,
login,
preservecookies,
validateMtaVersionInCli,
validateMtaVersionInUi,
} from "../../../utils/utils";
import { TagCategory } from "../../models/migration/controls/tagcategory";
import * as data from "../../../utils/data_utils";
Expand All @@ -41,10 +43,13 @@ describe(["@pre-upgrade"], "Creating pre-requisites before an upgrade", () => {
let sourceControlUsernameCredentials: CredentialsSourceControlUsername;
const assessment = new Assessment(getRandomApplicationData());
let stakeHolder: Stakeholders;
const expectedMtaVersion = Cypress.env("sourceMtaVersion");

before("Login", function () {
// Perform login
login();
validateMtaVersionInCli(expectedMtaVersion);
validateMtaVersionInUi(expectedMtaVersion);
});

beforeEach("Persist session", function () {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/views/common.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ export const nameHelperBusiness = "#business-service-name-helper";
export const nameHelperStakeholderGroup = "#-helper";
export const kebabMenuItem = "a.pf-c-dropdown__menu-item";
export const commonTable = "table[aria-label='main-table']";
export const aboutButton = "#about-button";
29 changes: 29 additions & 0 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
} from "../e2e/types/constants";
import { actionButton, date, createEntitiesCheckbox } from "../e2e/views/applicationinventory.view";
import {
aboutButton,
closeSuccessNotification,
confirmButton,
divHeader,
Expand Down Expand Up @@ -1757,3 +1758,31 @@ export function selectAssessmentApplications(apps: string): void {
export function closeModalWindow(): void {
click(closeModal, false, true);
}

export function getCommandOutput(command: string): Cypress.Chainable<Cypress.Exec> {
return cy.exec(command, { timeout: 30 * SEC }).then((result) => {
return result;
});
}

export function validateMtaVersionInCli(expectedMtaVersion: string): void {
const namespace = getNamespace();
const podName = `$(oc get pods -n${namespace}| grep ui|cut -d " " -f 1)`;
const command = `oc describe pod ${podName} -n${namespace}| grep -i version|awk '{print $2}'`;
getCommandOutput(command).then((output) => {
if (expectedMtaVersion !== output.stdout) {
throw new Error(
`Expected version in UI pod: ${expectedMtaVersion}, Actual version in UI pod: ${output.stdout}`
);
}
});
}

export function validateMtaVersionInUi(expectedVersion: string): void {
click(aboutButton);
cy.contains("dt", "Version")
.closest("dl")
.within(() => {
cy.get("dd").should("contain.text", expectedVersion);
});
}

0 comments on commit 01bb64b

Please sign in to comment.