@eclipse-che/che-e2e 7.46.1-dev-deca6d7 → 7.46.1-dev-e59785f
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/dist/driver/CheReporter.js +1 -1
- package/dist/driver/CheReporter.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/inversify.config.js +3 -1
- package/dist/inversify.config.js.map +1 -1
- package/dist/inversify.types.js +5 -3
- package/dist/inversify.types.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +51 -2
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +4 -2
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +4 -2
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +1 -1
- package/dist/tests/e2e/FactoryUrl.spec.js +1 -1
- package/dist/tests/e2e/FactoryUrl.spec.js.map +1 -1
- package/dist/tests/e2e/GitPublishBranch.spec.js +1 -1
- package/dist/tests/e2e/GitPublishBranch.spec.js.map +1 -1
- package/dist/tests/e2e/GitSelfSignCert.spec.js +1 -1
- package/dist/tests/e2e/GitSelfSignCert.spec.js.map +1 -1
- package/dist/tests/e2e/GitSsh.spec.js +1 -1
- package/dist/tests/e2e/GitSsh.spec.js.map +1 -1
- package/dist/tests/e2e/OpenshiftConnector.spec.js +1 -1
- package/dist/tests/e2e/OpenshiftConnector.spec.js.map +1 -1
- package/dist/testsLibrary/CodeExecutionTests.js +11 -4
- package/dist/testsLibrary/CodeExecutionTests.js.map +1 -1
- package/dist/utils/requestHandlers/CheApiRequestHandler.js +3 -0
- package/dist/utils/requestHandlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +35 -0
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -0
- package/dist/utils/workspace/{ITestWorkspaceUtil.js → IApiUrlResolver.js} +1 -1
- package/dist/utils/workspace/IApiUrlResolver.js.map +1 -0
- package/dist/utils/workspace/TestWorkspaceUtil.js +151 -25
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js +3 -3
- package/driver/CheReporter.ts +2 -2
- package/index.ts +2 -1
- package/inversify.config.ts +5 -4
- package/inversify.types.ts +5 -3
- package/package.json +1 -1
- package/pageobjects/dashboard/Dashboard.ts +56 -2
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +3 -3
- package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +3 -3
- package/tests/e2e/FactoryUrl.spec.ts +2 -2
- package/tests/e2e/GitPublishBranch.spec.ts +1 -1
- package/tests/e2e/GitSelfSignCert.spec.ts +12 -12
- package/tests/e2e/GitSsh.spec.ts +1 -1
- package/tests/e2e/OpenshiftConnector.spec.ts +1 -1
- package/tests/load_test/LoadTest.spec.ts +2 -0
- package/testsLibrary/CodeExecutionTests.ts +14 -5
- package/utils/requestHandlers/CheApiRequestHandler.ts +4 -0
- package/utils/workspace/ApiUrlResolver.ts +27 -0
- package/utils/workspace/IApiUrlResolver.ts +15 -0
- package/utils/workspace/TestWorkspaceUtil.ts +157 -29
- package/utils/workspace/WorkspaceStatus.ts +3 -3
- package/dist/utils/workspace/ITestWorkspaceUtil.js.map +0 -1
- package/utils/workspace/ITestWorkspaceUtil.ts +0 -26
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
import { DriverHelper } from '../../../utils/DriverHelper';
|
|
11
11
|
import { injectable, inject } from 'inversify';
|
|
12
|
-
import { CLASSES
|
|
12
|
+
import { CLASSES } from '../../../inversify.types';
|
|
13
13
|
import 'reflect-metadata';
|
|
14
14
|
import { TestConstants } from '../../../TestConstants';
|
|
15
15
|
import { By } from 'selenium-webdriver';
|
|
16
16
|
import { Ide } from '../../ide/Ide';
|
|
17
|
-
import {
|
|
17
|
+
import { TestWorkspaceUtil } from '../../../utils/workspace/TestWorkspaceUtil';
|
|
18
18
|
import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus';
|
|
19
19
|
import { Logger } from '../../../utils/Logger';
|
|
20
20
|
import { TimeoutConstants } from '../../../TimeoutConstants';
|
|
@@ -29,7 +29,7 @@ export class WorkspaceDetails {
|
|
|
29
29
|
private static readonly WORKSPACE_DETAILS_LOADER_CSS: string = 'workspace-details-overview md-progress-linear';
|
|
30
30
|
|
|
31
31
|
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
32
|
-
@inject(
|
|
32
|
+
@inject(CLASSES.WorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { }
|
|
33
33
|
|
|
34
34
|
async waitLoaderDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) {
|
|
35
35
|
Logger.debug('WorkspaceDetails.waitLoaderDisappearance');
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
import { DriverHelper } from '../../../utils/DriverHelper';
|
|
11
11
|
import { injectable, inject } from 'inversify';
|
|
12
12
|
import 'reflect-metadata';
|
|
13
|
-
import { CLASSES
|
|
13
|
+
import { CLASSES } from '../../../inversify.types';
|
|
14
14
|
import { By } from 'selenium-webdriver';
|
|
15
15
|
import { WorkspaceDetails } from './WorkspaceDetails';
|
|
16
|
-
import {
|
|
16
|
+
import { TestWorkspaceUtil } from '../../../utils/workspace/TestWorkspaceUtil';
|
|
17
17
|
import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus';
|
|
18
18
|
import { Logger } from '../../../utils/Logger';
|
|
19
19
|
import { TimeoutConstants } from '../../../TimeoutConstants';
|
|
@@ -23,7 +23,7 @@ import { TimeoutConstants } from '../../../TimeoutConstants';
|
|
|
23
23
|
export class WorkspaceDetailsPlugins {
|
|
24
24
|
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
25
25
|
@inject(CLASSES.WorkspaceDetails) private readonly workspaceDetails: WorkspaceDetails,
|
|
26
|
-
@inject(
|
|
26
|
+
@inject(CLASSES.WorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { }
|
|
27
27
|
|
|
28
28
|
async waitPluginListItem(pluginName: string) {
|
|
29
29
|
Logger.debug(`WorkspaceDetailsPlugins.waitPluginListItem ${pluginName}`);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// **********************************************************************/
|
|
10
10
|
|
|
11
11
|
import { e2eContainer } from '../../inversify.config';
|
|
12
|
-
import { CLASSES
|
|
12
|
+
import { CLASSES } from '../../inversify.types';
|
|
13
13
|
import { TestConstants } from '../../TestConstants';
|
|
14
14
|
import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests';
|
|
15
15
|
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
@@ -18,7 +18,7 @@ import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTest
|
|
|
18
18
|
|
|
19
19
|
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
|
|
20
20
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
21
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
21
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil);
|
|
22
22
|
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests);
|
|
23
23
|
|
|
24
24
|
const factoryUrl : string = `${TestConstants.TS_SELENIUM_BASE_URL}/f?url=https://raw.githubusercontent.com/eclipse/che-devfile-registry/master/devfiles/java-maven/devfile.yaml`;
|
|
@@ -34,7 +34,7 @@ const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
|
|
|
34
34
|
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
35
35
|
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
36
36
|
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
37
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
37
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil);
|
|
38
38
|
const workspaceNameHandler: WorkspaceNameHandler = e2eContainer.get(CLASSES.WorkspaceNameHandler);
|
|
39
39
|
|
|
40
40
|
const workspacePrefixUrl: string = `${TestConstants.TS_SELENIUM_BASE_URL}/dashboard/#/ide/${TestConstants.TS_SELENIUM_USERNAME}/`;
|
|
@@ -25,18 +25,18 @@ import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
|
|
|
25
25
|
import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTests';
|
|
26
26
|
import { Editor } from '../../pageobjects/ide/Editor';
|
|
27
27
|
|
|
28
|
-
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
29
|
-
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
30
|
-
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
31
|
-
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer);
|
|
32
|
-
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
|
|
33
|
-
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
34
|
-
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
35
|
-
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
36
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
37
|
-
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
38
|
-
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
39
|
-
const editor: Editor = e2eContainer.get(CLASSES.Editor);
|
|
28
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
29
|
+
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
30
|
+
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
31
|
+
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer);
|
|
32
|
+
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu);
|
|
33
|
+
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
34
|
+
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
35
|
+
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
36
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil);
|
|
37
|
+
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
38
|
+
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
39
|
+
const editor: Editor = e2eContainer.get(CLASSES.Editor);
|
|
40
40
|
|
|
41
41
|
const workspaceName = 'gitSelfSignCert';
|
|
42
42
|
|
package/tests/e2e/GitSsh.spec.ts
CHANGED
|
@@ -39,7 +39,7 @@ const gitHubUtils: GitHubUtil = e2eContainer.get<GitHubUtil>(CLASSES.GitHubUtil)
|
|
|
39
39
|
const cheGitAPI: CheGitApi = e2eContainer.get(CLASSES.CheGitApi);
|
|
40
40
|
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree);
|
|
41
41
|
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin);
|
|
42
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
42
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil);
|
|
43
43
|
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
44
44
|
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
|
|
45
45
|
const workspaceNameHandler: WorkspaceNameHandler = e2eContainer.get(CLASSES.WorkspaceNameHandler);
|
|
@@ -31,7 +31,7 @@ import { WorkspaceHandlingTests } from '../../testsLibrary/WorkspaceHandlingTest
|
|
|
31
31
|
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
|
|
32
32
|
const ide: Ide = e2eContainer.get(CLASSES.Ide);
|
|
33
33
|
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin);
|
|
34
|
-
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(
|
|
34
|
+
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil);
|
|
35
35
|
const openshiftPlugin: OpenshiftPlugin = e2eContainer.get(CLASSES.OpenshiftPlugin);
|
|
36
36
|
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
37
37
|
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer);
|
|
@@ -20,8 +20,8 @@ import { DialogWindow } from '../pageobjects/ide/DialogWindow';
|
|
|
20
20
|
import { DriverHelper } from '../utils/DriverHelper';
|
|
21
21
|
import { Logger } from '../utils/Logger';
|
|
22
22
|
import { QuickOpenContainer } from '../pageobjects/ide/QuickOpenContainer';
|
|
23
|
-
import { WorkspaceHandlingTests } from './WorkspaceHandlingTests';
|
|
24
23
|
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
|
|
24
|
+
import { WorkspaceHandlingTests } from './WorkspaceHandlingTests';
|
|
25
25
|
|
|
26
26
|
@injectable()
|
|
27
27
|
export class CodeExecutionTests {
|
|
@@ -36,7 +36,9 @@ export class CodeExecutionTests {
|
|
|
36
36
|
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
37
37
|
@inject(CLASSES.QuickOpenContainer) private readonly quickOpenContainer: QuickOpenContainer,
|
|
38
38
|
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil,
|
|
39
|
-
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests
|
|
39
|
+
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests
|
|
40
|
+
|
|
41
|
+
) {}
|
|
40
42
|
|
|
41
43
|
public runTask(taskName: string, timeout: number) {
|
|
42
44
|
test(`Run command '${taskName}'`, async () => {
|
|
@@ -66,7 +68,6 @@ export class CodeExecutionTests {
|
|
|
66
68
|
public runTaskWithDialogShellAndOpenLink(taskName: string, expectedDialogText: string, timeout: number) {
|
|
67
69
|
test(`Run command '${taskName}' expecting dialog shell`, async () => {
|
|
68
70
|
await this.runTaskUsingQuickOpenContainer(taskName);
|
|
69
|
-
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle());
|
|
70
71
|
await this.dialogWindow.waitDialogAndOpenLink(expectedDialogText, timeout);
|
|
71
72
|
});
|
|
72
73
|
}
|
|
@@ -108,8 +109,12 @@ export class CodeExecutionTests {
|
|
|
108
109
|
test(`Run command '${taskName}' expecting notification`, async () => {
|
|
109
110
|
await this.runTaskUsingQuickOpenContainer(taskName);
|
|
110
111
|
await this.ide.waitNotification(notificationText, timeout);
|
|
111
|
-
|
|
112
|
+
// the application can have delay before running. Sometimes it consume about sec.
|
|
113
|
+
// todo improve the check of avalibility test application
|
|
114
|
+
await this.driverHelper.wait(10_000);
|
|
112
115
|
await this.ide.clickOnNotificationButton(notificationText, buttonText);
|
|
116
|
+
// delay for openning an app. window
|
|
117
|
+
// todo may be improved.
|
|
113
118
|
await this.driverHelper.wait(5_000);
|
|
114
119
|
CodeExecutionTests.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl();
|
|
115
120
|
});
|
|
@@ -123,7 +128,12 @@ export class CodeExecutionTests {
|
|
|
123
128
|
await this.runTaskUsingQuickOpenContainer(taskName);
|
|
124
129
|
await this.ide.waitNotification(notificationText, timeout);
|
|
125
130
|
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle());
|
|
131
|
+
// the application can have delay before running. Sometimes it consume about sec.
|
|
132
|
+
// todo improve the check of avalibility test application
|
|
133
|
+
await this.driverHelper.wait(10_000);
|
|
126
134
|
await this.ide.clickOnNotificationButton(notificationText, 'Open In Preview');
|
|
135
|
+
// delay for openning an app. window
|
|
136
|
+
// todo may be improved.
|
|
127
137
|
await this.driverHelper.wait(5_000);
|
|
128
138
|
CodeExecutionTests.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl();
|
|
129
139
|
});
|
|
@@ -133,7 +143,6 @@ export class CodeExecutionTests {
|
|
|
133
143
|
test(`Run command '${taskName}' expecting notification with unexposed port`, async () => {
|
|
134
144
|
await this.runTaskUsingQuickOpenContainer(taskName);
|
|
135
145
|
await this.ide.waitNotificationAndConfirm(notificationText, timeout);
|
|
136
|
-
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle());
|
|
137
146
|
await this.ide.waitNotificationAndOpenLink(portOpenText, timeout);
|
|
138
147
|
await this.driverHelper.wait(5_000);
|
|
139
148
|
CodeExecutionTests.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl();
|
|
@@ -99,6 +99,10 @@ export class CheApiRequestHandler {
|
|
|
99
99
|
return await axios.delete(this.assembleUrl(relativeUrl), await this.headerHandler.get());
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
103
|
+
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
private assembleUrl(relativeUrl: string): string {
|
|
103
107
|
return `${TestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`;
|
|
104
108
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IApiUrlResolver } from './IApiUrlResolver';
|
|
2
|
+
|
|
3
|
+
/*********************************************************************
|
|
4
|
+
* Copyright (c) 2019 Red Hat, Inc.
|
|
5
|
+
*
|
|
6
|
+
* This program and the accompanying materials are made
|
|
7
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
8
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
9
|
+
*
|
|
10
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
11
|
+
**********************************************************************/
|
|
12
|
+
import { injectable } from 'inversify';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@injectable()
|
|
16
|
+
export class ApiUrlResolver implements IApiUrlResolver {
|
|
17
|
+
private dashboardApiUrl: string = 'dashboard/api/namespace';
|
|
18
|
+
|
|
19
|
+
public getWorkspaceApiUrl(namespace: string, workspaceName: string) {
|
|
20
|
+
return `${this.getWorkspacesApiUrl(namespace)}/${workspaceName}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getWorkspacesApiUrl(namespace: string) {
|
|
24
|
+
return `${this.dashboardApiUrl}/${namespace}-che/devworkspaces`;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export interface IApiUrlResolver {
|
|
12
|
+
getWorkspaceApiUrl(namespace: string, workspacename: string): string;
|
|
13
|
+
getWorkspacesApiUrl(namespace: string): string;
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -12,52 +12,158 @@ import { che } from '@eclipse-che/api';
|
|
|
12
12
|
import { TestConstants } from '../../TestConstants';
|
|
13
13
|
import { injectable, inject } from 'inversify';
|
|
14
14
|
import { DriverHelper } from '../DriverHelper';
|
|
15
|
+
import { ApiUrlResolver } from './ApiUrlResolver';
|
|
15
16
|
import 'reflect-metadata';
|
|
16
17
|
import { WorkspaceStatus } from './WorkspaceStatus';
|
|
17
|
-
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
|
|
18
18
|
import { error } from 'selenium-webdriver';
|
|
19
19
|
import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler';
|
|
20
20
|
import { CLASSES } from '../../inversify.types';
|
|
21
21
|
import { Logger } from '../Logger';
|
|
22
|
+
import axios from 'axios';
|
|
22
23
|
|
|
23
24
|
@injectable()
|
|
24
|
-
export class TestWorkspaceUtil
|
|
25
|
-
|
|
26
|
-
static readonly WORKSPACE_API_URL: string = 'api/workspace';
|
|
25
|
+
export class TestWorkspaceUtil {
|
|
27
26
|
|
|
27
|
+
static readonly WORKSPACE_API_URL: string = 'dashboard/api/namespace';
|
|
28
|
+
readonly attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS;
|
|
29
|
+
readonly polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING;
|
|
28
30
|
constructor(
|
|
29
31
|
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
30
|
-
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler
|
|
32
|
+
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler,
|
|
33
|
+
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver
|
|
31
34
|
) { }
|
|
32
35
|
|
|
33
36
|
public async waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) {
|
|
34
37
|
Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus');
|
|
35
38
|
|
|
36
|
-
const workspaceStatusApiUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${namespace}:${workspaceName}`;
|
|
37
|
-
const attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS;
|
|
38
|
-
const polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING;
|
|
39
39
|
let workspaceStatus: string = '';
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < attempts; i++) {
|
|
42
|
-
const response = await this.processRequestHandler.get(
|
|
40
|
+
let expectedStatus: boolean = false;
|
|
41
|
+
for (let i = 0; i < this.attempts; i++) {
|
|
42
|
+
const response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName));
|
|
43
43
|
|
|
44
44
|
if (response.status !== 200) {
|
|
45
|
-
|
|
46
|
-
continue;
|
|
45
|
+
throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
workspaceStatus = await response.data.status;
|
|
48
|
+
workspaceStatus = await response.data.status.phase;
|
|
50
49
|
|
|
51
50
|
if (workspaceStatus === expectedWorkspaceStatus) {
|
|
52
|
-
|
|
51
|
+
expectedStatus = true;
|
|
52
|
+
break;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
await this.driverHelper.wait(polling);
|
|
55
|
+
await this.driverHelper.wait(this.polling);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
if (!expectedStatus) {
|
|
59
|
+
let waitTime = this.attempts * this.polling;
|
|
60
|
+
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${workspaceStatus}`);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
public async stopWorkspaceByName(namespace: string, workspaceName: string) {
|
|
65
|
+
Logger.debug('TestWorkspaceUtil.stopWorkspaceByName');
|
|
66
|
+
|
|
67
|
+
const stopWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName);
|
|
68
|
+
let stopWorkspaceResponse;
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{'op': 'replace', 'path': '/spec/started', 'value': false}]);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`);
|
|
74
|
+
throw err;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (stopWorkspaceResponse.status !== 200) {
|
|
78
|
+
throw new Error(`Cannot stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await this.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.STOPPED);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// delete a worksapce without stopping phase (similar with force deleting)
|
|
85
|
+
public async deleteWorkspaceByName(namespace: string, workspaceName: string) {
|
|
86
|
+
Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` );
|
|
87
|
+
|
|
88
|
+
const deleteWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName);
|
|
89
|
+
let deleteWorkspaceResponse;
|
|
90
|
+
let deleteWorkspaceStatus: boolean = false;
|
|
91
|
+
try {
|
|
92
|
+
deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
95
|
+
Logger.error(`The workspace :${workspaceName} not found`);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
Logger.error(`Delete workspace call failed. URL used: ${deleteWorkspaceStatus}`);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (deleteWorkspaceResponse.status !== 204) {
|
|
103
|
+
throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i < this.attempts; i++) {
|
|
107
|
+
try {
|
|
108
|
+
deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
111
|
+
deleteWorkspaceStatus = true;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!deleteWorkspaceStatus) {
|
|
118
|
+
let waitTime = this.attempts * this.polling;
|
|
119
|
+
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// stop workspace before deleting with checking stopping phase
|
|
124
|
+
public async stopAndDeleteWorkspaceByName(namespace: string, workspaceName: string) {
|
|
125
|
+
Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName');
|
|
126
|
+
|
|
127
|
+
await this.stopWorkspaceByName(namespace, workspaceName);
|
|
128
|
+
await this.deleteWorkspaceByName(namespace, workspaceName);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// stop all run workspaces in the namespace
|
|
132
|
+
public async stopAllRunningWorkspaces(namespace: string) {
|
|
133
|
+
Logger.debug('TestWorkspaceUtil.stopAllRunProjects');
|
|
134
|
+
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
|
|
135
|
+
for (let i = 0; i < response.data.items.length; i++) {
|
|
136
|
+
Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name);
|
|
137
|
+
await this.stopWorkspaceByName(namespace, response.data.items[i].metadata.name);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// stop all run workspaces, check statused and remove the workspaces
|
|
142
|
+
public async stopAndDeleteAllRunningWorkspaces(namespace: string) {
|
|
143
|
+
Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects');
|
|
144
|
+
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
|
|
145
|
+
await this.stopAllRunningWorkspaces(namespace);
|
|
146
|
+
for (let i = 0; i < response.data.items.length; i++) {
|
|
147
|
+
Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name);
|
|
148
|
+
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// stop all run workspaces without stopping and waiting for of 'Stopped' phase
|
|
153
|
+
// similar with 'force' deleting
|
|
154
|
+
public async deleteAllWorkspaces(namespace: string) {
|
|
155
|
+
Logger.debug('TestWorkspaceUtil.deleteAllRunProjects');
|
|
156
|
+
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
|
|
157
|
+
|
|
158
|
+
for (let i = 0; i < response.data.items.length; i++) {
|
|
159
|
+
Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name);
|
|
160
|
+
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
166
|
+
*/
|
|
61
167
|
public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) {
|
|
62
168
|
Logger.debug('TestWorkspaceUtil.waitPluginAdding');
|
|
63
169
|
|
|
@@ -88,6 +194,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
88
194
|
}
|
|
89
195
|
}
|
|
90
196
|
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
199
|
+
*/
|
|
91
200
|
public async getListOfWorkspaceId(): Promise<string[]> {
|
|
92
201
|
Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId');
|
|
93
202
|
|
|
@@ -109,6 +218,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
109
218
|
return wsList;
|
|
110
219
|
}
|
|
111
220
|
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
223
|
+
*/
|
|
112
224
|
public async getIdOfRunningWorkspace(wsName: string): Promise<string> {
|
|
113
225
|
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace');
|
|
114
226
|
|
|
@@ -117,6 +229,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
117
229
|
|
|
118
230
|
}
|
|
119
231
|
|
|
232
|
+
/**
|
|
233
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
234
|
+
*/
|
|
120
235
|
public async getIdOfRunningWorkspaces(): Promise<Array<string>> {
|
|
121
236
|
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces');
|
|
122
237
|
|
|
@@ -144,13 +259,15 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
144
259
|
}
|
|
145
260
|
}
|
|
146
261
|
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
264
|
+
*/
|
|
147
265
|
public async removeWorkspaceById(id: string) {
|
|
148
266
|
Logger.debug('TestWorkspaceUtil.removeWorkspaceById');
|
|
149
267
|
|
|
150
268
|
const workspaceIdUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${id}`;
|
|
151
269
|
try {
|
|
152
270
|
const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl);
|
|
153
|
-
// response code 204: "No Content" expected
|
|
154
271
|
if (deleteWorkspaceResponse.status !== 204) {
|
|
155
272
|
throw new Error(`Can not remove workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
|
|
156
273
|
}
|
|
@@ -160,6 +277,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
160
277
|
}
|
|
161
278
|
}
|
|
162
279
|
|
|
280
|
+
/**
|
|
281
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
282
|
+
*/
|
|
163
283
|
public async stopWorkspaceById(id: string) {
|
|
164
284
|
Logger.debug('TestWorkspaceUtil.stopWorkspaceById');
|
|
165
285
|
|
|
@@ -167,20 +287,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
167
287
|
let stopWorkspaceResponse;
|
|
168
288
|
|
|
169
289
|
try {
|
|
170
|
-
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}
|
|
290
|
+
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}`);
|
|
171
291
|
} catch (err) {
|
|
172
|
-
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}
|
|
292
|
+
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`);
|
|
173
293
|
throw err;
|
|
174
294
|
}
|
|
175
295
|
|
|
176
|
-
|
|
177
|
-
if (stopWorkspaceResponse.status === 409) {
|
|
178
|
-
Logger.warn(`TestWorkspaceUtil.stopWorkspaceById Workspace {${id}} is already STOPPED`);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// response code 204: "No Content" expected
|
|
183
|
-
if (stopWorkspaceResponse.status !== 204) {
|
|
296
|
+
if (stopWorkspaceResponse.status !== 200) {
|
|
184
297
|
throw new Error(`Can not stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
|
|
185
298
|
}
|
|
186
299
|
|
|
@@ -188,7 +301,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
188
301
|
let wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
|
|
189
302
|
for (let i = 0; i < TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS; i++) {
|
|
190
303
|
wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
|
|
191
|
-
if (wsStatus.data.status ===
|
|
304
|
+
if (wsStatus.data.status === WorkspaceStatus.STOPPED) {
|
|
192
305
|
stopped = true;
|
|
193
306
|
break;
|
|
194
307
|
}
|
|
@@ -201,6 +314,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
201
314
|
}
|
|
202
315
|
}
|
|
203
316
|
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
319
|
+
*/
|
|
204
320
|
public async cleanUpAllWorkspaces() {
|
|
205
321
|
Logger.debug('TestWorkspaceUtil.cleanUpAllWorkspaces');
|
|
206
322
|
|
|
@@ -217,6 +333,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
217
333
|
|
|
218
334
|
}
|
|
219
335
|
|
|
336
|
+
/**
|
|
337
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
338
|
+
*/
|
|
220
339
|
public async cleanUpRunningWorkspace(workspaceName: string) {
|
|
221
340
|
if (workspaceName === undefined || workspaceName.length === 0) {
|
|
222
341
|
Logger.warn(`Could nod delete workspace because workspaceName is undefined or empty`);
|
|
@@ -237,6 +356,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
237
356
|
await this.removeWorkspaceById(workspaceID);
|
|
238
357
|
}
|
|
239
358
|
|
|
359
|
+
/**
|
|
360
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
361
|
+
*/
|
|
240
362
|
async createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile) {
|
|
241
363
|
Logger.debug('TestWorkspaceUtil.createWsFromDevFile');
|
|
242
364
|
|
|
@@ -248,6 +370,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
248
370
|
}
|
|
249
371
|
}
|
|
250
372
|
|
|
373
|
+
/**
|
|
374
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
375
|
+
*/
|
|
251
376
|
async getBaseDevfile(): Promise<che.workspace.devfile.Devfile> {
|
|
252
377
|
Logger.debug('TestWorkspaceUtil.getBaseDevfile');
|
|
253
378
|
|
|
@@ -261,6 +386,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
261
386
|
return baseDevfile;
|
|
262
387
|
}
|
|
263
388
|
|
|
389
|
+
/**
|
|
390
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
391
|
+
*/
|
|
264
392
|
async startWorkspace(workspaceId: string) {
|
|
265
393
|
Logger.debug('TestWorkspaceUtil.startWorkspace');
|
|
266
394
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ITestWorkspaceUtil.js","sourceRoot":"","sources":["../../../utils/workspace/ITestWorkspaceUtil.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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 { WorkspaceStatus } from './WorkspaceStatus';
|
|
12
|
-
import { che } from '@eclipse-che/api';
|
|
13
|
-
|
|
14
|
-
export interface ITestWorkspaceUtil {
|
|
15
|
-
cleanUpAllWorkspaces() : void;
|
|
16
|
-
cleanUpRunningWorkspace(workspaceName: string) : void;
|
|
17
|
-
waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) : void;
|
|
18
|
-
waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) : void;
|
|
19
|
-
removeWorkspaceById(id: string) : void;
|
|
20
|
-
stopWorkspaceById(id: string) : void;
|
|
21
|
-
getIdOfRunningWorkspace(workspaceName: string): Promise<string>;
|
|
22
|
-
getIdOfRunningWorkspaces(): Promise<Array<string>>;
|
|
23
|
-
createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile): void;
|
|
24
|
-
getBaseDevfile(): Promise<che.workspace.devfile.Devfile>;
|
|
25
|
-
startWorkspace(workspaceId: string): void;
|
|
26
|
-
}
|