Skip to content

Commit

Permalink
fix quarkus commands
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-ndp committed Jan 2, 2025
1 parent 90e9589 commit 8fc0998
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
13 changes: 8 additions & 5 deletions tests/e2e/specs/api/QuarkusDevFileAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -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 {
Expand Down
18 changes: 14 additions & 4 deletions tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium test

This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
);
} else {
return this.shellExecutor.executeCommand(
`${this.kubernetesCommandLineTool} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`

Check warning

Code scanning / CodeQL

Unsafe shell command constructed from library input Medium test

This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
This string concatenation which depends on
library input
is later used in a
shell command
.
);
}
}

applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
Expand Down

0 comments on commit 8fc0998

Please sign in to comment.