@eclipse-che/che-e2e 7.50.0-dev-d6432ff → 7.51.0-dev-6c69f4f
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 +2 -1
- package/dist/driver/CheReporter.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/inversify.config.js +2 -0
- package/dist/inversify.config.js.map +1 -1
- package/dist/inversify.types.js +2 -1
- package/dist/inversify.types.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
- package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +1 -1
- package/dist/pageobjects/ide/ProjectTree.js +12 -6
- package/dist/pageobjects/ide/ProjectTree.js.map +1 -1
- package/dist/tests/devfiles/CSlashCPlusPlus.spec.js +3 -4
- package/dist/tests/devfiles/CSlashCPlusPlus.spec.js.map +1 -1
- package/dist/tests/devfiles/DevfileSmoke.spec.js +4 -5
- package/dist/tests/devfiles/DevfileSmoke.spec.js.map +1 -1
- package/dist/tests/devfiles/DotNetCore.spec.js +3 -4
- package/dist/tests/devfiles/DotNetCore.spec.js.map +1 -1
- package/dist/tests/devfiles/Go.spec.js +3 -4
- package/dist/tests/devfiles/Go.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaMaven.spec.js +3 -4
- package/dist/tests/devfiles/JavaMaven.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaSpringBoot.spec.js +3 -4
- package/dist/tests/devfiles/JavaSpringBoot.spec.js.map +1 -1
- package/dist/tests/devfiles/JavaVertx.spec.js +3 -4
- package/dist/tests/devfiles/JavaVertx.spec.js.map +1 -1
- package/dist/tests/devfiles/NodeJS.spec.js +3 -4
- package/dist/tests/devfiles/NodeJS.spec.js.map +1 -1
- package/dist/tests/devfiles/PHPSimple.spec.js +3 -4
- package/dist/tests/devfiles/PHPSimple.spec.js.map +1 -1
- package/dist/tests/devfiles/Python.spec.js +3 -4
- package/dist/tests/devfiles/Python.spec.js.map +1 -1
- package/dist/tests/devfiles/PythonDjango.spec.js +3 -4
- package/dist/tests/devfiles/PythonDjango.spec.js.map +1 -1
- package/dist/tests/devfiles/Quarkus.spec.js +3 -4
- package/dist/tests/devfiles/Quarkus.spec.js.map +1 -1
- package/dist/tests/devfiles/Scala.spec.js +3 -4
- package/dist/tests/devfiles/Scala.spec.js.map +1 -1
- package/dist/tests/e2e/FactoryUrl.spec.js +4 -9
- package/dist/tests/e2e/FactoryUrl.spec.js.map +1 -1
- package/dist/tests/e2e/GitPublishBranch.spec.js +2 -0
- package/dist/tests/e2e/GitPublishBranch.spec.js.map +1 -1
- package/dist/tests/e2e/GitSelfSignCert.spec.js +7 -0
- package/dist/tests/e2e/GitSelfSignCert.spec.js.map +1 -1
- package/dist/tests/e2e/GitSsh.spec.js +4 -1
- package/dist/tests/e2e/GitSsh.spec.js.map +1 -1
- package/dist/tests/e2e/OpenshiftConnector.spec.js +2 -0
- package/dist/tests/e2e/OpenshiftConnector.spec.js.map +1 -1
- package/dist/tests/e2e/factories/DirectUrlFactoryWithKeepDirectoryTest.spec.js +3 -7
- package/dist/tests/e2e/factories/DirectUrlFactoryWithKeepDirectoryTest.spec.js.map +1 -1
- package/dist/tests/e2e/factories/DirectUrlFactoryWithRootFolderTest.spec.js +3 -7
- package/dist/tests/e2e/factories/DirectUrlFactoryWithRootFolderTest.spec.js.map +1 -1
- package/dist/tests/e2e/factories/DirectUrlFactoryWithSpecificBranchTest.spec.js +3 -7
- package/dist/tests/e2e/factories/DirectUrlFactoryWithSpecificBranchTest.spec.js.map +1 -1
- package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js +2 -0
- package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js.map +1 -1
- package/dist/tests/e2e_happy_path/HappyPath.spec.js +13 -8
- package/dist/tests/e2e_happy_path/HappyPath.spec.js.map +1 -1
- package/dist/tests/intelij/IntelijOpenWorkspace.spec.js +2 -6
- package/dist/tests/intelij/IntelijOpenWorkspace.spec.js.map +1 -1
- package/dist/tests/load_test/LoadTest.spec.js +2 -5
- package/dist/tests/load_test/LoadTest.spec.js.map +1 -1
- package/dist/tests/login/LinkCheAndOcpUsers.spec.js +2 -2
- package/dist/tests/login/LinkCheAndOcpUsers.spec.js.map +1 -1
- package/dist/tests/plugins/GitHubPullRequestPlugin.spec.js +4 -9
- package/dist/tests/plugins/GitHubPullRequestPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/InstallPluginUsingUI.spec.js +4 -10
- package/dist/tests/plugins/InstallPluginUsingUI.spec.js.map +1 -1
- package/dist/tests/plugins/JavaPlugin.spec.js +4 -8
- package/dist/tests/plugins/JavaPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/PhpPlugin.spec.js +12 -10
- package/dist/tests/plugins/PhpPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/PythonPlugin.spec.js +4 -8
- package/dist/tests/plugins/PythonPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/TypescriptPlugin.spec.js +4 -8
- package/dist/tests/plugins/TypescriptPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeKubernetesPlugin.spec.js +3 -10
- package/dist/tests/plugins/VscodeKubernetesPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeShellcheckPlugin.spec.js +3 -10
- package/dist/tests/plugins/VscodeShellcheckPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeValePlugin.spec.js +3 -10
- package/dist/tests/plugins/VscodeValePlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeXmlPlugin.spec.js +15 -1
- package/dist/tests/plugins/VscodeXmlPlugin.spec.js.map +1 -1
- package/dist/tests/plugins/VscodeYamlPlugin.spec.js +4 -8
- package/dist/tests/plugins/VscodeYamlPlugin.spec.js.map +1 -1
- package/dist/testsLibrary/CodeExecutionTests.js +14 -2
- package/dist/testsLibrary/CodeExecutionTests.js.map +1 -1
- package/dist/testsLibrary/WorkspaceHandlingTests.js +75 -10
- package/dist/testsLibrary/WorkspaceHandlingTests.js.map +1 -1
- package/dist/utils/requestHandlers/CheApiRequestHandler.js.map +1 -1
- package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js +17 -2
- package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
- package/dist/utils/workspace/ApiUrlResolver.js +67 -0
- package/dist/utils/workspace/ApiUrlResolver.js.map +1 -0
- package/dist/utils/workspace/TestWorkspaceUtil.js +60 -30
- package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
- package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
- package/driver/CheReporter.ts +2 -2
- package/index.ts +1 -0
- package/inversify.config.ts +4 -2
- package/inversify.types.ts +2 -1
- package/package.json +1 -1
- package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +2 -2
- package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +3 -3
- package/pageobjects/ide/ProjectTree.ts +13 -8
- package/tests/devfiles/CSlashCPlusPlus.spec.ts +3 -6
- package/tests/devfiles/DevfileSmoke.spec.ts +4 -7
- package/tests/devfiles/DotNetCore.spec.ts +3 -6
- package/tests/devfiles/Go.spec.ts +3 -4
- package/tests/devfiles/JavaMaven.spec.ts +3 -6
- package/tests/devfiles/JavaSpringBoot.spec.ts +3 -6
- package/tests/devfiles/JavaVertx.spec.ts +3 -6
- package/tests/devfiles/NodeJS.spec.ts +3 -6
- package/tests/devfiles/PHPSimple.spec.ts +3 -6
- package/tests/devfiles/Python.spec.ts +3 -6
- package/tests/devfiles/PythonDjango.spec.ts +3 -6
- package/tests/devfiles/Quarkus.spec.ts +3 -6
- package/tests/devfiles/Scala.spec.ts +3 -7
- package/tests/e2e/FactoryUrl.spec.ts +6 -10
- package/tests/e2e/GitPublishBranch.spec.ts +5 -3
- package/tests/e2e/GitSelfSignCert.spec.ts +68 -65
- package/tests/e2e/GitSsh.spec.ts +6 -3
- package/tests/e2e/OpenshiftConnector.spec.ts +4 -2
- package/tests/e2e/factories/DirectUrlFactoryWithKeepDirectoryTest.spec.ts +2 -5
- package/tests/e2e/factories/DirectUrlFactoryWithRootFolderTest.spec.ts +2 -5
- package/tests/e2e/factories/DirectUrlFactoryWithSpecificBranchTest.spec.ts +2 -5
- package/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.ts +2 -0
- package/tests/e2e_happy_path/HappyPath.spec.ts +13 -8
- package/tests/intelij/IntelijOpenWorkspace.spec.ts +2 -4
- package/tests/load_test/LoadTest.spec.ts +4 -4
- package/tests/login/LinkCheAndOcpUsers.spec.ts +4 -3
- package/tests/plugins/GitHubPullRequestPlugin.spec.ts +4 -7
- package/tests/plugins/InstallPluginUsingUI.spec.ts +4 -9
- package/tests/plugins/JavaPlugin.spec.ts +4 -6
- package/tests/plugins/PhpPlugin.spec.ts +3 -9
- package/tests/plugins/PythonPlugin.spec.ts +4 -6
- package/tests/plugins/TypescriptPlugin.spec.ts +4 -6
- package/tests/plugins/VscodeKubernetesPlugin.spec.ts +3 -9
- package/tests/plugins/VscodeShellcheckPlugin.spec.ts +3 -9
- package/tests/plugins/VscodeValePlugin.spec.ts +3 -9
- package/tests/plugins/VscodeXmlPlugin.spec.ts +17 -1
- package/tests/plugins/VscodeYamlPlugin.spec.ts +4 -7
- package/testsLibrary/CodeExecutionTests.ts +9 -1
- package/testsLibrary/WorkspaceHandlingTests.ts +72 -9
- package/utils/requestHandlers/CheApiRequestHandler.ts +1 -1
- package/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +17 -2
- package/utils/workspace/ApiUrlResolver.ts +50 -0
- package/utils/workspace/ITestWorkspaceUtil.ts +73 -1
- package/utils/workspace/TestWorkspaceUtil.ts +65 -33
- package/utils/workspace/WorkspaceStatus.ts +1 -1
|
@@ -15,46 +15,109 @@ import { Dashboard } from '../pageobjects/dashboard/Dashboard';
|
|
|
15
15
|
import { CreateWorkspace } from '../pageobjects/dashboard/CreateWorkspace';
|
|
16
16
|
import { Workspaces } from '../pageobjects/dashboard/Workspaces';
|
|
17
17
|
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
|
|
18
|
-
import { Logger } from '
|
|
18
|
+
import { Logger } from '../utils/Logger';
|
|
19
|
+
import { ApiUrlResolver } from '../utils/workspace/ApiUrlResolver';
|
|
20
|
+
import { TimeoutConstants } from '../TimeoutConstants';
|
|
21
|
+
import { DriverHelper } from '../utils/DriverHelper';
|
|
22
|
+
import { Ide } from '../pageobjects/ide/Ide';
|
|
23
|
+
import { By, error } from 'selenium-webdriver';
|
|
19
24
|
|
|
20
25
|
@injectable()
|
|
21
26
|
export class WorkspaceHandlingTests {
|
|
22
27
|
|
|
28
|
+
private static START_WORKSPACE_PAGE_NAME_LOCATOR: By = By.xpath(`//div[@class="ui-container"]/div[@class="pf-c-page"]//div[@class="pf-c-content"]/h1`);
|
|
23
29
|
private static workspaceName: string = 'undefined';
|
|
30
|
+
private static parentGUID: string;
|
|
24
31
|
|
|
25
32
|
public static getWorkspaceName(): string {
|
|
26
33
|
return WorkspaceHandlingTests.workspaceName;
|
|
27
34
|
}
|
|
28
35
|
|
|
36
|
+
public static setWorkspaceName(workspaceName: string) {
|
|
37
|
+
WorkspaceHandlingTests.workspaceName = workspaceName;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public setWindowHandle(guid: string) {
|
|
41
|
+
WorkspaceHandlingTests.parentGUID = guid;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public getWindowHandle(): string {
|
|
45
|
+
return WorkspaceHandlingTests.parentGUID;
|
|
46
|
+
}
|
|
47
|
+
|
|
29
48
|
constructor(
|
|
30
49
|
@inject(CLASSES.Dashboard) private readonly dashboard: Dashboard,
|
|
31
50
|
@inject(CLASSES.CreateWorkspace) private readonly createWorkspace: CreateWorkspace,
|
|
32
51
|
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces,
|
|
33
|
-
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil
|
|
52
|
+
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil,
|
|
53
|
+
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver,
|
|
54
|
+
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
55
|
+
@inject(CLASSES.Ide) private readonly ide: Ide) {}
|
|
34
56
|
|
|
35
57
|
public createAndOpenWorkspace(stack: string) {
|
|
36
|
-
test(`
|
|
58
|
+
test(`Create and open new workspace, stack:${stack}`, async () => {
|
|
37
59
|
await this.dashboard.waitPage();
|
|
60
|
+
Logger.debug(`Fetching user kubernetes namespace, storing auth token by getting workspaces API URL.`);
|
|
61
|
+
await this.apiUrlResolver.getWorkspacesApiUrl();
|
|
38
62
|
await this.dashboard.clickCreateWorkspaceButton();
|
|
39
63
|
await this.createWorkspace.waitPage();
|
|
40
|
-
|
|
64
|
+
WorkspaceHandlingTests.parentGUID = await this.browserTabsUtil.getCurrentWindowHandle();
|
|
41
65
|
await this.createWorkspace.clickOnSample(stack);
|
|
42
|
-
await this.browserTabsUtil.
|
|
43
|
-
WorkspaceHandlingTests.workspaceName = await this.dashboard.getRecentWorkspaceName(10000);
|
|
44
|
-
Logger.debug(`Workspace Name is: ${WorkspaceHandlingTests.workspaceName}`);
|
|
45
|
-
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(parentGUID, 10000);
|
|
66
|
+
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(WorkspaceHandlingTests.parentGUID, TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
46
67
|
});
|
|
47
68
|
}
|
|
48
69
|
|
|
49
70
|
public openExistingWorkspace(workspaceName: string) {
|
|
50
|
-
test('
|
|
71
|
+
test('Open and start existing workspace', async () => {
|
|
51
72
|
await this.dashboard.waitPage();
|
|
73
|
+
Logger.debug(`Fetching user kubernetes namespace, storing auth token by getting workspaces API URL.`);
|
|
74
|
+
await this.apiUrlResolver.getWorkspacesApiUrl();
|
|
52
75
|
await this.dashboard.clickWorkspacesButton();
|
|
53
76
|
await this.workspaces.waitPage();
|
|
54
77
|
await this.workspaces.clickOpenButton(workspaceName);
|
|
55
78
|
});
|
|
56
79
|
}
|
|
57
80
|
|
|
81
|
+
public obtainWorkspaceNameFromStartingPage() {
|
|
82
|
+
test('Obtain workspace name from workspace loader page', async() => {
|
|
83
|
+
try {
|
|
84
|
+
await this.driverHelper.waitVisibility(WorkspaceHandlingTests.START_WORKSPACE_PAGE_NAME_LOCATOR, TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT);
|
|
85
|
+
// it takes a while to update the element with the workspace name
|
|
86
|
+
await this.driverHelper.wait(TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
87
|
+
let startingWorkspaceLineContent = await this.driverHelper.getDriver().findElement(WorkspaceHandlingTests.START_WORKSPACE_PAGE_NAME_LOCATOR).getAttribute('innerHTML');
|
|
88
|
+
// cutting away leading text
|
|
89
|
+
WorkspaceHandlingTests.workspaceName = startingWorkspaceLineContent.substring('Starting workspace '.length).trim();
|
|
90
|
+
Logger.info(`Obtained workspace name from workspace loader page: ${WorkspaceHandlingTests.workspaceName}`);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
Logger.error(`Failed to obtain workspace name from workspace loader page: ${err}`);
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public switchBackToFirstOpenIdeTabFromLeftToRight() {
|
|
99
|
+
test('WorkspaceHandlingTests.switchBackToIdeTab', async () => {
|
|
100
|
+
let tabs = await this.driverHelper.getDriver().getAllWindowHandles();
|
|
101
|
+
Logger.trace(`WorkspaceHandlingTests.switchBackToIdeTab Found ${tabs.length} window handles, iterating...`);
|
|
102
|
+
for (let i = 0; i < tabs.length; i++) {
|
|
103
|
+
await this.browserTabsUtil.switchToWindow(tabs[i]);
|
|
104
|
+
try {
|
|
105
|
+
await this.ide.waitIde(TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
|
|
106
|
+
Logger.debug(`WorkspaceHandlingTests.switchBackToIdeTab located and switched to IDE tab`);
|
|
107
|
+
return;
|
|
108
|
+
} catch (err) {
|
|
109
|
+
if (err instanceof error.TimeoutError) {
|
|
110
|
+
Logger.warn(`WorkspaceHandlingTests.switchBackToIdeTab Locator timed out, trying with another window handle.`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
Logger.error(`WorkspaceHandlingTests.switchBackToIdeTab Received unexpected exception while trying to locate IDE tab:${err}`);
|
|
114
|
+
throw err;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
Logger.error(`WorkspaceHandlingTests.switchBackToIdeTab Failed to locate IDE tab, out of window handles.`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
58
121
|
public async stopWorkspace(workspaceName: string) {
|
|
59
122
|
await this.dashboard.openDashboard();
|
|
60
123
|
await this.dashboard.stopWorkspaceByUI(workspaceName);
|
|
@@ -100,7 +100,7 @@ export class CheApiRequestHandler {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
|
|
103
|
-
|
|
103
|
+
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
private assembleUrl(relativeUrl: string): string {
|
|
@@ -12,13 +12,28 @@ import { IAuthorizationHeaderHandler } from './IAuthorizationHeaderHandler';
|
|
|
12
12
|
import { inject, injectable } from 'inversify';
|
|
13
13
|
import { DriverHelper } from '../../DriverHelper';
|
|
14
14
|
import { CLASSES } from '../../../inversify.types';
|
|
15
|
+
import { Logger } from '../../Logger';
|
|
15
16
|
|
|
16
17
|
@injectable()
|
|
17
18
|
export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
|
|
19
|
+
private authorizationToken: string = '';
|
|
20
|
+
|
|
18
21
|
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
|
|
19
22
|
|
|
20
23
|
async get(): Promise<AxiosRequestConfig> {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
try {
|
|
25
|
+
let token = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy');
|
|
26
|
+
if (this.authorizationToken !== token.value) {
|
|
27
|
+
this.authorizationToken = token.value;
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
if (this.authorizationToken.length > 0) {
|
|
31
|
+
Logger.warn(`Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. Using stored value.`);
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(`Could not obtain _oauth_proxy cookie from chromedriver, browser session may have been killed. No stored token present!`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return { headers: { 'cookie': `_oauth_proxy=${this.authorizationToken}` } };
|
|
23
38
|
}
|
|
24
39
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
import { inject, injectable } from 'inversify';
|
|
11
|
+
import { CLASSES } from '../../inversify.types';
|
|
12
|
+
import { Logger } from '../Logger';
|
|
13
|
+
import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler';
|
|
14
|
+
|
|
15
|
+
@injectable()
|
|
16
|
+
export class ApiUrlResolver {
|
|
17
|
+
private static readonly DASHBOARD_API_URL: string = 'dashboard/api/namespace';
|
|
18
|
+
private static readonly KUBERNETES_API_URL: string = 'api/kubernetes/namespace';
|
|
19
|
+
|
|
20
|
+
private userNamespace: string = '';
|
|
21
|
+
|
|
22
|
+
constructor(@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler) {}
|
|
23
|
+
|
|
24
|
+
public async getWorkspaceApiUrl(workspaceName: string): Promise<string> {
|
|
25
|
+
return `${await this.getWorkspacesApiUrl()}/${workspaceName}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public async getWorkspacesApiUrl(): Promise<string> {
|
|
29
|
+
const namespace = await this.obtainUserNamespace();
|
|
30
|
+
return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public getKubernetesApiUrl(): string {
|
|
34
|
+
return ApiUrlResolver.KUBERNETES_API_URL;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private async obtainUserNamespace() : Promise<string> {
|
|
38
|
+
Logger.debug(`ApiUrlResolver.obtainUserNamespace ${this.userNamespace}`);
|
|
39
|
+
if (this.userNamespace.length === 0) {
|
|
40
|
+
Logger.trace(`ApiUrlResolver.obtainUserNamespace USER_NAMESPACE.length = 0, calling kubernetes API`);
|
|
41
|
+
const kubernetesResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL);
|
|
42
|
+
if (kubernetesResponse.status !== 200) {
|
|
43
|
+
throw new Error(`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`);
|
|
44
|
+
}
|
|
45
|
+
this.userNamespace = kubernetesResponse.data[0].name;
|
|
46
|
+
Logger.debug(`ApiUrlResolver.obtainUserNamespace kubeapi success: ${this.userNamespace}`);
|
|
47
|
+
}
|
|
48
|
+
return this.userNamespace;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -12,15 +12,87 @@ import { WorkspaceStatus } from './WorkspaceStatus';
|
|
|
12
12
|
import { che } from '@eclipse-che/api';
|
|
13
13
|
|
|
14
14
|
export interface ITestWorkspaceUtil {
|
|
15
|
+
waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) : void;
|
|
16
|
+
|
|
17
|
+
stopWorkspaceByName(workspaceName: string) : void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Delete a worksapce without stopping phase (similar with force deleting)
|
|
21
|
+
*/
|
|
22
|
+
deleteWorkspaceByName(workspaceName: string) : void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Stop workspace before deleting with checking stopping phase
|
|
26
|
+
*/
|
|
27
|
+
stopAndDeleteWorkspaceByName(workspaceName: string) : void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Stop all run workspaces in the namespace
|
|
31
|
+
*/
|
|
32
|
+
stopAllRunningWorkspaces(namespace: string) : void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Stop all run workspaces, check statused and remove the workspaces
|
|
36
|
+
*/
|
|
37
|
+
stopAndDeleteAllRunningWorkspaces(namespace: string) : void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Stop all run workspaces without stopping and waiting for of 'Stopped' phase
|
|
41
|
+
* Similar with 'force' deleting
|
|
42
|
+
*/
|
|
43
|
+
deleteAllWorkspaces(namespace: string) : void;
|
|
44
|
+
|
|
45
|
+
/*=====================
|
|
46
|
+
* DEPRECATED METHODS *
|
|
47
|
+
*====================*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
51
|
+
*/
|
|
15
52
|
cleanUpAllWorkspaces() : void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
56
|
+
*/
|
|
16
57
|
cleanUpRunningWorkspace(workspaceName: string) : void;
|
|
17
|
-
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
61
|
+
*/
|
|
18
62
|
waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) : void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
66
|
+
*/
|
|
19
67
|
removeWorkspaceById(id: string) : void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
71
|
+
*/
|
|
20
72
|
stopWorkspaceById(id: string) : void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
76
|
+
*/
|
|
21
77
|
getIdOfRunningWorkspace(workspaceName: string): Promise<string>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
81
|
+
*/
|
|
22
82
|
getIdOfRunningWorkspaces(): Promise<Array<string>>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
86
|
+
*/
|
|
23
87
|
createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
91
|
+
*/
|
|
24
92
|
getBaseDevfile(): Promise<che.workspace.devfile.Devfile>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Method deprecated. Works with CHE server only
|
|
96
|
+
*/
|
|
25
97
|
startWorkspace(workspaceId: string): void;
|
|
26
98
|
}
|
|
@@ -8,38 +8,38 @@
|
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
**********************************************************************/
|
|
10
10
|
|
|
11
|
+
import 'reflect-metadata';
|
|
11
12
|
import { che } from '@eclipse-che/api';
|
|
12
13
|
import { TestConstants } from '../../TestConstants';
|
|
13
14
|
import { injectable, inject } from 'inversify';
|
|
14
15
|
import { DriverHelper } from '../DriverHelper';
|
|
15
|
-
import 'reflect-metadata';
|
|
16
16
|
import { WorkspaceStatus } from './WorkspaceStatus';
|
|
17
|
-
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
|
|
18
17
|
import { error } from 'selenium-webdriver';
|
|
19
18
|
import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler';
|
|
20
19
|
import { CLASSES } from '../../inversify.types';
|
|
21
20
|
import { Logger } from '../Logger';
|
|
22
21
|
import axios from 'axios';
|
|
22
|
+
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
|
|
23
|
+
import { ApiUrlResolver } from './ApiUrlResolver';
|
|
23
24
|
|
|
24
25
|
@injectable()
|
|
25
26
|
export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
26
|
-
|
|
27
|
-
static readonly WORKSPACE_API_URL: string = 'dashboard/api/namespace';
|
|
28
27
|
readonly attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS;
|
|
29
28
|
readonly polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING;
|
|
29
|
+
|
|
30
30
|
constructor(
|
|
31
31
|
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
|
|
32
|
-
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler
|
|
32
|
+
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler,
|
|
33
|
+
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver
|
|
33
34
|
) { }
|
|
34
35
|
|
|
35
|
-
public async waitWorkspaceStatus(
|
|
36
|
+
public async waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) {
|
|
36
37
|
Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus');
|
|
37
38
|
|
|
38
|
-
const workspaceStatusApiUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${namespace}-che/devworkspaces/${workspaceName}`;
|
|
39
39
|
let workspaceStatus: string = '';
|
|
40
40
|
let expectedStatus: boolean = false;
|
|
41
41
|
for (let i = 0; i < this.attempts; i++) {
|
|
42
|
-
const response = await this.processRequestHandler.get(
|
|
42
|
+
const response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName));
|
|
43
43
|
|
|
44
44
|
if (response.status !== 200) {
|
|
45
45
|
throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`);
|
|
@@ -61,10 +61,10 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
public async stopWorkspaceByName(
|
|
64
|
+
public async stopWorkspaceByName(workspaceName: string) {
|
|
65
65
|
Logger.debug('TestWorkspaceUtil.stopWorkspaceByName');
|
|
66
66
|
|
|
67
|
-
const stopWorkspaceApiUrl: string =
|
|
67
|
+
const stopWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName);
|
|
68
68
|
let stopWorkspaceResponse;
|
|
69
69
|
|
|
70
70
|
try {
|
|
@@ -78,14 +78,14 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
78
78
|
throw new Error(`Cannot stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
await this.waitWorkspaceStatus(
|
|
81
|
+
await this.waitWorkspaceStatus(workspaceName, WorkspaceStatus.STOPPED);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
// delete a worksapce without stopping phase (similar with force deleting)
|
|
85
|
-
public async deleteWorkspaceByName(
|
|
86
|
-
Logger.debug(
|
|
85
|
+
public async deleteWorkspaceByName(workspaceName: string) {
|
|
86
|
+
Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` );
|
|
87
87
|
|
|
88
|
-
const deleteWorkspaceApiUrl: string =
|
|
88
|
+
const deleteWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName);
|
|
89
89
|
let deleteWorkspaceResponse;
|
|
90
90
|
let deleteWorkspaceStatus: boolean = false;
|
|
91
91
|
try {
|
|
@@ -95,16 +95,15 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
95
95
|
Logger.error(`The workspace :${workspaceName} not found`);
|
|
96
96
|
throw error;
|
|
97
97
|
}
|
|
98
|
-
Logger.error(`
|
|
98
|
+
Logger.error(`Delete workspace call failed. URL used: ${deleteWorkspaceStatus}`);
|
|
99
99
|
throw error;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (deleteWorkspaceResponse.status !== 204) {
|
|
103
|
-
throw new Error(`Can not
|
|
103
|
+
throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
for (let i = 0; i < this.attempts; i++) {
|
|
107
|
-
|
|
108
107
|
try {
|
|
109
108
|
deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl);
|
|
110
109
|
} catch (error) {
|
|
@@ -122,11 +121,44 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
// stop workspace before deleting with checking stopping phase
|
|
125
|
-
public async stopAndDeleteWorkspaceByName(
|
|
124
|
+
public async stopAndDeleteWorkspaceByName(workspaceName: string) {
|
|
126
125
|
Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName');
|
|
127
126
|
|
|
128
|
-
await this.stopWorkspaceByName(
|
|
129
|
-
await this.deleteWorkspaceByName(
|
|
127
|
+
await this.stopWorkspaceByName(workspaceName);
|
|
128
|
+
await this.deleteWorkspaceByName(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(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
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(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(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
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(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(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
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(response.data.items[i].metadata.name);
|
|
161
|
+
}
|
|
130
162
|
}
|
|
131
163
|
|
|
132
164
|
/**
|
|
@@ -135,7 +167,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
135
167
|
public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) {
|
|
136
168
|
Logger.debug('TestWorkspaceUtil.waitPluginAdding');
|
|
137
169
|
|
|
138
|
-
const workspaceStatusApiUrl: string = `${
|
|
170
|
+
const workspaceStatusApiUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${namespace}:${workspaceName}`;
|
|
139
171
|
const attempts: number = TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS;
|
|
140
172
|
const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
|
|
141
173
|
|
|
@@ -168,7 +200,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
168
200
|
public async getListOfWorkspaceId(): Promise<string[]> {
|
|
169
201
|
Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId');
|
|
170
202
|
|
|
171
|
-
const getAllWorkspacesResponse = await this.processRequestHandler.get(
|
|
203
|
+
const getAllWorkspacesResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
172
204
|
|
|
173
205
|
interface IMyObj {
|
|
174
206
|
id: string;
|
|
@@ -192,7 +224,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
192
224
|
public async getIdOfRunningWorkspace(wsName: string): Promise<string> {
|
|
193
225
|
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace');
|
|
194
226
|
|
|
195
|
-
const getWorkspacesByNameResponse = await this.processRequestHandler.get(`${
|
|
227
|
+
const getWorkspacesByNameResponse = await this.processRequestHandler.get(`${await this.apiUrlResolver.getWorkspacesApiUrl()}/:${wsName}`);
|
|
196
228
|
return getWorkspacesByNameResponse.data.id;
|
|
197
229
|
|
|
198
230
|
}
|
|
@@ -204,7 +236,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
204
236
|
Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces');
|
|
205
237
|
|
|
206
238
|
try {
|
|
207
|
-
const getAllWorkspacesResponse = await this.processRequestHandler.get(
|
|
239
|
+
const getAllWorkspacesResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl());
|
|
208
240
|
|
|
209
241
|
interface IMyObj {
|
|
210
242
|
id: string;
|
|
@@ -222,7 +254,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
222
254
|
|
|
223
255
|
return idOfRunningWorkspace;
|
|
224
256
|
} catch (err) {
|
|
225
|
-
console.log(`Getting id of running workspaces failed. URL used: ${
|
|
257
|
+
console.log(`Getting id of running workspaces failed. URL used: ${await this.apiUrlResolver.getWorkspacesApiUrl()}`);
|
|
226
258
|
throw err;
|
|
227
259
|
}
|
|
228
260
|
}
|
|
@@ -233,7 +265,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
233
265
|
public async removeWorkspaceById(id: string) {
|
|
234
266
|
Logger.debug('TestWorkspaceUtil.removeWorkspaceById');
|
|
235
267
|
|
|
236
|
-
const workspaceIdUrl: string = `${
|
|
268
|
+
const workspaceIdUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${id}`;
|
|
237
269
|
try {
|
|
238
270
|
const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl);
|
|
239
271
|
if (deleteWorkspaceResponse.status !== 204) {
|
|
@@ -251,7 +283,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
251
283
|
public async stopWorkspaceById(id: string) {
|
|
252
284
|
Logger.debug('TestWorkspaceUtil.stopWorkspaceById');
|
|
253
285
|
|
|
254
|
-
const stopWorkspaceApiUrl: string = `${
|
|
286
|
+
const stopWorkspaceApiUrl: string = `${await this.apiUrlResolver.getWorkspacesApiUrl()}/${id}`;
|
|
255
287
|
let stopWorkspaceResponse;
|
|
256
288
|
|
|
257
289
|
try {
|
|
@@ -306,16 +338,16 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
306
338
|
*/
|
|
307
339
|
public async cleanUpRunningWorkspace(workspaceName: string) {
|
|
308
340
|
if (workspaceName === undefined || workspaceName.length === 0) {
|
|
309
|
-
|
|
310
|
-
|
|
341
|
+
Logger.warn(`Could nod delete workspace because workspaceName is undefined or empty`);
|
|
342
|
+
return;
|
|
311
343
|
}
|
|
312
344
|
|
|
313
345
|
Logger.debug(`TestWorkspaceUtil.cleanUpRunningWorkspace ${workspaceName}`);
|
|
314
346
|
const workspaceID: string = await this.getIdOfRunningWorkspace(workspaceName);
|
|
315
347
|
|
|
316
348
|
if (workspaceID === undefined || workspaceID.length === 0) {
|
|
317
|
-
|
|
318
|
-
|
|
349
|
+
Logger.error(`Could nod delete workspace with name ${workspaceName} because workspaceID is undefined or empty`);
|
|
350
|
+
return;
|
|
319
351
|
}
|
|
320
352
|
|
|
321
353
|
Logger.trace(`TestWorkspaceUtil.cleanUpRunningWorkspace Stopping workspace:${workspaceName} with ID:${workspaceID}`);
|
|
@@ -331,7 +363,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
331
363
|
Logger.debug('TestWorkspaceUtil.createWsFromDevFile');
|
|
332
364
|
|
|
333
365
|
try {
|
|
334
|
-
await this.processRequestHandler.post(
|
|
366
|
+
await this.processRequestHandler.post(await this.apiUrlResolver.getWorkspacesApiUrl() + '/devfile', customTemplate);
|
|
335
367
|
} catch (error) {
|
|
336
368
|
console.error(error);
|
|
337
369
|
throw error;
|
|
@@ -361,7 +393,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
|
|
|
361
393
|
Logger.debug('TestWorkspaceUtil.startWorkspace');
|
|
362
394
|
|
|
363
395
|
try {
|
|
364
|
-
await this.processRequestHandler.post(`${
|
|
396
|
+
await this.processRequestHandler.post(`${await this.apiUrlResolver.getWorkspacesApiUrl()}/${workspaceId}/runtime`);
|
|
365
397
|
} catch (error) {
|
|
366
398
|
console.error(error);
|
|
367
399
|
throw error;
|