@eclipse-che/che-e2e 7.74.0-dev-41d1364 → 7.74.0-dev-aace77a
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/.eslintrc.js +15 -1
- package/CODE_STYLE.md +144 -0
- package/configs/inversify.config.ts +26 -5
- package/configs/inversify.types.ts +17 -3
- package/constants/CHROME_DRIVER_CONSTANTS.ts +1 -13
- package/dist/configs/inversify.config.js +22 -1
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +17 -3
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/constants/CHROME_DRIVER_CONSTANTS.js +1 -9
- package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -1
- package/dist/driver/ChromeDriver.js +1 -7
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/pageobjects/dashboard/CreateWorkspace.js +5 -5
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +5 -6
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +34 -39
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +27 -28
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +2 -2
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +18 -4
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js +11 -11
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +2 -2
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpLoginPage.js +20 -24
- package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +10 -13
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +3 -3
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js +16 -20
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +16 -15
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpApplicationPage.js +7 -7
- package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js +20 -20
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpMainPage.js +25 -25
- package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +9 -6
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +6 -6
- package/dist/specs/SmokeTest.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js +7 -14
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +11 -19
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js +10 -16
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
- package/dist/specs/api/PodOverridesAPI.spec.js +7 -14
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +5 -5
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/Quarkus.spec.js +6 -6
- package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +11 -11
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +11 -12
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
- package/dist/specs/factory/Factory.spec.js +13 -16
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +17 -18
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +17 -19
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +35 -41
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js +8 -8
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js +2 -2
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +8 -8
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +4 -9
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js +49 -23
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DevWorkspaceConfigurationHelper.js +27 -17
- package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
- package/dist/utils/DevfilesRegistryHelper.js +15 -5
- package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
- package/dist/utils/DriverHelper.js +9 -2
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/IContextParams.js +12 -0
- package/dist/utils/IContextParams.js.map +1 -0
- package/dist/utils/IKubernetesCommandLineToolsExecutor.js +3 -0
- package/dist/utils/IKubernetesCommandLineToolsExecutor.js.map +1 -0
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +133 -98
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
- package/dist/utils/ScreenCatcher.js +8 -4
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/ShellExecutor.js +20 -9
- package/dist/utils/ShellExecutor.js.map +1 -1
- package/dist/utils/StringUtil.js +4 -2
- package/dist/utils/StringUtil.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +2 -2
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +2 -2
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +2 -2
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +4 -4
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/driver/ChromeDriver.ts +0 -7
- package/index.ts +2 -0
- package/package.json +3 -3
- package/pageobjects/dashboard/CreateWorkspace.ts +5 -4
- package/pageobjects/dashboard/Dashboard.ts +3 -4
- package/pageobjects/dashboard/Workspaces.ts +40 -48
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +23 -26
- package/pageobjects/ide/CheCodeLocatorLoader.ts +3 -1
- package/pageobjects/login/interfaces/ICheLoginPage.ts +1 -1
- package/pageobjects/login/interfaces/IOcpLoginPage.ts +1 -1
- package/pageobjects/login/kubernetes/DexLoginPage.ts +9 -9
- package/pageobjects/login/openshift/OcpLoginPage.ts +18 -30
- package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +6 -11
- package/pageobjects/login/openshift/OcpUserLoginPage.ts +1 -1
- package/pageobjects/login/openshift/RedHatLoginPage.ts +17 -16
- package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +16 -11
- package/pageobjects/openshift/OcpApplicationPage.ts +5 -4
- package/pageobjects/openshift/OcpImportFromGitPage.ts +18 -20
- package/pageobjects/openshift/OcpMainPage.ts +24 -25
- package/specs/MochaHooks.ts +3 -5
- package/specs/SmokeTest.spec.ts +4 -5
- package/specs/api/ContainerOverridesAPI.spec.ts +8 -2
- package/specs/api/DevfileAcceptanceTestAPI.spec.ts +9 -7
- package/specs/api/EmptyWorkspaceAPI.spec.ts +8 -4
- package/specs/api/PodOverridesAPI.spec.ts +8 -3
- package/specs/dashboard-samples/EmptyWorkspace.spec.ts +5 -5
- package/specs/dashboard-samples/Quarkus.spec.ts +7 -6
- package/specs/dashboard-samples/RecommendedExtensions.spec.ts +8 -7
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +12 -11
- package/specs/factory/Factory.spec.ts +8 -12
- package/specs/factory/NoSetupRepoFactory.spec.ts +10 -11
- package/specs/factory/RefusedOAuthFactory.spec.ts +8 -10
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +40 -44
- package/tests-library/LoginTests.ts +3 -3
- package/tests-library/WorkspaceHandlingTests.ts +2 -2
- package/utils/BrowserTabsUtil.ts +7 -9
- package/utils/CheReporter.ts +26 -20
- package/utils/DevWorkspaceConfigurationHelper.ts +9 -24
- package/utils/DevfilesRegistryHelper.ts +8 -3
- package/utils/DriverHelper.ts +14 -12
- package/utils/IContextParams.ts +26 -0
- package/utils/IKubernetesCommandLineToolsExecutor.ts +42 -0
- package/utils/KubernetesCommandLineToolsExecutor.ts +133 -101
- package/utils/ShellExecutor.ts +10 -7
- package/utils/StringUtil.ts +6 -1
|
@@ -14,76 +14,100 @@ import * as path from 'path';
|
|
|
14
14
|
import { API_TEST_CONSTANTS, KubernetesCommandLineTool } from '../constants/API_TEST_CONSTANTS';
|
|
15
15
|
import { BASE_TEST_CONSTANTS } from '../constants/BASE_TEST_CONSTANTS';
|
|
16
16
|
import { OAUTH_CONSTANTS } from '../constants/OAUTH_CONSTANTS';
|
|
17
|
+
import { IKubernetesCommandLineToolsExecutor } from './IKubernetesCommandLineToolsExecutor';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { CLASSES } from '../configs/inversify.types';
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
@injectable()
|
|
22
|
+
export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLineToolsExecutor {
|
|
19
23
|
private static container: string;
|
|
20
24
|
private static pod: string;
|
|
21
|
-
private readonly
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
private readonly kubernetesCommandLineTool: string;
|
|
26
|
+
protected _namespace: string | undefined;
|
|
27
|
+
protected _workspaceName: string | undefined;
|
|
24
28
|
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
constructor(
|
|
30
|
+
@inject(CLASSES.ShellExecutor)
|
|
31
|
+
protected readonly shellExecutor: ShellExecutor
|
|
32
|
+
) {
|
|
33
|
+
this.kubernetesCommandLineTool = API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
set namespace(value: string | undefined) {
|
|
37
|
+
this._namespace = value;
|
|
33
38
|
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
set workspaceName(value: string | undefined) {
|
|
41
|
+
this._workspaceName = value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get workspaceName(): string | undefined {
|
|
45
|
+
return this._workspaceName;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get namespace(): string | undefined {
|
|
49
|
+
this._namespace =
|
|
50
|
+
this._namespace !== undefined
|
|
51
|
+
? this._namespace
|
|
52
|
+
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
|
|
53
|
+
? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces'
|
|
54
|
+
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
|
|
55
|
+
? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che'
|
|
56
|
+
: 'default';
|
|
57
|
+
return this._namespace;
|
|
37
58
|
}
|
|
38
59
|
|
|
39
60
|
// login to Openshift cluster with username and password
|
|
40
|
-
loginToOcp(): void {
|
|
41
|
-
if (this.
|
|
42
|
-
Logger.debug(`${this.
|
|
61
|
+
loginToOcp(user: string = OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME, password: string = OAUTH_CONSTANTS.TS_SELENIUM_OCP_PASSWORD): void {
|
|
62
|
+
if (this.kubernetesCommandLineTool === KubernetesCommandLineTool.OC) {
|
|
63
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - login to the "OC" client.`);
|
|
43
64
|
const url: string = this.getServerUrl();
|
|
44
|
-
if (this.isUserLoggedIn()) {
|
|
45
|
-
Logger.debug(`${this.
|
|
65
|
+
if (this.isUserLoggedIn(user)) {
|
|
66
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - user already logged`);
|
|
46
67
|
} else {
|
|
47
|
-
Logger.debug(`${this.
|
|
48
|
-
exec(
|
|
49
|
-
`oc login --server=${url} -u=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME} -p=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`
|
|
50
|
-
);
|
|
68
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - login ${url}, ${user}`);
|
|
69
|
+
exec(`oc login --server=${url} -u=${user} -p=${password} --insecure-skip-tls-verify`);
|
|
51
70
|
}
|
|
52
71
|
} else {
|
|
53
|
-
Logger.debug(`${this.
|
|
72
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - doesn't support login command`);
|
|
54
73
|
}
|
|
55
74
|
}
|
|
56
75
|
|
|
57
76
|
getContainerName(): string {
|
|
58
|
-
Logger.debug(`${this.
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - get container name.`);
|
|
78
|
+
|
|
79
|
+
const output: ShellString = this.shellExecutor.executeCommand(
|
|
80
|
+
`${this.kubernetesCommandLineTool} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`
|
|
61
81
|
);
|
|
62
82
|
echo('\n');
|
|
63
83
|
return output.stderr ? output.stderr : output.stdout;
|
|
64
84
|
}
|
|
65
85
|
|
|
66
86
|
getWorkspacePodName(): string {
|
|
67
|
-
Logger.debug(`${this.
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - get workspace pod name.`);
|
|
88
|
+
|
|
89
|
+
const output: ShellString = this.shellExecutor.executeCommand(
|
|
90
|
+
`${this.kubernetesCommandLineTool} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`
|
|
70
91
|
);
|
|
71
92
|
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
72
93
|
}
|
|
73
94
|
|
|
74
95
|
deleteDevWorkspace(): void {
|
|
75
|
-
Logger.debug(`${this.
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - delete '${this.workspaceName}' workspace`);
|
|
97
|
+
|
|
98
|
+
this.shellExecutor.executeCommand(
|
|
99
|
+
`${this.kubernetesCommandLineTool} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`
|
|
78
100
|
);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`${this.
|
|
101
|
+
this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
102
|
+
this.shellExecutor.executeCommand(
|
|
103
|
+
`${this.kubernetesCommandLineTool} delete dwt ${BASE_TEST_CONSTANTS.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`
|
|
82
104
|
);
|
|
83
105
|
}
|
|
84
106
|
|
|
85
107
|
applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
|
|
86
|
-
|
|
108
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
109
|
+
|
|
110
|
+
if (this.kubernetesCommandLineTool === KubernetesCommandLineTool.KUBECTL) {
|
|
87
111
|
this.createNamespace();
|
|
88
112
|
}
|
|
89
113
|
this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
|
|
@@ -91,116 +115,124 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
|
91
115
|
}
|
|
92
116
|
|
|
93
117
|
executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
|
|
94
|
-
Logger.debug(`${this.
|
|
95
|
-
|
|
96
|
-
|
|
118
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
119
|
+
|
|
120
|
+
return this.shellExecutor.executeCommand(
|
|
121
|
+
`${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`
|
|
97
122
|
);
|
|
98
123
|
}
|
|
99
124
|
|
|
100
125
|
applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
|
|
101
|
-
Logger.debug(`${this.
|
|
102
|
-
|
|
103
|
-
|
|
126
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
127
|
+
|
|
128
|
+
return this.shellExecutor.executeCommand(
|
|
129
|
+
`cat <<EOF | ${this.kubernetesCommandLineTool} apply -n ${this.namespace} -f - \n` + yamlConfiguration + '\n' + 'EOF'
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
applyWithoutNamespace(yamlConfiguration: string): ShellString {
|
|
134
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
135
|
+
|
|
136
|
+
return this.shellExecutor.executeCommand(
|
|
137
|
+
`cat <<EOF | ${this.kubernetesCommandLineTool} apply -f - \n` + yamlConfiguration + '\n' + 'EOF'
|
|
104
138
|
);
|
|
105
139
|
}
|
|
106
140
|
|
|
107
141
|
applyYamlConfigurationAsFile(pathToFile: string): void {
|
|
108
|
-
Logger.debug(`${this.
|
|
109
|
-
|
|
142
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
143
|
+
|
|
144
|
+
this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
|
|
110
145
|
}
|
|
111
146
|
|
|
112
147
|
getDevWorkspaceYamlConfiguration(): ShellString {
|
|
113
|
-
Logger.debug(`${this.
|
|
114
|
-
|
|
148
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
149
|
+
|
|
150
|
+
return this.shellExecutor.executeCommand(
|
|
151
|
+
`${this.kubernetesCommandLineTool} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`
|
|
152
|
+
);
|
|
115
153
|
}
|
|
116
154
|
|
|
117
155
|
waitDevWorkspace(timeout: number = 360): ShellString {
|
|
118
|
-
Logger.debug(`${this.
|
|
119
|
-
|
|
120
|
-
|
|
156
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - wait till workspace ready.`);
|
|
157
|
+
|
|
158
|
+
const output: ShellString = this.shellExecutor.executeCommand(
|
|
159
|
+
`${this.kubernetesCommandLineTool} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`
|
|
121
160
|
);
|
|
122
161
|
this.getPodAndContainerNames();
|
|
123
162
|
return output;
|
|
124
163
|
}
|
|
125
164
|
|
|
126
165
|
createNamespace(): void {
|
|
127
|
-
Logger.debug(`${this.
|
|
128
|
-
|
|
166
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - create namespace "${this.namespace}".`);
|
|
167
|
+
|
|
168
|
+
this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} create namespace ${this.namespace}`);
|
|
129
169
|
}
|
|
130
170
|
|
|
131
171
|
createProject(projectName: string): void {
|
|
132
|
-
Logger.debug(`${this.
|
|
133
|
-
|
|
172
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - create new project "${projectName}".`);
|
|
173
|
+
|
|
174
|
+
this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} new-project ${projectName} -n ${this.namespace}`);
|
|
134
175
|
}
|
|
135
176
|
|
|
136
177
|
deleteProject(projectName: string): void {
|
|
137
|
-
Logger.debug(`${this.
|
|
138
|
-
|
|
178
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - delete "${projectName}".`);
|
|
179
|
+
|
|
180
|
+
this.shellExecutor.executeCommand(`${this.kubernetesCommandLineTool} delete project ${projectName} -n ${this.namespace}`);
|
|
139
181
|
}
|
|
140
182
|
|
|
141
|
-
|
|
183
|
+
getPodAndContainerNames(): void {
|
|
184
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
185
|
+
|
|
142
186
|
KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
|
|
143
187
|
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
144
188
|
}
|
|
145
189
|
|
|
146
|
-
|
|
147
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @param userName
|
|
192
|
+
*/
|
|
193
|
+
isUserLoggedIn(userName: string): boolean {
|
|
194
|
+
Logger.debug(`${this.kubernetesCommandLineTool}`);
|
|
148
195
|
|
|
149
|
-
|
|
150
|
-
whoamiCommandOutput.stdout.includes(OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME) &&
|
|
151
|
-
whoamiCommandOutput.stdout.includes(this.getServerUrl())
|
|
152
|
-
);
|
|
153
|
-
}
|
|
196
|
+
const whoamiCommandOutput: ShellString = this.shellExecutor.executeCommand('oc whoami && oc whoami --show-server=true');
|
|
154
197
|
|
|
155
|
-
|
|
156
|
-
_namespace =
|
|
157
|
-
_namespace !== undefined
|
|
158
|
-
? _namespace
|
|
159
|
-
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
|
|
160
|
-
? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces'
|
|
161
|
-
: BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
|
|
162
|
-
? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che'
|
|
163
|
-
: 'default';
|
|
164
|
-
return _namespace;
|
|
198
|
+
return whoamiCommandOutput.stdout.includes(userName) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
|
|
165
199
|
}
|
|
166
200
|
|
|
167
|
-
|
|
168
|
-
Logger.debug(`${this.
|
|
201
|
+
getServerUrl(): string {
|
|
202
|
+
Logger.debug(`${this.kubernetesCommandLineTool} - get server api url.`);
|
|
203
|
+
|
|
169
204
|
return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
170
205
|
}
|
|
171
206
|
}
|
|
172
207
|
|
|
173
|
-
|
|
174
|
-
export
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
208
|
+
@injectable()
|
|
209
|
+
export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
|
|
210
|
+
constructor(
|
|
211
|
+
@inject(CLASSES.ShellExecutor)
|
|
212
|
+
readonly shellExecutor: ShellExecutor,
|
|
213
|
+
@inject(CLASSES.KubernetesCommandLineToolsExecutor)
|
|
214
|
+
readonly cluster: KubernetesCommandLineToolsExecutor
|
|
215
|
+
) {
|
|
216
|
+
super(shellExecutor);
|
|
217
|
+
}
|
|
183
218
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
219
|
+
ls(path: string = ''): ShellString {
|
|
220
|
+
return this.shellExecutor.executeCommand('ls ' + path);
|
|
221
|
+
}
|
|
187
222
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
223
|
+
pwd(): ShellString {
|
|
224
|
+
return this.shellExecutor.executeCommand('pwd');
|
|
225
|
+
}
|
|
191
226
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
227
|
+
cd(path: string): ShellString {
|
|
228
|
+
return this.shellExecutor.executeCommand('cd ' + path);
|
|
229
|
+
}
|
|
195
230
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
231
|
+
gitClone(repository: string): ShellString {
|
|
232
|
+
return this.shellExecutor.executeCommand('git clone ' + repository);
|
|
233
|
+
}
|
|
199
234
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const output: ShellString = this.executeCommand(`env | grep ${envName}`);
|
|
203
|
-
return output.stderr ? output.stderr : output.stdout.substring(output.stdout.lastIndexOf('=') + 1).replace('\n', '');
|
|
204
|
-
}
|
|
235
|
+
removeFolder(path: string): ShellString {
|
|
236
|
+
return this.shellExecutor.executeCommand('rm -rf ' + path);
|
|
205
237
|
}
|
|
206
238
|
}
|
package/utils/ShellExecutor.ts
CHANGED
|
@@ -7,19 +7,22 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
**********************************************************************/
|
|
10
|
-
import {
|
|
10
|
+
import { exec, ShellString } from 'shelljs';
|
|
11
|
+
import { Logger } from './Logger';
|
|
12
|
+
import { injectable } from 'inversify';
|
|
11
13
|
|
|
14
|
+
@injectable()
|
|
12
15
|
export class ShellExecutor {
|
|
13
|
-
|
|
14
|
-
this.
|
|
16
|
+
wait(seconds: number): void {
|
|
17
|
+
this.executeCommand(`sleep ${seconds}s`);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
return this.
|
|
20
|
+
curl(link: string): ShellString {
|
|
21
|
+
return this.executeCommand(`curl -k ${link}`);
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
executeCommand(command: string): ShellString {
|
|
25
|
+
Logger.debug(command);
|
|
23
26
|
return exec(command);
|
|
24
27
|
}
|
|
25
28
|
}
|
package/utils/StringUtil.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
|
-
import { injectable } from 'inversify';
|
|
12
11
|
import { Logger } from './Logger';
|
|
12
|
+
import { injectable } from 'inversify';
|
|
13
13
|
|
|
14
14
|
@injectable()
|
|
15
15
|
export class StringUtil {
|
|
@@ -22,6 +22,7 @@ export class StringUtil {
|
|
|
22
22
|
*/
|
|
23
23
|
static getProjectNameFromGitUrl(url: string): string {
|
|
24
24
|
Logger.debug(`${url}`);
|
|
25
|
+
|
|
25
26
|
if (url.includes('?')) {
|
|
26
27
|
url = url.substring(0, url.indexOf('?'));
|
|
27
28
|
}
|
|
@@ -37,6 +38,8 @@ export class StringUtil {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
static sanitizeTitle(arg: string): string {
|
|
41
|
+
Logger.trace();
|
|
42
|
+
|
|
40
43
|
return arg
|
|
41
44
|
.replace(/\//g, '+')
|
|
42
45
|
.replace(/,/g, '.')
|
|
@@ -52,6 +55,8 @@ export class StringUtil {
|
|
|
52
55
|
*/
|
|
53
56
|
|
|
54
57
|
static updateCommandEnvsToShStyle(command: string): string {
|
|
58
|
+
Logger.trace();
|
|
59
|
+
|
|
55
60
|
return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, '"$&"');
|
|
56
61
|
}
|
|
57
62
|
}
|