Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Fix JF for Actions in Task Manager Page #1318

Merged
merged 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions cypress/e2e/models/migration/task-manager/task-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export class TaskManager {
}

private static getTaskRow(
application: string,
applicationName: string,
kind: TaskKind
): Cypress.Chainable<JQuery<HTMLTableRowElement>> {
return cy
.get(trTag)
.filter(':contains("' + application + '")')
.filter(':contains("' + applicationName + '")')
.filter(':contains("' + kind + '")');
}

Expand All @@ -91,17 +91,27 @@ export class TaskManager {
cy.wait(2 * SEC);
}

public static setPreemption(preemption: boolean): void {
public static setPreemption(
applicationName: string,
kind: TaskKind,
preemption: boolean
): void {
const setPreemption = preemption === true ? "Enable preemption" : "Disable preemption";
TaskManager.open();
cy.contains("Pending")
.closest(trTag)
.within(() => {
click(sideKebabMenu);
});
TaskManager.getTaskRow(applicationName, kind).find(sideKebabMenu).click();
cy.get(actionMenuItem).contains(setPreemption).click();
}

public static verifyPreemption(
applicationName: string,
kind: TaskKind,
preemption: boolean
): void {
TaskManager.getTaskRow(applicationName, kind)
.find(TaskManagerColumns.preemption, { timeout: 10 * MIN })
.should("contain.text", preemption);
}

public static cancelTask(status: string): void {
TaskManager.open();
cy.contains(status)
Expand Down
61 changes: 39 additions & 22 deletions cypress/e2e/tests/migration/task-manager/miscellaneous.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@ limitations under the License.
import {
checkSuccessAlert,
deleteApplicationTableRows,
deleteCustomResource,
getCommandOutput,
getNamespace,
getRandomAnalysisData,
getRandomApplicationData,
limitPodsByQuota,
login,
validateTextPresence,
} from "../../../../utils/utils";
import { Analysis } from "../../../models/migration/applicationinventory/analysis";
import { TaskManager } from "../../../models/migration/task-manager/task-manager";
import { TaskKind } from "../../../types/constants";
import * as commonView from "../../../views/common.view";
import { TaskManagerColumns } from "../../../views/taskmanager.view";

describe(["@tier2"], "Actions in Task Manager Page", function () {
const applicationsList: Analysis[] = [];
const applicationsList: Array<Analysis> = [];
mguetta1 marked this conversation as resolved.
Show resolved Hide resolved
let bookServerApp: Analysis;

before("Login", function () {
login();
Expand All @@ -45,31 +51,37 @@ describe(["@tier2"], "Actions in Task Manager Page", function () {
});
});

it("Test Enable and Disable Premeption", function () {
const bookServerApp = new Analysis(
getRandomApplicationData("TaskApp1_", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["analysis_for_openSourceLibraries"])
);
bookServerApp.create();
TaskManager.setPreemption(true);
checkSuccessAlert(commonView.infoAlertMessage, "Update request submitted.");
validateTextPresence(TaskManagerColumns.preemption, "true");
TaskManager.setPreemption(false);
it("Limit pods to the number of tackle pods + 1", function () {
mguetta1 marked this conversation as resolved.
Show resolved Hide resolved
let namespace = getNamespace();
let command = `oc get pod --no-headers -n ${namespace} | grep -v task | grep -v Completed | wc -l`;
getCommandOutput(command).then((output) => {
let podsNumber = Number(output.stdout) + 1;
limitPodsByQuota(podsNumber);
});
});

it("Test Enable and Disable Preemption", function () {
for (let i = 0; i < 2; i++) {
bookServerApp = new Analysis(
getRandomApplicationData("TaskApp1_", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["analysis_for_openSourceLibraries"])
);
bookServerApp.create();
applicationsList.push(bookServerApp);
}
TaskManager.setPreemption(applicationsList[1].name, TaskKind.languageDiscovery, true);
checkSuccessAlert(commonView.infoAlertMessage, "Update request submitted.");
validateTextPresence(TaskManagerColumns.preemption, "false");
TaskManager.verifyPreemption(applicationsList[1].name, TaskKind.languageDiscovery, true);
TaskManager.setPreemption(applicationsList[1].name, TaskKind.languageDiscovery, false);
checkSuccessAlert(commonView.infoAlertMessage, "Update request submitted.", true);
TaskManager.verifyPreemption(applicationsList[1].name, TaskKind.languageDiscovery, false);
});

it("Cancel Task", function () {
const bookServerApp = new Analysis(
getRandomApplicationData("TaskApp1_", {
sourceData: this.appData["bookserver-app"],
}),
getRandomAnalysisData(this.analysisData["analysis_for_openSourceLibraries"])
);
bookServerApp.create();
TaskManager.cancelTask("Pending");
Analysis.analyzeAll(bookServerApp);
TaskManager.cancelTask("Postponed");
checkSuccessAlert(commonView.infoAlertMessage, "Cancelation request submitted");
validateTextPresence(TaskManagerColumns.status, "Canceled");
TaskManager.cancelTask("Running");
Expand All @@ -78,4 +90,9 @@ describe(["@tier2"], "Actions in Task Manager Page", function () {
// Succeeded tasks cannot be cancelled.
TaskManager.cancelTask("Succeeded");
});

after("Perform test data clean up", function () {
deleteCustomResource("quota", "task-pods");
deleteApplicationTableRows();
});
});
3 changes: 3 additions & 0 deletions cypress/fixtures/custom-resource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"resourceQuota": "cypress/fixtures/yaml/resource-quota.yaml"
}
8 changes: 8 additions & 0 deletions cypress/fixtures/yaml/resource-quota.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: ResourceQuota
metadata:
name: task-pods
spec:
hard:
pods: "${PODS_NUMBER}"
20 changes: 20 additions & 0 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2018,3 +2018,23 @@ export function downloadTaskDetails(format = downloadFormatDetails.yaml) {
}
});
}

export function limitPodsByQuota(podsNumber: number) {
let namespace = getNamespace();
cy.fixture("custom-resource").then((cr) => {
let manifast = cr["resourceQuota"];
let command = `PODS_NUMBER=${podsNumber} envsubst < ${manifast} | oc apply -f - -n ${namespace}`;
// let command = `export PODS_COUNT=6; oc apply -f ${manifast} -n${namespace}`;
mguetta1 marked this conversation as resolved.
Show resolved Hide resolved
getCommandOutput(command).then((output) => {
expect(output.stdout).to.equal("resourcequota/task-pods created");
});
});
}

export function deleteCustomResource(resourceType: string, resourceName: string) {
let namespace = getNamespace();
let command = `oc delete ${resourceType} ${resourceName} -n${namespace}`;
getCommandOutput(command).then((output) => {
expect(output.code).to.equal(0);
});
}
Loading