From 8fc09983f9079a4b4b30906ab89b377eb4dc34eb Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Thu, 2 Jan 2025 18:02:55 +0200 Subject: [PATCH] fix quarkus commands --- tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts | 13 ++++++++----- .../KubernetesCommandLineToolsExecutor.ts | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts b/tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts index 3386de40027..cd5ccfac13c 100644 --- a/tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts +++ b/tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts @@ -72,7 +72,7 @@ suite('Quarkus devfile API test', function (): void { runCommandInBash = `cd ${workdir} && ` + runCommandInBash; } - const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName); + const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName, '5m'); expect(output.code).eqls(0); expect(output.stdout.trim()).contains('BUILD SUCCESS'); }); @@ -86,12 +86,15 @@ suite('Quarkus devfile API test', function (): void { let runCommandInBash: string = commandLine.replaceAll('$', '\\$'); // don't wipe out env. vars like "${PROJECTS_ROOT}" if (workdir !== undefined && workdir !== '') { - runCommandInBash = `cd ${workdir} && ` + runCommandInBash; + runCommandInBash = `cd ${workdir} && sh -c "(` + runCommandInBash + ' > server.log 2>&1 &) && exit"'; } - const output: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName); - expect(output.code).eqls(0); - expect(output.stdout.trim()).contains('Listening for transport dt_socket at address: 5005'); + const commandOutput: ShellString = containerTerminal.execInContainerCommand(runCommandInBash, containerName); + expect(commandOutput.code).eqls(0); + + const commandLog: ShellString = containerTerminal.execInContainerCommand(`cat ${workdir}/command.log`, containerName); + Logger.info(`Command log: ${commandLog.stdout}`); + expect(commandLog.stdout.trim()).contains('Listening on: http://0.0.0.0:8080'); }); suiteTeardown('Delete workspace', function (): void { diff --git a/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts b/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts index d27be4e2cd7..2aefe897f8a 100644 --- a/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts +++ b/tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts @@ -124,12 +124,22 @@ export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLin return this.waitDevWorkspace(); } - execInContainerCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString { + execInContainerCommand( + commandToExecute: string, + container: string = KubernetesCommandLineToolsExecutor.container, + requestTimeout?: string + ): ShellString { Logger.debug(`${this.kubernetesCommandLineTool}`); - return this.shellExecutor.executeCommand( - `${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'` - ); + if (requestTimeout) { + return this.shellExecutor.executeCommand( + `${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} --request-timeout=${requestTimeout} -- sh -c '${commandToExecute}'` + ); + } else { + return this.shellExecutor.executeCommand( + `${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'` + ); + } } applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {