@eclipse-che/che-e2e 7.64.0-dev-2c00276 → 7.64.1-dev-43c3317
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/inversify.config.ts +10 -4
- package/configs/inversify.types.ts +3 -0
- package/constants/TestConstants.ts +14 -1
- package/constants/TimeoutConstants.ts +3 -3
- package/dist/configs/inversify.config.js +7 -3
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +3 -0
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/constants/TestConstants.js +12 -2
- package/dist/constants/TestConstants.js.map +1 -1
- package/dist/constants/TimeoutConstants.js +3 -3
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +5 -4
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +4 -1
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +5 -0
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/RedHatLoginPage.js +14 -15
- package/dist/pageobjects/login/RedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpApplicationPage.js +60 -0
- package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -0
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js +91 -0
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -0
- package/dist/pageobjects/openshift/OcpLoginPage.js +3 -3
- package/dist/pageobjects/openshift/OcpLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpMainPage.js +108 -0
- package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -0
- package/dist/specs/api/CloneGitRepoAPI.spec.js +7 -7
- package/dist/specs/api/CloneGitRepoAPI.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js +36 -0
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -0
- package/dist/specs/api/PodOverridesAPI.spec.js +42 -0
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -0
- package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js +58 -19
- package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js.map +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +75 -0
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -0
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js +19 -10
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js +4 -0
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +2 -2
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +16 -1
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js +6 -0
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DriverHelper.js +29 -3
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +162 -0
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -0
- package/dist/utils/ShellExecutor.js +15 -0
- package/dist/utils/ShellExecutor.js.map +1 -0
- package/index.ts +5 -1
- package/package.json +4 -3
- package/pageobjects/dashboard/Dashboard.ts +5 -4
- package/pageobjects/dashboard/Workspaces.ts +5 -2
- package/pageobjects/ide/CheCodeLocatorLoader.ts +5 -0
- package/pageobjects/login/RedHatLoginPage.ts +14 -16
- package/pageobjects/openshift/OcpApplicationPage.ts +42 -0
- package/pageobjects/openshift/OcpImportFromGitPage.ts +87 -0
- package/pageobjects/openshift/OcpLoginPage.ts +3 -3
- package/pageobjects/openshift/OcpMainPage.ts +109 -0
- package/resources/container-overrides.yaml +28 -0
- package/resources/pod-overrides.yaml +37 -0
- package/specs/api/CloneGitRepoAPI.spec.ts +8 -7
- package/specs/api/ContainerOverridesAPI.spec.ts +37 -0
- package/specs/api/PodOverridesAPI.spec.ts +43 -0
- package/specs/dashboard-samples/RecomendedExtentions.spec.ts +73 -21
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +98 -0
- package/specs/factory/Factory.spec.ts +1 -1
- package/specs/factory/NoSetupRepoFactory.spec.ts +1 -1
- package/specs/factory/RefusedOAuthFactory.spec.ts +1 -1
- package/tests-library/LoginTests.ts +17 -7
- package/tests-library/ProjectAndFileTests.ts +4 -0
- package/tests-library/WorkspaceHandlingTests.ts +2 -2
- package/utils/BrowserTabsUtil.ts +18 -3
- package/utils/CheReporter.ts +6 -0
- package/utils/DriverHelper.ts +36 -4
- package/utils/KubernetesCommandLineToolsExecutor.ts +167 -0
- package/utils/ShellExecutor.ts +13 -0
- package/dist/utils/OpenshiftClientExecutor.js +0 -98
- package/dist/utils/OpenshiftClientExecutor.js.map +0 -1
- package/utils/OpenshiftClientExecutor.ts +0 -117
package/utils/DriverHelper.ts
CHANGED
|
@@ -48,6 +48,12 @@ export class DriverHelper {
|
|
|
48
48
|
await this.driver.sleep(milliseconds);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
public async refreshPage(): Promise<void> {
|
|
52
|
+
Logger.trace(`DriverHelper.refreshPage`);
|
|
53
|
+
|
|
54
|
+
await this.driver.navigate().refresh();
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
public async waitVisibilityBoolean(locator: By,
|
|
52
58
|
attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
|
|
53
59
|
polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
|
|
@@ -273,12 +279,27 @@ export class DriverHelper {
|
|
|
273
279
|
await element.click();
|
|
274
280
|
return;
|
|
275
281
|
} catch (err) {
|
|
276
|
-
|
|
277
|
-
|
|
282
|
+
function isElementClickInterceptedOnLastAttempt(err: Error, i: number): boolean {
|
|
283
|
+
return err instanceof error.ElementClickInterceptedError && i === attempts - 1;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (err instanceof error.StaleElementReferenceError || err instanceof error.ElementClickInterceptedError) {
|
|
287
|
+
Logger.debug(`DriverHelper.waitAndClick - ${elementLocator} - ${err}`);
|
|
278
288
|
await this.wait(polling);
|
|
279
289
|
continue;
|
|
280
290
|
}
|
|
281
291
|
|
|
292
|
+
if (isElementClickInterceptedOnLastAttempt(err, i)) {
|
|
293
|
+
Logger.debug(`DriverHelper.waitAndClick - Element is not clickable, try to perform pointer click`);
|
|
294
|
+
await this.getAction()
|
|
295
|
+
.move({
|
|
296
|
+
origin: await this.waitPresence(elementLocator)
|
|
297
|
+
})
|
|
298
|
+
.click()
|
|
299
|
+
.perform();
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
282
303
|
Logger.error(`DriverHelper.waitAndClick - failed with an unexpected exception - ${err}`);
|
|
283
304
|
throw err;
|
|
284
305
|
}
|
|
@@ -658,7 +679,8 @@ export class DriverHelper {
|
|
|
658
679
|
}
|
|
659
680
|
|
|
660
681
|
try {
|
|
661
|
-
await this.
|
|
682
|
+
await this.getDriver()
|
|
683
|
+
.executeScript('arguments[0].scrollIntoView(true);', element);
|
|
662
684
|
return;
|
|
663
685
|
} catch (err) {
|
|
664
686
|
if (err instanceof error.StaleElementReferenceError) {
|
|
@@ -674,7 +696,17 @@ export class DriverHelper {
|
|
|
674
696
|
throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
|
|
675
697
|
}
|
|
676
698
|
|
|
677
|
-
|
|
699
|
+
public async scrollToAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
700
|
+
await this.scrollTo(elementLocator, timeout);
|
|
701
|
+
await this.waitAndClick(elementLocator, timeout);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
public async scrollToAndEnterValue(elementLocator: By, value: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
705
|
+
await this.scrollTo(elementLocator, timeout);
|
|
706
|
+
await this.enterValue(elementLocator, value, timeout);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
getDriver(): ThenableWebDriver {
|
|
678
710
|
Logger.trace('DriverHelper.getDriver');
|
|
679
711
|
|
|
680
712
|
return this.driver;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { echo, exec, ShellString } from 'shelljs';
|
|
2
|
+
import { KubernetesCommandLineTool, TestConstants } from '../constants/TestConstants';
|
|
3
|
+
import { Logger } from './Logger';
|
|
4
|
+
import { ShellExecutor } from './ShellExecutor';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
|
|
7
|
+
export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
8
|
+
private static container: string;
|
|
9
|
+
private static pod: string;
|
|
10
|
+
private readonly namespace: string;
|
|
11
|
+
private readonly workspaceName: string | undefined;
|
|
12
|
+
private readonly KUBERNETES_COMMAND_LINE_TOOL: string = TestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
|
|
13
|
+
|
|
14
|
+
constructor(_workspaceName?: string, _namespace?: string) {
|
|
15
|
+
super();
|
|
16
|
+
this.workspaceName = _workspaceName;
|
|
17
|
+
this.namespace = this.setNamespace(_namespace);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get getWorkspaceName(): string {
|
|
21
|
+
return <string>this.workspaceName;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get getNamespace(): string {
|
|
25
|
+
return this.namespace;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// login to Openshift cluster with username and password
|
|
29
|
+
loginToOcp(): void {
|
|
30
|
+
if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
|
|
31
|
+
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login to the "OC" client.`);
|
|
32
|
+
const url: string = this.getServerUrl();
|
|
33
|
+
if (this.isUserLoggedIn()) {
|
|
34
|
+
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: User already logged`);
|
|
35
|
+
} else {
|
|
36
|
+
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${TestConstants.TS_SELENIUM_OCP_USERNAME}`);
|
|
37
|
+
exec(`oc login --server=${url} -u=${TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: doesn't support login command`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getContainerName(): string {
|
|
45
|
+
Logger.debug(`${this.getLoggingName(this.getContainerName.name)}: Get container name.`);
|
|
46
|
+
const output: ShellString = this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get ${(KubernetesCommandLineToolsExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
|
|
47
|
+
echo('\n');
|
|
48
|
+
return output.stderr ? output.stderr : output.stdout;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getWorkspacePodName(): string {
|
|
52
|
+
Logger.debug(`${this.getLoggingName(this.getWorkspacePodName.name)}: Get workspace pod name.`);
|
|
53
|
+
const output: ShellString = this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
|
|
54
|
+
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
deleteDevWorkspace(): void {
|
|
58
|
+
Logger.debug(`${this.getLoggingName(this.deleteDevWorkspace.name)}: Delete '${this.workspaceName}' workspace`);
|
|
59
|
+
this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
|
|
60
|
+
this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
61
|
+
this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dwt ${TestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
|
|
65
|
+
if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.KUBECTL) {
|
|
66
|
+
this.createNamespace();
|
|
67
|
+
}
|
|
68
|
+
this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
|
|
69
|
+
const output: ShellString = this.waitDevWorkspace();
|
|
70
|
+
KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
|
|
71
|
+
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
72
|
+
return output;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
executeCommand(commandToExecute: string): ShellString {
|
|
76
|
+
Logger.debug(`${this.getLoggingName(this.executeCommand.name)}:`);
|
|
77
|
+
return this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${KubernetesCommandLineToolsExecutor.container} -- sh -c "${commandToExecute}"`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
applyYamlConfigurationAsStringOutput(yamlConfiguration: string): void {
|
|
81
|
+
Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsStringOutput.name)}:`);
|
|
82
|
+
this.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
|
|
83
|
+
yamlConfiguration + '\n' +
|
|
84
|
+
'EOF');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
applyYamlConfigurationAsFile(pathToFile: string): void {
|
|
88
|
+
Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsFile.name)}:`);
|
|
89
|
+
this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
getDevWorkspaceYamlConfiguration(): ShellString {
|
|
93
|
+
Logger.debug(`${this.getLoggingName(this.getDevWorkspaceYamlConfiguration.name)}:`);
|
|
94
|
+
return this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
waitDevWorkspace(timeout: number = 360): ShellString {
|
|
98
|
+
Logger.debug(`${this.getLoggingName(this.waitDevWorkspace.name)}: Wait till workspace ready.`);
|
|
99
|
+
return this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
createNamespace(): void {
|
|
103
|
+
Logger.debug(`${this.getLoggingName(this.createNamespace.name)}: Create namespace "${this.namespace}".`);
|
|
104
|
+
this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
createProject(projectName: string): void {
|
|
108
|
+
Logger.debug(`${this.getLoggingName(this.createProject.name)}: Create new project "${projectName}".`);
|
|
109
|
+
this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
deleteProject(projectName: string): void {
|
|
113
|
+
Logger.debug(`${this.getLoggingName(this.deleteProject.name)}: Delete "${projectName}".`);
|
|
114
|
+
this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private isUserLoggedIn(): boolean {
|
|
118
|
+
const whoamiCommandOutput: ShellString = this.execWithLog('oc whoami && oc whoami --show-server=true');
|
|
119
|
+
|
|
120
|
+
return whoamiCommandOutput.stdout.includes(TestConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private getLoggingName(methodName: string): string {
|
|
124
|
+
return `${this.constructor.name}.${methodName} - ${(this.KUBERNETES_COMMAND_LINE_TOOL)}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private setNamespace(_namespace: string | undefined): string {
|
|
128
|
+
_namespace = _namespace !== undefined ? _namespace
|
|
129
|
+
: TestConstants.TS_SELENIUM_BASE_URL.includes('devspaces') ? TestConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
|
|
130
|
+
: TestConstants.TS_SELENIUM_BASE_URL.includes('che') ? TestConstants.TS_SELENIUM_OCP_USERNAME + '-che'
|
|
131
|
+
: 'default';
|
|
132
|
+
return _namespace;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private getServerUrl(): string {
|
|
136
|
+
Logger.debug(`${this.getLoggingName(this.getServerUrl.name)}: Get server api url.`);
|
|
137
|
+
return TestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export namespace KubernetesCommandLineToolsExecutor {
|
|
142
|
+
export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
|
|
143
|
+
constructor(cluster: KubernetesCommandLineToolsExecutor) {
|
|
144
|
+
super(cluster.getWorkspaceName, cluster.getNamespace);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
ls(path: string = ''): ShellString {
|
|
148
|
+
return this.executeCommand('ls ' + path);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
pwd(): ShellString {
|
|
152
|
+
return this.executeCommand('pwd');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
cd(path: string): ShellString {
|
|
156
|
+
return this.executeCommand('cd ' + path);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
gitClone(repository: string): ShellString {
|
|
160
|
+
return this.executeCommand('git clone ' + repository);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
removeFolder(path: string): ShellString {
|
|
164
|
+
return this.executeCommand('rm -rf ' + path);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { echo, exec, ShellString } from 'shelljs';
|
|
2
|
+
|
|
3
|
+
export class ShellExecutor {
|
|
4
|
+
|
|
5
|
+
wait(seconds: number): void {
|
|
6
|
+
this.execWithLog(`sleep ${seconds}s`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
protected execWithLog(command: string): ShellString {
|
|
10
|
+
echo(command);
|
|
11
|
+
return exec(command);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpenshiftClientExecutor = void 0;
|
|
4
|
-
const shelljs_1 = require("shelljs");
|
|
5
|
-
const TestConstants_1 = require("../constants/TestConstants");
|
|
6
|
-
const Logger_1 = require("./Logger");
|
|
7
|
-
class OpenshiftClientExecutor {
|
|
8
|
-
constructor(_workspaceName, _namespace) {
|
|
9
|
-
this.workspaceName = _workspaceName;
|
|
10
|
-
this.namespace = this.setNamespace(_namespace);
|
|
11
|
-
}
|
|
12
|
-
get getWorkspaceName() {
|
|
13
|
-
return this.workspaceName;
|
|
14
|
-
}
|
|
15
|
-
get getNamespace() {
|
|
16
|
-
return this.namespace;
|
|
17
|
-
}
|
|
18
|
-
loginToOcp() {
|
|
19
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.loginToOcp: Login to the \'OC\' client');
|
|
20
|
-
const url = this.getServerUrl();
|
|
21
|
-
Logger_1.Logger.debug(url, TestConstants_1.TestConstants.TS_SELENIUM_OCP_USERNAME);
|
|
22
|
-
shelljs_1.exec(`sleep 5
|
|
23
|
-
oc login --server=${url} -u=${TestConstants_1.TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants_1.TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
|
|
24
|
-
}
|
|
25
|
-
getContainerName() {
|
|
26
|
-
Logger_1.Logger.debug(`OpenshiftClientExecutor.getContainerName: Get container name.`);
|
|
27
|
-
const output = this.execWithLog(`oc get ${(OpenshiftClientExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
|
|
28
|
-
shelljs_1.echo('\n');
|
|
29
|
-
return output.stderr ? output.stderr : output.stdout;
|
|
30
|
-
}
|
|
31
|
-
getWorkspacePodName() {
|
|
32
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.getWorkspacePodName: Get workspace pod name.');
|
|
33
|
-
const output = this.execWithLog(`oc get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
|
|
34
|
-
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
35
|
-
}
|
|
36
|
-
deleteDevWorkspace() {
|
|
37
|
-
Logger_1.Logger.debug(`OpenshiftClientExecutor.deleteWorkspace: Delete '${this.workspaceName}' workspace`);
|
|
38
|
-
this.execWithLog(`oc patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
|
|
39
|
-
this.execWithLog(`oc delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
40
|
-
}
|
|
41
|
-
applyAndWaitDevWorkspace(yamlConfiguration) {
|
|
42
|
-
this.apply(yamlConfiguration);
|
|
43
|
-
const output = this.waitDevWorkspace();
|
|
44
|
-
OpenshiftClientExecutor.pod = this.getWorkspacePodName();
|
|
45
|
-
OpenshiftClientExecutor.container = this.getContainerName();
|
|
46
|
-
return output;
|
|
47
|
-
}
|
|
48
|
-
executeCommand(commandToExecute) {
|
|
49
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.executeCommand');
|
|
50
|
-
return this.execWithLog(`oc exec -i ${OpenshiftClientExecutor.pod} -n ${this.namespace} -c ${OpenshiftClientExecutor.container} -- sh -c "${commandToExecute}"`);
|
|
51
|
-
}
|
|
52
|
-
apply(yamlConfiguration) {
|
|
53
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.apply:');
|
|
54
|
-
this.execWithLog('cat <<EOF | oc apply -n ' + this.namespace + ' -f - \n' +
|
|
55
|
-
yamlConfiguration + '\n' +
|
|
56
|
-
'EOF');
|
|
57
|
-
}
|
|
58
|
-
waitDevWorkspace(timeout = 360) {
|
|
59
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.wait: Wait till workspace ready.');
|
|
60
|
-
return this.execWithLog(`oc wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
|
|
61
|
-
}
|
|
62
|
-
setNamespace(_namespace) {
|
|
63
|
-
return _namespace !== undefined ? _namespace : TestConstants_1.TestConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces';
|
|
64
|
-
}
|
|
65
|
-
getServerUrl() {
|
|
66
|
-
Logger_1.Logger.debug('OpenshiftClientExecutor.getServerUrl: Get server api url.');
|
|
67
|
-
return TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
68
|
-
}
|
|
69
|
-
execWithLog(command) {
|
|
70
|
-
shelljs_1.echo(command);
|
|
71
|
-
return shelljs_1.exec(command);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.OpenshiftClientExecutor = OpenshiftClientExecutor;
|
|
75
|
-
(function (OpenshiftClientExecutor) {
|
|
76
|
-
class ContainerTerminal extends OpenshiftClientExecutor {
|
|
77
|
-
constructor(cluster) {
|
|
78
|
-
super(cluster.getWorkspaceName, cluster.getNamespace);
|
|
79
|
-
}
|
|
80
|
-
ls(path = '') {
|
|
81
|
-
return this.executeCommand('ls ' + path);
|
|
82
|
-
}
|
|
83
|
-
pwd() {
|
|
84
|
-
return this.executeCommand('pwd');
|
|
85
|
-
}
|
|
86
|
-
cd(path) {
|
|
87
|
-
return this.executeCommand('cd ' + path);
|
|
88
|
-
}
|
|
89
|
-
gitClone(repository) {
|
|
90
|
-
return this.executeCommand('git clone ' + repository);
|
|
91
|
-
}
|
|
92
|
-
removeFolder(path) {
|
|
93
|
-
return this.executeCommand('rm -rf ' + path);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
OpenshiftClientExecutor.ContainerTerminal = ContainerTerminal;
|
|
97
|
-
})(OpenshiftClientExecutor = exports.OpenshiftClientExecutor || (exports.OpenshiftClientExecutor = {}));
|
|
98
|
-
//# sourceMappingURL=OpenshiftClientExecutor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OpenshiftClientExecutor.js","sourceRoot":"","sources":["../../utils/OpenshiftClientExecutor.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAClD,8DAA2D;AAC3D,qCAAkC;AAElC,MAAa,uBAAuB;IAMhC,YAAY,cAAuB,EAAE,UAAmB;QACpD,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,gBAAgB;QAChB,OAAe,IAAI,CAAC,aAAa,CAAC;IACtC,CAAC;IAED,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,C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,CAAC,2DAA2D,CAAC,CAAC;QAC1E,OAAO,6BAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC;IACzF,CAAC;IAEO,WAAW,CAAC,OAAe;QAC/B,cAAI,CAAC,OAAO,CAAC,CAAC;QACd,OAAO,cAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CACJ;AApFD,0DAoFC;AAED,WAAiB,uBAAuB;IACpC,MAAa,iBAAkB,SAAQ,uBAAuB;QAC1D,YAAY,OAAgC;YACxC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC;QAED,EAAE,CAAC,OAAe,EAAE;YAChB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,GAAG;YACC,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,EAAE,CAAC,IAAY;YACX,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC;QAED,QAAQ,CAAC,UAAkB;YACvB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,GAAG,UAAU,CAAC,CAAC;QAC1D,CAAC;QAED,YAAY,CAAC,IAAY;YACrB,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QACjD,CAAC;KACJ;IAxBY,yCAAiB,oBAwB7B,CAAA;AACL,CAAC,EA1BgB,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QA0BvC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { echo, exec, ShellString } from 'shelljs';
|
|
2
|
-
import { TestConstants } from '../constants/TestConstants';
|
|
3
|
-
import { Logger } from './Logger';
|
|
4
|
-
|
|
5
|
-
export class OpenshiftClientExecutor {
|
|
6
|
-
protected static container: string;
|
|
7
|
-
protected static pod: string | undefined;
|
|
8
|
-
protected workspaceName: string | undefined;
|
|
9
|
-
protected namespace: string;
|
|
10
|
-
|
|
11
|
-
constructor(_workspaceName?: string, _namespace?: string) {
|
|
12
|
-
this.workspaceName = _workspaceName;
|
|
13
|
-
this.namespace = this.setNamespace(_namespace);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get getWorkspaceName(): string {
|
|
17
|
-
return <string>this.workspaceName;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get getNamespace(): string {
|
|
21
|
-
return this.namespace;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
loginToOcp(): void {
|
|
25
|
-
Logger.debug('OpenshiftClientExecutor.loginToOcp: Login to the \'OC\' client');
|
|
26
|
-
const url: string = this.getServerUrl();
|
|
27
|
-
Logger.debug(url, TestConstants.TS_SELENIUM_OCP_USERNAME);
|
|
28
|
-
exec(`sleep 5
|
|
29
|
-
oc login --server=${url} -u=${TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getContainerName(): string {
|
|
33
|
-
Logger.debug(`OpenshiftClientExecutor.getContainerName: Get container name.`);
|
|
34
|
-
const output: ShellString = this.execWithLog(`oc get ${(OpenshiftClientExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
|
|
35
|
-
echo('\n');
|
|
36
|
-
return output.stderr ? output.stderr : output.stdout;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getWorkspacePodName(): string {
|
|
40
|
-
Logger.debug('OpenshiftClientExecutor.getWorkspacePodName: Get workspace pod name.');
|
|
41
|
-
const output: ShellString = this.execWithLog(`oc get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
|
|
42
|
-
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
deleteDevWorkspace(): void {
|
|
46
|
-
Logger.debug(`OpenshiftClientExecutor.deleteWorkspace: Delete '${this.workspaceName}' workspace`);
|
|
47
|
-
this.execWithLog(`oc patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
|
|
48
|
-
this.execWithLog(`oc delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
|
|
52
|
-
this.apply(yamlConfiguration);
|
|
53
|
-
const output: ShellString = this.waitDevWorkspace();
|
|
54
|
-
OpenshiftClientExecutor.pod = this.getWorkspacePodName();
|
|
55
|
-
OpenshiftClientExecutor.container = this.getContainerName();
|
|
56
|
-
return output;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
executeCommand(commandToExecute: string): ShellString {
|
|
60
|
-
Logger.debug('OpenshiftClientExecutor.executeCommand');
|
|
61
|
-
return this.execWithLog(`oc exec -i ${OpenshiftClientExecutor.pod} -n ${this.namespace} -c ${OpenshiftClientExecutor.container} -- sh -c "${commandToExecute}"`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
apply(yamlConfiguration: string): void {
|
|
65
|
-
Logger.debug('OpenshiftClientExecutor.apply:');
|
|
66
|
-
this.execWithLog('cat <<EOF | oc apply -n ' + this.namespace + ' -f - \n' +
|
|
67
|
-
yamlConfiguration + '\n' +
|
|
68
|
-
'EOF');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
waitDevWorkspace(timeout: number = 360): ShellString {
|
|
72
|
-
Logger.debug('OpenshiftClientExecutor.wait: Wait till workspace ready.');
|
|
73
|
-
return this.execWithLog(`oc wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private setNamespace(_namespace: string | undefined): string {
|
|
77
|
-
return _namespace !== undefined ? _namespace : TestConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private getServerUrl(): string {
|
|
81
|
-
Logger.debug('OpenshiftClientExecutor.getServerUrl: Get server api url.');
|
|
82
|
-
return TestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private execWithLog(command: string): ShellString {
|
|
86
|
-
echo(command);
|
|
87
|
-
return exec(command);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export namespace OpenshiftClientExecutor {
|
|
92
|
-
export class ContainerTerminal extends OpenshiftClientExecutor {
|
|
93
|
-
constructor(cluster: OpenshiftClientExecutor) {
|
|
94
|
-
super(cluster.getWorkspaceName, cluster.getNamespace);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
ls(path: string = ''): ShellString {
|
|
98
|
-
return this.executeCommand('ls ' + path);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
pwd(): ShellString {
|
|
102
|
-
return this.executeCommand('pwd');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
cd(path: string): ShellString {
|
|
106
|
-
return this.executeCommand('cd ' + path);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
gitClone(repository: string): ShellString {
|
|
110
|
-
return this.executeCommand('git clone ' + repository);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
removeFolder(path: string): ShellString {
|
|
114
|
-
return this.executeCommand('rm -rf ' + path);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|