@eclipse-che/che-e2e 7.76.0-next-6068ce8 → 7.76.0

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.
Files changed (106) hide show
  1. package/CODE_STYLE.md +1 -1
  2. package/configs/inversify.config.ts +1 -7
  3. package/configs/mocharc.ts +7 -3
  4. package/configs/sh-scripts/runFunctionalTests.sh +104 -0
  5. package/constants/API_TEST_CONSTANTS.ts +5 -2
  6. package/constants/BASE_TEST_CONSTANTS.ts +25 -7
  7. package/constants/MOCHA_CONSTANTS.ts +9 -2
  8. package/dist/configs/inversify.config.js +0 -5
  9. package/dist/configs/inversify.config.js.map +1 -1
  10. package/dist/configs/mocharc.js +14 -11
  11. package/dist/configs/mocharc.js.map +1 -1
  12. package/dist/constants/API_TEST_CONSTANTS.js +3 -2
  13. package/dist/constants/API_TEST_CONSTANTS.js.map +1 -1
  14. package/dist/constants/BASE_TEST_CONSTANTS.js +12 -0
  15. package/dist/constants/BASE_TEST_CONSTANTS.js.map +1 -1
  16. package/dist/constants/MOCHA_CONSTANTS.js +7 -4
  17. package/dist/constants/MOCHA_CONSTANTS.js.map +1 -1
  18. package/dist/specs/MochaHooks.js +10 -0
  19. package/dist/specs/MochaHooks.js.map +1 -1
  20. package/dist/specs/api/ContainerOverridesAPI.spec.js +2 -1
  21. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  22. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +9 -7
  23. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  24. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +2 -2
  25. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  26. package/dist/specs/api/InbuiltApplicationDevWorkspacesAPI.spec.js +97 -0
  27. package/dist/specs/api/InbuiltApplicationDevWorkspacesAPI.spec.js.map +1 -0
  28. package/dist/specs/api/PodOverridesAPI.spec.js +1 -1
  29. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  30. package/dist/specs/dashboard-samples/Documentation.spec.js +1 -1
  31. package/dist/specs/dashboard-samples/Documentation.spec.js.map +1 -1
  32. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +2 -1
  33. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  34. package/dist/specs/dashboard-samples/Quarkus.spec.js +1 -1
  35. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
  36. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +2 -1
  37. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
  38. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +1 -1
  39. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  40. package/dist/specs/factory/Factory.spec.js +1 -1
  41. package/dist/specs/factory/Factory.spec.js.map +1 -1
  42. package/dist/specs/factory/NoSetupRepoFactory.spec.js +1 -1
  43. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  44. package/dist/specs/factory/RefusedOAuthFactory.spec.js +1 -1
  45. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  46. package/dist/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.js +1 -1
  47. package/dist/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.js.map +1 -1
  48. package/dist/specs/miscellaneous/KubedockPodmanTest.spec.js +3 -2
  49. package/dist/specs/miscellaneous/KubedockPodmanTest.spec.js.map +1 -1
  50. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +2 -1
  51. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
  52. package/dist/specs/miscellaneous/WorkspaceWithParent.spec.js +6 -1
  53. package/dist/specs/miscellaneous/WorkspaceWithParent.spec.js.map +1 -1
  54. package/dist/specs/web-terminal/WebTerminalTest.spec.js +2 -1
  55. package/dist/specs/web-terminal/WebTerminalTest.spec.js.map +1 -1
  56. package/dist/suites/disconnected-ocp/APITest.suite.js +14 -0
  57. package/dist/suites/disconnected-ocp/APITest.suite.js.map +1 -0
  58. package/dist/suites/disconnected-ocp/DynamicallyGeneratingAPITest.suite.js +13 -0
  59. package/dist/suites/disconnected-ocp/DynamicallyGeneratingAPITest.suite.js.map +1 -0
  60. package/dist/suites/disconnected-ocp/UITest.suite.js +19 -0
  61. package/dist/suites/disconnected-ocp/UITest.suite.js.map +1 -0
  62. package/dist/suites/online-ocp/APITest.suite.js +15 -0
  63. package/dist/suites/online-ocp/APITest.suite.js.map +1 -0
  64. package/dist/suites/online-ocp/DynamicallyGeneratingAPITest.suite.js +13 -0
  65. package/dist/suites/online-ocp/DynamicallyGeneratingAPITest.suite.js.map +1 -0
  66. package/dist/suites/online-ocp/UITest.suite.js +22 -0
  67. package/dist/suites/online-ocp/UITest.suite.js.map +1 -0
  68. package/dist/tests-library/LoginTests.js +2 -0
  69. package/dist/tests-library/LoginTests.js.map +1 -1
  70. package/dist/utils/DevWorkspaceConfigurationHelper.js +43 -2
  71. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
  72. package/dist/utils/DevfilesRegistryHelper.js +22 -8
  73. package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
  74. package/dist/utils/KubernetesCommandLineToolsExecutor.js +6 -6
  75. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  76. package/package.json +5 -2
  77. package/specs/MochaHooks.ts +11 -0
  78. package/specs/api/ContainerOverridesAPI.spec.ts +2 -1
  79. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +10 -8
  80. package/specs/api/EmptyWorkspaceAPI.spec.ts +2 -2
  81. package/specs/api/InbuiltApplicationDevWorkspacesAPI.spec.ts +130 -0
  82. package/specs/api/PodOverridesAPI.spec.ts +1 -1
  83. package/specs/dashboard-samples/Documentation.spec.ts +1 -1
  84. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +2 -1
  85. package/specs/dashboard-samples/Quarkus.spec.ts +1 -1
  86. package/specs/dashboard-samples/RecommendedExtensions.spec.ts +2 -1
  87. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +1 -1
  88. package/specs/factory/Factory.spec.ts +1 -1
  89. package/specs/factory/NoSetupRepoFactory.spec.ts +1 -1
  90. package/specs/factory/RefusedOAuthFactory.spec.ts +1 -1
  91. package/specs/miscellaneous/CreateWorkspaceWithExistedName.spec.ts +1 -1
  92. package/specs/miscellaneous/KubedockPodmanTest.spec.ts +63 -59
  93. package/specs/miscellaneous/PredefinedNamespace.spec.ts +2 -1
  94. package/specs/miscellaneous/WorkspaceWithParent.spec.ts +9 -2
  95. package/specs/web-terminal/WebTerminalTest.spec.ts +2 -1
  96. package/suites/disconnected-ocp/APITest.suite.ts +11 -0
  97. package/suites/disconnected-ocp/DynamicallyGeneratingAPITest.suite.ts +10 -0
  98. package/suites/disconnected-ocp/UITest.suite.ts +16 -0
  99. package/suites/online-ocp/APITest.suite.ts +12 -0
  100. package/suites/online-ocp/DynamicallyGeneratingAPITest.suite.ts +10 -0
  101. package/suites/online-ocp/UITest.suite.ts +19 -0
  102. package/tests-library/LoginTests.ts +2 -0
  103. package/utils/DevWorkspaceConfigurationHelper.ts +33 -3
  104. package/utils/DevfilesRegistryHelper.ts +28 -9
  105. package/utils/IKubernetesCommandLineToolsExecutor.ts +1 -1
  106. package/utils/KubernetesCommandLineToolsExecutor.ts +6 -6
@@ -0,0 +1,130 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
11
+ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
12
+ import { ShellString } from 'shelljs';
13
+ import { expect } from 'chai';
14
+ import { StringUtil } from '../../utils/StringUtil';
15
+ import { DevfilesRegistryHelper } from '../../utils/DevfilesRegistryHelper';
16
+ import { Logger } from '../../utils/Logger';
17
+ import { e2eContainer } from '../../configs/inversify.config';
18
+ import { CLASSES } from '../../configs/inversify.types';
19
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
20
+ import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
21
+ import { API_TEST_CONSTANTS } from '../../constants/API_TEST_CONSTANTS';
22
+ import { MOCHA_CONSTANTS } from '../../constants/MOCHA_CONSTANTS';
23
+
24
+ /**
25
+ * dynamically generating tests
26
+ * info: https://mochajs.org/#delayed-root-suite
27
+ */
28
+
29
+ void (async function (): Promise<void> {
30
+ const devfilesRegistryHelper: DevfilesRegistryHelper = e2eContainer.get(CLASSES.DevfilesRegistryHelper);
31
+ let devfileSamples: any;
32
+ if (MOCHA_CONSTANTS.MOCHA_DELAYED_SUITE) {
33
+ devfileSamples = await devfilesRegistryHelper.collectPathsToDevfilesFromRegistry(
34
+ true,
35
+ API_TEST_CONSTANTS.TS_API_TEST_DEV_WORKSPACE_LIST?.split(',')
36
+ );
37
+ }
38
+
39
+ for (const devfileSample of devfileSamples) {
40
+ suite(
41
+ `Inbuilt DevWorkspaces test suite for "${devfileSample.name}" sample ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
42
+ function (): void {
43
+ this.bail(false);
44
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
45
+ let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
46
+ let containerTerminal: ContainerTerminal;
47
+ let devfileContextYaml: any;
48
+ let devWorkspaceName: string | undefined;
49
+ let clonedProjectName: string;
50
+ let containerWorkDir: string;
51
+ const devfilesBuildCommands: any[] = [];
52
+
53
+ test('Get DevWorkspace configuration', function (): void {
54
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({});
55
+ devfileContextYaml = devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationsAsYaml(
56
+ devfileSample.devWorkspaceConfigurationString
57
+ );
58
+ devWorkspaceName = devfileContextYaml.DevWorkspace.metadata.name;
59
+ kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor);
60
+ kubernetesCommandLineToolsExecutor.workspaceName = devWorkspaceName;
61
+ containerTerminal = e2eContainer.get(CLASSES.ContainerTerminal);
62
+ kubernetesCommandLineToolsExecutor.loginToOcp();
63
+ });
64
+
65
+ test('Collect build commands from the devfile', function (): void {
66
+ if (devfileContextYaml.DevWorkspace.spec.template.commands === undefined) {
67
+ Logger.info('Devfile does not contains any commands.');
68
+ } else {
69
+ devfileContextYaml.DevWorkspace.spec.template.commands.forEach((command: any): void => {
70
+ if (command.exec?.group?.kind === 'build') {
71
+ Logger.debug(`Build command found: ${command.exec.commandLine}`);
72
+ devfilesBuildCommands.push(command);
73
+ }
74
+ });
75
+ }
76
+ });
77
+
78
+ test('Create and wait DevWorkspace', function (): void {
79
+ const output: ShellString = kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput(
80
+ devfileSample.devWorkspaceConfigurationString
81
+ );
82
+ expect(output.stdout)
83
+ .contains('devworkspacetemplate')
84
+ .and.contains('devworkspace')
85
+ .and.contains.oneOf(['created', 'configured']);
86
+ });
87
+
88
+ test('Wait until DevWorkspace has status "ready"', function (): void {
89
+ this.timeout(TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT);
90
+ expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
91
+ });
92
+
93
+ test('Check if project was created', function (): void {
94
+ clonedProjectName = devfileContextYaml.DevWorkspace.spec.template.projects[0].name;
95
+ expect(containerTerminal.ls().stdout).includes(clonedProjectName);
96
+ });
97
+
98
+ test('Check if project files are imported', function (): void {
99
+ containerWorkDir = containerTerminal.pwd().stdout.replace('\n', '');
100
+ expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout).includes('devfile.yaml');
101
+ });
102
+
103
+ test('Check if build commands returns success', function (): void {
104
+ this.test?.timeout(1500000); // 25 minutes because build of Quarkus sample takes 20+ minutes
105
+ if (devfilesBuildCommands.length === 0) {
106
+ Logger.info('Devfile does not contains build commands.');
107
+ } else {
108
+ devfilesBuildCommands.forEach((command): void => {
109
+ Logger.info(`command.exec: ${JSON.stringify(command.exec)}`);
110
+
111
+ const commandString: string = StringUtil.updateCommandEnvsToShStyle(
112
+ `cd ${command.exec.workingDir} && ${command.exec.commandLine}`
113
+ );
114
+ Logger.info(`Full build command to be executed: ${commandString}`);
115
+
116
+ const output: ShellString = containerTerminal.execInContainerCommand(commandString, command.exec.component);
117
+ expect(output.code).eqls(0);
118
+ });
119
+ }
120
+ });
121
+
122
+ test('Delete DevWorkspace', function (): void {
123
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
124
+ });
125
+ }
126
+ );
127
+ }
128
+
129
+ run();
130
+ })();
@@ -17,7 +17,7 @@ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
17
17
  import { e2eContainer } from '../../configs/inversify.config';
18
18
  import { CLASSES } from '../../configs/inversify.types';
19
19
 
20
- suite('Test defining pod overrides via attribute.', function (): void {
20
+ suite(`Test defining pod overrides via attribute ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
21
21
  const pathToSampleFile: string = path.resolve(
22
22
  `resources/pod-overrides${BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED() ? '-airgap' : ''}.yaml`
23
23
  );
@@ -26,7 +26,7 @@ import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
26
26
  import { Logger } from '../../utils/Logger';
27
27
 
28
28
  // suit works for DevSpaces
29
- suite('Check links to documentation page in Dashboard', function (): void {
29
+ suite(`Check links to documentation page in Dashboard ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
30
30
  this.timeout(180000);
31
31
  const pathToSampleFile: string = path.resolve('resources/default-devfile.yaml');
32
32
  const workspaceName: string = YAML.parse(fs.readFileSync(pathToSampleFile, 'utf8')).metadata.name;
@@ -16,10 +16,11 @@ import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
16
16
  import { LoginTests } from '../../tests-library/LoginTests';
17
17
  import { registerRunningWorkspace } from '../MochaHooks';
18
18
  import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
19
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
19
20
 
20
21
  const stackName: string = 'Empty Workspace';
21
22
 
22
- suite(`${stackName} test`, function (): void {
23
+ suite(`${stackName} test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
23
24
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
24
25
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
25
26
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
@@ -21,7 +21,7 @@ import { expect } from 'chai';
21
21
 
22
22
  const stackName: string = 'Java 11 with Quarkus';
23
23
 
24
- suite(`The ${stackName} userstory`, function (): void {
24
+ suite(`The ${stackName} userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
25
25
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
26
26
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
27
27
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
@@ -33,11 +33,12 @@ import { expect } from 'chai';
33
33
  import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
34
34
  import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
35
35
  import { PLUGIN_TEST_CONSTANTS } from '../../constants/PLUGIN_TEST_CONSTANTS';
36
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
36
37
 
37
38
  const samples: string[] = PLUGIN_TEST_CONSTANTS.TS_SAMPLE_LIST.split(',');
38
39
 
39
40
  for (const sample of samples) {
40
- suite(`Check if recommended extensions installed for ${sample}`, function (): void {
41
+ suite(`Check if recommended extensions installed for ${sample} ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
41
42
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
42
43
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
43
44
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
@@ -25,7 +25,7 @@ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
25
25
  import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
26
26
  import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
27
27
 
28
- suite('DevConsole Integration', function (): void {
28
+ suite(`DevConsole Integration ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
29
29
  let ocpImportPage: OcpImportFromGitPage;
30
30
  let ocpApplicationPage: OcpApplicationPage;
31
31
 
@@ -39,7 +39,7 @@ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
39
39
  import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
40
40
 
41
41
  suite(
42
- `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository`,
42
+ `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
43
43
  function (): void {
44
44
  const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
45
45
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
@@ -41,7 +41,7 @@ import { OAUTH_CONSTANTS } from '../../constants/OAUTH_CONSTANTS';
41
41
  import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
42
42
 
43
43
  suite(
44
- `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without PAT/OAuth setup`,
44
+ `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without PAT/OAuth setup ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
45
45
  function (): void {
46
46
  const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
47
47
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
@@ -40,7 +40,7 @@ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
40
40
  import { FACTORY_TEST_CONSTANTS, GitProviderType } from '../../constants/FACTORY_TEST_CONSTANTS';
41
41
 
42
42
  suite(
43
- `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access`,
43
+ `Create a workspace via launching a factory from the ${FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
44
44
  function (): void {
45
45
  const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
46
46
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
@@ -23,7 +23,7 @@ import { FACTORY_TEST_CONSTANTS } from '../../constants/FACTORY_TEST_CONSTANTS';
23
23
  const stackName: string = BASE_TEST_CONSTANTS.TS_SELENIUM_DASHBOARD_SAMPLE_NAME || 'Python';
24
24
  const projectName: string = FACTORY_TEST_CONSTANTS.TS_SELENIUM_PROJECT_NAME || 'python-hello-world';
25
25
 
26
- suite('"Start workspace with existed workspace name" test', function (): void {
26
+ suite(`"Start workspace with existed workspace name" test ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
27
27
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
28
28
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
29
29
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
@@ -18,75 +18,79 @@ import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
18
18
  import { expect } from 'chai';
19
19
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
20
20
  import { ShellString } from 'shelljs';
21
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
21
22
 
22
- suite('Check possibility to manage containers within a workspace with kubedock and podman', function (): void {
23
- const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
24
- const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
25
- const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
26
- const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
27
- let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
28
- let workspaceName: string = '';
23
+ suite(
24
+ `Check possibility to manage containers within a workspace with kubedock and podman ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`,
25
+ function (): void {
26
+ const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
27
+ const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
28
+ const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
29
+ const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
30
+ let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
31
+ let workspaceName: string = '';
29
32
 
30
- const testScript: string =
31
- '# Enable Kubedock\n' +
32
- 'export KUBEDOCK_ENABLED=true\n' +
33
- 'echo KUBEDOCK_ENABLED\n' +
34
- '/entrypoint.sh\n' +
35
- 'cd $PROJECT_SOURCE\n' +
36
- 'export USER=$(oc whoami)\n' +
37
- 'export TKN=$(oc whoami -t)\n' +
38
- 'export REG="image-registry.openshift-image-registry.svc:5000"\n' +
39
- 'export PROJECT=$(oc project -q)\n' +
40
- 'export IMG="${REG}/${PROJECT}/hello"\n' +
41
- 'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' +
42
- 'podman build -t ${IMG} .\n' +
43
- 'podman push --tls-verify=false ${IMG}\n' +
44
- 'podman run --rm ${IMG}';
33
+ const testScript: string =
34
+ '# Enable Kubedock\n' +
35
+ 'export KUBEDOCK_ENABLED=true\n' +
36
+ 'echo KUBEDOCK_ENABLED\n' +
37
+ '/entrypoint.sh\n' +
38
+ 'cd $PROJECT_SOURCE\n' +
39
+ 'export USER=$(oc whoami)\n' +
40
+ 'export TKN=$(oc whoami -t)\n' +
41
+ 'export REG="image-registry.openshift-image-registry.svc:5000"\n' +
42
+ 'export PROJECT=$(oc project -q)\n' +
43
+ 'export IMG="${REG}/${PROJECT}/hello"\n' +
44
+ 'podman login --tls-verify=false --username ${USER} --password ${TKN} ${REG}\n' +
45
+ 'podman build -t ${IMG} .\n' +
46
+ 'podman push --tls-verify=false ${IMG}\n' +
47
+ 'podman run --rm ${IMG}';
45
48
 
46
- const factoryUrl: string = 'https://github.com/l0rd/dockerfile-hello-world';
49
+ const factoryUrl: string = 'https://github.com/l0rd/dockerfile-hello-world';
47
50
 
48
- loginTests.loginIntoChe();
51
+ loginTests.loginIntoChe();
49
52
 
50
- test(`Create and open new workspace from factory:${factoryUrl}`, async function (): Promise<void> {
51
- await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
52
- });
53
+ test(`Create and open new workspace from factory:${factoryUrl}`, async function (): Promise<void> {
54
+ await workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl);
55
+ });
53
56
 
54
- test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
55
- await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
56
- workspaceName = WorkspaceHandlingTests.getWorkspaceName();
57
- expect(workspaceName, 'Workspace name was not fetched from the loading page').not.undefined;
58
- });
57
+ test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
58
+ await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
59
+ workspaceName = WorkspaceHandlingTests.getWorkspaceName();
60
+ expect(workspaceName, 'Workspace name was not fetched from the loading page').not.undefined;
61
+ });
59
62
 
60
- test('Register running workspace', function (): void {
61
- registerRunningWorkspace(workspaceName);
62
- });
63
+ test('Register running workspace', function (): void {
64
+ registerRunningWorkspace(workspaceName);
65
+ });
63
66
 
64
- test('Wait workspace readiness', async function (): Promise<void> {
65
- await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
66
- });
67
+ test('Wait workspace readiness', async function (): Promise<void> {
68
+ await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor();
69
+ });
67
70
 
68
- test('Check the project files were imported', async function (): Promise<void> {
69
- const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession();
70
- expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile'), 'Files not imported').not.undefined;
71
- });
71
+ test('Check the project files were imported', async function (): Promise<void> {
72
+ const projectSection: ViewSection = await projectAndFileTests.getProjectViewSession();
73
+ expect(await projectAndFileTests.getProjectTreeItem(projectSection, 'Dockerfile'), 'Files not imported').not.undefined;
74
+ });
72
75
 
73
- test('Create and check container runs using kubedock and podman', function (): void {
74
- kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor);
75
- kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
76
- kubernetesCommandLineToolsExecutor.loginToOcp();
77
- kubernetesCommandLineToolsExecutor.getPodAndContainerNames();
78
- const output: ShellString = kubernetesCommandLineToolsExecutor.executeCommand(testScript);
79
- expect(output, 'Podman test script failed').contains('Hello from Kubedock!');
80
- });
76
+ test('Create and check container runs using kubedock and podman', function (): void {
77
+ kubernetesCommandLineToolsExecutor = e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor);
78
+ kubernetesCommandLineToolsExecutor.workspaceName = workspaceName;
79
+ kubernetesCommandLineToolsExecutor.loginToOcp();
80
+ kubernetesCommandLineToolsExecutor.getPodAndContainerNames();
81
+ const output: ShellString = kubernetesCommandLineToolsExecutor.execInContainerCommand(testScript);
82
+ expect(output, 'Podman test script failed').contains('Hello from Kubedock!');
83
+ });
81
84
 
82
- test('Stop the workspace', async function (): Promise<void> {
83
- await workspaceHandlingTests.stopWorkspace(workspaceName);
84
- await browserTabsUtil.closeAllTabsExceptCurrent();
85
- });
85
+ test('Stop the workspace', async function (): Promise<void> {
86
+ await workspaceHandlingTests.stopWorkspace(workspaceName);
87
+ await browserTabsUtil.closeAllTabsExceptCurrent();
88
+ });
86
89
 
87
- test('Delete the workspace', async function (): Promise<void> {
88
- await workspaceHandlingTests.removeWorkspace(workspaceName);
89
- });
90
+ test('Delete the workspace', async function (): Promise<void> {
91
+ await workspaceHandlingTests.removeWorkspace(workspaceName);
92
+ });
90
93
 
91
- loginTests.logoutFromChe();
92
- });
94
+ loginTests.logoutFromChe();
95
+ }
96
+ );
@@ -16,8 +16,9 @@ import { LoginTests } from '../../tests-library/LoginTests';
16
16
  import { registerRunningWorkspace } from '../MochaHooks';
17
17
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
18
18
  import { ShellExecutor } from '../../utils/ShellExecutor';
19
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
19
20
 
20
- suite('Create predefined workspace and check it', function (): void {
21
+ suite(`Create predefined workspace and check it ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
21
22
  const predefinedNamespaceName: string = 'predefined-ns';
22
23
  const stackName: string = 'Empty Workspace';
23
24
 
@@ -10,7 +10,7 @@
10
10
  import { e2eContainer } from '../../configs/inversify.config';
11
11
  import { ShellExecutor } from '../../utils/ShellExecutor';
12
12
  import { InputBox, QuickOpenBox, QuickPickItem, ViewItem, ViewSection, Workbench } from 'monaco-page-objects';
13
- import { CLASSES } from '../../configs/inversify.types';
13
+ import { CLASSES, TYPES } from '../../configs/inversify.types';
14
14
  import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
15
15
  import { LoginTests } from '../../tests-library/LoginTests';
16
16
  import { Dashboard } from '../../pageobjects/dashboard/Dashboard';
@@ -21,13 +21,15 @@ import { API_TEST_CONSTANTS } from '../../constants/API_TEST_CONSTANTS';
21
21
  import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests';
22
22
  import { registerRunningWorkspace } from '../MochaHooks';
23
23
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
24
+ import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil';
24
25
 
25
- suite('Workspace using a parent test suite', function (): void {
26
+ suite(`Workspace using a parent test suite ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
26
27
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
27
28
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
28
29
  const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
29
30
  const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
30
31
  const shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor);
32
+ const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
31
33
  const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
32
34
  const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
33
35
  CLASSES.KubernetesCommandLineToolsExecutor
@@ -96,5 +98,10 @@ suite('Workspace using a parent test suite', function (): void {
96
98
  expect(envList).contains('DEVFILE_ENV_VAR=true').and.contains('PARENT_ENV_VAR=true');
97
99
  });
98
100
 
101
+ test('Stop and delete the workspace by API', async function (): Promise<void> {
102
+ await browserTabsUtil.closeAllTabsExceptCurrent();
103
+ testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
104
+ });
105
+
99
106
  loginTests.logoutFromChe();
100
107
  });
@@ -11,8 +11,9 @@ import { CLASSES } from '../../configs/inversify.types';
11
11
  import { e2eContainer } from '../../configs/inversify.config';
12
12
  import { LoginTests } from '../../tests-library/LoginTests';
13
13
  import { OcpMainPage } from '../../pageobjects/openshift/OcpMainPage';
14
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
14
15
 
15
- suite('Login to Openshift console and start WebTerminal', function (): void {
16
+ suite(`Login to Openshift console and start WebTerminal ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
16
17
  const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
17
18
  const ocpMainPage: OcpMainPage = e2eContainer.get(CLASSES.OcpMainPage);
18
19
 
@@ -0,0 +1,11 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/api/ContainerOverridesAPI.spec';
11
+ import '../../specs/api/PodOverridesAPI.spec';
@@ -0,0 +1,10 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/api/InbuiltApplicationDevWorkspacesAPI.spec';
@@ -0,0 +1,16 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/dashboard-samples/Quarkus.spec';
11
+ import '../../specs/dashboard-samples/RecommendedExtensions.spec';
12
+ import '../../specs/dashboard-samples/Documentation.spec';
13
+ import '../../specs/devconsole-intergration/DevConsoleIntegration.spec';
14
+ import '../../specs/miscellaneous/CreateWorkspaceWithExistedName.spec';
15
+ import '../../specs/miscellaneous/PredefinedNamespace.spec';
16
+ import '../../specs/miscellaneous/WorkspaceWithParent.spec';
@@ -0,0 +1,12 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/api/ContainerOverridesAPI.spec';
11
+ import '../../specs/api/EmptyWorkspaceAPI.spec';
12
+ import '../../specs/api/PodOverridesAPI.spec';
@@ -0,0 +1,10 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/api/InbuiltApplicationDevWorkspacesAPI.spec';
@@ -0,0 +1,19 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import '../../specs/SmokeTest.spec';
11
+ import '../../specs/dashboard-samples/EmptyWorkspace.spec';
12
+ import '../../specs/dashboard-samples/Quarkus.spec';
13
+ import '../../specs/dashboard-samples/RecommendedExtensions.spec';
14
+ import '../../specs/dashboard-samples/Documentation.spec';
15
+ import '../../specs/devconsole-intergration/DevConsoleIntegration.spec';
16
+ import '../../specs/miscellaneous/CreateWorkspaceWithExistedName.spec';
17
+ import '../../specs/miscellaneous/KubedockPodmanTest.spec';
18
+ import '../../specs/miscellaneous/PredefinedNamespace.spec';
19
+ import '../../specs/miscellaneous/WorkspaceWithParent.spec';
@@ -15,6 +15,7 @@ import { inject, injectable } from 'inversify';
15
15
  import { Dashboard } from '../pageobjects/dashboard/Dashboard';
16
16
  import { IOcpLoginPage } from '../pageobjects/login/interfaces/IOcpLoginPage';
17
17
  import { BASE_TEST_CONSTANTS } from '../constants/BASE_TEST_CONSTANTS';
18
+ import { registerRunningWorkspace } from '../specs/MochaHooks';
18
19
 
19
20
  @injectable()
20
21
  export class LoginTests {
@@ -50,6 +51,7 @@ export class LoginTests {
50
51
  logoutFromChe(): void {
51
52
  test('Logout', async (): Promise<void> => {
52
53
  await this.dashboard.logout();
54
+ registerRunningWorkspace('');
53
55
  });
54
56
  }
55
57
  }
@@ -19,12 +19,16 @@ import { injectable } from 'inversify';
19
19
  import { IContextParams } from './IContextParams';
20
20
  import { e2eContainer } from '../configs/inversify.config';
21
21
  import { CLASSES, EXTERNAL_CLASSES } from '../configs/inversify.types';
22
+ import getDecorators from 'inversify-inject-decorators';
23
+
24
+ const { lazyInject } = getDecorators(e2eContainer);
22
25
 
23
26
  @injectable()
24
27
  export class DevWorkspaceConfigurationHelper {
25
- private generator: Generator = e2eContainer.get(EXTERNAL_CLASSES.Generator);
26
- private shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor);
27
-
28
+ @lazyInject(EXTERNAL_CLASSES.Generator)
29
+ private readonly generator!: Generator;
30
+ @lazyInject(CLASSES.ShellExecutor)
31
+ private readonly shellExecutor!: ShellExecutor;
28
32
  private readonly params: IContextParams;
29
33
 
30
34
  constructor(params: IContextParams) {
@@ -74,4 +78,30 @@ export class DevWorkspaceConfigurationHelper {
74
78
 
75
79
  return allContentArray.join('---\n');
76
80
  }
81
+
82
+ getDevWorkspaceConfigurationsAsYaml(allContentString: string): string {
83
+ Logger.debug(`${this.constructor.name}.${this.getDevWorkspaceConfigurationsAsYaml.name}`);
84
+ const content: any = {};
85
+ const contentArray: string[] = allContentString.split('---\n');
86
+ contentArray.forEach((e: any): void => {
87
+ e = YAML.parse(e);
88
+ e.kind === 'DevWorkspace'
89
+ ? (content.DevWorkspace = e)
90
+ : e.kind === 'DevWorkspaceTemplate'
91
+ ? (content.DevWorkspaceTemplate = e)
92
+ : Logger.error(
93
+ 'Problems with configuration parsing, string should be in format "DevWorkspace\\n---\\nDevWorkspaceTemplate"'
94
+ );
95
+ });
96
+
97
+ return content;
98
+ }
99
+ patchDevWorkspaceConfigWithBuildContainerAttribute(devfileContextDevWorkspace: any): void {
100
+ devfileContextDevWorkspace.spec.template.attributes = YAML.parse(`
101
+ controller.devfile.io/devworkspace-config:
102
+ name: devworkspace-config
103
+ namespace: openshift-devspaces
104
+ controller.devfile.io/scc: container-build
105
+ controller.devfile.io/storage-type: per-user`);
106
+ }
77
107
  }