@eclipse-che/che-e2e 7.64.0-dev-20514b2 → 7.64.0-dev-f0466d9
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 +11 -37
- package/build/dockerfiles/entrypoint.sh +1 -1
- package/configs/inversify.config.ts +11 -26
- package/configs/inversify.types.ts +5 -35
- package/configs/mocharc.ts +9 -3
- package/configs/sh-scripts/initDefaultValues.sh +0 -5
- package/constants/TestConstants.ts +35 -97
- package/constants/TimeoutConstants.ts +1 -1
- package/dist/configs/inversify.config.js +8 -23
- package/dist/configs/inversify.config.js.map +1 -1
- package/dist/configs/inversify.types.js +3 -33
- package/dist/configs/inversify.types.js.map +1 -1
- package/dist/configs/mocharc.js +11 -4
- package/dist/configs/mocharc.js.map +1 -1
- package/dist/constants/TestConstants.js +31 -86
- package/dist/constants/TestConstants.js.map +1 -1
- package/dist/constants/TimeoutConstants.js.map +1 -1
- package/dist/driver/ChromeDriver.js +1 -1
- package/dist/driver/ChromeDriver.js.map +1 -1
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/pageobjects/dashboard/CreateWorkspace.js +8 -16
- package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +16 -1
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/Workspaces.js +1 -3
- package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
- package/dist/pageobjects/git-providers/OauthPage.js +150 -0
- package/dist/pageobjects/git-providers/OauthPage.js.map +1 -0
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js +65 -0
- package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -0
- package/dist/pageobjects/login/OcpRedHatLoginPage.js +67 -0
- package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/RedHatLoginPage.js +78 -0
- package/dist/pageobjects/login/RedHatLoginPage.js.map +1 -0
- package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js +3 -21
- package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/CheLoginPage.js +0 -33
- package/dist/pageobjects/openshift/CheLoginPage.js.map +1 -1
- package/dist/pageobjects/openshift/OcpLoginPage.js +0 -14
- package/dist/pageobjects/openshift/OcpLoginPage.js.map +1 -1
- package/dist/specs/MochaHooks.js +2 -2
- package/dist/specs/MochaHooks.js.map +1 -1
- package/dist/specs/SmokeTest.spec.js +49 -0
- package/dist/specs/SmokeTest.spec.js.map +1 -0
- package/dist/specs/devfiles/EmptyWorkspace.spec.js +1 -0
- package/dist/specs/devfiles/EmptyWorkspace.spec.js.map +1 -1
- package/dist/specs/devfiles/Quarkus.spec.js +50 -0
- package/dist/specs/devfiles/Quarkus.spec.js.map +1 -0
- package/dist/specs/factory/Factory.spec.js +160 -0
- package/dist/specs/factory/Factory.spec.js.map +1 -0
- package/dist/specs/factory/NoSetupRepoFactory.spec.js +228 -0
- package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -0
- package/dist/specs/factory/RefusedOAuthFactory.spec.js +220 -0
- package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -0
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +66 -0
- package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -0
- package/dist/tests-library/LoginTests.js +10 -2
- package/dist/tests-library/LoginTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +15 -6
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/BrowserTabsUtil.js +2 -21
- package/dist/utils/BrowserTabsUtil.js.map +1 -1
- package/dist/utils/CheReporter.js +5 -2
- package/dist/utils/CheReporter.js.map +1 -1
- package/dist/utils/DriverHelper.js +11 -73
- package/dist/utils/DriverHelper.js.map +1 -1
- package/dist/utils/Logger.js +5 -0
- package/dist/utils/Logger.js.map +1 -1
- package/dist/utils/Sanitizer.js.map +1 -1
- package/dist/utils/ScreenCatcher.js.map +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js +1 -1
- package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/vsc/GitUtil.js +36 -0
- package/dist/utils/vsc/GitUtil.js.map +1 -0
- package/dist/utils/workspace/ApiUrlResolver.js +0 -3
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
- package/dist/utils/workspace/TestWorkspaceUtil.js +3 -193
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/driver/ChromeDriver.ts +3 -3
- package/index.ts +37 -0
- package/package.json +9 -5
- package/pageobjects/dashboard/CreateWorkspace.ts +10 -21
- package/pageobjects/dashboard/Dashboard.ts +37 -16
- package/pageobjects/dashboard/Workspaces.ts +21 -23
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +16 -16
- package/pageobjects/git-providers/OauthPage.ts +156 -0
- package/pageobjects/ide/CheCodeLocatorLoader.ts +69 -0
- package/pageobjects/login/OcpRedHatLoginPage.ts +49 -0
- package/pageobjects/login/OcpUserLoginPage.ts +1 -1
- package/pageobjects/login/RedHatLoginPage.ts +62 -0
- package/pageobjects/login/RegularUserOcpCheLoginPage.ts +2 -21
- package/pageobjects/openshift/CheLoginPage.ts +8 -57
- package/pageobjects/openshift/OcpLoginPage.ts +8 -29
- package/specs/MochaHooks.ts +9 -9
- package/specs/SmokeTest.spec.ts +50 -0
- package/specs/devfiles/EmptyWorkspace.spec.ts +1 -0
- package/specs/devfiles/Quarkus.spec.ts +52 -0
- package/specs/factory/Factory.spec.ts +199 -0
- package/specs/factory/NoSetupRepoFactory.spec.ts +272 -0
- package/specs/factory/RefusedOAuthFactory.spec.ts +260 -0
- package/specs/miscellaneous/PredefinedNamespace.spec.ts +74 -0
- package/tests-library/LoginTests.ts +9 -1
- package/tests-library/WorkspaceHandlingTests.ts +16 -7
- package/tslint.json +4 -4
- package/utils/BrowserTabsUtil.ts +9 -31
- package/utils/CheReporter.ts +12 -8
- package/utils/DriverHelper.ts +40 -115
- package/utils/Logger.ts +13 -8
- package/utils/Sanitizer.ts +0 -1
- package/utils/ScreenCatcher.ts +8 -7
- package/utils/request-handlers/CheApiRequestHandler.ts +1 -1
- package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +2 -1
- package/utils/vsc/GitUtil.ts +25 -0
- package/utils/workspace/ApiUrlResolver.ts +3 -6
- package/utils/workspace/ITestWorkspaceUtil.ts +1 -56
- package/utils/workspace/TestWorkspaceUtil.ts +24 -265
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +0 -97
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +0 -1
- package/dist/pageobjects/login/MultiUserLoginPage.js +0 -49
- package/dist/pageobjects/login/MultiUserLoginPage.js.map +0 -1
- package/dist/pageobjects/login/UpdateAccountInformationPage.js +0 -74
- package/dist/pageobjects/login/UpdateAccountInformationPage.js.map +0 -1
- package/dist/pageobjects/third-parties/GitLoginPage.js +0 -85
- package/dist/pageobjects/third-parties/GitLoginPage.js.map +0 -1
- package/dist/pageobjects/third-parties/GitOauthAppsSettings.js +0 -110
- package/dist/pageobjects/third-parties/GitOauthAppsSettings.js.map +0 -1
- package/dist/specs/login/LinkCheAndOcpUsers.spec.js +0 -40
- package/dist/specs/login/LinkCheAndOcpUsers.spec.js.map +0 -1
- package/dist/utils/WorkspaceNameHandler.js +0 -60
- package/dist/utils/WorkspaceNameHandler.js.map +0 -1
- package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js +0 -50
- package/dist/utils/request-handlers/tokens/CheMultiuserTokenHandler.js.map +0 -1
- package/dist/utils/request-handlers/tokens/ITokenHandler.js +0 -12
- package/dist/utils/request-handlers/tokens/ITokenHandler.js.map +0 -1
- package/dist/utils/vsc/CheGitApi.js +0 -42
- package/dist/utils/vsc/CheGitApi.js.map +0 -1
- package/dist/utils/vsc/github/GitHubUtil.js +0 -126
- package/dist/utils/vsc/github/GitHubUtil.js.map +0 -1
- package/files/devfiles/plugins/GitHubPullRequestPlugin.yaml +0 -11
- package/files/devfiles/plugins/InstallPluginUsingUI.yaml +0 -3
- package/files/devfiles/plugins/Java11PluginTest.yaml +0 -17
- package/files/devfiles/plugins/PhpPluginTest.yaml +0 -47
- package/files/devfiles/plugins/PythonPluginTest.yaml +0 -14
- package/files/devfiles/plugins/TypescriptNodeDebug2PluginTest.yaml +0 -49
- package/files/devfiles/plugins/VscodeKubernetesPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeShellcheckPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeValePlugin.yaml +0 -42
- package/files/devfiles/plugins/VscodeXmlPlugin.yaml +0 -12
- package/files/devfiles/plugins/VscodeYamlPlugin.yaml +0 -12
- package/files/happy-path/containers-happy-path.yaml +0 -127
- package/files/happy-path/happy-path-workspace.yaml +0 -95
- package/files/happy-path/petclinic-classpath.txt +0 -49
- package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +0 -95
- package/pageobjects/login/MultiUserLoginPage.ts +0 -33
- package/pageobjects/login/UpdateAccountInformationPage.ts +0 -70
- package/pageobjects/third-parties/GitLoginPage.ts +0 -81
- package/pageobjects/third-parties/GitOauthAppsSettings.ts +0 -110
- package/specs/login/LinkCheAndOcpUsers.spec.ts +0 -49
- package/utils/WorkspaceNameHandler.ts +0 -48
- package/utils/request-handlers/tokens/CheMultiuserTokenHandler.ts +0 -41
- package/utils/request-handlers/tokens/ITokenHandler.ts +0 -14
- package/utils/vsc/CheGitApi.ts +0 -22
- package/utils/vsc/github/GitHubUtil.ts +0 -110
package/utils/Logger.ts
CHANGED
|
@@ -15,16 +15,18 @@ export abstract class Logger {
|
|
|
15
15
|
/**
|
|
16
16
|
* Uses for logging of fatal errors.
|
|
17
17
|
* @param text log text
|
|
18
|
+
* @param indentLevel log level
|
|
18
19
|
*/
|
|
19
|
-
public static error(text: string, indentLevel: number = 1) {
|
|
20
|
+
public static error(text: string, indentLevel: number = 1): void {
|
|
20
21
|
this.logText(indentLevel, `[ERROR] ${text}`);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Uses for logging of recoverable errors and general warnings.
|
|
25
26
|
* @param text log text
|
|
27
|
+
* @param indentLevel log level
|
|
26
28
|
*/
|
|
27
|
-
public static warn(text: string, indentLevel: number = 1) {
|
|
29
|
+
public static warn(text: string, indentLevel: number = 1): void {
|
|
28
30
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR') {
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
@@ -34,8 +36,9 @@ export abstract class Logger {
|
|
|
34
36
|
/**
|
|
35
37
|
* Uses for logging of the public methods of the pageobjects.
|
|
36
38
|
* @param text log text
|
|
39
|
+
* @param indentLevel log level
|
|
37
40
|
*/
|
|
38
|
-
public static info(text: string, indentLevel: number = 3) {
|
|
41
|
+
public static info(text: string, indentLevel: number = 3): void {
|
|
39
42
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
40
43
|
TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN') {
|
|
41
44
|
return;
|
|
@@ -46,8 +49,9 @@ export abstract class Logger {
|
|
|
46
49
|
/**
|
|
47
50
|
* Uses for logging of the public methods of the pageobjects.
|
|
48
51
|
* @param text log text
|
|
52
|
+
* @param indentLevel log level
|
|
49
53
|
*/
|
|
50
|
-
public static debug(text: string, indentLevel: number = 5) {
|
|
54
|
+
public static debug(text: string, indentLevel: number = 5): void {
|
|
51
55
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
52
56
|
TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
|
|
53
57
|
TestConstants.TS_SELENIUM_LOG_LEVEL === 'INFO') {
|
|
@@ -60,8 +64,9 @@ export abstract class Logger {
|
|
|
60
64
|
* Uses for logging of the public methods of the {@link DriverHelper} or
|
|
61
65
|
* private methods inside of pageobjects.
|
|
62
66
|
* @param text log text
|
|
67
|
+
* @param indentLevel log level
|
|
63
68
|
*/
|
|
64
|
-
public static trace(text: string, indentLevel: number = 6) {
|
|
69
|
+
public static trace(text: string, indentLevel: number = 6): void {
|
|
65
70
|
if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
|
|
66
71
|
TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
|
|
67
72
|
TestConstants.TS_SELENIUM_LOG_LEVEL === 'INFO' ||
|
|
@@ -71,16 +76,16 @@ export abstract class Logger {
|
|
|
71
76
|
this.logText(indentLevel, `‣ ${text}`);
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
private static logText(messageIndentationLevel: number, text: string) {
|
|
79
|
+
private static logText(messageIndentationLevel: number, text: string): void {
|
|
75
80
|
// start group for every level
|
|
76
|
-
for (let i = 0; i < messageIndentationLevel; i++) {
|
|
81
|
+
for (let i: number = 0; i < messageIndentationLevel; i++) {
|
|
77
82
|
console.group();
|
|
78
83
|
}
|
|
79
84
|
// print the trimmed text
|
|
80
85
|
// if multiline, the message should be properly padded
|
|
81
86
|
console.log(text);
|
|
82
87
|
// end group for every level
|
|
83
|
-
for (let i = 0; i < messageIndentationLevel; i++) {
|
|
88
|
+
for (let i: number = 0; i < messageIndentationLevel; i++) {
|
|
84
89
|
console.groupEnd();
|
|
85
90
|
}
|
|
86
91
|
}
|
package/utils/Sanitizer.ts
CHANGED
package/utils/ScreenCatcher.ts
CHANGED
|
@@ -14,15 +14,16 @@ import { DriverHelper } from './DriverHelper';
|
|
|
14
14
|
import { Sanitizer } from './Sanitizer';
|
|
15
15
|
import { error } from 'selenium-webdriver';
|
|
16
16
|
import { TestConstants } from '../constants/TestConstants';
|
|
17
|
+
import { WriteStream } from 'fs';
|
|
17
18
|
|
|
18
19
|
@injectable()
|
|
19
20
|
export class ScreenCatcher {
|
|
20
21
|
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
21
22
|
@inject(CLASSES.Sanitizer) private readonly sanitizer: Sanitizer) { }
|
|
22
23
|
|
|
23
|
-
async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number) {
|
|
24
|
-
const executionScreenCastDir = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
|
|
25
|
-
const executionScreenCastErrorsDir = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`;
|
|
24
|
+
async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
|
|
25
|
+
const executionScreenCastDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
|
|
26
|
+
const executionScreenCastErrorsDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`;
|
|
26
27
|
const formattedMethodIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(methodIndex);
|
|
27
28
|
const formattedScreenshotIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 5 }).format(screenshotIndex).replace(/,/g, '');
|
|
28
29
|
|
|
@@ -54,18 +55,18 @@ export class ScreenCatcher {
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
async catchScreen(screenshotPath: string) {
|
|
58
|
+
async catchScreen(screenshotPath: string): Promise<void> {
|
|
58
59
|
const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
|
|
59
|
-
const screenshotStream = fs.createWriteStream(screenshotPath);
|
|
60
|
+
const screenshotStream: WriteStream = fs.createWriteStream(screenshotPath);
|
|
60
61
|
screenshotStream.write(Buffer.from(screenshot, 'base64'));
|
|
61
62
|
screenshotStream.end();
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
async writeErrorLog(errorLogPath: string, err: error.IError) {
|
|
65
|
+
async writeErrorLog(errorLogPath: string, err: error.IError): Promise<void> {
|
|
65
66
|
console.log(`Failed to save screenshot, additional information in the ${errorLogPath}`);
|
|
66
67
|
|
|
67
68
|
if (err.stack) {
|
|
68
|
-
const screenshotStream = fs.createWriteStream(errorLogPath);
|
|
69
|
+
const screenshotStream: WriteStream = fs.createWriteStream(errorLogPath);
|
|
69
70
|
screenshotStream.write(Buffer.from(err.stack, 'utf8'));
|
|
70
71
|
screenshotStream.end();
|
|
71
72
|
}
|
|
@@ -21,7 +21,7 @@ export class CheApiRequestHandler {
|
|
|
21
21
|
/**
|
|
22
22
|
* This method adds a request interceptor into axios request interceptors list and returns an ID of the interceptor
|
|
23
23
|
*/
|
|
24
|
-
public static
|
|
24
|
+
public static enableRequestInterceptor(): number {
|
|
25
25
|
Logger.debug(`CheApiRequestHandler.enableRequestInterceptor`);
|
|
26
26
|
return axios.interceptors.request.use( request => {
|
|
27
27
|
try {
|
|
@@ -13,6 +13,7 @@ import { inject, injectable } from 'inversify';
|
|
|
13
13
|
import { DriverHelper } from '../../DriverHelper';
|
|
14
14
|
import { CLASSES } from '../../../configs/inversify.types';
|
|
15
15
|
import { Logger } from '../../Logger';
|
|
16
|
+
import { IWebDriverCookie } from 'selenium-webdriver';
|
|
16
17
|
|
|
17
18
|
@injectable()
|
|
18
19
|
export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
|
|
@@ -22,7 +23,7 @@ export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHea
|
|
|
22
23
|
|
|
23
24
|
async get(): Promise<AxiosRequestConfig> {
|
|
24
25
|
try {
|
|
25
|
-
let token = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy');
|
|
26
|
+
let token: IWebDriverCookie = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy');
|
|
26
27
|
if (this.authorizationToken !== token.value) {
|
|
27
28
|
this.authorizationToken = token.value;
|
|
28
29
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* Copyright (c) 2019 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
|
+
|
|
11
|
+
import { injectable } from 'inversify';
|
|
12
|
+
|
|
13
|
+
@injectable()
|
|
14
|
+
export class GitUtil {
|
|
15
|
+
/**
|
|
16
|
+
* Method extracts a test repo name from git clone https url;
|
|
17
|
+
* it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git" word, than returns the last one;
|
|
18
|
+
* please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
|
|
19
|
+
* @param url git https url (which using for "git clone")
|
|
20
|
+
* @return project name
|
|
21
|
+
*/
|
|
22
|
+
getProjectNameFromGitUrl(url: string): string {
|
|
23
|
+
return url.split(/[\/.]/).filter((e: string) => e !== '' && e !== 'git').reverse()[0];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -11,6 +11,7 @@ import { inject, injectable } from 'inversify';
|
|
|
11
11
|
import { CLASSES } from '../../configs/inversify.types';
|
|
12
12
|
import { Logger } from '../Logger';
|
|
13
13
|
import { CheApiRequestHandler } from '../request-handlers/CheApiRequestHandler';
|
|
14
|
+
import { AxiosResponse } from 'axios';
|
|
14
15
|
|
|
15
16
|
@injectable()
|
|
16
17
|
export class ApiUrlResolver {
|
|
@@ -26,19 +27,15 @@ export class ApiUrlResolver {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
public async getWorkspacesApiUrl(): Promise<string> {
|
|
29
|
-
const namespace = await this.obtainUserNamespace();
|
|
30
|
+
const namespace: string = await this.obtainUserNamespace();
|
|
30
31
|
return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
public getKubernetesApiUrl(): string {
|
|
34
|
-
return ApiUrlResolver.KUBERNETES_API_URL;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
34
|
private async obtainUserNamespace(): Promise<string> {
|
|
38
35
|
Logger.debug(`ApiUrlResolver.obtainUserNamespace ${this.userNamespace}`);
|
|
39
36
|
if (this.userNamespace.length === 0) {
|
|
40
37
|
Logger.trace(`ApiUrlResolver.obtainUserNamespace USER_NAMESPACE.length = 0, calling kubernetes API`);
|
|
41
|
-
const kubernetesResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
38
|
+
const kubernetesResponse: AxiosResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
42
39
|
if (kubernetesResponse.status !== 200) {
|
|
43
40
|
throw new Error(`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`);
|
|
44
41
|
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
11
|
import { WorkspaceStatus } from './WorkspaceStatus';
|
|
12
|
-
import { che } from '@eclipse-che/api';
|
|
13
12
|
|
|
14
13
|
export interface ITestWorkspaceUtil {
|
|
15
14
|
waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): void;
|
|
@@ -17,7 +16,7 @@ export interface ITestWorkspaceUtil {
|
|
|
17
16
|
stopWorkspaceByName(workspaceName: string): void;
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
|
-
* Delete a
|
|
19
|
+
* Delete a workspace without stopping phase (similar with force deleting)
|
|
21
20
|
*/
|
|
22
21
|
deleteWorkspaceByName(workspaceName: string): void;
|
|
23
22
|
|
|
@@ -41,58 +40,4 @@ export interface ITestWorkspaceUtil {
|
|
|
41
40
|
* Similar with 'force' deleting
|
|
42
41
|
*/
|
|
43
42
|
deleteAllWorkspaces(namespace: string): void;
|
|
44
|
-
|
|
45
|
-
/*=====================
|
|
46
|
-
* DEPRECATED METHODS *
|
|
47
|
-
*====================*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
51
|
-
*/
|
|
52
|
-
cleanUpAllWorkspaces(): void;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
56
|
-
*/
|
|
57
|
-
cleanUpRunningWorkspace(workspaceName: string): void;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
61
|
-
*/
|
|
62
|
-
waitPluginAdding(namespace: string, workspaceName: string, pluginId: string): void;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
66
|
-
*/
|
|
67
|
-
removeWorkspaceById(id: string): void;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
71
|
-
*/
|
|
72
|
-
stopWorkspaceById(id: string): void;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
76
|
-
*/
|
|
77
|
-
getIdOfRunningWorkspace(workspaceName: string): Promise<string>;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
81
|
-
*/
|
|
82
|
-
getIdOfRunningWorkspaces(): Promise<Array<string>>;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
86
|
-
*/
|
|
87
|
-
createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile): void;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
91
|
-
*/
|
|
92
|
-
getBaseDevfile(): Promise<che.workspace.devfile.Devfile>;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
96
|
-
*/
|
|
97
|
-
startWorkspace(workspaceId: string): void;
|
|
98
43
|
}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
11
|
import 'reflect-metadata';
|
|
12
|
-
import { che } from '@eclipse-che/api';
|
|
13
12
|
import { TestConstants } from '../../constants/TestConstants';
|
|
14
13
|
import { injectable, inject } from 'inversify';
|
|
15
14
|
import { DriverHelper } from '../DriverHelper';
|
|
@@ -18,7 +17,7 @@ import { error } from 'selenium-webdriver';
|
|
|
18
17
|
import { CheApiRequestHandler } from '../request-handlers/CheApiRequestHandler';
|
|
19
18
|
import { CLASSES } from '../../configs/inversify.types';
|
|
20
19
|
import { Logger } from '../Logger';
|
|
21
|
-
import axios from 'axios';
|
|
20
|
+
import axios, { AxiosResponse } from 'axios';
|
|
22
21
|
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
|
|
23
22
|
import { ApiUrlResolver } from './ApiUrlResolver';
|
|
24
23
|
|
|
@@ -33,13 +32,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
33
32
|
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver
|
|
34
33
|
) { }
|
|
35
34
|
|
|
36
|
-
public async waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) {
|
|
35
|
+
public async waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): Promise<void> {
|
|
37
36
|
Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus');
|
|
38
37
|
|
|
39
38
|
let workspaceStatus: string = '';
|
|
40
39
|
let expectedStatus: boolean = false;
|
|
41
|
-
for (let i = 0; i < this.attempts; i++) {
|
|
42
|
-
const response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName));
|
|
40
|
+
for (let i: number = 0; i < this.attempts; i++) {
|
|
41
|
+
const response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName));
|
|
43
42
|
|
|
44
43
|
if (response.status !== 200) {
|
|
45
44
|
throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`);
|
|
@@ -56,16 +55,16 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
if (!expectedStatus) {
|
|
59
|
-
let waitTime = this.attempts * this.polling;
|
|
60
|
-
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.
|
|
58
|
+
let waitTime: number = this.attempts * this.polling;
|
|
59
|
+
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Current status is: ${workspaceStatus}`);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
public async stopWorkspaceByName(workspaceName: string) {
|
|
63
|
+
public async stopWorkspaceByName(workspaceName: string): Promise<void> {
|
|
65
64
|
Logger.debug('TestWorkspaceUtil.stopWorkspaceByName');
|
|
66
65
|
|
|
67
66
|
const stopWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName);
|
|
68
|
-
let stopWorkspaceResponse;
|
|
67
|
+
let stopWorkspaceResponse: AxiosResponse;
|
|
69
68
|
|
|
70
69
|
try {
|
|
71
70
|
stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{'op': 'replace', 'path': '/spec/started', 'value': false}]);
|
|
@@ -81,12 +80,12 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
81
80
|
await this.waitWorkspaceStatus(workspaceName, WorkspaceStatus.STOPPED);
|
|
82
81
|
}
|
|
83
82
|
|
|
84
|
-
// delete a
|
|
85
|
-
public async deleteWorkspaceByName(workspaceName: string) {
|
|
83
|
+
// delete a workspace without stopping phase (similar with force deleting)
|
|
84
|
+
public async deleteWorkspaceByName(workspaceName: string): Promise<void> {
|
|
86
85
|
Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` );
|
|
87
86
|
|
|
88
87
|
const deleteWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName);
|
|
89
|
-
let deleteWorkspaceResponse;
|
|
88
|
+
let deleteWorkspaceResponse: AxiosResponse;
|
|
90
89
|
let deleteWorkspaceStatus: boolean = false;
|
|
91
90
|
try {
|
|
92
91
|
deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl);
|
|
@@ -103,7 +102,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
103
102
|
throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
for (let i = 0; i < this.attempts; i++) {
|
|
105
|
+
for (let i: number = 0; i < this.attempts; i++) {
|
|
107
106
|
try {
|
|
108
107
|
deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl);
|
|
109
108
|
} catch (error) {
|
|
@@ -115,13 +114,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
if (!deleteWorkspaceStatus) {
|
|
118
|
-
let waitTime = this.attempts * this.polling;
|
|
117
|
+
let waitTime: number = this.attempts * this.polling;
|
|
119
118
|
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
// stop workspace before deleting with checking stopping phase
|
|
124
|
-
public async stopAndDeleteWorkspaceByName(workspaceName: string) {
|
|
123
|
+
public async stopAndDeleteWorkspaceByName(workspaceName: string): Promise<void> {
|
|
125
124
|
Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName');
|
|
126
125
|
|
|
127
126
|
await this.stopWorkspaceByName(workspaceName);
|
|
@@ -129,21 +128,21 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
// stop all run workspaces in the namespace
|
|
132
|
-
public async stopAllRunningWorkspaces(namespace: string) {
|
|
131
|
+
public async stopAllRunningWorkspaces(namespace: string): Promise<void> {
|
|
133
132
|
Logger.debug('TestWorkspaceUtil.stopAllRunProjects');
|
|
134
|
-
let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
135
|
-
for (let i = 0; i < response.data.items.length; i++) {
|
|
133
|
+
let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
134
|
+
for (let i: number = 0; i < response.data.items.length; i++) {
|
|
136
135
|
Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name);
|
|
137
136
|
await this.stopWorkspaceByName(response.data.items[i].metadata.name);
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
|
|
141
|
-
// stop all run workspaces, check
|
|
142
|
-
public async stopAndDeleteAllRunningWorkspaces(namespace: string) {
|
|
140
|
+
// stop all run workspaces, check statuses and remove the workspaces
|
|
141
|
+
public async stopAndDeleteAllRunningWorkspaces(namespace: string): Promise<void> {
|
|
143
142
|
Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects');
|
|
144
|
-
let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
143
|
+
let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
145
144
|
await this.stopAllRunningWorkspaces(namespace);
|
|
146
|
-
for (let i = 0; i < response.data.items.length; i++) {
|
|
145
|
+
for (let i: number = 0; i < response.data.items.length; i++) {
|
|
147
146
|
Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name);
|
|
148
147
|
await this.deleteWorkspaceByName(response.data.items[i].metadata.name);
|
|
149
148
|
}
|
|
@@ -151,253 +150,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
151
150
|
|
|
152
151
|
// stop all run workspaces without stopping and waiting for of 'Stopped' phase
|
|
153
152
|
// similar with 'force' deleting
|
|
154
|
-
public async deleteAllWorkspaces(namespace: string) {
|
|
153
|
+
public async deleteAllWorkspaces(namespace: string): Promise<void> {
|
|
155
154
|
Logger.debug('TestWorkspaceUtil.deleteAllRunProjects');
|
|
156
|
-
let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
155
|
+
let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
157
156
|
|
|
158
|
-
for (let i = 0; i < response.data.items.length; i++) {
|
|
157
|
+
for (let i: number = 0; i < response.data.items.length; i++) {
|
|
159
158
|
Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name);
|
|
160
159
|
await this.deleteWorkspaceByName(response.data.items[i].metadata.name);
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
166
|
-
*/
|
|
167
|
-
public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) {
|
|
168
|
-
Logger.debug('TestWorkspaceUtil.waitPluginAdding');
|
|
169
|
-
|
|
170
|
-
const workspaceStatusApiUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${namespace}:${workspaceName}`;
|
|
171
|
-
const attempts: number = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS;
|
|
172
|
-
const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
173
|
-
|
|
174
|
-
for (let i = 0; i < attempts; i++) {
|
|
175
|
-
const response = await this.processRequestHandler.get(workspaceStatusApiUrl);
|
|
176
|
-
|
|
177
|
-
if (response.status !== 200) {
|
|
178
|
-
await this.driverHelper.wait(polling);
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const machines: string = JSON.stringify(response.data.runtime.machines);
|
|
183
|
-
const isPluginPresent: boolean = machines.search(pluginName) > 0;
|
|
184
|
-
|
|
185
|
-
if (isPluginPresent) {
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (i === attempts - 1) {
|
|
190
|
-
throw new error.TimeoutError(`Exceeded maximum tries attempts, the '${pluginName}' plugin is not present in the workspace runtime.`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
await this.driverHelper.wait(polling);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
199
|
-
*/
|
|
200
|
-
public async getListOfWorkspaceId(): Promise<string[]> {
|
|
201
|
-
Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId');
|
|
202
|
-
|
|
203
|
-
const getAllWorkspacesResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
204
|
-
|
|
205
|
-
interface IMyObj {
|
|
206
|
-
id: string;
|
|
207
|
-
status: string;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
let stringified = JSON.stringify(getAllWorkspacesResponse.data);
|
|
211
|
-
let arrayOfWorkspaces = <IMyObj[]>JSON.parse(stringified);
|
|
212
|
-
let wsList: Array<string> = [];
|
|
213
|
-
|
|
214
|
-
for (let entry of arrayOfWorkspaces) {
|
|
215
|
-
wsList.push(entry.id);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return wsList;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
223
|
-
*/
|
|
224
|
-
public async getIdOfRunningWorkspace(wsName: string): Promise<string> {
|
|
225
|
-
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace');
|
|
226
|
-
|
|
227
|
-
const getWorkspacesByNameResponse = await this.processRequestHandler.get(`${await this.apiUrlResolver.getWorkspacesApiUrl()}/:${wsName}`);
|
|
228
|
-
return getWorkspacesByNameResponse.data.id;
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
234
|
-
*/
|
|
235
|
-
public async getIdOfRunningWorkspaces(): Promise<Array<string>> {
|
|
236
|
-
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces');
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
const getAllWorkspacesResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
240
|
-
|
|
241
|
-
interface IMyObj {
|
|
242
|
-
id: string;
|
|
243
|
-
status: string;
|
|
244
|
-
}
|
|
245
|
-
let stringified = JSON.stringify(getAllWorkspacesResponse.data);
|
|
246
|
-
let arrayOfWorkspaces = <IMyObj[]>JSON.parse(stringified);
|
|
247
|
-
let idOfRunningWorkspace: Array<string> = new Array();
|
|
248
|
-
|
|
249
|
-
for (let entry of arrayOfWorkspaces) {
|
|
250
|
-
if (entry.status === 'RUNNING') {
|
|
251
|
-
idOfRunningWorkspace.push(entry.id);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return idOfRunningWorkspace;
|
|
256
|
-
} catch (err) {
|
|
257
|
-
console.log(`Getting id of running workspaces failed. URL used: ${await this.apiUrlResolver.getWorkspacesApiUrl()}`);
|
|
258
|
-
throw err;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
264
|
-
*/
|
|
265
|
-
public async removeWorkspaceById(id: string) {
|
|
266
|
-
Logger.debug('TestWorkspaceUtil.removeWorkspaceById');
|
|
267
|
-
|
|
268
|
-
const workspaceIdUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${id}`;
|
|
269
|
-
try {
|
|
270
|
-
const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl);
|
|
271
|
-
if (deleteWorkspaceResponse.status !== 204) {
|
|
272
|
-
throw new Error(`Can not remove workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
|
|
273
|
-
}
|
|
274
|
-
} catch (err) {
|
|
275
|
-
console.log(`Removing of workspace failed.`);
|
|
276
|
-
throw err;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
282
|
-
*/
|
|
283
|
-
public async stopWorkspaceById(id: string) {
|
|
284
|
-
Logger.debug('TestWorkspaceUtil.stopWorkspaceById');
|
|
285
|
-
|
|
286
|
-
const stopWorkspaceApiUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${id}`;
|
|
287
|
-
let stopWorkspaceResponse;
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}`);
|
|
291
|
-
} catch (err) {
|
|
292
|
-
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`);
|
|
293
|
-
throw err;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (stopWorkspaceResponse.status !== 200) {
|
|
297
|
-
throw new Error(`Can not stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
let stopped: boolean = false;
|
|
301
|
-
let wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
|
|
302
|
-
for (let i = 0; i < TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS; i++) {
|
|
303
|
-
wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
|
|
304
|
-
if (wsStatus.data.status === WorkspaceStatus.STOPPED) {
|
|
305
|
-
stopped = true;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
await this.driverHelper.wait(TestConstants.TS_SELENIUM_DEFAULT_POLLING);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (!stopped) {
|
|
312
|
-
let waitTime = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS * TestConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
313
|
-
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${wsStatus.data.status}`);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
319
|
-
*/
|
|
320
|
-
public async cleanUpAllWorkspaces() {
|
|
321
|
-
Logger.debug('TestWorkspaceUtil.cleanUpAllWorkspaces');
|
|
322
|
-
|
|
323
|
-
let listOfRunningWorkspaces: Array<string> = await this.getIdOfRunningWorkspaces();
|
|
324
|
-
for (const entry of listOfRunningWorkspaces) {
|
|
325
|
-
await this.stopWorkspaceById(entry);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
let listAllWorkspaces: Array<string> = await this.getListOfWorkspaceId();
|
|
329
|
-
|
|
330
|
-
for (const entry of listAllWorkspaces) {
|
|
331
|
-
await this.removeWorkspaceById(entry);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
338
|
-
*/
|
|
339
|
-
public async cleanUpRunningWorkspace(workspaceName: string) {
|
|
340
|
-
if (workspaceName === undefined || workspaceName.length === 0) {
|
|
341
|
-
Logger.warn(`Could nod delete workspace because workspaceName is undefined or empty`);
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
Logger.debug(`TestWorkspaceUtil.cleanUpRunningWorkspace ${workspaceName}`);
|
|
346
|
-
const workspaceID: string = await this.getIdOfRunningWorkspace(workspaceName);
|
|
347
|
-
|
|
348
|
-
if (workspaceID === undefined || workspaceID.length === 0) {
|
|
349
|
-
Logger.error(`Could nod delete workspace with name ${workspaceName} because workspaceID is undefined or empty`);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
Logger.trace(`TestWorkspaceUtil.cleanUpRunningWorkspace Stopping workspace:${workspaceName} with ID:${workspaceID}`);
|
|
354
|
-
await this.stopWorkspaceById(workspaceID);
|
|
355
|
-
Logger.trace(`TestWorkspaceUtil.cleanUpRunningWorkspace Deleting workspace ${workspaceName}`);
|
|
356
|
-
await this.removeWorkspaceById(workspaceID);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
361
|
-
*/
|
|
362
|
-
async createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile) {
|
|
363
|
-
Logger.debug('TestWorkspaceUtil.createWsFromDevFile');
|
|
364
|
-
|
|
365
|
-
try {
|
|
366
|
-
await this.processRequestHandler.post(await this.apiUrlResolver.getWorkspacesApiUrl() + '/devfile', customTemplate);
|
|
367
|
-
} catch (error) {
|
|
368
|
-
console.error(error);
|
|
369
|
-
throw error;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
375
|
-
*/
|
|
376
|
-
async getBaseDevfile(): Promise<che.workspace.devfile.Devfile> {
|
|
377
|
-
Logger.debug('TestWorkspaceUtil.getBaseDevfile');
|
|
378
|
-
|
|
379
|
-
const baseDevfile: che.workspace.devfile.Devfile = {
|
|
380
|
-
apiVersion: '1.0.0',
|
|
381
|
-
metadata: {
|
|
382
|
-
name: 'test-workspace'
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
return baseDevfile;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* @deprecated Method deprecated. Works with CHE server only
|
|
391
|
-
*/
|
|
392
|
-
async startWorkspace(workspaceId: string) {
|
|
393
|
-
Logger.debug('TestWorkspaceUtil.startWorkspace');
|
|
394
|
-
|
|
395
|
-
try {
|
|
396
|
-
await this.processRequestHandler.post(`${await this.apiUrlResolver.getWorkspacesApiUrl()}/${workspaceId}/runtime`);
|
|
397
|
-
} catch (error) {
|
|
398
|
-
console.error(error);
|
|
399
|
-
throw error;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
162
|
}
|