@eclipse-che/che-e2e 7.78.0-next-4d97c65 → 7.78.0-next-fcfd29d

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.
@@ -14,20 +14,16 @@ const chai_1 = require("chai");
14
14
  const inversify_types_1 = require("../../configs/inversify.types");
15
15
  const WorkspaceHandlingTests_1 = require("../../tests-library/WorkspaceHandlingTests");
16
16
  const Logger_1 = require("../../utils/Logger");
17
- const MochaHooks_1 = require("../MochaHooks");
18
17
  const BASE_TEST_CONSTANTS_1 = require("../../constants/BASE_TEST_CONSTANTS");
19
- const OAUTH_CONSTANTS_1 = require("../../constants/OAUTH_CONSTANTS");
18
+ const DevWorkspaceConfigurationHelper_1 = require("../../utils/DevWorkspaceConfigurationHelper");
20
19
  suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS_1.BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function () {
21
20
  const predefinedNamespaceName = 'predefined-ns';
22
- const stackName = 'Empty Workspace';
21
+ const workspaceName = 'empty-ws';
22
+ const shellExecutor = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.ShellExecutor);
23
23
  const userName = 'user';
24
- const browserTabsUtil = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.BrowserTabsUtil);
25
- const dashboard = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.Dashboard);
26
- const loginTests = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.LoginTests);
27
- const workspaceHandlingTests = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceHandlingTests);
24
+ let devWorkspaceConfigurationHelper;
25
+ let devfileContext;
28
26
  const kubernetesCommandLineToolsExecutor = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.KubernetesCommandLineToolsExecutor);
29
- const shellExecutor = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.ShellExecutor);
30
- const testWorkspaceUtil = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil);
31
27
  suiteSetup(function () {
32
28
  // create a predefined namespace for user using shell script and login into user dashboard
33
29
  Logger_1.Logger.debug('Test prerequisites:');
@@ -47,39 +43,40 @@ suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS_1.BASE_TES
47
43
  const setEditRightsForUser = `oc adm policy add-role-to-user edit user -n ${predefinedNamespaceName}`;
48
44
  shellExecutor.executeCommand(setEditRightsForUser);
49
45
  });
46
+ // generate empty workspace DevFile and create it through oc client under a regular user
50
47
  suiteSetup('Login', async function () {
51
- if (OAUTH_CONSTANTS_1.OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME === userName) {
52
- await loginTests.loginIntoChe();
53
- }
54
- else {
55
- try {
56
- await loginTests.logoutFromChe();
57
- }
58
- catch (e) {
59
- Logger_1.Logger.trace('user was not logged in.');
60
- }
61
- await loginTests.loginIntoChe(userName);
62
- }
48
+ const devfileContent = 'schemaVersion: 2.2.0\n' + 'metadata:\n' + ` name: ${workspaceName}\n`;
49
+ kubernetesCommandLineToolsExecutor.loginToOcp(userName);
50
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper_1.DevWorkspaceConfigurationHelper({
51
+ devfileContent
52
+ });
53
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
54
+ const devWorkspaceConfigurationYamlString = devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
55
+ kubernetesCommandLineToolsExecutor.applyWithoutNamespace(devWorkspaceConfigurationYamlString);
63
56
  });
64
- // create the Empty workspace using CHE Dashboard
65
- test(`Create and open new workspace, stack:${stackName}`, async function () {
66
- await workspaceHandlingTests.createAndOpenWorkspace(stackName);
57
+ // verify that just created workspace is available for the dedicated user
58
+ test('Validate the created workspace is present in predefined namespace', function () {
59
+ const expectedProject = shellExecutor.executeArbitraryShellScript('oc get projects');
60
+ (0, chai_1.expect)(expectedProject).contains(predefinedNamespaceName);
67
61
  });
68
- test('Obtain workspace name from workspace loader page', async function () {
69
- await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
62
+ // make sure that the generated devspace has been created in the predefined namespace
63
+ test('Validate the created workspace is present in predefined namespace', function () {
64
+ kubernetesCommandLineToolsExecutor.namespace = predefinedNamespaceName;
65
+ kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
66
+ // relogin under the admin user (because regular user does not have permissions for getting pod states)
67
+ kubernetesCommandLineToolsExecutor.loginToOcp('admin');
68
+ (0, chai_1.expect)(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
70
69
  });
71
70
  // verify that just created workspace with unique name is present in the predefined namespace
72
71
  test('Validate the created workspace is present in predefined namespace', function () {
73
- const workspaceName = WorkspaceHandlingTests_1.WorkspaceHandlingTests.getWorkspaceName();
74
- (0, MochaHooks_1.registerRunningWorkspace)(workspaceName);
75
- kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
76
- kubernetesCommandLineToolsExecutor.namespace = predefinedNamespaceName;
77
72
  const ocDevWorkspaceOutput = kubernetesCommandLineToolsExecutor.getDevWorkspaceYamlConfiguration();
78
73
  (0, chai_1.expect)(ocDevWorkspaceOutput).includes(workspaceName);
79
74
  });
80
75
  suiteTeardown(function () {
81
76
  const workspaceName = WorkspaceHandlingTests_1.WorkspaceHandlingTests.getWorkspaceName();
82
77
  try {
78
+ // the test can failed under the regular user. Need login as admin for removing test namespace and DevSpaces.
79
+ kubernetesCommandLineToolsExecutor.loginToOcp('admin');
83
80
  kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
84
81
  kubernetesCommandLineToolsExecutor.deleteProject(predefinedNamespaceName);
85
82
  }
@@ -87,21 +84,5 @@ suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS_1.BASE_TES
87
84
  Logger_1.Logger.error(`Cannot remove the predefined project: ${workspaceName}, please fix it manually: ${e}`);
88
85
  }
89
86
  });
90
- suiteTeardown('Re-login with test user', async function () {
91
- if (OAUTH_CONSTANTS_1.OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME !== userName) {
92
- await loginTests.logoutFromChe();
93
- await loginTests.loginIntoChe();
94
- }
95
- });
96
- suiteTeardown('Open dashboard and close all other tabs', async function () {
97
- await dashboard.openDashboard();
98
- await browserTabsUtil.closeAllTabsExceptCurrent();
99
- });
100
- suiteTeardown('Stop and delete the workspace by API', async function () {
101
- await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests_1.WorkspaceHandlingTests.getWorkspaceName());
102
- });
103
- suiteTeardown('Unregister running workspace', function () {
104
- (0, MochaHooks_1.registerRunningWorkspace)('');
105
- });
106
87
  });
107
88
  //# sourceMappingURL=PredefinedNamespace.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PredefinedNamespace.spec.js","sourceRoot":"","sources":["../../../specs/miscellaneous/PredefinedNamespace.spec.ts"],"names":[],"mappings":";;AAAA;;;;;;;;wEAQwE;AACxE,qEAA8D;AAC9D,+BAA8B;AAC9B,mEAA+D;AAC/D,uFAAoF;AACpF,+CAA4C;AAE5C,8CAAyD;AAGzD,6EAA0E;AAG1E,qEAAkE;AAGlE,KAAK,CAAC,4CAA4C,yCAAmB,CAAC,gBAAgB,EAAE,EAAE;IACzF,MAAM,uBAAuB,GAAW,eAAe,CAAC;IACxD,MAAM,SAAS,GAAW,iBAAiB,CAAC;IAC5C,MAAM,QAAQ,GAAW,MAAM,CAAC;IAEhC,MAAM,eAAe,GAAoB,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,eAAe,CAAC,CAAC;IACnF,MAAM,SAAS,GAAc,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,SAAS,CAAC,CAAC;IACjE,MAAM,UAAU,GAAe,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,UAAU,CAAC,CAAC;IACpE,MAAM,sBAAsB,GAA2B,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,sBAAsB,CAAC,CAAC;IACxG,MAAM,kCAAkC,GAAuC,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gB,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;IAEH,6FAA6F;IAC7F,IAAI,CAAC,mEAAmE,EAAE;QACzE,MAAM,oBAAoB,GAAW,kCAAkC,CAAC,gCAAgC,EAAE,CAAC;QAC3G,IAAA,aAAM,EAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC;QACb,MAAM,aAAa,GAAW,+CAAsB,CAAC,gBAAgB,EAAE,CAAC;QACxE,IAAI;YACH,6GAA6G;YAC7G,kCAAkC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACvD,kCAAkC,CAAC,kBAAkB,EAAE,CAAC;YACxD,kCAAkC,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;SAC1E;QAAC,OAAO,CAAC,EAAE;YACX,eAAM,CAAC,KAAK,CAAC,yCAAyC,aAAa,6BAA6B,CAAC,EAAE,CAAC,CAAC;SACrG;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-che/che-e2e",
3
- "version": "7.78.0-next-4d97c65",
3
+ "version": "7.78.0-next-fcfd29d",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -9,33 +9,25 @@
9
9
  **********************************************************************/
10
10
  import { e2eContainer } from '../../configs/inversify.config';
11
11
  import { expect } from 'chai';
12
- import { CLASSES, TYPES } from '../../configs/inversify.types';
12
+ import { CLASSES } from '../../configs/inversify.types';
13
13
  import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
14
14
  import { Logger } from '../../utils/Logger';
15
- import { LoginTests } from '../../tests-library/LoginTests';
16
- import { registerRunningWorkspace } from '../MochaHooks';
17
15
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
18
16
  import { ShellExecutor } from '../../utils/ShellExecutor';
19
17
  import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
20
- import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
21
- import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
22
- import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
23
- import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
18
+ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
19
+ import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
24
20
 
25
21
  suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
26
22
  const predefinedNamespaceName: string = 'predefined-ns';
27
- const stackName: string = 'Empty Workspace';
23
+ const workspaceName: string = 'empty-ws';
24
+ const shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor);
28
25
  const userName: string = 'user';
29
-
30
- const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
31
- const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
32
- const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
33
- const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
26
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
27
+ let devfileContext: DevfileContext;
34
28
  const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
35
29
  CLASSES.KubernetesCommandLineToolsExecutor
36
30
  );
37
- const shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor);
38
- const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
39
31
 
40
32
  suiteSetup(function (): void {
41
33
  // create a predefined namespace for user using shell script and login into user dashboard
@@ -59,33 +51,36 @@ suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS.TEST_ENVIR
59
51
  const setEditRightsForUser: string = `oc adm policy add-role-to-user edit user -n ${predefinedNamespaceName}`;
60
52
  shellExecutor.executeCommand(setEditRightsForUser);
61
53
  });
62
-
54
+ // generate empty workspace DevFile and create it through oc client under a regular user
63
55
  suiteSetup('Login', async function (): Promise<void> {
64
- if (OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME === userName) {
65
- await loginTests.loginIntoChe();
66
- } else {
67
- try {
68
- await loginTests.logoutFromChe();
69
- } catch (e) {
70
- Logger.trace('user was not logged in.');
71
- }
72
- await loginTests.loginIntoChe(userName);
73
- }
56
+ const devfileContent: string = 'schemaVersion: 2.2.0\n' + 'metadata:\n' + ` name: ${workspaceName}\n`;
57
+ kubernetesCommandLineToolsExecutor.loginToOcp(userName);
58
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
59
+ devfileContent
60
+ });
61
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
62
+ const devWorkspaceConfigurationYamlString: string =
63
+ devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
64
+ kubernetesCommandLineToolsExecutor.applyWithoutNamespace(devWorkspaceConfigurationYamlString);
74
65
  });
75
- // create the Empty workspace using CHE Dashboard
76
- test(`Create and open new workspace, stack:${stackName}`, async function (): Promise<void> {
77
- await workspaceHandlingTests.createAndOpenWorkspace(stackName);
66
+
67
+ // verify that just created workspace is available for the dedicated user
68
+ test('Validate the created workspace is present in predefined namespace', function (): void {
69
+ const expectedProject: string = shellExecutor.executeArbitraryShellScript('oc get projects');
70
+ expect(expectedProject).contains(predefinedNamespaceName);
78
71
  });
79
- test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
80
- await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
72
+
73
+ // make sure that the generated devspace has been created in the predefined namespace
74
+ test('Validate the created workspace is present in predefined namespace', function (): void {
75
+ kubernetesCommandLineToolsExecutor.namespace = predefinedNamespaceName;
76
+ kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
77
+ // relogin under the admin user (because regular user does not have permissions for getting pod states)
78
+ kubernetesCommandLineToolsExecutor.loginToOcp('admin');
79
+ expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
81
80
  });
82
81
 
83
82
  // verify that just created workspace with unique name is present in the predefined namespace
84
83
  test('Validate the created workspace is present in predefined namespace', function (): void {
85
- const workspaceName: string = WorkspaceHandlingTests.getWorkspaceName();
86
- registerRunningWorkspace(workspaceName);
87
- kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
88
- kubernetesCommandLineToolsExecutor.namespace = predefinedNamespaceName;
89
84
  const ocDevWorkspaceOutput: string = kubernetesCommandLineToolsExecutor.getDevWorkspaceYamlConfiguration();
90
85
  expect(ocDevWorkspaceOutput).includes(workspaceName);
91
86
  });
@@ -93,30 +88,12 @@ suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS.TEST_ENVIR
93
88
  suiteTeardown(function (): void {
94
89
  const workspaceName: string = WorkspaceHandlingTests.getWorkspaceName();
95
90
  try {
91
+ // the test can failed under the regular user. Need login as admin for removing test namespace and DevSpaces.
92
+ kubernetesCommandLineToolsExecutor.loginToOcp('admin');
96
93
  kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
97
94
  kubernetesCommandLineToolsExecutor.deleteProject(predefinedNamespaceName);
98
95
  } catch (e) {
99
96
  Logger.error(`Cannot remove the predefined project: ${workspaceName}, please fix it manually: ${e}`);
100
97
  }
101
98
  });
102
-
103
- suiteTeardown('Re-login with test user', async function (): Promise<void> {
104
- if (OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME !== userName) {
105
- await loginTests.logoutFromChe();
106
- await loginTests.loginIntoChe();
107
- }
108
- });
109
-
110
- suiteTeardown('Open dashboard and close all other tabs', async function (): Promise<void> {
111
- await dashboard.openDashboard();
112
- await browserTabsUtil.closeAllTabsExceptCurrent();
113
- });
114
-
115
- suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
116
- await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
117
- });
118
-
119
- suiteTeardown('Unregister running workspace', function (): void {
120
- registerRunningWorkspace('');
121
- });
122
99
  });