@eclipse-che/che-e2e 7.73.0-dev-1397a5e → 7.73.0-dev-62c0c9d
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 +6 -6
- package/configs/inversify.types.ts +27 -27
- package/configs/mocharc.ts +21 -21
- package/constants/APITestConstants.ts +39 -38
- package/constants/BaseTestConstants.ts +44 -43
- package/constants/ChromeDriverConstants.ts +29 -29
- package/constants/FactoryTestConstants.ts +30 -30
- package/constants/MonacoConstants.ts +10 -10
- package/constants/OAuthConstants.ts +46 -46
- package/constants/ReporterConstants.ts +28 -28
- package/constants/TimeoutConstants.ts +101 -101
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +1 -1
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/APITestConstants.js +2 -2
- package/dist/constants/APITestConstants.js.map +1 -1
- package/dist/constants/BaseTestConstants.js +1 -1
- package/dist/constants/BaseTestConstants.js.map +1 -1
- package/dist/constants/ChromeDriverConstants.js +1 -1
- package/dist/constants/ChromeDriverConstants.js.map +1 -1
- package/dist/constants/FactoryTestConstants.js +1 -1
- package/dist/constants/FactoryTestConstants.js.map +1 -1
- package/dist/constants/MonacoConstants.js +1 -1
- package/dist/constants/MonacoConstants.js.map +1 -1
- package/dist/constants/OAuthConstants.js +1 -1
- package/dist/constants/OAuthConstants.js.map +1 -1
- package/dist/constants/ReporterConstants.js +1 -1
- package/dist/constants/ReporterConstants.js.map +1 -1
- package/dist/constants/TimeoutConstants.js.map +1 -1
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/pageobjects/dashboard/CreateWorkspace.js +8 -8
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +11 -11
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +14 -14
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +8 -8
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +17 -17
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js +5 -5
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +1 -1
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpLoginPage.js +10 -10
- package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +2 -2
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +1 -1
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js +6 -6
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +2 -2
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpApplicationPage.js +2 -2
- package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js +5 -5
- package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpMainPage.js +11 -11
- package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +1 -1
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +7 -3
- package/dist/specs/SmokeTest.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +7 -5
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js +1 -1
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +9 -5
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/Quarkus.spec.js +7 -3
- package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +6 -2
- package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +3 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
- package/dist/specs/factory/Factory.spec.js +3 -1
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +4 -2
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +4 -2
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +6 -2
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js +3 -3
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +54 -74
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +10 -10
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DevWorkspaceConfigurationHelper.js +2 -2
- package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
- package/dist/utils/DevfilesRegistryHelper.js +7 -7
- package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
- package/dist/utils/DriverHelper.js +81 -81
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +38 -35
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
- package/dist/utils/Logger.js +19 -10
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/ShellExecutor.js.map +1 -1
- package/dist/utils/StringUtil.js +2 -2
- package/dist/utils/StringUtil.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +13 -11
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +3 -3
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +20 -16
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
- package/driver/ChromeDriver.ts +44 -44
- package/driver/IDriver.ts +1 -1
- package/package.json +1 -1
- package/pageobjects/dashboard/CreateWorkspace.ts +52 -52
- package/pageobjects/dashboard/Dashboard.ts +72 -72
- package/pageobjects/dashboard/Workspaces.ts +138 -139
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +92 -93
- package/pageobjects/git-providers/OauthPage.ts +136 -136
- package/pageobjects/ide/CheCodeLocatorLoader.ts +40 -40
- package/pageobjects/login/interfaces/ICheLoginPage.ts +1 -1
- package/pageobjects/login/interfaces/IOcpLoginPage.ts +1 -1
- package/pageobjects/login/kubernetes/DexLoginPage.ts +27 -27
- package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +11 -11
- package/pageobjects/login/openshift/OcpLoginPage.ts +50 -50
- package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +21 -21
- package/pageobjects/login/openshift/OcpUserLoginPage.ts +14 -14
- package/pageobjects/login/openshift/RedHatLoginPage.ts +44 -41
- package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +23 -23
- package/pageobjects/openshift/OcpApplicationPage.ts +16 -16
- package/pageobjects/openshift/OcpImportFromGitPage.ts +54 -54
- package/pageobjects/openshift/OcpMainPage.ts +64 -64
- package/specs/MochaHooks.ts +44 -44
- package/specs/SmokeTest.spec.ts +35 -31
- package/specs/api/ContainerOverridesAPI.spec.ts +23 -23
- package/specs/api/DevfileAcceptanceTestAPI.spec.ts +93 -91
- package/specs/api/EmptyWorkspaceAPI.spec.ts +50 -50
- package/specs/api/PodOverridesAPI.spec.ts +29 -29
- package/specs/dashboard-samples/EmptyWorkspace.spec.ts +29 -25
- package/specs/dashboard-samples/Quarkus.spec.ts +31 -27
- package/specs/dashboard-samples/RecommendedExtensions.spec.ts +156 -152
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +62 -64
- package/specs/factory/Factory.spec.ts +149 -147
- package/specs/factory/NoSetupRepoFactory.spec.ts +188 -186
- package/specs/factory/RefusedOAuthFactory.spec.ts +182 -180
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +52 -48
- package/tests-library/LoginTests.ts +29 -29
- package/tests-library/ProjectAndFileTests.ts +13 -13
- package/tests-library/WorkspaceHandlingTests.ts +84 -103
- package/utils/BrowserTabsUtil.ts +69 -69
- package/utils/CheReporter.ts +4 -6
- package/utils/DevWorkspaceConfigurationHelper.ts +58 -58
- package/utils/DevfilesRegistryHelper.ts +51 -51
- package/utils/DriverHelper.ts +599 -600
- package/utils/KubernetesCommandLineToolsExecutor.ts +166 -158
- package/utils/Logger.ts +98 -67
- package/utils/ScreenCatcher.ts +42 -42
- package/utils/ShellExecutor.ts +10 -10
- package/utils/StringUtil.ts +29 -29
- package/utils/request-handlers/CheApiRequestHandler.ts +84 -82
- package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +18 -18
- package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +1 -1
- package/utils/workspace/ApiUrlResolver.ts +23 -23
- package/utils/workspace/ITestWorkspaceUtil.ts +29 -29
- package/utils/workspace/TestWorkspaceUtil.ts +120 -116
- package/utils/workspace/WorkspaceStatus.ts +3 -3
|
@@ -7,176 +7,184 @@ import { BaseTestConstants } from '../constants/BaseTestConstants';
|
|
|
7
7
|
import { OAuthConstants } from '../constants/OAuthConstants';
|
|
8
8
|
|
|
9
9
|
export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
10
|
+
private static container: string;
|
|
11
|
+
private static pod: string;
|
|
12
|
+
private readonly namespace: string;
|
|
13
|
+
private readonly workspaceName: string | undefined;
|
|
14
|
+
private readonly KUBERNETES_COMMAND_LINE_TOOL: string =
|
|
15
|
+
APITestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
|
|
16
|
+
|
|
17
|
+
constructor(_workspaceName?: string, _namespace?: string) {
|
|
18
|
+
super();
|
|
19
|
+
this.workspaceName = _workspaceName;
|
|
20
|
+
this.namespace = this.setNamespace(_namespace);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get getWorkspaceName(): string {
|
|
24
|
+
return <string>this.workspaceName;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get getNamespace(): string {
|
|
28
|
+
return this.namespace;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// login to Openshift cluster with username and password
|
|
32
|
+
loginToOcp(): void {
|
|
33
|
+
if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
|
|
34
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login to the "OC" client.`);
|
|
35
|
+
const url: string = this.getServerUrl();
|
|
36
|
+
if (this.isUserLoggedIn()) {
|
|
37
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - user already logged`);
|
|
38
|
+
} else {
|
|
39
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login ${url}, ${OAuthConstants.TS_SELENIUM_OCP_USERNAME}`);
|
|
40
|
+
exec(`oc login --server=${url} -u=${OAuthConstants.TS_SELENIUM_OCP_USERNAME} -p=${OAuthConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - doesn't support login command`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getContainerName(): string {
|
|
48
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get container name.`);
|
|
49
|
+
const output: ShellString = ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
|
|
50
|
+
echo('\n');
|
|
51
|
+
return output.stderr ? output.stderr : output.stdout;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getWorkspacePodName(): string {
|
|
55
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get workspace pod name.`);
|
|
56
|
+
const output: ShellString = ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
|
|
57
|
+
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
deleteDevWorkspace(): void {
|
|
61
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete '${this.workspaceName}' workspace`);
|
|
62
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
|
|
63
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
64
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dwt ${BaseTestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
|
|
68
|
+
if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.KUBECTL) {
|
|
69
|
+
this.createNamespace();
|
|
70
|
+
}
|
|
71
|
+
this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
|
|
72
|
+
return this.waitDevWorkspace();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
executeCommand(
|
|
76
|
+
commandToExecute: string,
|
|
77
|
+
container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
|
|
78
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
|
|
79
|
+
return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
|
|
83
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
|
|
84
|
+
return ShellExecutor.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
|
|
85
|
+
yamlConfiguration +
|
|
86
|
+
'\n' +
|
|
87
|
+
'EOF');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
applyYamlConfigurationAsFile(pathToFile: string): void {
|
|
91
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
|
|
92
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
getDevWorkspaceYamlConfiguration(): ShellString {
|
|
96
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
|
|
97
|
+
return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
waitDevWorkspace(timeout: number = 360): ShellString {
|
|
101
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - wait till workspace ready.`);
|
|
102
|
+
const output: ShellString = ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
|
|
103
|
+
this.getPodAndContainerNames();
|
|
104
|
+
return output;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
createNamespace(): void {
|
|
108
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create namespace "${this.namespace}".`);
|
|
109
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
createProject(projectName: string): void {
|
|
113
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create new project "${projectName}".`);
|
|
114
|
+
ShellExecutor.execWithLog(
|
|
115
|
+
`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
deleteProject(projectName: string): void {
|
|
120
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete "${projectName}".`);
|
|
121
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private getPodAndContainerNames(): void {
|
|
125
|
+
KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
|
|
126
|
+
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private isUserLoggedIn(): boolean {
|
|
130
|
+
const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
whoamiCommandOutput.stdout.includes(OAuthConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl()));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private setNamespace(_namespace: string | undefined): string {
|
|
137
|
+
_namespace =
|
|
138
|
+
_namespace !== undefined
|
|
139
|
+
? _namespace
|
|
140
|
+
: BaseTestConstants.TS_SELENIUM_BASE_URL.includes('devspaces')
|
|
141
|
+
? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
|
|
142
|
+
: BaseTestConstants.TS_SELENIUM_BASE_URL.includes('che')
|
|
143
|
+
? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-che'
|
|
144
|
+
: 'default';
|
|
145
|
+
return _namespace;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private getServerUrl(): string {
|
|
149
|
+
Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get server api url.`);
|
|
150
|
+
return (BaseTestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
112
153
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
154
|
+
export namespace KubernetesCommandLineToolsExecutor {
|
|
155
|
+
export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
|
|
156
|
+
constructor(cluster: KubernetesCommandLineToolsExecutor) {
|
|
157
|
+
super(cluster.getWorkspaceName, cluster.getNamespace);
|
|
116
158
|
}
|
|
117
159
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
160
|
+
ls(path: string = ''): ShellString {
|
|
161
|
+
return this.executeCommand('ls ' + path);
|
|
121
162
|
}
|
|
122
163
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return whoamiCommandOutput.stdout.includes(OAuthConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
|
|
164
|
+
pwd(): ShellString {
|
|
165
|
+
return this.executeCommand('pwd');
|
|
127
166
|
}
|
|
128
167
|
|
|
129
|
-
|
|
130
|
-
|
|
168
|
+
cd(path: string): ShellString {
|
|
169
|
+
return this.executeCommand('cd ' + path);
|
|
131
170
|
}
|
|
132
171
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
: BaseTestConstants.TS_SELENIUM_BASE_URL.includes('devspaces') ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
|
|
136
|
-
: BaseTestConstants.TS_SELENIUM_BASE_URL.includes('che') ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-che'
|
|
137
|
-
: 'default';
|
|
138
|
-
return _namespace;
|
|
172
|
+
gitClone(repository: string): ShellString {
|
|
173
|
+
return this.executeCommand('git clone ' + repository);
|
|
139
174
|
}
|
|
140
175
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return BaseTestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
176
|
+
removeFolder(path: string): ShellString {
|
|
177
|
+
return this.executeCommand('rm -rf ' + path);
|
|
144
178
|
}
|
|
145
|
-
}
|
|
146
179
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
pwd(): ShellString {
|
|
158
|
-
return this.executeCommand('pwd');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
cd(path: string): ShellString {
|
|
162
|
-
return this.executeCommand('cd ' + path);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
gitClone(repository: string): ShellString {
|
|
166
|
-
return this.executeCommand('git clone ' + repository);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
removeFolder(path: string): ShellString {
|
|
170
|
-
return this.executeCommand('rm -rf ' + path);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
getEnvValue(envName: string): string {
|
|
174
|
-
envName = envName.replace(/[${}]/g, '');
|
|
175
|
-
const output: ShellString = this.executeCommand(`env | grep ${envName}`);
|
|
176
|
-
return output.stderr ? output.stderr :
|
|
177
|
-
output.stdout
|
|
178
|
-
.substring(output.stdout.lastIndexOf('=') + 1)
|
|
179
|
-
.replace('\n', '');
|
|
180
|
-
}
|
|
180
|
+
getEnvValue(envName: string): string {
|
|
181
|
+
envName = envName.replace(/[${}]/g, '');
|
|
182
|
+
const output: ShellString = this.executeCommand(`env | grep ${envName}`);
|
|
183
|
+
return output.stderr
|
|
184
|
+
? output.stderr
|
|
185
|
+
: output.stdout
|
|
186
|
+
.substring(output.stdout.lastIndexOf('=') + 1)
|
|
187
|
+
.replace('\n', '');
|
|
181
188
|
}
|
|
189
|
+
}
|
|
182
190
|
}
|
package/utils/Logger.ts
CHANGED
|
@@ -10,82 +10,113 @@
|
|
|
10
10
|
import { ReporterConstants } from '../constants/ReporterConstants';
|
|
11
11
|
|
|
12
12
|
export abstract class Logger {
|
|
13
|
+
/**
|
|
14
|
+
* Uses for logging of fatal errors.
|
|
15
|
+
* @param text log text
|
|
16
|
+
* @param indentLevel log level
|
|
17
|
+
*/
|
|
18
|
+
static error(text: string = '', indentLevel: number = 1): void {
|
|
19
|
+
this.logText(
|
|
20
|
+
indentLevel,
|
|
21
|
+
`[ERROR] ${this.getCallerInfo()} ${this.separator(text)} ${text}`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Uses for logging of recoverable errors and general warnings.
|
|
27
|
+
* @param text log text
|
|
28
|
+
* @param indentLevel log level
|
|
29
|
+
*/
|
|
30
|
+
static warn(text: string = '', indentLevel: number = 1): void {
|
|
31
|
+
if (ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR') {
|
|
32
|
+
return;
|
|
21
33
|
}
|
|
34
|
+
this.logText(
|
|
35
|
+
indentLevel,
|
|
36
|
+
`[WARN] ${this.getCallerInfo()} ${this.separator(text)} ${text}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
22
39
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Uses for logging of the public methods of the pageobjects.
|
|
42
|
+
* @param text log text
|
|
43
|
+
* @param indentLevel log level
|
|
44
|
+
*/
|
|
45
|
+
static info(text: string = '', indentLevel: number = 3): void {
|
|
46
|
+
if (
|
|
47
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
48
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN'
|
|
49
|
+
) {
|
|
50
|
+
return;
|
|
33
51
|
}
|
|
52
|
+
this.logText(
|
|
53
|
+
indentLevel,
|
|
54
|
+
`• ${this.getCallerInfo()} ${this.separator(text)} ${text}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
34
57
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Uses for logging of the public methods of the pageobjects.
|
|
60
|
+
* @param text log text
|
|
61
|
+
* @param indentLevel log level
|
|
62
|
+
*/
|
|
63
|
+
static debug(text: string = '', indentLevel: number = 5): void {
|
|
64
|
+
if (
|
|
65
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
66
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
|
|
67
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'INFO'
|
|
68
|
+
) {
|
|
69
|
+
return;
|
|
46
70
|
}
|
|
71
|
+
this.logText(
|
|
72
|
+
indentLevel,
|
|
73
|
+
`▼ ${this.getCallerInfo()} ${this.separator(text)} ${text}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
47
76
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Uses for logging of the public methods of the {@link DriverHelper} or
|
|
79
|
+
* private methods inside of pageobjects.
|
|
80
|
+
* @param text log text
|
|
81
|
+
* @param indentLevel log level
|
|
82
|
+
*/
|
|
83
|
+
static trace(text: string = '', indentLevel: number = 6): void {
|
|
84
|
+
if (
|
|
85
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
86
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
|
|
87
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'INFO' ||
|
|
88
|
+
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'DEBUG'
|
|
89
|
+
) {
|
|
90
|
+
return;
|
|
60
91
|
}
|
|
92
|
+
this.logText(
|
|
93
|
+
indentLevel,
|
|
94
|
+
`‣ ${this.getCallerInfo()} ${this.separator(text)} ${text}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
61
97
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param indentLevel log level
|
|
67
|
-
*/
|
|
68
|
-
static trace(text: string, indentLevel: number = 6): void {
|
|
69
|
-
if (ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
70
|
-
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
|
|
71
|
-
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'INFO' ||
|
|
72
|
-
ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'DEBUG') {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
this.logText(indentLevel, `‣ ${text}`);
|
|
98
|
+
private static logText(messageIndentationLevel: number, text: string): void {
|
|
99
|
+
// start group for every level
|
|
100
|
+
for (let i: number = 0; i < messageIndentationLevel; i++) {
|
|
101
|
+
console.group();
|
|
76
102
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// print the trimmed text
|
|
84
|
-
// if multiline, the message should be properly padded
|
|
85
|
-
console.log(text);
|
|
86
|
-
// end group for every level
|
|
87
|
-
for (let i: number = 0; i < messageIndentationLevel; i++) {
|
|
88
|
-
console.groupEnd();
|
|
89
|
-
}
|
|
103
|
+
// print the trimmed text
|
|
104
|
+
// if multiline, the message should be properly padded
|
|
105
|
+
console.log(text);
|
|
106
|
+
// end group for every level
|
|
107
|
+
for (let i: number = 0; i < messageIndentationLevel; i++) {
|
|
108
|
+
console.groupEnd();
|
|
90
109
|
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private static getCallerInfo(): string {
|
|
113
|
+
const e: Error = new Error();
|
|
114
|
+
const stack: string[] = e.stack ? e.stack.split('\n') : [];
|
|
115
|
+
// " at functionName ( ..." => "functionName"
|
|
116
|
+
return stack[3].replace(/^\s+at\s+(.+?)\s.+/g, '$1');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private static separator(text: string): string {
|
|
120
|
+
return text ? '-' : '';
|
|
121
|
+
}
|
|
91
122
|
}
|
package/utils/ScreenCatcher.ts
CHANGED
|
@@ -8,67 +8,67 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
import * as fs from 'fs';
|
|
11
|
-
import {
|
|
11
|
+
import { WriteStream } from 'fs';
|
|
12
|
+
import { inject, injectable } from 'inversify';
|
|
12
13
|
import { CLASSES } from '../configs/inversify.types';
|
|
13
14
|
import { DriverHelper } from './DriverHelper';
|
|
14
15
|
import { error } from 'selenium-webdriver';
|
|
15
|
-
import { WriteStream } from 'fs';
|
|
16
16
|
import { StringUtil } from './StringUtil';
|
|
17
17
|
import { ReporterConstants } from '../constants/ReporterConstants';
|
|
18
18
|
|
|
19
19
|
@injectable()
|
|
20
20
|
export class ScreenCatcher {
|
|
21
|
-
|
|
21
|
+
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
|
|
24
|
+
const executionScreenCastDir: string = `${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
|
|
25
|
+
const executionScreenCastErrorsDir: string = `${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`;
|
|
26
|
+
const formattedMethodIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(methodIndex);
|
|
27
|
+
const formattedScreenshotIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 5 }).format(screenshotIndex).replace(/,/g, '');
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (!fs.existsSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER)) {
|
|
30
|
+
fs.mkdirSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!fs.existsSync(executionScreenCastDir)) {
|
|
34
|
+
fs.mkdirSync(executionScreenCastDir);
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const date: Date = new Date();
|
|
38
|
+
const timeStr: string = date.toLocaleTimeString('en-us', { hour12: false }) + '.' + new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(date.getMilliseconds());
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${StringUtil.sanitizeTitle(timeStr)})_${StringUtil.sanitizeTitle(methodName)}.png`;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
try {
|
|
43
|
+
await this.catchScreen(screenshotPath);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (!fs.existsSync(executionScreenCastErrorsDir)) {
|
|
46
|
+
fs.mkdirSync(executionScreenCastErrorsDir);
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
49
|
+
let errorLogFilePath: string = screenshotPath.replace('.png', '.txt');
|
|
50
|
+
errorLogFilePath = errorLogFilePath.replace(executionScreenCastDir, executionScreenCastErrorsDir);
|
|
51
|
+
if (err instanceof error.IError) {
|
|
52
|
+
await this.writeErrorLog(errorLogFilePath, err);
|
|
53
|
+
}
|
|
55
54
|
}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
async catchScreen(screenshotPath: string): Promise<void> {
|
|
58
|
+
const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
|
|
59
|
+
const screenshotStream: WriteStream = fs.createWriteStream(screenshotPath);
|
|
60
|
+
screenshotStream.write(Buffer.from(screenshot, 'base64'));
|
|
61
|
+
screenshotStream.end();
|
|
62
|
+
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
async writeErrorLog(errorLogPath: string, err: error.IError): Promise<void> {
|
|
65
|
+
console.log(`Failed to save screenshot, additional information in the ${errorLogPath}`);
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
67
|
+
if (err.stack) {
|
|
68
|
+
const screenshotStream: WriteStream = fs.createWriteStream(errorLogPath);
|
|
69
|
+
screenshotStream.write(Buffer.from(err.stack, 'utf8'));
|
|
70
|
+
screenshotStream.end();
|
|
72
71
|
}
|
|
72
|
+
}
|
|
73
73
|
|
|
74
74
|
}
|