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] Create trigger validation test for custom migration targets and custom rules #1213

Merged
merged 9 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
Copyright © 2021 the Konveyor Contributors (https://konveyor.io/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/// <reference types="cypress" />

import {
click,
clickByText,
closeSuccessAlert,
deleteAllMigrationWaves,
deleteApplicationTableRows,
getRandomAnalysisData,
getRandomApplicationData,
login,
next,
selectItemsPerPage,
} from "../../../../utils/utils";
import {
AnalysisStatuses,
analyzeButton,
button,
CredentialType,
Languages,
SEC,
UserCredentials,
} from "../../../types/constants";
import * as data from "../../../../utils/data_utils";
import { CustomMigrationTarget } from "../../../models/administration/custom-migration-targets/custom-migration-target";
import { CustomMigrationTargetView } from "../../../views/custom-migration-target.view";
import { CredentialsSourceControlUsername } from "../../../models/administration/credentials/credentialsSourceControlUsername";
import { getRulesData } from "../../../../utils/data_utils";
import { Analysis } from "../../../models/migration/applicationinventory/analysis";
import { cancelButton } from "../../../views/common.view";
import * as commonView from "../../../views/common.view";
import { RulesRepositoryFields } from "../../../types/types";
import { Application } from "../../../models/migration/applicationinventory/application";

// Automates Bug MTA-3330 | Polarion TC MTA-597
describe(["@tier3"], "Custom Migration Targets rules trigger validation", () => {
let target: CustomMigrationTarget;
const applications: Analysis[] = [];
const EXPECTED_EFFORT = 5;

before("Login", function () {
login();
deleteAllMigrationWaves();
deleteApplicationTableRows();
});

beforeEach("Fixtures and Interceptors", function () {
cy.fixture("application").then(function (appData) {
this.appData = appData;
});

cy.fixture("analysis").then(function (analysisData) {
this.analysisData = analysisData;
});

cy.fixture("custom-rules").then(function (customMigrationTargets) {
this.customMigrationTargets = customMigrationTargets;
});

CustomMigrationTarget.open(true);
});

it("Test same rules are triggered for custom rules and custom migration target", function () {
const targetData = this.customMigrationTargets["rules_from_bug_3330"];
target = new CustomMigrationTarget(
data.getRandomWord(8),
data.getDescription(),
targetData.image,
getRulesData(targetData),
Languages.Java
);
target.create();

for (let i = 0; i < 2; i++) {
const application = new Analysis(
getRandomApplicationData("Tackle Public", {
sourceData: this.appData["tackle-testapp-public"],
}),
{
source: "Source code",
target: [],
}
);
application.create();
applications.push(application);
}

applications[0].target = [target.name];
applications[1].customRuleRepository = getRulesData(targetData) as RulesRepositoryFields;
abrugaro marked this conversation as resolved.
Show resolved Hide resolved

applications[0].analyze();
applications[0].selectApplication();
applications[1].analyze();

applications.forEach((app) => {
app.verifyAnalysisStatus(AnalysisStatuses.completed);
Application.open(true);
app.verifyEffort(EXPECTED_EFFORT);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abrugaro I also want to validate that the custom rule is triggered not just the effort .
We can use the same app from the bug MTA-3330 if needed , https://github.com/selrahal/mta-bug and check if custom rule is triggered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sshveta Here I'm running the analysis using the custom rules from the bug (https://github.com/selrahal/mta-bug) I just uploaded the same rules to the bookserver repo to have everything together (https://github.com/ibraginsky/book-server/tree/main/bug-3330-rules).

Since I'm analyzing the app with just these rules, validating the effort is equivalent to validate the triggering of the rules because I analyze both apps with the same rules that should be equally triggered, hence, report the same effort.

});
});

after("Clear state", function () {
Application.open(true);
target.delete();
applications.forEach((app) => app.delete());
});
});
9 changes: 9 additions & 0 deletions cypress/fixtures/custom-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
"rootPath": "custom-rules"
}
},
"rules_from_bug_3330": {
"image": "img/cloud.png",
"repository": {
"repositoryType": "git",
"repositoryUrl": "https://github.com/abrugaro/book-server",
"branch": "",
"rootPath": "bug-3330-rules"
}
},
"hazelcast_target": {
"image": "img/cloud.png",
"rulesFiles": ["xml/hazelcast.windup.xml"]
Expand Down
Loading