@eclipse-che/che-e2e 7.97.0-next-b219dd1 → 7.97.0-next-76b99e7
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,80 @@
|
|
|
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('Go 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 = 'go';
|
|
28
|
+
const containerTerminal = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.ContainerTerminal);
|
|
29
|
+
let devWorkspaceConfigurationHelper;
|
|
30
|
+
let devfileContext;
|
|
31
|
+
let devfileContent = '';
|
|
32
|
+
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS_1.BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function () {
|
|
33
|
+
kubernetesCommandLineToolsExecutor.loginToOcp();
|
|
34
|
+
});
|
|
35
|
+
test(`Create ${devfileID} workspace`, async function () {
|
|
36
|
+
const randomPref = crypto_1.default.randomBytes(4).toString('hex');
|
|
37
|
+
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS_1.API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
|
|
38
|
+
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
|
|
39
|
+
const editorDevfileContent = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
|
|
40
|
+
const uniqName = yaml_1.default.parse(devfileContent).metadata.name + randomPref;
|
|
41
|
+
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
|
|
42
|
+
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper_1.DevWorkspaceConfigurationHelper({
|
|
43
|
+
editorContent: editorDevfileContent,
|
|
44
|
+
devfileContent: devfileContent
|
|
45
|
+
});
|
|
46
|
+
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
|
|
47
|
+
if (devfileContext.devWorkspace.metadata) {
|
|
48
|
+
devfileContext.devWorkspace.metadata.name = uniqName;
|
|
49
|
+
}
|
|
50
|
+
const devWorkspaceConfigurationYamlString = devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
|
|
51
|
+
const output = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
|
|
52
|
+
(0, chai_1.expect)(output.stdout).contains('condition met');
|
|
53
|
+
});
|
|
54
|
+
test('Check devfile commands', function () {
|
|
55
|
+
const workdir = yaml_1.default.parse(devfileContent).commands[0].exec.workingDir;
|
|
56
|
+
const buildCommandLine = yaml_1.default.parse(devfileContent).commands[0].exec.commandLine;
|
|
57
|
+
const containerName = yaml_1.default.parse(devfileContent).commands[0].exec.component;
|
|
58
|
+
Logger_1.Logger.info('"Test \'build\' command execution"');
|
|
59
|
+
Logger_1.Logger.info(`workdir from exec section of DevFile: ${workdir}`);
|
|
60
|
+
Logger_1.Logger.info(`commandLine from exec section of DevFile: ${buildCommandLine}`);
|
|
61
|
+
const runCommandInBash = `cd ${workdir} && ${buildCommandLine}`;
|
|
62
|
+
const output = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
|
|
63
|
+
Logger_1.Logger.info(`Output stderr: ${output.stderr}`);
|
|
64
|
+
(0, chai_1.expect)(output.code).eqls(0);
|
|
65
|
+
(0, chai_1.expect)(output.stderr.trim()).contains('go: downloading');
|
|
66
|
+
Logger_1.Logger.info('"Test \'run\' command execution"');
|
|
67
|
+
const runCommandLine = yaml_1.default.parse(devfileContent).commands[1].exec.commandLine;
|
|
68
|
+
Logger_1.Logger.info(`commandLine from exec section of DevFile: ${runCommandLine}`);
|
|
69
|
+
const runCommandInBash2 = `cd ${workdir} && sh -c "(${runCommandLine} > server.log 2>&1 &) && exit"`;
|
|
70
|
+
const output2 = containerTerminal.execInContainerCommand(runCommandInBash2, containerName);
|
|
71
|
+
(0, chai_1.expect)(output2.code).eqls(0);
|
|
72
|
+
const logOutput = containerTerminal.execInContainerCommand(`cat ${workdir}/server.log`, containerName);
|
|
73
|
+
Logger_1.Logger.info(`Log output: ${logOutput.stdout}`);
|
|
74
|
+
(0, chai_1.expect)(logOutput.stdout.trim()).contains('Web server running on port 8080');
|
|
75
|
+
});
|
|
76
|
+
suiteTeardown('Delete workspace', function () {
|
|
77
|
+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
|
|
78
|
+
});
|
|
79
|
+
});
|
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CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,kBAAkB,EAAE;QACjC,kCAAkC,CAAC,kBAAkB,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
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('Go 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 = 'go';
|
|
31
|
+
const containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal);
|
|
32
|
+
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
|
|
33
|
+
let devfileContext: DevfileContext;
|
|
34
|
+
let devfileContent: 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
|
+
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
|
|
46
|
+
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
|
|
47
|
+
|
|
48
|
+
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
|
|
49
|
+
editorContent: editorDevfileContent,
|
|
50
|
+
devfileContent: devfileContent
|
|
51
|
+
});
|
|
52
|
+
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
|
|
53
|
+
if (devfileContext.devWorkspace.metadata) {
|
|
54
|
+
devfileContext.devWorkspace.metadata.name = uniqName;
|
|
55
|
+
}
|
|
56
|
+
const devWorkspaceConfigurationYamlString: string =
|
|
57
|
+
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
|
|
58
|
+
const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
|
|
59
|
+
expect(output.stdout).contains('condition met');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Check devfile commands', function (): void {
|
|
63
|
+
const workdir: string = YAML.parse(devfileContent).commands[0].exec.workingDir;
|
|
64
|
+
const buildCommandLine: string = YAML.parse(devfileContent).commands[0].exec.commandLine;
|
|
65
|
+
const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;
|
|
66
|
+
|
|
67
|
+
Logger.info('"Test \'build\' command execution"');
|
|
68
|
+
Logger.info(`workdir from exec section of DevFile: ${workdir}`);
|
|
69
|
+
Logger.info(`commandLine from exec section of DevFile: ${buildCommandLine}`);
|
|
70
|
+
const runCommandInBash: string = `cd ${workdir} && ${buildCommandLine}`;
|
|
71
|
+
const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
|
|
72
|
+
Logger.info(`Output stderr: ${output.stderr}`);
|
|
73
|
+
expect(output.code).eqls(0);
|
|
74
|
+
expect(output.stderr.trim()).contains('go: downloading');
|
|
75
|
+
|
|
76
|
+
Logger.info('"Test \'run\' command execution"');
|
|
77
|
+
const runCommandLine: string = YAML.parse(devfileContent).commands[1].exec.commandLine;
|
|
78
|
+
Logger.info(`commandLine from exec section of DevFile: ${runCommandLine}`);
|
|
79
|
+
const runCommandInBash2: string = `cd ${workdir} && sh -c "(${runCommandLine} > server.log 2>&1 &) && exit"`;
|
|
80
|
+
const output2: ShellString = containerTerminal.execInContainerCommand(runCommandInBash2, containerName);
|
|
81
|
+
expect(output2.code).eqls(0);
|
|
82
|
+
const logOutput: ShellString = containerTerminal.execInContainerCommand(`cat ${workdir}/server.log`, containerName);
|
|
83
|
+
Logger.info(`Log output: ${logOutput.stdout}`);
|
|
84
|
+
expect(logOutput.stdout.trim()).contains('Web server running on port 8080');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
suiteTeardown('Delete workspace', function (): void {
|
|
88
|
+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
|
|
89
|
+
});
|
|
90
|
+
});
|