Skip to content

Commit 4c060ae

Browse files
authored
Add QuarkusDevFileAPI and LombokDevFileAPI tests; renew Documentation test (#23295)
* Add QuarkusDevFileAPI test Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com> * Simplified removal of dev workspace template in API tests Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com> * Fix lint errors Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com> * Fix DevfileID Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com> * fix quarkus commands * fix run command * Add timeout to the run application command * fix command execution * Add Lombok API test * Add support of airgap cluster; remove useless '--request-timeout' parameter * Fix address to the product.json repo in Documentation.spec.ts test Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com> --------- Signed-off-by: Dmytro Nochevnov <dnochevn@redhat.com>
1 parent dfc2d2b commit 4c060ae

9 files changed

+252
-52
lines changed

tests/e2e/specs/api/CppDevFileAPI.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ suite('Cpp devfile API test', function (): void {
3232
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
3333
let devfileContext: DevfileContext;
3434
let devfileContent: string = '';
35-
let dwtName: string = '';
35+
let devfileName: string = '';
3636
const workDirPath: string = 'c-plus-plus/strings';
3737
const fileName: string = 'knuth_morris_pratt.cpp';
3838
const tasksJsonPath: string = 'c-plus-plus/.vscode/tasks.json';
@@ -46,17 +46,17 @@ suite('Cpp devfile API test', function (): void {
4646
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
4747
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
4848
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;
49+
devfileName = YAML.parse(devfileContent).metadata.name;
50+
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
51+
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
5252

5353
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
5454
editorContent: editorDevfileContent,
5555
devfileContent: devfileContent
5656
});
5757
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
5858
if (devfileContext.devWorkspace.metadata) {
59-
devfileContext.devWorkspace.metadata.name = uniqName;
59+
devfileContext.devWorkspace.metadata.name = uniqueName;
6060
}
6161
const devWorkspaceConfigurationYamlString: string =
6262
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
@@ -92,6 +92,6 @@ suite('Cpp devfile API test', function (): void {
9292
});
9393

9494
suiteTeardown('Delete workspace', function (): void {
95-
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
95+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
9696
});
9797
});

tests/e2e/specs/api/DotnetDevFileAPI.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ suite('Dotnet devfile API test', function (): void {
3131
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
3232
let devfileContext: DevfileContext;
3333
let devfileContent: string = '';
34-
let dwtName: string = '';
34+
let devfileName: string = '';
3535

3636
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
3737
kubernetesCommandLineToolsExecutor.loginToOcp();
@@ -42,17 +42,17 @@ suite('Dotnet devfile API test', function (): void {
4242
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
4343
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
4444
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
45-
dwtName = YAML.parse(devfileContent).metadata.name;
46-
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
47-
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
45+
devfileName = YAML.parse(devfileContent).metadata.name;
46+
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
47+
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
4848

4949
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
5050
editorContent: editorDevfileContent,
5151
devfileContent: devfileContent
5252
});
5353
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
5454
if (devfileContext.devWorkspace.metadata) {
55-
devfileContext.devWorkspace.metadata.name = uniqName;
55+
devfileContext.devWorkspace.metadata.name = uniqueName;
5656
}
5757
const devWorkspaceConfigurationYamlString: string =
5858
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
@@ -94,6 +94,6 @@ suite('Dotnet devfile API test', function (): void {
9494
});
9595

9696
suiteTeardown('Delete DevWorkspace', function (): void {
97-
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
97+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
9898
});
9999
});

tests/e2e/specs/api/GoDevFileAPI.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ suite('Go devfile API test', function (): void {
3232
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
3333
let devfileContext: DevfileContext;
3434
let devfileContent: string = '';
35-
let dwtName: string = '';
35+
let devfileName: string = '';
3636

3737
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
3838
kubernetesCommandLineToolsExecutor.loginToOcp();
3939
});
4040

41-
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
41+
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
4242
const randomPref: string = crypto.randomBytes(4).toString('hex');
4343
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
4444
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
4545
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
46-
dwtName = YAML.parse(devfileContent).metadata.name;
47-
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
48-
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
46+
devfileName = YAML.parse(devfileContent).metadata.name;
47+
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
48+
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
4949

5050
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
5151
editorContent: editorDevfileContent,
5252
devfileContent: devfileContent
5353
});
5454
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
5555
if (devfileContext.devWorkspace.metadata) {
56-
devfileContext.devWorkspace.metadata.name = uniqName;
56+
devfileContext.devWorkspace.metadata.name = uniqueName;
5757
}
5858
const devWorkspaceConfigurationYamlString: string =
5959
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
@@ -87,6 +87,6 @@ suite('Go devfile API test', function (): void {
8787
});
8888

8989
suiteTeardown('Delete DevWorkspace', function (): void {
90-
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
90+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
9191
});
9292
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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('Lombok 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 = 'java-lombok';
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 build 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. Init Java Truststore...');
68+
const initJavaTruststoreCommand: string =
69+
'cp /home/user/init-java-truststore.sh /tmp && chmod +x /tmp/init-java-truststore.sh && /tmp/init-java-truststore.sh';
70+
const output: ShellString = containerTerminal.execInContainerCommand(initJavaTruststoreCommand, containerName);
71+
expect(output.code).eqls(0);
72+
}
73+
74+
const workdir: string = YAML.parse(devfileContent).commands[0].exec.workingDir;
75+
const commandLine: string = YAML.parse(devfileContent).commands[0].exec.commandLine;
76+
Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
77+
Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);
78+
79+
let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
80+
if (workdir !== undefined && workdir !== '') {
81+
runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
82+
}
83+
84+
const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
85+
expect(output.code).eqls(0);
86+
87+
const outputText: string = output.stdout.trim();
88+
expect(outputText).contains('BUILD SUCCESS');
89+
});
90+
91+
suiteTeardown('Delete workspace', function (): void {
92+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
93+
});
94+
});

tests/e2e/specs/api/PhpDevFileAPI.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ suite('PHP devfile API test', function (): void {
3131
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
3232
let devfileContext: DevfileContext;
3333
let devfileContent: string = '';
34-
let dwtName: string = '';
34+
let devfileName: string = '';
3535

3636
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
3737
kubernetesCommandLineToolsExecutor.loginToOcp();
3838
});
3939

40-
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
40+
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
4141
const randomPref: string = crypto.randomBytes(4).toString('hex');
4242
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
4343
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
4444
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
45-
dwtName = YAML.parse(devfileContent).metadata.name;
46-
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
47-
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
45+
devfileName = YAML.parse(devfileContent).metadata.name;
46+
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
47+
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
4848

4949
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
5050
editorContent: editorDevfileContent,
5151
devfileContent: devfileContent
5252
});
5353
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
5454
if (devfileContext.devWorkspace.metadata) {
55-
devfileContext.devWorkspace.metadata.name = uniqName;
55+
devfileContext.devWorkspace.metadata.name = uniqueName;
5656
}
5757
const devWorkspaceConfigurationYamlString: string =
5858
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
@@ -73,6 +73,6 @@ suite('PHP devfile API test', function (): void {
7373
});
7474

7575
suiteTeardown('Delete DevWorkspace', function (): void {
76-
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
76+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
7777
});
7878
});

tests/e2e/specs/api/PythonDevFileAPI.spec.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ suite('Python devfile API test', function (): void {
3232
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
3333
let devfileContext: DevfileContext;
3434
let devfileContent: string = '';
35-
let dwtName: string = '';
35+
let devfileName: string = '';
3636

3737
suiteSetup(`Prepare login ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, function (): void {
3838
kubernetesCommandLineToolsExecutor.loginToOcp();
3939
});
4040

41-
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
41+
test(`Create ${devfileID} workspace`, async function (): Promise<void> {
4242
const randomPref: string = crypto.randomBytes(4).toString('hex');
4343
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
4444
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
4545
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
46-
dwtName = YAML.parse(devfileContent).metadata.name;
47-
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
48-
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
46+
devfileName = YAML.parse(devfileContent).metadata.name;
47+
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
48+
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;
4949

5050
devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
5151
editorContent: editorDevfileContent,
5252
devfileContent: devfileContent
5353
});
5454
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
5555
if (devfileContext.devWorkspace.metadata) {
56-
devfileContext.devWorkspace.metadata.name = uniqName;
56+
devfileContext.devWorkspace.metadata.name = uniqueName;
5757
}
5858
const devWorkspaceConfigurationYamlString: string =
5959
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
@@ -74,6 +74,6 @@ suite('Python devfile API test', function (): void {
7474
});
7575

7676
suiteTeardown('Delete DevWorkspace', function (): void {
77-
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
77+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
7878
});
7979
});

0 commit comments

Comments
 (0)