@eclipse-che/che-e2e 7.67.0 → 7.67.1-dev-e49f025
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/README.md +13 -4
- package/build/dockerfiles/Dockerfile +1 -1
- package/configs/inversify.config.ts +20 -17
- package/configs/inversify.types.ts +3 -3
- package/configs/mocharc.ts +14 -4
- package/configs/sh-scripts/generateIndex.sh +2 -3
- package/constants/APITestConstants.ts +56 -0
- package/constants/BaseTestConstants.ts +65 -0
- package/constants/ChromeDriverConstants.ts +46 -0
- package/constants/FactoryTestConstants.ts +45 -0
- package/constants/MonacoConstants.ts +22 -0
- package/constants/OAuthConstants.ts +56 -0
- package/constants/PluginsTestConstants.ts +15 -0
- package/constants/ReporterConstants.ts +45 -0
- package/constants/TimeoutConstants.ts +28 -146
- package/dist/configs/inversify.config.js +17 -13
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +3 -2
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +13 -4
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/APITestConstants.js +54 -0
- package/dist/constants/APITestConstants.js.map +1 -0
- package/dist/constants/BaseTestConstants.js +61 -0
- package/dist/constants/BaseTestConstants.js.map +1 -0
- package/dist/constants/ChromeDriverConstants.js +44 -0
- package/dist/constants/ChromeDriverConstants.js.map +1 -0
- package/dist/constants/FactoryTestConstants.js +44 -0
- package/dist/constants/FactoryTestConstants.js.map +1 -0
- package/dist/constants/MonacoConstants.js +25 -0
- package/dist/constants/MonacoConstants.js.map +1 -0
- package/dist/constants/OAuthConstants.js +52 -0
- package/dist/constants/OAuthConstants.js.map +1 -0
- package/dist/constants/PluginsTestConstants.js +19 -0
- package/dist/constants/PluginsTestConstants.js.map +1 -0
- package/dist/constants/ReporterConstants.js +43 -0
- package/dist/constants/ReporterConstants.js.map +1 -0
- package/dist/constants/TimeoutConstants.js +22 -113
- package/dist/constants/TimeoutConstants.js.map +1 -1
- package/dist/driver/ChromeDriver.js +7 -7
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/index.js +22 -12
- package/dist/index.js.map +1 -1
- package/dist/pageobjects/dashboard/CreateWorkspace.js +2 -2
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +7 -6
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +3 -4
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +2 -3
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +12 -19
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +2 -2
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
- package/dist/pageobjects/login/interfaces/ICheLoginPage.js.map +1 -0
- package/dist/pageobjects/login/interfaces/IOcpLoginPage.js.map +1 -0
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js +68 -0
- package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -0
- package/dist/pageobjects/{openshift/CheLoginPage.js → login/kubernetes/KubernetesLoginPage.js} +21 -26
- package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -0
- package/dist/pageobjects/{openshift → login/openshift}/OcpLoginPage.js +7 -7
- package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -0
- package/dist/pageobjects/login/{OcpRedHatLoginPage.js → openshift/OcpRedHatLoginPage.js} +5 -5
- package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/{OcpUserLoginPage.js → openshift/OcpUserLoginPage.js} +7 -7
- package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -0
- package/dist/pageobjects/login/{RedHatLoginPage.js → openshift/RedHatLoginPage.js} +6 -6
- package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/{RegularUserOcpCheLoginPage.js → openshift/RegularUserOcpCheLoginPage.js} +8 -8
- package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -0
- package/dist/specs/MochaHooks.js +18 -11
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +5 -2
- package/dist/specs/SmokeTest.spec.js.map +1 -1
- package/dist/specs/api/ContainerOverridesAPI.spec.js +5 -4
- package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +93 -0
- package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -0
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js +62 -0
- package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -0
- package/dist/specs/api/PodOverridesAPI.spec.js +5 -4
- package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +7 -2
- package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js +7 -6
- package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js.map +1 -1
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +4 -4
- package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
- package/dist/specs/factory/Factory.spec.js +20 -18
- package/dist/specs/factory/Factory.spec.js.map +1 -1
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +28 -28
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +28 -26
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
- package/dist/tests-library/LoginTests.js +4 -4
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +1 -2
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +2 -2
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js +33 -36
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DevWorkspaceConfigurationHelper.js +72 -0
- package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -0
- package/dist/utils/DevfilesRegistryHelper.js +82 -0
- package/dist/utils/DevfilesRegistryHelper.js.map +1 -0
- package/dist/utils/DriverHelper.js +20 -17
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/KubernetesCommandLineToolsExecutor.js +42 -29
- package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
- package/dist/utils/Logger.js +11 -11
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/ScreenCatcher.js +9 -12
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/ShellExecutor.js +5 -2
- package/dist/utils/ShellExecutor.js.map +1 -1
- package/dist/utils/{vsc/GitUtil.js → StringUtil.js} +26 -8
- package/dist/utils/StringUtil.js.map +1 -0
- 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 +4 -2
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +9 -7
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/driver/ChromeDriver.ts +7 -7
- package/index.ts +22 -12
- package/package.json +4 -2
- package/pageobjects/dashboard/CreateWorkspace.ts +2 -2
- package/pageobjects/dashboard/Dashboard.ts +7 -6
- package/pageobjects/dashboard/Workspaces.ts +3 -4
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +2 -3
- package/pageobjects/git-providers/OauthPage.ts +8 -16
- package/pageobjects/ide/CheCodeLocatorLoader.ts +2 -2
- package/pageobjects/login/kubernetes/DexLoginPage.ts +58 -0
- package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +33 -0
- package/pageobjects/{openshift → login/openshift}/OcpLoginPage.ts +7 -7
- package/pageobjects/login/{OcpRedHatLoginPage.ts → openshift/OcpRedHatLoginPage.ts} +6 -6
- package/pageobjects/login/{OcpUserLoginPage.ts → openshift/OcpUserLoginPage.ts} +8 -8
- package/pageobjects/login/{RedHatLoginPage.ts → openshift/RedHatLoginPage.ts} +6 -6
- package/pageobjects/login/{RegularUserOcpCheLoginPage.ts → openshift/RegularUserOcpCheLoginPage.ts} +9 -9
- package/specs/MochaHooks.ts +18 -12
- package/specs/SmokeTest.spec.ts +5 -2
- package/specs/api/ContainerOverridesAPI.spec.ts +5 -4
- package/specs/api/DevfileAcceptanceTestAPI.spec.ts +106 -0
- package/specs/api/EmptyWorkspaceAPI.spec.ts +74 -0
- package/specs/api/PodOverridesAPI.spec.ts +5 -4
- package/specs/dashboard-samples/EmptyWorkspace.spec.ts +10 -2
- package/specs/dashboard-samples/RecomendedExtentions.spec.ts +8 -7
- package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +4 -4
- package/specs/factory/Factory.spec.ts +21 -19
- package/specs/factory/NoSetupRepoFactory.spec.ts +29 -30
- package/specs/factory/RefusedOAuthFactory.spec.ts +29 -28
- package/tests-library/LoginTests.ts +9 -9
- package/tests-library/ProjectAndFileTests.ts +1 -1
- package/tests-library/WorkspaceHandlingTests.ts +11 -12
- package/utils/BrowserTabsUtil.ts +2 -2
- package/utils/CheReporter.ts +35 -42
- package/utils/DevWorkspaceConfigurationHelper.ts +83 -0
- package/utils/DevfilesRegistryHelper.ts +77 -0
- package/utils/DriverHelper.ts +54 -50
- package/utils/KubernetesCommandLineToolsExecutor.ts +43 -28
- package/utils/Logger.ts +16 -17
- package/utils/ScreenCatcher.ts +8 -9
- package/utils/ShellExecutor.ts +6 -2
- package/utils/StringUtil.ts +46 -0
- package/utils/request-handlers/CheApiRequestHandler.ts +4 -4
- package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +4 -2
- package/utils/workspace/ApiUrlResolver.ts +2 -2
- package/utils/workspace/TestWorkspaceUtil.ts +16 -14
- package/constants/TestConstants.ts +0 -247
- package/dist/constants/TestConstants.js +0 -198
- package/dist/constants/TestConstants.js.map +0 -1
- package/dist/pageobjects/login/ICheLoginPage.js.map +0 -1
- package/dist/pageobjects/login/IOcpLoginPage.js.map +0 -1
- package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +0 -1
- package/dist/pageobjects/login/OcpUserLoginPage.js.map +0 -1
- package/dist/pageobjects/login/RedHatLoginPage.js.map +0 -1
- package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +0 -1
- package/dist/pageobjects/openshift/CheLoginPage.js.map +0 -1
- package/dist/pageobjects/openshift/OcpLoginPage.js.map +0 -1
- package/dist/specs/api/CloneGitRepoAPI.spec.js +0 -60
- package/dist/specs/api/CloneGitRepoAPI.spec.js.map +0 -1
- package/dist/utils/Sanitizer.js +0 -29
- package/dist/utils/Sanitizer.js.map +0 -1
- package/dist/utils/vsc/GitUtil.js.map +0 -1
- package/pageobjects/openshift/CheLoginPage.ts +0 -42
- package/specs/api/CloneGitRepoAPI.spec.ts +0 -72
- package/utils/Sanitizer.ts +0 -19
- package/utils/vsc/GitUtil.ts +0 -25
- /package/dist/pageobjects/login/{ICheLoginPage.js → interfaces/ICheLoginPage.js} +0 -0
- /package/dist/pageobjects/login/{IOcpLoginPage.js → interfaces/IOcpLoginPage.js} +0 -0
- /package/pageobjects/login/{ICheLoginPage.ts → interfaces/ICheLoginPage.ts} +0 -0
- /package/pageobjects/login/{IOcpLoginPage.ts → interfaces/IOcpLoginPage.ts} +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/main';
|
|
2
|
+
import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
|
|
3
|
+
import { V1alpha2DevWorkspaceTemplate } from '@devfile/api';
|
|
4
|
+
import YAML from 'yaml';
|
|
5
|
+
import * as axios from 'axios';
|
|
6
|
+
import { Logger } from './Logger';
|
|
7
|
+
import { ShellExecutor } from './ShellExecutor';
|
|
8
|
+
import { APITestConstants } from '../constants/APITestConstants';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* to see more about IContextParams and generateDevfileContext(params) check README.md in "@eclipse-che/che-devworkspace-generator;
|
|
12
|
+
* tests/e2e/node_modules/@eclipse-che/che-devworkspace-generator/README.md
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface IContextParams {
|
|
16
|
+
devfilePath?: string | undefined;
|
|
17
|
+
devfileUrl?: string | undefined;
|
|
18
|
+
devfileContent?: string | undefined;
|
|
19
|
+
outputFile?: string | undefined;
|
|
20
|
+
editorPath?: string | undefined;
|
|
21
|
+
editorContent?: string | undefined;
|
|
22
|
+
editorEntry?: string | undefined;
|
|
23
|
+
pluginRegistryUrl?: string | undefined;
|
|
24
|
+
projects?: {
|
|
25
|
+
name: string;
|
|
26
|
+
location: string;
|
|
27
|
+
}[];
|
|
28
|
+
injectDefaultComponent?: string | undefined;
|
|
29
|
+
defaultComponentImage?: string | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class DevWorkspaceConfigurationHelper {
|
|
33
|
+
private generator: Generator = new Generator();
|
|
34
|
+
private readonly params: IContextParams;
|
|
35
|
+
|
|
36
|
+
constructor(params: IContextParams) {
|
|
37
|
+
// check if all undefined
|
|
38
|
+
if (!(params.editorPath || params.editorEntry || params.editorContent)) {
|
|
39
|
+
params.editorEntry = 'che-incubator/che-code/latest';
|
|
40
|
+
}
|
|
41
|
+
// check if one or both has value
|
|
42
|
+
if (APITestConstants.TS_API_TEST_UDI_IMAGE || params.defaultComponentImage) {
|
|
43
|
+
params.injectDefaultComponent = 'true';
|
|
44
|
+
// check if not explicitly passed than assign value from the constants
|
|
45
|
+
if (!params.defaultComponentImage) {
|
|
46
|
+
params.defaultComponentImage = APITestConstants.TS_API_TEST_UDI_IMAGE;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// assign value from the constants if not explicitly passed
|
|
50
|
+
if (APITestConstants.TS_API_TEST_PLUGIN_REGISTRY_URL && !params.pluginRegistryUrl) {
|
|
51
|
+
params.pluginRegistryUrl = APITestConstants.TS_API_TEST_PLUGIN_REGISTRY_URL;
|
|
52
|
+
}
|
|
53
|
+
if (APITestConstants.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI && !params.editorContent) {
|
|
54
|
+
params.editorContent = ShellExecutor.curl(APITestConstants.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI).stdout;
|
|
55
|
+
}
|
|
56
|
+
this.params = params;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async generateDevfileContext(): Promise<DevfileContext> {
|
|
60
|
+
Logger.debug(`${this.constructor.name}.${this.generateDevfileContext.name}`);
|
|
61
|
+
if (!this.params.projects) {
|
|
62
|
+
this.params.projects = [];
|
|
63
|
+
}
|
|
64
|
+
return await this.generator.generateDevfileContext(
|
|
65
|
+
{
|
|
66
|
+
...this.params,
|
|
67
|
+
projects: this.params.projects
|
|
68
|
+
},
|
|
69
|
+
axios.default as any
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// write templates and then DevWorkspace in a single file
|
|
74
|
+
async getDevWorkspaceConfigurationYamlAsString(context: DevfileContext): Promise<string> {
|
|
75
|
+
Logger.debug(`${this.constructor.name}.${this.getDevWorkspaceConfigurationYamlAsString.name}`);
|
|
76
|
+
const allContentArray: any[] = context.devWorkspaceTemplates.map(
|
|
77
|
+
(template: V1alpha2DevWorkspaceTemplate) => YAML.stringify(template)
|
|
78
|
+
);
|
|
79
|
+
allContentArray.push(YAML.stringify(context.devWorkspace));
|
|
80
|
+
|
|
81
|
+
return allContentArray.join('---\n');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
**********************************************************************/
|
|
10
|
+
import axios, { AxiosResponse } from 'axios';
|
|
11
|
+
import { Logger } from './Logger';
|
|
12
|
+
import YAML from 'yaml';
|
|
13
|
+
import { APITestConstants, SupportedDevfilesRegistries } from '../constants/APITestConstants';
|
|
14
|
+
|
|
15
|
+
export class DevfilesRegistryHelper {
|
|
16
|
+
|
|
17
|
+
async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
|
|
18
|
+
Logger.debug(`${this.constructor.name}.${this.getInbuiltDevfilesRegistryContent.name}`);
|
|
19
|
+
return await this.getContent(SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
|
|
23
|
+
Logger.debug(`${this.constructor.name}.${this.getGitHubCheDevfileRegistryContent.name}`);
|
|
24
|
+
return await this.getContent(SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
|
|
28
|
+
Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}`);
|
|
29
|
+
const devfileSamples: object[] = [];
|
|
30
|
+
const sampleNames: string[] = [];
|
|
31
|
+
switch (APITestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()) {
|
|
32
|
+
case (SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL): {
|
|
33
|
+
const content: any[any] = await this.getGitHubCheDevfileRegistryContent();
|
|
34
|
+
content.forEach((e: any) => {
|
|
35
|
+
if (e.name[0] !== '.') { sampleNames.push(e.name); }
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
for (const sample of sampleNames) {
|
|
39
|
+
const sampleEndpoint: string = `${SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL}${sample}/meta.yaml`;
|
|
40
|
+
const sampleEndpointContent: AxiosResponse = await this.getContent(sampleEndpoint);
|
|
41
|
+
const decodedFileContent: string = Buffer.from((sampleEndpointContent as any).content, 'base64').toString();
|
|
42
|
+
const metaYamlContent: any = YAML.parse(decodedFileContent);
|
|
43
|
+
devfileSamples.push({name: sample, link: metaYamlContent.links.v2});
|
|
44
|
+
}
|
|
45
|
+
Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
case (SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL()): {
|
|
49
|
+
const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
|
|
50
|
+
|
|
51
|
+
for (const sample of content) {
|
|
52
|
+
devfileSamples.push({name: sample.displayName, link: sample.links.v2});
|
|
53
|
+
}
|
|
54
|
+
Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
default: {
|
|
58
|
+
Logger.error(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: unsupported registry url - ${APITestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
|
|
59
|
+
supported registries: ${JSON.stringify(SupportedDevfilesRegistries)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return devfileSamples;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
|
|
66
|
+
Logger.debug(`${this.constructor.name}.${this.getContent.name}: ${url}`);
|
|
67
|
+
|
|
68
|
+
let response: AxiosResponse | undefined;
|
|
69
|
+
try {
|
|
70
|
+
response = await axios.get(url, headers);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
Logger.error(`${error} + ${url}`);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
return response?.data;
|
|
76
|
+
}
|
|
77
|
+
}
|
package/utils/DriverHelper.ts
CHANGED
|
@@ -12,7 +12,6 @@ import { inject, injectable } from 'inversify';
|
|
|
12
12
|
import { TYPES } from '../configs/inversify.types';
|
|
13
13
|
import { Actions, By, error, ThenableWebDriver, until, WebElement } from 'selenium-webdriver';
|
|
14
14
|
import 'reflect-metadata';
|
|
15
|
-
import { TestConstants } from '../constants/TestConstants';
|
|
16
15
|
import { Logger } from './Logger';
|
|
17
16
|
import { TimeoutConstants } from '../constants/TimeoutConstants';
|
|
18
17
|
|
|
@@ -25,13 +24,13 @@ export class DriverHelper {
|
|
|
25
24
|
this.driver = driver.get() as ThenableWebDriver;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
getAction(): Actions {
|
|
29
28
|
Logger.trace('DriverHelper.getAction');
|
|
30
29
|
|
|
31
30
|
return this.driver.actions();
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
async isVisible(locator: By): Promise<boolean> {
|
|
35
34
|
Logger.trace(`DriverHelper.isVisible ${locator}`);
|
|
36
35
|
|
|
37
36
|
try {
|
|
@@ -42,21 +41,21 @@ export class DriverHelper {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
async wait(milliseconds: number): Promise<void> {
|
|
46
45
|
Logger.trace(`DriverHelper.wait (${milliseconds} milliseconds)`);
|
|
47
46
|
|
|
48
47
|
await this.driver.sleep(milliseconds);
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
async refreshPage(): Promise<void> {
|
|
52
51
|
Logger.trace(`DriverHelper.refreshPage`);
|
|
53
52
|
|
|
54
53
|
await this.driver.navigate().refresh();
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
attempts: number =
|
|
59
|
-
polling: number =
|
|
56
|
+
async waitVisibilityBoolean(locator: By,
|
|
57
|
+
attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
|
|
58
|
+
polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
|
|
60
59
|
|
|
61
60
|
Logger.trace(`DriverHelper.waitVisibilityBoolean ${locator}`);
|
|
62
61
|
|
|
@@ -73,9 +72,9 @@ export class DriverHelper {
|
|
|
73
72
|
return false;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
attempts: number =
|
|
78
|
-
polling: number =
|
|
75
|
+
async waitDisappearanceBoolean(locator: By,
|
|
76
|
+
attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
|
|
77
|
+
polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
|
|
79
78
|
|
|
80
79
|
Logger.trace(`DriverHelper.waitDisappearanceBoolean ${locator}`);
|
|
81
80
|
|
|
@@ -92,8 +91,8 @@ export class DriverHelper {
|
|
|
92
91
|
return false;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
const polling: number =
|
|
94
|
+
async waitVisibility(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
|
|
95
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
97
96
|
const attempts: number = Math.ceil(timeout / polling);
|
|
98
97
|
|
|
99
98
|
Logger.trace(`DriverHelper.waitVisibility ${elementLocator}`);
|
|
@@ -150,8 +149,8 @@ export class DriverHelper {
|
|
|
150
149
|
throw new error.TimeoutError(`Exceeded maximum visibility checkings attempts for '${elementLocator}' element, timeouted after ${timeout}`);
|
|
151
150
|
}
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
const polling: number =
|
|
152
|
+
async waitPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
|
|
153
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
155
154
|
const attempts: number = Math.ceil(timeout / polling);
|
|
156
155
|
|
|
157
156
|
Logger.trace(`DriverHelper.waitPresence ${elementLocator}`);
|
|
@@ -178,8 +177,8 @@ export class DriverHelper {
|
|
|
178
177
|
throw new error.TimeoutError(`Exceeded maximum presence checking attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
|
|
182
|
-
const polling: number =
|
|
180
|
+
async waitAllPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<Array<WebElement>> {
|
|
181
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
183
182
|
const attempts: number = Math.ceil(timeout / polling);
|
|
184
183
|
|
|
185
184
|
Logger.trace(`DriverHelper.waitAllPresence ${elementLocator}`);
|
|
@@ -206,7 +205,7 @@ export class DriverHelper {
|
|
|
206
205
|
throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
|
|
207
206
|
}
|
|
208
207
|
|
|
209
|
-
|
|
208
|
+
async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
|
|
210
209
|
Logger.trace(`DriverHelper.waitAllVisibility ${locators}`);
|
|
211
210
|
|
|
212
211
|
for (const elementLocator of locators) {
|
|
@@ -214,9 +213,9 @@ export class DriverHelper {
|
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
attempts: number =
|
|
219
|
-
polling: number =
|
|
216
|
+
async waitDisappearance(elementLocator: By,
|
|
217
|
+
attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
|
|
218
|
+
polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
|
|
220
219
|
|
|
221
220
|
Logger.trace(`DriverHelper.waitDisappearance ${elementLocator}`);
|
|
222
221
|
|
|
@@ -227,7 +226,7 @@ export class DriverHelper {
|
|
|
227
226
|
}
|
|
228
227
|
}
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
async waitDisappearanceWithTimeout(elementLocator: By, timeout: number): Promise<void> {
|
|
231
230
|
Logger.trace(`DriverHelper.waitDisappearanceWithTimeout ${elementLocator}`);
|
|
232
231
|
|
|
233
232
|
await this.getDriver().wait(async () => {
|
|
@@ -239,9 +238,9 @@ export class DriverHelper {
|
|
|
239
238
|
}, timeout);
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
|
|
243
|
-
attemptsPerLocator: number =
|
|
244
|
-
pollingPerLocator: number =
|
|
241
|
+
async waitAllDisappearance(locators: Array<By>,
|
|
242
|
+
attemptsPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
|
|
243
|
+
pollingPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
|
|
245
244
|
|
|
246
245
|
Logger.trace(`DriverHelper.waitAllDisappearance ${locators}`);
|
|
247
246
|
|
|
@@ -250,8 +249,8 @@ export class DriverHelper {
|
|
|
250
249
|
}
|
|
251
250
|
}
|
|
252
251
|
|
|
253
|
-
|
|
254
|
-
const polling: number =
|
|
252
|
+
async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
253
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
255
254
|
const attempts: number = Math.ceil(timeout / polling);
|
|
256
255
|
|
|
257
256
|
Logger.trace(`DriverHelper.waitAndClick ${elementLocator}`);
|
|
@@ -308,9 +307,9 @@ export class DriverHelper {
|
|
|
308
307
|
throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
|
|
309
308
|
}
|
|
310
309
|
|
|
311
|
-
|
|
310
|
+
async waitAndGetElementAttribute(elementLocator: By, attribute: string,
|
|
312
311
|
timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
|
|
313
|
-
const polling: number =
|
|
312
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
314
313
|
const attempts: number = Math.ceil(timeout / polling);
|
|
315
314
|
|
|
316
315
|
Logger.trace(`DriverHelper.waitAndGetElementAttribute ${elementLocator} attribute: '${attribute}'`);
|
|
@@ -350,9 +349,9 @@ export class DriverHelper {
|
|
|
350
349
|
throw new error.TimeoutError(`Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`);
|
|
351
350
|
}
|
|
352
351
|
|
|
353
|
-
|
|
352
|
+
async waitAndGetCssValue(elementLocator: By, cssAttribute: string,
|
|
354
353
|
timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
|
|
355
|
-
const polling: number =
|
|
354
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
356
355
|
const attempts: number = Math.ceil(timeout / polling);
|
|
357
356
|
|
|
358
357
|
Logger.trace(`DriverHelper.waitAndGetCssValue ${elementLocator} cssAttribute: ${cssAttribute}`);
|
|
@@ -392,7 +391,7 @@ export class DriverHelper {
|
|
|
392
391
|
throw new error.TimeoutError(`Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`);
|
|
393
392
|
}
|
|
394
393
|
|
|
395
|
-
|
|
394
|
+
async waitAttributeValue(elementLocator: By,
|
|
396
395
|
attribute: string,
|
|
397
396
|
expectedValue: string,
|
|
398
397
|
timeout: number): Promise<void> {
|
|
@@ -408,8 +407,8 @@ export class DriverHelper {
|
|
|
408
407
|
`The '${attribute}' attribute value doesn't match with expected value '${expectedValue}'`);
|
|
409
408
|
}
|
|
410
409
|
|
|
411
|
-
|
|
412
|
-
const polling: number =
|
|
410
|
+
async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
411
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
413
412
|
const attempts: number = Math.ceil(timeout / polling);
|
|
414
413
|
|
|
415
414
|
if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
|
|
@@ -454,8 +453,8 @@ export class DriverHelper {
|
|
|
454
453
|
throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
|
|
455
454
|
}
|
|
456
455
|
|
|
457
|
-
|
|
458
|
-
const polling: number =
|
|
456
|
+
async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
457
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
459
458
|
const attempts: number = Math.ceil(timeout / polling);
|
|
460
459
|
|
|
461
460
|
Logger.trace(`DriverHelper.typeToInvisible ${elementLocator} text: ${text}`);
|
|
@@ -496,8 +495,8 @@ export class DriverHelper {
|
|
|
496
495
|
throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
|
|
497
496
|
}
|
|
498
497
|
|
|
499
|
-
|
|
500
|
-
const polling: number =
|
|
498
|
+
async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
499
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
501
500
|
const attempts: number = Math.ceil(timeout / polling);
|
|
502
501
|
|
|
503
502
|
Logger.trace(`DriverHelper.clear ${elementLocator}`);
|
|
@@ -538,8 +537,8 @@ export class DriverHelper {
|
|
|
538
537
|
throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
|
|
539
538
|
}
|
|
540
539
|
|
|
541
|
-
|
|
542
|
-
const polling: number =
|
|
540
|
+
async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
541
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
543
542
|
const attempts: number = Math.ceil(timeout / polling);
|
|
544
543
|
|
|
545
544
|
Logger.trace(`DriverHelper.clearInvisible ${elementLocator}`);
|
|
@@ -580,7 +579,7 @@ export class DriverHelper {
|
|
|
580
579
|
throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
|
|
581
580
|
}
|
|
582
581
|
|
|
583
|
-
|
|
582
|
+
async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
584
583
|
if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
|
|
585
584
|
Logger.trace(`DriverHelper.enterValue ${elementLocator} text: ***`);
|
|
586
585
|
} else {
|
|
@@ -594,14 +593,14 @@ export class DriverHelper {
|
|
|
594
593
|
await this.waitAttributeValue(elementLocator, 'value', text, timeout);
|
|
595
594
|
}
|
|
596
595
|
|
|
597
|
-
|
|
596
|
+
async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise<void> {
|
|
598
597
|
Logger.trace(`DriverHelper.waitAndSwitchToFrame ${iframeLocator}`);
|
|
599
598
|
|
|
600
599
|
await this.driver.wait(until.ableToSwitchToFrame(iframeLocator), timeout);
|
|
601
600
|
}
|
|
602
601
|
|
|
603
|
-
|
|
604
|
-
const polling: number =
|
|
602
|
+
async waitAndGetText(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
|
|
603
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
605
604
|
const attempts: number = Math.ceil(timeout / polling);
|
|
606
605
|
|
|
607
606
|
Logger.trace(`DriverHelper.waitAndGetText ${elementLocator}`);
|
|
@@ -641,20 +640,20 @@ export class DriverHelper {
|
|
|
641
640
|
throw new error.TimeoutError(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
|
|
642
641
|
}
|
|
643
642
|
|
|
644
|
-
|
|
643
|
+
async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
|
|
645
644
|
Logger.trace(`DriverHelper.waitAndGetValue ${elementLocator}`);
|
|
646
645
|
|
|
647
646
|
return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout);
|
|
648
647
|
}
|
|
649
648
|
|
|
650
|
-
|
|
649
|
+
async waitUntilTrue(callback: any, timeout: number): Promise<void> {
|
|
651
650
|
Logger.trace('DriverHelper.waitUntilTrue');
|
|
652
651
|
|
|
653
652
|
await this.driver.wait(callback, timeout);
|
|
654
653
|
}
|
|
655
654
|
|
|
656
|
-
|
|
657
|
-
const polling: number =
|
|
655
|
+
async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
656
|
+
const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
658
657
|
const attempts: number = Math.ceil(timeout / polling);
|
|
659
658
|
|
|
660
659
|
Logger.trace(`DriverHelper.scrollTo ${elementLocator}`);
|
|
@@ -696,16 +695,21 @@ export class DriverHelper {
|
|
|
696
695
|
throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
|
|
697
696
|
}
|
|
698
697
|
|
|
699
|
-
|
|
698
|
+
async scrollToAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
700
699
|
await this.scrollTo(elementLocator, timeout);
|
|
701
700
|
await this.waitAndClick(elementLocator, timeout);
|
|
702
701
|
}
|
|
703
702
|
|
|
704
|
-
|
|
703
|
+
async scrollToAndEnterValue(elementLocator: By, value: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
|
|
705
704
|
await this.scrollTo(elementLocator, timeout);
|
|
706
705
|
await this.enterValue(elementLocator, value, timeout);
|
|
707
706
|
}
|
|
708
707
|
|
|
708
|
+
// method is useful to debug page object elements
|
|
709
|
+
async highLightElement(element: WebElement): Promise<void> {
|
|
710
|
+
await this.getDriver().executeScript('arguments[0].style.border=\'2px solid red\'', element);
|
|
711
|
+
}
|
|
712
|
+
|
|
709
713
|
getDriver(): ThenableWebDriver {
|
|
710
714
|
Logger.trace('DriverHelper.getDriver');
|
|
711
715
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { echo, exec, ShellString } from 'shelljs';
|
|
2
|
-
import { KubernetesCommandLineTool, TestConstants } from '../constants/TestConstants';
|
|
3
2
|
import { Logger } from './Logger';
|
|
4
3
|
import { ShellExecutor } from './ShellExecutor';
|
|
5
4
|
import * as path from 'path';
|
|
5
|
+
import { APITestConstants, KubernetesCommandLineTool } from '../constants/APITestConstants';
|
|
6
|
+
import { BaseTestConstants } from '../constants/BaseTestConstants';
|
|
7
|
+
import { OAuthConstants } from '../constants/OAuthConstants';
|
|
6
8
|
|
|
7
9
|
export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
8
10
|
private static container: string;
|
|
9
11
|
private static pod: string;
|
|
10
12
|
private readonly namespace: string;
|
|
11
13
|
private readonly workspaceName: string | undefined;
|
|
12
|
-
private readonly KUBERNETES_COMMAND_LINE_TOOL: string =
|
|
14
|
+
private readonly KUBERNETES_COMMAND_LINE_TOOL: string = APITestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
|
|
13
15
|
|
|
14
16
|
constructor(_workspaceName?: string, _namespace?: string) {
|
|
15
17
|
super();
|
|
@@ -33,8 +35,8 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
|
33
35
|
if (this.isUserLoggedIn()) {
|
|
34
36
|
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: User already logged`);
|
|
35
37
|
} else {
|
|
36
|
-
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${
|
|
37
|
-
exec(`oc login --server=${url} -u=${
|
|
38
|
+
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${APITestConstants.TS_SELENIUM_OCP_USERNAME}`);
|
|
39
|
+
exec(`oc login --server=${url} -u=${APITestConstants.TS_SELENIUM_OCP_USERNAME} -p=${APITestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
|
|
38
40
|
}
|
|
39
41
|
} else {
|
|
40
42
|
Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: doesn't support login command`);
|
|
@@ -43,22 +45,22 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
|
43
45
|
|
|
44
46
|
getContainerName(): string {
|
|
45
47
|
Logger.debug(`${this.getLoggingName(this.getContainerName.name)}: Get container name.`);
|
|
46
|
-
const output: ShellString =
|
|
48
|
+
const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get ${(KubernetesCommandLineToolsExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
|
|
47
49
|
echo('\n');
|
|
48
50
|
return output.stderr ? output.stderr : output.stdout;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
getWorkspacePodName(): string {
|
|
52
54
|
Logger.debug(`${this.getLoggingName(this.getWorkspacePodName.name)}: Get workspace pod name.`);
|
|
53
|
-
const output: ShellString =
|
|
55
|
+
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`);
|
|
54
56
|
return output.stderr ? output.stderr : output.stdout.replace('\n', '');
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
deleteDevWorkspace(): void {
|
|
58
60
|
Logger.debug(`${this.getLoggingName(this.deleteDevWorkspace.name)}: Delete '${this.workspaceName}' workspace`);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
|
|
62
|
+
ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
|
|
63
|
+
ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dwt ${APITestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
|
|
@@ -66,58 +68,62 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
|
66
68
|
this.createNamespace();
|
|
67
69
|
}
|
|
68
70
|
this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
|
|
69
|
-
|
|
70
|
-
KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
|
|
71
|
-
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
72
|
-
return output;
|
|
71
|
+
return this.waitDevWorkspace();
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
executeCommand(commandToExecute: string): ShellString {
|
|
74
|
+
executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
|
|
76
75
|
Logger.debug(`${this.getLoggingName(this.executeCommand.name)}:`);
|
|
77
|
-
return
|
|
76
|
+
return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
applyYamlConfigurationAsStringOutput(yamlConfiguration: string):
|
|
79
|
+
applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
|
|
81
80
|
Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsStringOutput.name)}:`);
|
|
82
|
-
|
|
81
|
+
return ShellExecutor.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
|
|
83
82
|
yamlConfiguration + '\n' +
|
|
84
83
|
'EOF');
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
applyYamlConfigurationAsFile(pathToFile: string): void {
|
|
88
87
|
Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsFile.name)}:`);
|
|
89
|
-
|
|
88
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
getDevWorkspaceYamlConfiguration(): ShellString {
|
|
93
92
|
Logger.debug(`${this.getLoggingName(this.getDevWorkspaceYamlConfiguration.name)}:`);
|
|
94
|
-
return
|
|
93
|
+
return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
96
|
waitDevWorkspace(timeout: number = 360): ShellString {
|
|
98
97
|
Logger.debug(`${this.getLoggingName(this.waitDevWorkspace.name)}: Wait till workspace ready.`);
|
|
99
|
-
|
|
98
|
+
const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
|
|
99
|
+
this.getPodAndContainerNames();
|
|
100
|
+
return output;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
createNamespace(): void {
|
|
103
104
|
Logger.debug(`${this.getLoggingName(this.createNamespace.name)}: Create namespace "${this.namespace}".`);
|
|
104
|
-
|
|
105
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
createProject(projectName: string): void {
|
|
108
109
|
Logger.debug(`${this.getLoggingName(this.createProject.name)}: Create new project "${projectName}".`);
|
|
109
|
-
|
|
110
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
deleteProject(projectName: string): void {
|
|
113
114
|
Logger.debug(`${this.getLoggingName(this.deleteProject.name)}: Delete "${projectName}".`);
|
|
114
|
-
|
|
115
|
+
ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private getPodAndContainerNames(): void {
|
|
119
|
+
KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
|
|
120
|
+
KubernetesCommandLineToolsExecutor.container = this.getContainerName();
|
|
115
121
|
}
|
|
116
122
|
|
|
117
123
|
private isUserLoggedIn(): boolean {
|
|
118
|
-
const whoamiCommandOutput: ShellString =
|
|
124
|
+
const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
|
|
119
125
|
|
|
120
|
-
return whoamiCommandOutput.stdout.includes(
|
|
126
|
+
return whoamiCommandOutput.stdout.includes(OAuthConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
private getLoggingName(methodName: string): string {
|
|
@@ -126,15 +132,15 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
|
|
|
126
132
|
|
|
127
133
|
private setNamespace(_namespace: string | undefined): string {
|
|
128
134
|
_namespace = _namespace !== undefined ? _namespace
|
|
129
|
-
:
|
|
130
|
-
:
|
|
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'
|
|
131
137
|
: 'default';
|
|
132
138
|
return _namespace;
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
private getServerUrl(): string {
|
|
136
142
|
Logger.debug(`${this.getLoggingName(this.getServerUrl.name)}: Get server api url.`);
|
|
137
|
-
return
|
|
143
|
+
return BaseTestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
|
|
@@ -163,5 +169,14 @@ export namespace KubernetesCommandLineToolsExecutor {
|
|
|
163
169
|
removeFolder(path: string): ShellString {
|
|
164
170
|
return this.executeCommand('rm -rf ' + path);
|
|
165
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
|
+
}
|
|
166
181
|
}
|
|
167
182
|
}
|