Skip to content

Commit

Permalink
Add QuarkusDevFileAPI and LombokDevFileAPI tests; renew Documentation…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
dmytro-ndp authored Jan 5, 2025
1 parent dfc2d2b commit 4c060ae
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 52 deletions.
12 changes: 6 additions & 6 deletions tests/e2e/specs/api/CppDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suite('Cpp devfile API test', function (): void {
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let dwtName: string = '';
let devfileName: string = '';
const workDirPath: string = 'c-plus-plus/strings';
const fileName: string = 'knuth_morris_pratt.cpp';
const tasksJsonPath: string = 'c-plus-plus/.vscode/tasks.json';
Expand All @@ -46,17 +46,17 @@ suite('Cpp devfile API test', function (): void {
kubernetesCommandLineToolsExecutor.namespace = API_TEST_CONSTANTS.TS_API_TEST_NAMESPACE || 'admin-devspaces';
devfileContent = devfilesRegistryHelper.getDevfileContent(devfileID);
const editorDevfileContent: string = devfilesRegistryHelper.obtainCheDevFileEditorFromCheConfigMap('editors-definitions');
dwtName = YAML.parse(devfileContent).metadata.name;
const uniqName: string = YAML.parse(devfileContent).metadata.name + randomPref;
kubernetesCommandLineToolsExecutor.workspaceName = uniqName;
devfileName = YAML.parse(devfileContent).metadata.name;
const uniqueName: string = YAML.parse(devfileContent).metadata.name + randomPref;
kubernetesCommandLineToolsExecutor.workspaceName = uniqueName;

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqName;
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
Expand Down Expand Up @@ -92,6 +92,6 @@ suite('Cpp devfile API test', function (): void {
});

suiteTeardown('Delete workspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
12 changes: 6 additions & 6 deletions tests/e2e/specs/api/DotnetDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite('Dotnet devfile API test', function (): void {
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let dwtName: string = '';
let devfileName: string = '';

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

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqName;
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
Expand Down Expand Up @@ -94,6 +94,6 @@ suite('Dotnet devfile API test', function (): void {
});

suiteTeardown('Delete DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
14 changes: 7 additions & 7 deletions tests/e2e/specs/api/GoDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ suite('Go devfile API test', function (): void {
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let dwtName: string = '';
let devfileName: string = '';

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

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

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqName;
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
Expand Down Expand Up @@ -87,6 +87,6 @@ suite('Go devfile API test', function (): void {
});

suiteTeardown('Delete DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
94 changes: 94 additions & 0 deletions tests/e2e/specs/api/LombokDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/** *******************************************************************
* copyright (c) 2024 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
import { e2eContainer } from '../../configs/inversify.config';
import { CLASSES } from '../../configs/inversify.types';
import { DevfilesHelper } from '../../utils/DevfilesHelper';
import { ContainerTerminal, KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
import { ShellString } from 'shelljs';
import { expect } from 'chai';
import { API_TEST_CONSTANTS } from '../../constants/API_TEST_CONSTANTS';
import YAML from 'yaml';
import { Logger } from '../../utils/Logger';
import crypto from 'crypto';

suite('Lombok devfile API test', function (): void {
const devfilesRegistryHelper: DevfilesHelper = e2eContainer.get(CLASSES.DevfilesRegistryHelper);
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
CLASSES.KubernetesCommandLineToolsExecutor
);
const devfileID: string = 'java-lombok';
const containerTerminal: ContainerTerminal = e2eContainer.get(CLASSES.ContainerTerminal);
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let devfileName: string = '';

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

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

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(devWorkspaceConfigurationYamlString);
expect(output.stdout).contains('condition met');
});

test('Check build application', function (): void {
const containerName: string = YAML.parse(devfileContent).commands[0].exec.component;

if (BASE_TEST_CONSTANTS.IS_CLUSTER_DISCONNECTED()) {
Logger.info('Test cluster is disconnected. Init Java Truststore...');
const initJavaTruststoreCommand: string =
'cp /home/user/init-java-truststore.sh /tmp && chmod +x /tmp/init-java-truststore.sh && /tmp/init-java-truststore.sh';
const output: ShellString = containerTerminal.execInContainerCommand(initJavaTruststoreCommand, containerName);
expect(output.code).eqls(0);
}

const workdir: string = YAML.parse(devfileContent).commands[0].exec.workingDir;
const commandLine: string = YAML.parse(devfileContent).commands[0].exec.commandLine;
Logger.info(`workdir from exec section of DevWorkspace file: ${workdir}`);
Logger.info(`commandLine from exec section of DevWorkspace file: ${commandLine}`);

let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}"
if (workdir !== undefined && workdir !== '') {
runCommandInBash = `cd ${workdir} && ` + runCommandInBash;
}

const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName);
expect(output.code).eqls(0);

const outputText: string = output.stdout.trim();
expect(outputText).contains('BUILD SUCCESS');
});

suiteTeardown('Delete workspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
14 changes: 7 additions & 7 deletions tests/e2e/specs/api/PhpDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ suite('PHP devfile API test', function (): void {
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let dwtName: string = '';
let devfileName: string = '';

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

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

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqName;
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
Expand All @@ -73,6 +73,6 @@ suite('PHP devfile API test', function (): void {
});

suiteTeardown('Delete DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
14 changes: 7 additions & 7 deletions tests/e2e/specs/api/PythonDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ suite('Python devfile API test', function (): void {
let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
let devfileContext: DevfileContext;
let devfileContent: string = '';
let dwtName: string = '';
let devfileName: string = '';

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

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

devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
editorContent: editorDevfileContent,
devfileContent: devfileContent
});
devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
if (devfileContext.devWorkspace.metadata) {
devfileContext.devWorkspace.metadata.name = uniqName;
devfileContext.devWorkspace.metadata.name = uniqueName;
}
const devWorkspaceConfigurationYamlString: string =
devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
Expand All @@ -74,6 +74,6 @@ suite('Python devfile API test', function (): void {
});

suiteTeardown('Delete DevWorkspace', function (): void {
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(dwtName);
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(devfileName);
});
});
Loading

0 comments on commit 4c060ae

Please sign in to comment.