@eclipse-che/che-e2e 7.98.0-next-04d0b55 → 7.98.0-next-2f9d491

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/CODE_STYLE.md CHANGED
@@ -33,8 +33,8 @@ Automated lint checking and code format performs with ESLint and Prettier tools
33
33
  pre-commit hook.
34
34
  Full set of rules can be found:
35
35
 
36
- - [.eslintrc](.eslintrc.js)
37
- - [.prettierrc](.prettierrc.json)
36
+ - [.eslintrc](.eslintrc.js)
37
+ - [.prettierrc](.prettierrc.json)
38
38
 
39
39
  ### Preferable code style
40
40
 
package/README.md CHANGED
@@ -2,33 +2,33 @@
2
2
 
3
3
  ## Requirements
4
4
 
5
- - node 16.x
6
- - "Chrome" browser 114.x or later
7
- - deployed Che 7 with accessible URL
5
+ - node 16.x
6
+ - "Chrome" browser 114.x or later
7
+ - deployed Che 7 with accessible URL
8
8
 
9
9
  ## Before launch
10
10
 
11
11
  **Perform commands:**
12
12
 
13
- - `export TS_SELENIUM_BASE_URL=<Che7 URL>`
14
- - `npm ci`
13
+ - `export TS_SELENIUM_BASE_URL=<Che7 URL>`
14
+ - `npm ci`
15
15
 
16
16
  Note: If there is any modifications in package.json, manually execute the `npm install` to update the package-lock.json. So that errors can be avoided while executing npm ci
17
17
 
18
18
  ## Default launch
19
19
 
20
- - Provide connection credentials:
21
- - `export TS_SELENIUM_OCP_USERNAME=<username>`
22
- - `export TS_SELENIUM_OCP_PASSWORD=<password>`
23
- - `npm run test`
20
+ - Provide connection credentials:
21
+ - `export TS_SELENIUM_OCP_USERNAME=<username>`
22
+ - `export TS_SELENIUM_OCP_PASSWORD=<password>`
23
+ - `npm run test`
24
24
 
25
25
  ## Custom launch
26
26
 
27
- - Use environment variables which described in the "constants" folder
28
- - Use environment variables for setting timeouts if needed. You can see the list in **`'TimeoutConstants.ts'`**. You can see the list of those variables and their value if you set the `'TS_SELENIUM_PRINT_TIMEOUT_VARIABLES = true'`
29
- - To test one specification export file name as `export USERSTORY=<spec-file-name-without-extension> && npm run test` (example: `-e USERSTORY=Quarkus`)
30
- - To run test without Selenium WebDriver (API tests etc.) use `export USERSTORY=<spec-file-name-without-extension> && npm run driver-less-test` (example: `-e USERSTORY=CloneGitRepoAPI`)
31
- - This project support application testing deployed on Kubernetes or Openshift platform. Openshift is default value. To switch into Kubernetes, please, use `TS_PLATFORM=kubernetes` environmental variable and `TS_SELENIUM_K8S_PASSWORD`, `TS_SELENIUM_K8S_USERNAME` to provide credentials. The sample of test command in this case:
27
+ - Use environment variables which described in the "constants" folder
28
+ - Use environment variables for setting timeouts if needed. You can see the list in **`'TimeoutConstants.ts'`**. You can see the list of those variables and their value if you set the `'TS_SELENIUM_PRINT_TIMEOUT_VARIABLES = true'`
29
+ - To test one specification export file name as `export USERSTORY=<spec-file-name-without-extension> && npm run test` (example: `-e USERSTORY=Quarkus`)
30
+ - To run test without Selenium WebDriver (API tests etc.) use `export USERSTORY=<spec-file-name-without-extension> && npm run driver-less-test` (example: `-e USERSTORY=CloneGitRepoAPI`)
31
+ - This project support application testing deployed on Kubernetes or Openshift platform. Openshift is default value. To switch into Kubernetes, please, use `TS_PLATFORM=kubernetes` environmental variable and `TS_SELENIUM_K8S_PASSWORD`, `TS_SELENIUM_K8S_USERNAME` to provide credentials. The sample of test command in this case:
32
32
  ```
33
33
  export TS_PLATFORM=kubernetes && \
34
34
  export TS_SELENIUM_K8S_USERNAME=<username> && \
@@ -37,21 +37,21 @@ Note: If there is any modifications in package.json, manually execute the `npm i
37
37
  npm run test
38
38
  ```
39
39
  Also, environmental variables can be set in files in "constants" folder.
40
- - Local test results can be represented with Allure reporter `npm run open-allure-dasboard`
40
+ - Local test results can be represented with Allure reporter `npm run open-allure-dasboard`
41
41
 
42
42
  ## Docker launch
43
43
 
44
- - open terminal and go to the "e2e" directory
45
- - export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
46
- - run command `"npm run test-docker"`
44
+ - open terminal and go to the "e2e" directory
45
+ - export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
46
+ - run command `"npm run test-docker"`
47
47
 
48
48
  ## Docker launch with changed tests
49
49
 
50
50
  **For launching tests with local changes perform next steps:**
51
51
 
52
- - open terminal and go to the "e2e" directory
53
- - export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
54
- - run command `"npm run test-docker-mount-e2e"`
52
+ - open terminal and go to the "e2e" directory
53
+ - export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
54
+ - run command `"npm run test-docker-mount-e2e"`
55
55
 
56
56
  ## Debug docker launch
57
57
 
@@ -62,27 +62,27 @@ The `'eclipse/che-e2e'` docker image has VNC server installed inside. For connec
62
62
  **The easiest way to do that is to perform steps which are described in the "Docker launch" paragraph.
63
63
  For running tests without docker, please perform next steps:**
64
64
 
65
- - Deploy Che on Kubernetes infrastructure by using 'Minikube' and 'Chectl' <https://github.com/eclipse-che/che-server/blob/HEAD/deploy/kubernetes/README.md>
66
- - Create workspace by using 'Chectl' and devfile
67
- - link to 'Chectl' manual <https://github.com/che-incubator/chectl#chectl-workspacestart>
68
- - link to devfile ( **`For successfull test passing, exactly provided devfile should be used`** )
69
- <https://gist.githubusercontent.com/Ohrimenko1988/93f5426f4ebc1705c55feb8ff0396a49/raw/cbea89ad145ba33ed34a151a12c50f045f9f3b78/yaml-ls-bug.yaml>
70
- - Provide the **`'TS_SELENIUM_BASE_URL'`** environment variable as described above
71
- - export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
72
- - perform command **`export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`**
65
+ - Deploy Che on Kubernetes infrastructure by using 'Minikube' and 'Chectl' <https://github.com/eclipse-che/che-server/blob/HEAD/deploy/kubernetes/README.md>
66
+ - Create workspace by using 'Chectl' and devfile
67
+ - link to 'Chectl' manual <https://github.com/che-incubator/chectl#chectl-workspacestart>
68
+ - link to devfile ( **`For successfull test passing, exactly provided devfile should be used`** )
69
+ <https://gist.githubusercontent.com/Ohrimenko1988/93f5426f4ebc1705c55feb8ff0396a49/raw/cbea89ad145ba33ed34a151a12c50f045f9f3b78/yaml-ls-bug.yaml>
70
+ - Provide the **`'TS_SELENIUM_BASE_URL'`** environment variable as described above
71
+ - export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
72
+ - perform command **`export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`**
73
73
 
74
74
  ## Launching the DevWorkspaceHappyPath spec file using Che with oauth authentication
75
75
 
76
76
  **Setup next environment variables:**
77
77
 
78
- - export TS_SELENIUM_BASE_URL=\<Che-URL\>
79
- - export TS_SELENIUM_OCP_USERNAME=\<cluster-username\>
80
- - export TS_SELENIUM_OCP_PASSWORD=\<cluster-password\>
81
- - export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
82
- - export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=\<login-provide-title\>
83
- - export TS_SELENIUM_DEVWORKSPACE_URL=\<devworkspace-url\>
84
- - export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
78
+ - export TS_SELENIUM_BASE_URL=\<Che-URL\>
79
+ - export TS_SELENIUM_OCP_USERNAME=\<cluster-username\>
80
+ - export TS_SELENIUM_OCP_PASSWORD=\<cluster-password\>
81
+ - export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
82
+ - export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=\<login-provide-title\>
83
+ - export TS_SELENIUM_DEVWORKSPACE_URL=\<devworkspace-url\>
84
+ - export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
85
85
 
86
86
  **Execute the npm command:**
87
87
 
88
- - perform command `export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`
88
+ - perform command `export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /** *******************************************************************
7
+ * copyright (c) 2024 Red Hat, Inc.
8
+ *
9
+ * This program and the accompanying materials are made
10
+ * available under the terms of the Eclipse Public License 2.0
11
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
12
+ *
13
+ * SPDX-License-Identifier: EPL-2.0
14
+ **********************************************************************/
15
+ const BASE_TEST_CONSTANTS_1 = require("../../constants/BASE_TEST_CONSTANTS");
16
+ const inversify_config_1 = require("../../configs/inversify.config");
17
+ const inversify_types_1 = require("../../configs/inversify.types");
18
+ const DevWorkspaceConfigurationHelper_1 = require("../../utils/DevWorkspaceConfigurationHelper");
19
+ const chai_1 = require("chai");
20
+ const API_TEST_CONSTANTS_1 = require("../../constants/API_TEST_CONSTANTS");
21
+ const yaml_1 = __importDefault(require("yaml"));
22
+ const Logger_1 = require("../../utils/Logger");
23
+ const crypto_1 = __importDefault(require("crypto"));
24
+ suite('NodeJS Express devfile API test', function () {
25
+ const devfilesRegistryHelper = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.DevfilesRegistryHelper);
26
+ const kubernetesCommandLineToolsExecutor = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.KubernetesCommandLineToolsExecutor);
27
+ const devfileID = 'nodejs-express';
28
+ const containerTerminal = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.ContainerTerminal);
29
+ let devWorkspaceConfigurationHelper;
30
+ let devfileContext;
31
+ let devfileContent = '';
32
+ let devfileName = '';
33
+ suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS_1.BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function () {
34
+ kubernetesCommandLineToolsExecutor.loginToOcp();
35
+ });
36
+ test(`Create ${devfileID} workspace`, async function () {
37
+ const randomPref = crypto_1.default.randomBytes(4).toString('hex');
38
+ kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS_1.API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
39
+ devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
40
+ const editorDevfileContent = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
41
+ devfileName = yaml_1.default.parse(devfileContent).metadata.name;
42
+ const uniqueName = yaml_1.default.parse(devfileContent).metadata.name + randomPref;
43
+ kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
44
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper_1.DevWorkspaceConfigurationHelper({
45
+ editorContent: editorDevfileContent,
46
+ devfileContent: devfileContent
47
+ });
48
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
49
+ if (devfileContext.devWorkspace.metadata) {
50
+ devfileContext.devWorkspace.metadata.name = uniqueName;
51
+ }
52
+ const devWorkspaceConfigurationYamlString = devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
53
+ const output = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
54
+ (0, chai_1.expect)(output.stdout).contains('condition met');
55
+ });
56
+ test('Check packaging application', function () {
57
+ const containerName = yaml_1.default.parse(devfileContent).commands[0].exec.component;
58
+ if (BASE_TEST_CONSTANTS_1.BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) {
59
+ Logger_1.Logger.info('Test cluster is disconnected. Ignore Self-Signed Certificate error.');
60
+ const ignoreSelfSignedCertificateErrorCommand = 'npm config set strict-ssl false';
61
+ const output = containerTerminal.execInContainerCommand(ignoreSelfSignedCertificateErrorCommand, containerName);
62
+ (0, chai_1.expect)(output.code).eqls(0);
63
+ }
64
+ const workdir = yaml_1.default.parse(devfileContent).commands[0].exec.workingDir;
65
+ const commandLine = yaml_1.default.parse(devfileContent).commands[0].exec.commandLine;
66
+ Logger_1.Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
67
+ Logger_1.Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
68
+ let runCommandInBash = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
69
+ if (workdir !== undefined && workdir !== '') {
70
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
71
+ }
72
+ const output = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
73
+ (0, chai_1.expect)(output.code).eqls(0);
74
+ const outputText = output.stdout.trim();
75
+ (0, chai_1.expect)(outputText).contains('packages in');
76
+ });
77
+ test('Check "run the web app" command', function () {
78
+ const containerName = yaml_1.default.parse(devfileContent).commands[0].exec.component;
79
+ const workdir = yaml_1.default.parse(devfileContent).commands[1].exec.workingDir;
80
+ const commandLine = yaml_1.default.parse(devfileContent).commands[1].exec.commandLine;
81
+ Logger_1.Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
82
+ Logger_1.Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
83
+ let runCommandInBash = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
84
+ if (workdir !== undefined && workdir !== '') {
85
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
86
+ }
87
+ const output = containerTerminal.execInContainerCommandWithTimeout(runCommandInBash, containerName);
88
+ (0, chai_1.expect)(output.code).eqls(124);
89
+ const outputText = output.stdout.trim();
90
+ (0, chai_1.expect)(outputText).contains('Example app listening on port 3000!');
91
+ });
92
+ test('Check "stop the web app" command', function () {
93
+ const containerName = yaml_1.default.parse(devfileContent).commands[0].exec.component;
94
+ const workdir = yaml_1.default.parse(devfileContent).commands[4].exec.workingDir;
95
+ const commandLine = yaml_1.default.parse(devfileContent).commands[4].exec.commandLine;
96
+ Logger_1.Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
97
+ Logger_1.Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
98
+ // stop app command has single and double quotes in the command line, so it should be escaped properly to run by oc exec command in bash
99
+ // stop command -> `node_server_pids=$(pgrep -fx '.*nodemon (--inspect )?app.js' | tr "\\n" " ") && echo "Stopping node server with PIDs: ${node_server_pids}" && kill -15 ${node_server_pids} &>/dev/null && echo 'Done.''`
100
+ // prettier changes next line to `replaceAll("'", "'\"'\"'")` that throws an error from eslint.
101
+ // prettier-ignore
102
+ let runCommandInBash = commandLine.replaceAll('\'', '\'\"\'\"\'');
103
+ if (workdir !== undefined && workdir !== '') {
104
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
105
+ }
106
+ const output = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
107
+ (0, chai_1.expect)(output.code).eqls(0);
108
+ const outputText = output.stdout.trim();
109
+ (0, chai_1.expect)(outputText).contains('Done.');
110
+ });
111
+ test('Check "Run the web app (debugging enabled)" command', function () {
112
+ const containerName = yaml_1.default.parse(devfileContent).commands[0].exec.component;
113
+ const workdir = yaml_1.default.parse(devfileContent).commands[3].exec.workingDir;
114
+ const commandLine = yaml_1.default.parse(devfileContent).commands[3].exec.commandLine;
115
+ Logger_1.Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
116
+ Logger_1.Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
117
+ let runCommandInBash = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
118
+ if (workdir !== undefined && workdir !== '') {
119
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
120
+ }
121
+ const output = containerTerminal.execInContainerCommandWithTimeout(runCommandInBash, containerName);
122
+ (0, chai_1.expect)(output.code).eqls(124);
123
+ const outputText = output.stdout.trim();
124
+ (0, chai_1.expect)(outputText).contains('Example app listening on port 3000!');
125
+ });
126
+ suiteTeardown('Delete workspace', function () {
127
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
128
+ });
129
+ });
130
+ //# sourceMappingURL=NodeJsExpressDevFileAPI.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeJsExpressDevFileAPI.spec.js","sourceRoot":"","sources":["../../../specs/api/NodeJsExpressDevFileAPI.spec.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;wEAQwE;AACxE,6EAA0E;AAC1E,qEAA8D;AAC9D,mEAAwD;AAGxD,iGAA8F;AAG9F,+BAA8B;AAC9B,2EAAwE;AACxE,gDAAwB;AACxB,+CAA4C;AAC5C,oDAA4B;AAE5B,KAAK,CAAC,iCAAiC,EAAE;IACxC,MAAM,sBAAsB,GAAmB,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,sBAAsB,CAAC,CAAC;IAChG,MAAM,kCAAkC,GAAuC,+BAAY,CAAC,GAAG,CAC9F,yBAAO,CAAC,kCAAkC,CAC1C,CAAC;IACF,MAAM,SAAS,GAAW,gBAAgB,CAAC;IAC3C,MAAM,iBAAiB,GAAsB,+BAAY,CAAC,GAAG,CAAC,yBAAO,CAAC,iBAAiB,CAAC,CAAC;IACzF,IAAI,+BAAgE,CAAC;IACrE,IAAI,cAA8B,CAAC;IACnC,IAAI,cAAc,GAAW,EAAE,CAAC;IAChC,IAAI,WAAW,GAAW,EAAE,CAAC;IAE7B,UAAU,CAAC,iBAAiB,yCAAmB,CAAC,gBAAgB,EAAE,EAAE;QACnE,kCAAkC,CAAC,UAAU,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,UAAU,SAAS,YAAY,EAAE,KAAK;QAC1C,MAAM,UAAU,GAAW,gBAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjE,kCAAkC,CAAC,SAAS,GAAG,uCAAkB,CAAC,qBAAqB,IAAI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CAAC,IAAI,CAAC,WAAW,CAAC;QACpF,eAAM,CAAC,IAAI,CAAC,mDAAmD,OAAO,EAAE,CAAC,CAAC;QAC1E,eAAM,CAAC,IAAI,CAAC,uDAAuD,WAAW,EAAE,CAAC,CAAC;QAElF,IAAI,gBAAgB,GAAW,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,mDAAmD;QACtH,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE;YAC5C,gBAAgB,GAAG,MAAM,OAAO,MAAM,GAAG,gBAAgB,CAAC;SAC1D;QAED,MAAM,MAAM,GAAgB,iBAAiB,CAAC,iCAAiC,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QACjH,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE9B,MAAM,UAAU,GAAW,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAChD,IAAA,aAAM,EAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,qCAAqC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,kBAAkB,EAAE;QACjC,kCAAkC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACpE,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.98.0-next-04d0b55",
3
+ "version": "7.98.0-next-2f9d491",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,157 @@
1
+ /** *******************************************************************
2
+ * copyright (c) 2024 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 { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
11
+ import { e2eContainer } from '../../configs/inversify.config';
12
+ import { CLASSES } from '../../configs/inversify.types';
13
+ import { DevfilesHelper } from '../../utils/DevfilesHelper';
14
+ import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
15
+ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
16
+ import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
17
+ import { ShellString } from 'shelljs';
18
+ import { expect } from 'chai';
19
+ import { API_TEST_CONSTANTS } from '../../constants/API_TEST_CONSTANTS';
20
+ import YAML from 'yaml';
21
+ import { Logger } from '../../utils/Logger';
22
+ import crypto from 'crypto';
23
+
24
+ suite('NodeJS Express devfile API test', function (): void {
25
+ const devfilesRegistryHelper: DevfilesHelper = e2eContainer.get(CLASSES.DevfilesRegistryHelper);
26
+ const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
27
+ CLASSES.KubernetesCommandLineToolsExecutor
28
+ );
29
+ const devfileID: string = 'nodejs-express';
30
+ const containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal);
31
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
32
+ let devfileContext: DevfileContext;
33
+ let devfileContent: string = '';
34
+ let devfileName: string = '';
35
+
36
+ suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
37
+ kubernetesCommandLineToolsExecutor.loginToOcp();
38
+ });
39
+
40
+ test(`Create ${devfileID} workspace`, async function (): Promise<void> {
41
+ const randomPref: string = crypto.randomBytes(4).toString('hex');
42
+ kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
43
+ devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
44
+ const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
45
+ devfileName = YAML.parse(devfileContent).metadata.name;
46
+ const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
47
+ kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
48
+
49
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
50
+ editorContent: editorDevfileContent,
51
+ devfileContent: devfileContent
52
+ });
53
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
54
+ if (devfileContext.devWorkspace.metadata) {
55
+ devfileContext.devWorkspace.metadata.name = uniqueName;
56
+ }
57
+ const devWorkspaceConfigurationYamlString: string =
58
+ devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
59
+ const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
60
+ expect(output.stdout).contains('condition met');
61
+ });
62
+
63
+ test('Check packaging application', function (): void {
64
+ const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;
65
+
66
+ if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) {
67
+ Logger.info('Test cluster is disconnected. Ignore Self-Signed Certificate error.');
68
+ const ignoreSelfSignedCertificateErrorCommand: string = 'npm config set strict-ssl false';
69
+ const output: ShellString = containerTerminal.execInContainerCommand(ignoreSelfSignedCertificateErrorCommand, containerName);
70
+ expect(output.code).eqls(0);
71
+ }
72
+
73
+ const workdir: string = YAML.parse(devfileContent).commands[0].exec.workingDir;
74
+ const commandLine: string = YAML.parse(devfileContent).commands[0].exec.commandLine;
75
+ Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
76
+ Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
77
+
78
+ let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
79
+ if (workdir !== undefined && workdir !== '') {
80
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
81
+ }
82
+
83
+ const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
84
+ expect(output.code).eqls(0);
85
+
86
+ const outputText: string = output.stdout.trim();
87
+ expect(outputText).contains('packages in');
88
+ });
89
+
90
+ test('Check "run the web app" command', function (): void {
91
+ const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;
92
+ const workdir: string = YAML.parse(devfileContent).commands[1].exec.workingDir;
93
+ const commandLine: string = YAML.parse(devfileContent).commands[1].exec.commandLine;
94
+ Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
95
+ Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
96
+
97
+ let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
98
+ if (workdir !== undefined && workdir !== '') {
99
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
100
+ }
101
+
102
+ const output: ShellString = containerTerminal.execInContainerCommandWithTimeout(runCommandInBash, containerName);
103
+ expect(output.code).eqls(124);
104
+
105
+ const outputText: string = output.stdout.trim();
106
+ expect(outputText).contains('Example app listening on port 3000!');
107
+ });
108
+
109
+ test('Check "stop the web app" command', function (): void {
110
+ const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;
111
+ const workdir: string = YAML.parse(devfileContent).commands[4].exec.workingDir;
112
+ const commandLine: string = YAML.parse(devfileContent).commands[4].exec.commandLine;
113
+ Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
114
+ Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
115
+
116
+ // stop app command has single and double quotes in the command line, so it should be escaped properly to run by oc exec command in bash
117
+ // stop command -> `node_server_pids=$(pgrep -fx '.*nodemon (--inspect )?app.js' | tr "\\n" " ") && echo "Stopping node server with PIDs: ${node_server_pids}" && kill -15 ${node_server_pids} &>/dev/null && echo 'Done.''`
118
+
119
+ // prettier changes next line to `replaceAll("'", "'\"'\"'")` that throws an error from eslint.
120
+ // prettier-ignore
121
+ let runCommandInBash: string = commandLine.replaceAll('\'', '\'\"\'\"\'');
122
+
123
+ if (workdir !== undefined && workdir !== '') {
124
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
125
+ }
126
+
127
+ const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
128
+ expect(output.code).eqls(0);
129
+
130
+ const outputText: string = output.stdout.trim();
131
+ expect(outputText).contains('Done.');
132
+ });
133
+
134
+ test('Check "Run the web app (debugging enabled)" command', function (): void {
135
+ const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;
136
+
137
+ const workdir: string = YAML.parse(devfileContent).commands[3].exec.workingDir;
138
+ const commandLine: string = YAML.parse(devfileContent).commands[3].exec.commandLine;
139
+ Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
140
+ Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
141
+
142
+ let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
143
+ if (workdir !== undefined && workdir !== '') {
144
+ runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
145
+ }
146
+
147
+ const output: ShellString = containerTerminal.execInContainerCommandWithTimeout(runCommandInBash, containerName);
148
+ expect(output.code).eqls(124);
149
+
150
+ const outputText: string = output.stdout.trim();
151
+ expect(outputText).contains('Example app listening on port 3000!');
152
+ });
153
+
154
+ suiteTeardown('Delete workspace', function (): void {
155
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
156
+ });
157
+ });