@eclipse-che/che-e2e 7.97.0-next-34e2649 → 7.97.0-next-dfc2d2b

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.
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /** *******************************************************************
3
+ * copyright (c) 2024 Red Hat, Inc.
4
+ *
5
+ * This program and the accompanying materials are made
6
+ * available under the terms of the Eclipse Public License 2.0
7
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
8
+ *
9
+ * SPDX-License-Identifier: EPL-2.0
10
+ **********************************************************************/
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
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('Cpp 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 = 'cpp';
28
+ const containerTerminal = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.ContainerTerminal);
29
+ let devWorkspaceConfigurationHelper;
30
+ let devfileContext;
31
+ let devfileContent = '';
32
+ let dwtName = '';
33
+ const workDirPath = 'c-plus-plus/strings';
34
+ const fileName = 'knuth_morris_pratt.cpp';
35
+ const tasksJsonPath = 'c-plus-plus/.vscode/tasks.json';
36
+ suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS_1.BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function () {
37
+ kubernetesCommandLineToolsExecutor.loginToOcp();
38
+ });
39
+ test(`Create ${devfileID} workspace`, async function () {
40
+ const randomPref = crypto_1.default.randomBytes(4).toString('hex');
41
+ kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS_1.API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
42
+ devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
43
+ const editorDevfileContent = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
44
+ dwtName = yaml_1.default.parse(devfileContent).metadata.name;
45
+ const uniqName = yaml_1.default.parse(devfileContent).metadata.name + randomPref;
46
+ kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
47
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper_1.DevWorkspaceConfigurationHelper({
48
+ editorContent: editorDevfileContent,
49
+ devfileContent: devfileContent
50
+ });
51
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
52
+ if (devfileContext.devWorkspace.metadata) {
53
+ devfileContext.devWorkspace.metadata.name = uniqName;
54
+ }
55
+ const devWorkspaceConfigurationYamlString = devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
56
+ const output = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
57
+ (0, chai_1.expect)(output.stdout).contains('condition met');
58
+ });
59
+ test('Check commands', function () {
60
+ let output;
61
+ const toolsComponent = yaml_1.default.parse(devfileContent).components.find((component) => component.name === 'tools');
62
+ const containerName = toolsComponent ? toolsComponent.name : 'Component not found';
63
+ Logger_1.Logger.info(`container from components section of Devfile:: ${containerName}`);
64
+ const tasksJsonContent = containerTerminal.execInContainerCommand(`cat ${tasksJsonPath}`, containerName).stdout;
65
+ const parsedJson = yaml_1.default.parse(tasksJsonContent);
66
+ Logger_1.Logger.info('"Check \'build current algorithm\' command"');
67
+ const buildTaskCommand = parsedJson.tasks[0].command;
68
+ const buildCommand = buildTaskCommand.replaceAll('${file}', fileName).replaceAll(/'/g, '"');
69
+ Logger_1.Logger.info(`commandLine from tasks.json file of project: ${buildCommand}`);
70
+ const runCommandInBash = `cd ${workDirPath} && ${buildCommand}`;
71
+ output = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
72
+ (0, chai_1.expect)(output.code).eqls(0);
73
+ (0, chai_1.expect)(output.stdout.trim()).contains('Build complete');
74
+ Logger_1.Logger.info('"Check \'run current algorithm\' command"');
75
+ const runTaskCommand = parsedJson.tasks[1].command;
76
+ const runCommand = runTaskCommand.replaceAll('${file}', fileName).replaceAll(/'/g, '"');
77
+ Logger_1.Logger.info(`commandLine from tasks.json file of project: ${runCommand}`);
78
+ const runCommandInBash2 = `cd ${workDirPath} && ${runCommand}`;
79
+ output = containerTerminal.execInContainerCommand(runCommandInBash2, containerName);
80
+ (0, chai_1.expect)(output.code).eqls(0);
81
+ (0, chai_1.expect)(output.stdout.trim()).contains('Found');
82
+ });
83
+ suiteTeardown('Delete workspace', function () {
84
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
85
+ });
86
+ });
87
+ //# sourceMappingURL=CppDevFileAPI.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CppDevFileAPI.spec.js","sourceRoot":"","sources":["../../../specs/api/CppDevFileAPI.spec.ts"],"names":[],"mappings":";AAAA;;;;;;;;wEAQwE;;;;;AAExE,6EAA0E;AAC1E,qEAA8D;AAC9D,mEAAwD;AAGxD,iGAA8F;AAG9F,+BAA8B;AAC9B,2EAAwE;AACxE,gDAAwB;AACxB,+CAA4C;AAC5C,oDAA4B;AAE5B,KAAK,CAAC,sBAAsB,EAAE;IAC7B,MAAM,sBAAsB,GAAmB,+BAAY,CAAC,GAA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QACjC,kCAAkC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAChE,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.97.0-next-34e2649",
3
+ "version": "7.97.0-next-dfc2d2b",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,97 @@
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
+
11
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
12
+ import { e2eContainer } from '../../configs/inversify.config';
13
+ import { CLASSES } from '../../configs/inversify.types';
14
+ import { DevfilesHelper } from '../../utils/DevfilesHelper';
15
+ import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
16
+ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
17
+ import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
18
+ import { ShellString } from 'shelljs';
19
+ import { expect } from 'chai';
20
+ import { API_TEST_CONSTANTS } from '../../constants/API_TEST_CONSTANTS';
21
+ import YAML from 'yaml';
22
+ import { Logger } from '../../utils/Logger';
23
+ import crypto from 'crypto';
24
+
25
+ suite('Cpp devfile API test', function (): void {
26
+ const devfilesRegistryHelper: DevfilesHelper = e2eContainer.get(CLASSES.DevfilesRegistryHelper);
27
+ const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
28
+ CLASSES.KubernetesCommandLineToolsExecutor
29
+ );
30
+ const devfileID: string = 'cpp';
31
+ const containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal);
32
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
33
+ let devfileContext: DevfileContext;
34
+ let devfileContent: string = '';
35
+ let dwtName: string = '';
36
+ const workDirPath: string = 'c-plus-plus/strings';
37
+ const fileName: string = 'knuth_morris_pratt.cpp';
38
+ const tasksJsonPath: string = 'c-plus-plus/.vscode/tasks.json';
39
+
40
+ suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
41
+ kubernetesCommandLineToolsExecutor.loginToOcp();
42
+ });
43
+
44
+ test(`Create ${devfileID} workspace`, async function (): Promise<void> {
45
+ const randomPref: string = crypto.randomBytes(4).toString('hex');
46
+ kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
47
+ devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
48
+ const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
49
+ dwtName = YAML.parse(devfileContent).metadata.name;
50
+ const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
51
+ kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
52
+
53
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
54
+ editorContent: editorDevfileContent,
55
+ devfileContent: devfileContent
56
+ });
57
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
58
+ if (devfileContext.devWorkspace.metadata) {
59
+ devfileContext.devWorkspace.metadata.name = uniqName;
60
+ }
61
+ const devWorkspaceConfigurationYamlString: string =
62
+ devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
63
+ const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
64
+ expect(output.stdout).contains('condition met');
65
+ });
66
+
67
+ test('Check commands', function (): void {
68
+ let output: ShellString;
69
+ const toolsComponent: any = YAML.parse(devfileContent).components.find((component: any): boolean => component.name === 'tools');
70
+ const containerName: string = toolsComponent ? toolsComponent.name : 'Component not found';
71
+ Logger.info(`container from components section of Devfile:: ${containerName}`);
72
+ const tasksJsonContent: string = containerTerminal.execInContainerCommand(`cat ${tasksJsonPath}`, containerName).stdout;
73
+ const parsedJson: any = YAML.parse(tasksJsonContent);
74
+
75
+ Logger.info('"Check \'build current algorithm\' command"');
76
+ const buildTaskCommand: string = parsedJson.tasks[0].command;
77
+ const buildCommand: string = buildTaskCommand.replaceAll('${file}', fileName).replaceAll(/'/g, '"');
78
+ Logger.info(`commandLine from tasks.json file of project: ${buildCommand}`);
79
+ const runCommandInBash: string = `cd ${workDirPath} && ${buildCommand}`;
80
+ output = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
81
+ expect(output.code).eqls(0);
82
+ expect(output.stdout.trim()).contains('Build complete');
83
+
84
+ Logger.info('"Check \'run current algorithm\' command"');
85
+ const runTaskCommand: string = parsedJson.tasks[1].command;
86
+ const runCommand: string = runTaskCommand.replaceAll('${file}', fileName).replaceAll(/'/g, '"');
87
+ Logger.info(`commandLine from tasks.json file of project: ${runCommand}`);
88
+ const runCommandInBash2: string = `cd ${workDirPath} && ${runCommand}`;
89
+ output = containerTerminal.execInContainerCommand(runCommandInBash2, containerName);
90
+ expect(output.code).eqls(0);
91
+ expect(output.stdout.trim()).contains('Found');
92
+ });
93
+
94
+ suiteTeardown('Delete workspace', function (): void {
95
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
96
+ });
97
+ });