-
Notifications
You must be signed in to change notification settings - Fork 59
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
Gui custom capabilities testcases #2287
Changes from 22 commits
9d7de35
d87e3a2
d0c6ccc
3912ec8
00c63e9
7f8ef8f
1d1b3e0
15fe275
c87ba0d
793ae0e
07428b8
a291bef
02ec2ef
0577eae
b4639f7
8fb19ca
0e25883
cb62a26
cba79a5
1d0c0b6
4b11fd4
8a380e9
a0bb643
dc12530
b707d47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# "Custom" capabilities implementation | ||
|
||
Test verifies that admin can specify custom scripts in the platform settings and allow users to select them in the **Run capabilities** menu. | ||
|
||
**Prerequisites**: | ||
- Admin user | ||
- Non-admin user | ||
- Test tool is available to the non-admin user | ||
|
||
| Steps | Actions | Expected results | | ||
| :---: | --- | --- | | ||
| 1 | Login as the admin user from the prerequisites | | | ||
| 2 | Open the **Settings** page | | | ||
| 3 | Open the **PREFERENCES** tab | | | ||
| 4 | Click the **Launch** tab | | | ||
| 5 | Find the **`launch.capabilities`** preference | | | ||
| 6 | Save the preference value, then clear and input the following json <ul> `{` <ul> `"testCapability1": {` <ul> `"description": "Custom test capability 1"`, <br> `"commands": [` <ul> `"echo testLine1"`, <br> `"echo 'testLine1' > ~/testFile1.txt"` </ul> `]` </ul> `},` <br> `"testCapability2": {` <ul> `"description": "Custom test capability 2",` <br> `"commands": [` <ul> `"echo testLine2",` <br> `"echo 'testLine2' >> ~/testFile1.txt"` </ul> `]` </ul> `}` </ul> `}` | | ||
| 7 | Click **Save** button | | | ||
| 8 | Login as the non-admin user from the prerequisites | | | ||
| 9 | Open the **Tools** page | | | ||
| 10 | Select the test tool | | | ||
| 11 | Click the button ***Run with custom settings*** | | | ||
| 12 | Expand **Exec environment** section | | | ||
| 13 | Click into the field near the ***Run capabilities*** label | Drop-down list of capabilities appears and contains ***testCapability1*** and ***testCapability2*** | | ||
| 14 | Select ***testCapability1*** and ***testCapability2*** from list | | | ||
| 15 | Hover over ***testCapability1*** and ***testCapability2*** values in the ***Run capabilities*** field | Descriptions *Custom test capability 1* and *Custom test capability 2* are shown on the corresponding tooltips | | ||
| 16 | Launch the tool | | | ||
| 17 | At the **Runs** page, click the just-launched run | | | ||
| 18 | Expand the Parameters section | The Parameters section contains **CP_CAP_CUSTOM_testCapability1: true** and **CP_CAP_CUSTOM_testCapability2: true** | | ||
| 19 | Wait until the SSH hyperlink appears. Click the *Console* task. | Log contains next text: <ul> `Running 'testCapability1' commands:` <br> `--> Command: 'echo testLine1'` <br> `Running 'testCapability2' commands:` <br> `--> Command: 'echo testLine2'`| | ||
| 20 | Click the SSH hyperlink | | | ||
| 21 | In the opened tab, enter and perform the command: `ls` | Name of the ***testFile1.txt*** file is displayed | | ||
| 22 | Enter and perform the command: <ul> `cat testFile1.txt` | `testFile1.txt` file contains `testLine1` and `testLine2` | | ||
| 23 | Close the tab with terminal | | | ||
|
||
**After:** | ||
- Stop the run launched at step 16 | ||
- Restore the value of the `launch.capabilities` preference to the previous value saved at step 6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# "Custom" capabilities with configured job parameters | ||
|
||
Test verifies that | ||
- administrator shall be able to add params field to the capability - list of key/values. | ||
- parameters are set as the parameters for a job. | ||
|
||
**Prerequisites**: | ||
- Admin user | ||
- Non-admin user | ||
- Test tool is available to the non-admin user | ||
|
||
| Steps | Actions | Expected results | | ||
| :---: | --- | --- | | ||
| 1 | Login as the admin user from the prerequisites | | | ||
| 2 | Open the **Settings** page | | | ||
| 3 | Open the **PREFERENCES** tab | | | ||
| 4 | Click the **Launch** tab | | | ||
| 5 | Find the **`launch.capabilities`** preference | | | ||
| 6 | Save the preference value, then clear and input the following json <ul> `{` <ul> `"testCapability1": {` <ul> `"description": "Custom test capability 1"`, <br> `"commands": [` <ul> `"echo testLine1"`, <br> `"echo 'testLine1' > ~/testFile1.txt"` </ul> `],` <br> `"params": {` <ul> `"MY_PARAM1": "MY_VALUE1"`, <br> `"MY_BOOLEAN_PARAM": true,` <br> `"MY_NUMBER_PARAM": 1` </ul> `}` </ul> `},` <br> `"testCapability2": {` <ul> `"description": "Custom test capability 2",` <br> `"commands": [` <ul> `"echo testLine2",` <br> `"echo 'testLine2' > ~/testFile1.txt"` </ul> `],` <br> `"params": {` <ul> `"MY_PARAM2": "MY_VALUE2"`, <br> `"MY_BOOLEAN_PARAM": false,` <br> `"MY_NUMBER_PARAM": 2` </ul> `}` </ul> `}` </ul> `}` | | ||
| 7 | Click **Save** button | | | ||
| 8 | Login as the non-admin user from the prerequisites | | | ||
| 9 | Open the **Tools** page | | | ||
| 10 | Select the test tool | | | ||
| 11 | Click the button ***Run with custom settings*** | | | ||
| 12 | Expand **Exec environment** section | | | ||
| 13 | Click into the field near the ***Run capabilities*** label | Drop-down list of capabilities appears and contains ***testCapability1*** and ***testCapability2*** | | ||
| 14 | Select ***testCapability1*** and ***testCapability2*** from list | | | ||
| 15 | Launch the tool | | | ||
| 16 | At the **Runs** page, click the just-launched run | | | ||
| 17 | Expand the Parameters section | The Parameters section contains parameters <ul> *CP_CAP_CUSTOM_testCapability1: true* <br> *CP_CAP_CUSTOM_testCapability2: true* <br> *MY_PARAM1: MY_VALUE1* <br> *MY_PARAM2: MY_VALUE2* <br> *MY_BOOLEAN_PARAM: false* <br> *MY_NUMBER_PARAM: 2* | | ||
|
||
**After:** | ||
- Stop the run launched at step 15 | ||
- Restore the value of the `launch.capabilities` preference to the previous value saved at step 6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2017-2019 EPAM Systems, Inc. (https://www.epam.com/) | ||
* Copyright 2017-2021 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. | ||
|
@@ -16,35 +16,72 @@ | |
package com.epam.pipeline.autotests; | ||
|
||
import com.epam.pipeline.autotests.ao.RunsMenuAO; | ||
import com.epam.pipeline.autotests.ao.ToolTab; | ||
import com.epam.pipeline.autotests.mixins.Authorization; | ||
import com.epam.pipeline.autotests.mixins.Tools; | ||
import com.epam.pipeline.autotests.utils.C; | ||
import com.epam.pipeline.autotests.utils.TestCase; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import static com.codeborne.selenide.Condition.exist; | ||
import static com.codeborne.selenide.Condition.matchText; | ||
import static com.codeborne.selenide.Selenide.open; | ||
import static com.epam.pipeline.autotests.ao.LogAO.configurationParameter; | ||
import static com.epam.pipeline.autotests.ao.LogAO.log; | ||
import static com.epam.pipeline.autotests.ao.LogAO.taskWithName; | ||
import static com.epam.pipeline.autotests.ao.Primitive.DISK; | ||
import static com.epam.pipeline.autotests.ao.Primitive.EXEC_ENVIRONMENT; | ||
import static com.epam.pipeline.autotests.ao.Primitive.PARAMETERS; | ||
import static com.epam.pipeline.autotests.ao.Primitive.RUN_CAPABILITIES; | ||
import static com.epam.pipeline.autotests.utils.Utils.readResourceFully; | ||
import static java.lang.String.format; | ||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
|
||
public class ToolsParametersTest | ||
extends AbstractSinglePipelineRunningTest | ||
implements Tools { | ||
extends AbstractSeveralPipelineRunningTest | ||
implements Authorization, Tools { | ||
|
||
private final String tool = C.TESTING_TOOL_NAME; | ||
private final String registry = C.DEFAULT_REGISTRY; | ||
private final String group = C.DEFAULT_GROUP; | ||
private final String invalidEndpoint = "8700"; | ||
private final String launchCapabilities = "launch.capabilities"; | ||
private static final String CUSTOM_CAPABILITIES_1_JSON = "/customCapabilities1.json"; | ||
private static final String CUSTOM_CAPABILITIES_2_JSON = "/customCapabilities2.json"; | ||
private String prefInitialValue = ""; | ||
private final String custCapability1 = "testCapability1"; | ||
private final String custCapability2 = "testCapability2"; | ||
|
||
@BeforeClass | ||
public void getPreferencesValue() { | ||
open(C.ROOT_ADDRESS); | ||
fallbackToToolDefaultState(registry, group, tool); | ||
prefInitialValue = navigationMenu() | ||
.settings() | ||
.switchToPreferences() | ||
.getPreference(launchCapabilities); | ||
} | ||
|
||
@AfterClass(alwaysRun = true) | ||
public void fallBackToDefaultToolSettings() { | ||
logoutIfNeeded(); | ||
loginAs(admin); | ||
open(C.ROOT_ADDRESS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we open the root address twice (we already open it in loginAs())? |
||
fallbackToToolDefaultState(registry, group, tool); | ||
navigationMenu() | ||
.settings() | ||
.switchToPreferences() | ||
.clearAndSetJsonToPreference(launchCapabilities, prefInitialValue, true) | ||
.saveIfNeeded(); | ||
} | ||
|
||
@Test | ||
@TestCase(value = {"EPMCMBIBPC-502"}) | ||
public void runToolThatHaveNoNginxEndpoint() { | ||
logoutIfNeeded(); | ||
loginAs(admin); | ||
tools() | ||
.perform(registry, group, tool, tool -> | ||
tool.settings() | ||
|
@@ -54,11 +91,83 @@ public void runToolThatHaveNoNginxEndpoint() { | |
.save() | ||
.run(this) | ||
) | ||
.showLog(getRunId()); | ||
.showLog(getLastRunId()); | ||
new RunsMenuAO() | ||
.waitForInitializeNode(getRunId()) | ||
.waitForInitializeNode(getLastRunId()) | ||
.clickEndpoint() | ||
.screenshot("test501screenshot") | ||
.assertPageTitleIs("502 Bad Gateway"); | ||
} | ||
|
||
@Test | ||
@TestCase(value = {"2234"}) | ||
public void customCapabilitiesImplementation() { | ||
logoutIfNeeded(); | ||
loginAs(admin); | ||
navigationMenu() | ||
.settings() | ||
.switchToPreferences() | ||
.clearAndSetJsonToPreference(launchCapabilities, | ||
readResourceFully(CUSTOM_CAPABILITIES_1_JSON), true) | ||
.saveIfNeeded(); | ||
logout(); | ||
loginAs(user); | ||
tools() | ||
.perform(registry, group, tool, ToolTab::runWithCustomSettings) | ||
.expandTab(EXEC_ENVIRONMENT) | ||
.selectValue(RUN_CAPABILITIES, custCapability1) | ||
.click(DISK) | ||
.selectValue(RUN_CAPABILITIES, custCapability2) | ||
.checkTooltipText(custCapability1, "Custom test capability 1") | ||
.checkTooltipText(custCapability2, "Custom test capability 2") | ||
.launch(this) | ||
.showLog(getLastRunId()) | ||
.expandTab(PARAMETERS) | ||
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability1), "true"), exist) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "CP_CAP_CUSTOM_%s" can be constant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability2), "true"), exist) | ||
.waitForSshLink() | ||
.click(taskWithName("Console")) | ||
.waitForLog("start.sh") | ||
.ensure(log(), matchText(format("Running '%s' commands:", custCapability1))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Running '%s' commands:" can be constant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
.ensure(log(), matchText(format("Running '%s' commands:", custCapability2))) | ||
.ensure(log(), matchText( "Command: 'echo testLine1'")) | ||
.ensure(log(), matchText( "Command: 'echo testLine2'")) | ||
.ssh(shell -> shell | ||
.waitUntilTextAppears(getLastRunId()) | ||
.execute("ls") | ||
.assertOutputContains("testFile1.txt") | ||
.execute("cat testFile1.txt") | ||
.assertOutputContains("testLine1", "testLine2") | ||
.close()); | ||
} | ||
|
||
@Test | ||
@TestCase(value = {"2295"}) | ||
public void customCapabilitiesWithConfiguredJobParameters() { | ||
logoutIfNeeded(); | ||
loginAs(admin); | ||
navigationMenu() | ||
.settings() | ||
.switchToPreferences() | ||
.clearAndSetJsonToPreference(launchCapabilities, | ||
readResourceFully(CUSTOM_CAPABILITIES_2_JSON), true) | ||
.saveIfNeeded(); | ||
logout(); | ||
loginAs(user); | ||
tools() | ||
.perform(registry, group, tool, ToolTab::runWithCustomSettings) | ||
.expandTab(EXEC_ENVIRONMENT) | ||
.selectValue(RUN_CAPABILITIES, custCapability1) | ||
.click(DISK) | ||
.selectValue(RUN_CAPABILITIES, custCapability2) | ||
.launch(this) | ||
.showLog(getLastRunId()) | ||
.expandTab(PARAMETERS) | ||
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability1), "true"), exist) | ||
.ensure(configurationParameter(format("CP_CAP_CUSTOM_%s", custCapability2), "true"), exist) | ||
.ensure(configurationParameter("MY_PARAM1", "MY_VALUE1"), exist) | ||
.ensure(configurationParameter("MY_PARAM2", "MY_VALUE2"), exist) | ||
.ensure(configurationParameter("MY_BOOLEAN_PARAM", "false"), exist) | ||
.ensure(configurationParameter("MY_NUMBER_PARAM", "2"), exist); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1175,6 +1175,30 @@ public PreferencesAO setPreference(String preference, String value, boolean eyeI | |
return this; | ||
} | ||
|
||
public String getPreference(String preference) { | ||
searchPreference(preference); | ||
String[] strings = context().$(byClassName("CodeMirror-code")) | ||
.findAll(byClassName("CodeMirror-line")).texts().toArray(new String[0]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should we result in String[] instead of List? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
return String.join("\n", strings); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if |
||
} | ||
|
||
public PreferencesAO clearAndSetJsonToPreference(String preference, String value, boolean eyeIsChecked) { | ||
SelenideElement pref = context().$(byClassName("preference-group__code-editor")); | ||
searchPreference(preference); | ||
Utils.clearTextField(pref); | ||
Utils.clickAndSendKeysWithSlashes(pref, value); | ||
for (int i = 0; i < 100; i++) { | ||
actions().sendKeys(Keys.DELETE).perform(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this? |
||
final SelenideElement eye = context().find(byClassName("preference-group__preference-row")) | ||
.find(byClassName("anticon")); | ||
if((eye.has(cssClass("anticon-eye-o")) && eyeIsChecked) || | ||
(eye.has(cssClass("anticon-eye")) && !eyeIsChecked)) { | ||
eye.click(); | ||
} | ||
return this; | ||
} | ||
|
||
public PreferencesAO setCheckboxPreference(String preference, boolean checkboxIsEnable, boolean eyeIsChecked) { | ||
searchPreference(preference); | ||
final SelenideElement checkBox = context().shouldBe(visible) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"testCapability1": { | ||
"description": "Custom test capability 1", | ||
"commands": [ | ||
"echo testLine1", | ||
"echo 'testLine1' > ~/testFile1.txt" | ||
] | ||
}, | ||
"testCapability2": { | ||
"description": "Custom test capability 2", | ||
"commands": [ | ||
"echo testLine2", | ||
"echo 'testLine2' >> ~/testFile1.txt" | ||
] | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a new line, please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"testCapability1": { | ||
"description": "Custom test capability 1", | ||
"commands": [ | ||
"echo testLine1", | ||
"echo 'testLine1' > ~/testFile1.txt" | ||
], | ||
"params": { | ||
"MY_PARAM1": "MY_VALUE1", | ||
"MY_BOOLEAN_PARAM": true, | ||
"MY_NUMBER_PARAM": 1 | ||
} | ||
}, | ||
"testCapability2": { | ||
"description": "Custom test capability 2", | ||
"commands": [ | ||
"echo testLine2", | ||
"echo 'testLine2' >> ~/testFile1.txt" | ||
], | ||
"params": { | ||
"MY_PARAM2": "MY_VALUE2", | ||
"MY_BOOLEAN_PARAM": false, | ||
"MY_NUMBER_PARAM": 2 | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a new line, please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move constants over instance variables
https://www.oracle.com/java/technologies/javase/codeconventions-fileorganization.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done