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

Add e2e-tests for Run Restriction #3181

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import static com.codeborne.selenide.Condition.*;
import static com.codeborne.selenide.Selectors.*;
import static com.codeborne.selenide.Selectors.byClassName;
import static com.codeborne.selenide.Selenide.*;
import static com.epam.pipeline.autotests.ao.Primitive.*;
import static com.epam.pipeline.autotests.utils.PipelineSelectors.button;
Expand All @@ -45,6 +46,7 @@
import static org.openqa.selenium.By.tagName;
import org.openqa.selenium.NoSuchWindowException;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;

public class PipelineRunFormAO implements AccessObject<PipelineRunFormAO> {
Expand All @@ -62,7 +64,7 @@ public class PipelineRunFormAO implements AccessObject<PipelineRunFormAO> {
entry(DISK, context().find(byId("exec.disk"))),
entry(TIMEOUT, context().find(byId("advanced.timeout"))),
entry(CONFIGURATION, context().find(byXpath("//*[.//*[contains(text(), 'Configuration name')] and contains(@class, 'ant-select-selection')]"))),
entry(LAUNCH_CLUSTER, context().find(byText("Configure cluster"))),
entry(LAUNCH_CLUSTER, context().find(byClassName("underline"))),
entry(START_IDLE, context().find(byText("Start idle")).closest(".ant-checkbox-wrapper")),
entry(EXEC_ENVIRONMENT, context().find(byId("launch-pipeline-exec-environment-panel"))),
entry(ADVANCED_PANEL, context().find(byId("launch-pipeline-advanced-panel"))),
Expand Down Expand Up @@ -203,7 +205,7 @@ public PipelineRunFormAO checkTooltipText(String capability, String tooltip) {
return this;
}

public ConfigureClusterPopupAO enableClusterLaunch() {
public ConfigureClusterPopupAO<PipelineRunFormAO> enableClusterLaunch() {
click(LAUNCH_CLUSTER);
return new ConfigureClusterPopupAO(this);
}
Expand Down Expand Up @@ -304,7 +306,7 @@ private boolean checkMessage(final String typeMessage, final String message) {
.findBy(text("Launch"))
.find(byClassName("ob-estimated-price-info__info"))
.shouldBe(visible);
boolean messageExist = context().$(byClassName("ant-modal-body"))
boolean messageExist = context().$(byClassName("ant-confirm-content"))
.findAll(byClassName(format("ant-alert-%s", typeMessage)))
.stream()
.map(SelenideElement::getText)
Expand Down Expand Up @@ -337,6 +339,12 @@ public PipelineRunFormAO launch() {
return this;
}

public PipelineRunFormAO launchWithError(String errorMessage) {
launch();
messageShouldAppear(errorMessage);
return this;
}

public PipelineRunFormAO validateThereIsParameterOfType(String name, String value, ParameterType type, boolean required) {
final String parameterNameClass = "launch-pipeline-form__parameter-name";
final SelenideElement nameElement = $(byXpath(format(
Expand Down Expand Up @@ -411,7 +419,7 @@ public PipelineRunFormAO chooseConfiguration(final String profileName) {
}

public PipelineRunFormAO checkConfigureClusterLabel(String label) {
context().find(byXpath(".//div[@class='ant-row-flex launch-pipeline-form__form-item-container']/a"))
context().find(byClassName("underline"))
.shouldBe(visible).shouldHave(text(label));
return this;
}
Expand Down Expand Up @@ -575,16 +583,17 @@ public SystemParameterPopupAO<PARENT_AO> validateNotFoundParameters() {
}
}

public static class ConfigureClusterPopupAO extends PopupAO<ConfigureClusterPopupAO, PipelineRunFormAO> {
public static class ConfigureClusterPopupAO<PARENT_AO> extends PopupAO<ConfigureClusterPopupAO<PARENT_AO>, PARENT_AO> {

private final Map<Primitive, SelenideElement> elements = initialiseElements(
entry(WORKERS_PRICE_TYPE, context().find(byText("Workers price type:")).parent().find(byClassName("ant-select-selection--single"))),
entry(WORKERS_PRICE_TYPE, context().find(byText("Workers price type:"))
.parent().find(byClassName("ant-select-selection--single"))),
entry(WORKING_NODES, context().find(byXpath("(.//*[@class = 'ant-input-number-input'])[1]"))),
entry(DEFAULT_CHILD_NODES, context().find(byXpath("(.//*[@class = 'ant-input-number-input'])[last()]"))),
entry(RESET, context().$(byXpath("//*[contains(text(), 'Reset')]")))
);

public ConfigureClusterPopupAO(PipelineRunFormAO parentAO) {
public ConfigureClusterPopupAO(PARENT_AO parentAO) {
super(parentAO);
}

Expand All @@ -593,7 +602,7 @@ public Map<Primitive, SelenideElement> elements() {
return elements;
}

public ConfigureClusterPopupAO clusterSettingsForm(String type){
public ConfigureClusterPopupAO<PARENT_AO> clusterSettingsForm(String type){
if (type.equals("Single node") || type.equals("Cluster") || type.equals("Auto-scaled cluster")) {
context()
.find(byXpath(
Expand All @@ -605,33 +614,36 @@ public ConfigureClusterPopupAO clusterSettingsForm(String type){
return this;
}

public ConfigureClusterPopupAO setWorkingNodesCount(final String nodesCount) {
public ConfigureClusterPopupAO<PARENT_AO> setWorkingNodesCount(final String nodesCount) {
return setValue(WORKING_NODES, nodesCount);
}

public ConfigureClusterPopupAO setDefaultChildNodes(final String nodesCount) {
$(byText("Setup default child nodes count")).click();
public ConfigureClusterPopupAO<PARENT_AO> setDefaultChildNodes(final String nodesCount) {
final SelenideElement setupDefault = $(byText("Setup default child nodes count"));
if(setupDefault.exists()) {
setupDefault.click();
}
return setValue(DEFAULT_CHILD_NODES, nodesCount);
}

public ConfigureClusterPopupAO resetClusterChildNodes () {
public ConfigureClusterPopupAO<PARENT_AO> resetClusterChildNodes () {
return click(RESET);
}

public ConfigureClusterPopupAO setWorkersPriceType(final String priceType) {
public ConfigureClusterPopupAO<PARENT_AO> setWorkersPriceType(final String priceType) {
click(WORKERS_PRICE_TYPE);
context().find(visible(byClassName("ant-select-dropdown"))).find(byText(priceType))
.shouldBe(visible)
.click();
return this;
}

public ConfigureClusterPopupAO enableHybridClusterSelect () {
public ConfigureClusterPopupAO<PARENT_AO> enableHybridClusterSelect () {
$(byXpath(".//span[.='Enable Hybrid cluster']/preceding-sibling::span")).click();
return this;
}

public ConfigureClusterPopupAO clusterEnableCheckboxSelect(String checkBox){
public ConfigureClusterPopupAO<PARENT_AO> clusterEnableCheckboxSelect(String checkBox){
if (checkBox.equals("Enable GridEngine")
|| checkBox.equals("Enable Apache Spark")
|| checkBox.equals("Enable Slurm")
Expand All @@ -645,5 +657,20 @@ public ConfigureClusterPopupAO clusterEnableCheckboxSelect(String checkBox){
}
return this;
}

public ConfigureClusterPopupAO<PARENT_AO> checkWarningMessageExist(final String message) {
sleep(5, SECONDS);
assertEquals(message,
$(byClassName("ant-modal-content")).find(byClassName("ant-alert-message")).text(),
format("Message '%s' isn't visible", message));
return this;
}

public ConfigureClusterPopupAO<PARENT_AO> checkWarningMessageNotExist() {
sleep(5, SECONDS);
assertFalse($(byClassName("ant-modal-content")).find(byClassName("ant-alert-message")).exists(),
"Warning message shouldn't be visible");
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ public RunsMenuAO resume(final String runId, final String pipelineName) {
return this;
}

public PipelineRunFormAO rerun(final String runId) {
$("#run-" + runId + "-rerun-button").shouldBe(visible).click();
return new PipelineRunFormAO();
}

public RunsMenuAO waitUntilStopButtonAppear(final String runId) {
$("#run-" + runId + "-stop-button").waitUntil(appear, APPEARING_TIMEOUT);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openqa.selenium.Keys;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

import java.awt.*;
import java.awt.datatransfer.StringSelection;
Expand Down Expand Up @@ -841,6 +842,16 @@ public UsersTabAO deleteUser(final String user) {

public EditUserPopup addAllowedLaunchOptions(final String option, final String mask) {
SettingsPageAO.this.addAllowedLaunchOptions(option, mask);
sleep(1, SECONDS);
return this;
}

public EditUserPopup addAllowedInstanceMaxCount(final String value) {
if (StringUtils.isBlank(value)) {
clearByKey(byClassName("ant-input-number-input"));
return this;
}
setValue(byClassName("ant-input-number-input"), value);
return this;
}

Expand Down Expand Up @@ -954,6 +965,13 @@ public CreateGroupPopup pressCreateGroup() {
return new CreateGroupPopup(this);
}

public GroupsTabAO createGroupIfNoPresent(final String group) {
searchGroupBySubstring(group.split(StringUtils.SPACE)[0]);
performIf(!context().$$(byText(group)).filterBy(visible).first().exists(), t ->
pressCreateGroup().enterGroupName(group).create());
return this;
}

public GroupsTabAO deleteGroupIfPresent(String group) {
sleep(2, SECONDS);
searchGroupBySubstring(group.split(StringUtils.SPACE)[0]);
Expand Down Expand Up @@ -1044,7 +1062,9 @@ public class EditGroupPopup extends PopupAO<EditGroupPopup, GroupsTabAO>
public final Map<Primitive, SelenideElement> elements = initialiseElements(
entry(OK, context().find(By.id("close-edit-user-form"))),
entry(PRICE_TYPE, context().find(byXpath(
format("//div/b[text()='%s']/following::div/input", "Allowed price types"))))
format("//div/b[text()='%s']/following::div/input", "Allowed price types")))),
entry(SEARCH, $(By.id("find-user-autocomplete-container"))),
entry(ADD, context().find(By.id("add-user-button")))
);

public EditGroupPopup(final GroupsTabAO parentAO) {
Expand All @@ -1063,8 +1083,28 @@ public GroupsTabAO ok() {
return parentAO;
}

public EditGroupPopup addUser(final Account name) {
click(SEARCH);
actions().sendKeys(name.login).perform();
$(byClassName("ant-select-dropdown")).shouldBe(Condition.visible);
enter();
click(ADD);
return this;
}

public EditGroupPopup addAllowedLaunchOptions(String option, String mask) {
SettingsPageAO.this.addAllowedLaunchOptions(option, mask);
sleep(1, SECONDS);
return this;
}

public EditGroupPopup addAllowedInstanceMaxCount(final String value) {
final By optionField = byClassName("ant-input-number-input");
if (StringUtils.isBlank(value)) {
clearByKey(optionField);
return this;
}
setValue(optionField, value);
return this;
}

Expand Down Expand Up @@ -1243,6 +1283,16 @@ public PreferencesAO setPreference(String preference, String value, boolean eyeI
return this;
}

public PreferencesAO setNumberPreference(final String preference,
final String value,
final boolean eyeIsChecked) {
searchPreference(preference);
final Actions action = actions().moveToElement($(byClassName("CodeMirror-line"))).click();
action.sendKeys(Keys.chord(Keys.CONTROL, "a")).sendKeys(value).perform();
setEyeOption(eyeIsChecked);
return this;
}

public String[] getPreference(String preference) {
searchPreference(preference);
$(byClassName("CodeMirror-code")).shouldBe(visible);
Expand Down Expand Up @@ -1837,8 +1887,10 @@ private void addAllowedLaunchOptions(final String option, final String mask) {
final By optionField = byXpath(format("//div/b[text()='%s']/following::div/input", option));
if (StringUtils.isBlank(mask)) {
clearByKey(optionField);
sleep(3, SECONDS);
return;
}
setValue(optionField, mask);
sleep(3, SECONDS);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 EPAM Systems, Inc. (https://www.epam.com/)
* Copyright 2017-2023 EPAM Systems, Inc. (https://www.epam.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -98,6 +98,8 @@ public ShellAO assertOutputDoesNotContain(String... messages) {
}

public ShellAO assertPageAfterCommandContainsStrings(String command, String... messages) {
sleep(2, SECONDS);
screenshot("check_command_out_" + Utils.randomSuffix());
Arrays.stream(messages)
.forEach(message -> assertTrue(lastCommandResult(command).contains(message)));
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 EPAM Systems, Inc. (https://www.epam.com/)
* Copyright 2017-2023 EPAM Systems, Inc. (https://www.epam.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.SelenideElement;
import com.epam.pipeline.autotests.utils.PipelineSelectors;
import com.epam.pipeline.autotests.utils.Utils;
import java.util.Arrays;
import java.util.List;
Expand All @@ -31,18 +30,17 @@
import static com.codeborne.selenide.Condition.enabled;
import static com.codeborne.selenide.Condition.exist;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selectors.by;
import static com.codeborne.selenide.Selectors.byAttribute;
import static com.codeborne.selenide.Selectors.byClassName;
import static com.codeborne.selenide.Selectors.byCssSelector;
import static com.codeborne.selenide.Selectors.byId;
import static com.codeborne.selenide.Selectors.byText;
import static com.codeborne.selenide.Selectors.byTitle;
import static com.codeborne.selenide.Selectors.byValue;
import static com.codeborne.selenide.Selectors.byXpath;
import static com.codeborne.selenide.Selectors.withText;
import static com.codeborne.selenide.Selenide.$;
import static com.epam.pipeline.autotests.ao.Primitive.*;
import static com.epam.pipeline.autotests.ao.PipelineRunFormAO.ConfigureClusterPopupAO;
import static com.epam.pipeline.autotests.utils.PipelineSelectors.button;
import static com.epam.pipeline.autotests.utils.PipelineSelectors.visible;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down Expand Up @@ -82,7 +80,8 @@ public ToolSettings(final ToolGroup toolGroup, final String toolName) {
entry(ADD_SYSTEM_PARAMETER, context().find(button("Add system parameters"))),
entry(ADD_PARAMETER, context().find(byId("add-parameter-button"))),
entry(RUN_CAPABILITIES, context().find(byXpath("//*[contains(text(), 'Run capabilities')]"))
.closest(".ant-row").find(className("ant-form-item-control ")))
.closest(".ant-row").find(className("ant-form-item-control "))),
entry(LAUNCH_CLUSTER, context().find(byClassName("underline")))
);
}

Expand Down Expand Up @@ -298,4 +297,9 @@ public ToolSettings checkCapabilityTooltip(final String capability, final String
.shouldHave(Condition.text(text));
return this;
}

public ConfigureClusterPopupAO<ToolSettings> enableClusterLaunch() {
click(LAUNCH_CLUSTER);
return new ConfigureClusterPopupAO<>(this);
}
}
6 changes: 6 additions & 0 deletions e2e/gui/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,12 @@
</classes>
</test>

<test name="LaunchParametersRestrictionRunsTest">
<classes>
<class name="com.epam.pipeline.autotests.LaunchParametersRestrictionRunsTest"/>
</classes>
</test>

<test name="RestrictionsOnInstancePriceTypeTest">
<classes>
<class name="com.epam.pipeline.autotests.RestrictionsOnInstancePriceTypeTest"/>
Expand Down