Skip to content

Commit

Permalink
FI-765 fix: writes HTML report after exit signals to `dockerEntrypoin…
Browse files Browse the repository at this point in the history
…t.sh`
  • Loading branch information
uid11 committed Mar 6, 2024
1 parent a62f161 commit cf47ec3
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions autotests/bin/runDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ fi
onExit() {
CONTAINER_ID=$(docker ps --filter "label=$CONTAINER_LABEL" --format "{{.ID}}")

sleep 4

if [[ -z $CONTAINER_ID ]]
then
echo "Docker container from image $E2ED_DOCKER_IMAGE:$VERSION already stopped"
Expand Down
3 changes: 2 additions & 1 deletion bin/dockerEntrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ onExit() {
if [[ $PID ]] && ps -p $PID > /dev/null
then
echo "$PID is running"
kill $PID
kill -USR1 $PID
sleep 4
fi

restoreE2edPackage;
Expand Down
2 changes: 1 addition & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare module 'bin-v8-flags-filter' {
}>;

/**
* Filters out nodejs cli options and runs node module on cliPath.
* Filters out `nodejs` cli options and runs node module on `cliPath`.
*/
const v8FlagsFilter: (cliPath: string, options: Options) => void;

Expand Down
6 changes: 4 additions & 2 deletions src/utils/end/setProcessEndHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {generalLog} from '../generalLog';
import {endE2ed} from './endE2ed';

/**
* nodejs e2ed process end hanlder.
* `nodejs` e2ed process end hanlder.
* @internal
*/
const endHandler = (signal: NodeJS.Signals): void => {
Expand All @@ -15,10 +15,12 @@ const endHandler = (signal: NodeJS.Signals): void => {
};

/**
* Set nodejs e2ed process end hanlders (SIGINT, SIGTERM).
* Set `nodejs` e2ed process end hanlders (`SIGHUP`, `SIGINT`, `SIGTERM`).
* @internal
*/
export const setProcessEndHandlers = (): void => {
process.on('SIGHUP', endHandler);
process.on('SIGINT', endHandler);
process.on('SIGTERM', endHandler);
process.on('SIGUSR1', endHandler);
};
2 changes: 1 addition & 1 deletion src/utils/error/E2edError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class E2edError extends Error {
}

/**
* Custom presentation of error for nodejs `inspect`.
* Custom presentation of error for `nodejs` `inspect`.
*/
[inspect.custom](): string {
return this.toString();
Expand Down
8 changes: 8 additions & 0 deletions src/utils/events/registerEndE2edRunEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import {runAfterPackFunctions} from './runAfterPackFunctions';

import type {ReportData} from '../../types/internal';

let isEndAlreadyCalled = false;

/**
* Registers end e2ed run event (for report) after closing of all tests.
* @internal
*/
export const registerEndE2edRunEvent = async (): Promise<void> => {
if (isEndAlreadyCalled) {
return;
}

isEndAlreadyCalled = true;

generalLog('Starting to close e2ed...');

let reportData: ReportData | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/report/writeHtmlReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {renderReportToHtml} from './render';
import type {FilePathFromRoot, ReportData, UtcTimeInMs} from '../../types/internal';

/**
* Writes HTML report (report.html file) with test runs results.
* Writes HTML report (`report.html` file) with test runs results.
* @internal
*/
export const writeHtmlReport = async (reportData: ReportData): Promise<void> => {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/retry/runRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const runRetry = (runRetryOptions: RunRetryOptions): Promise<void> =>
setTestsSubprocess(newTestsSubprocess);

newTestsSubprocess.on('error', reject);
newTestsSubprocess.on('exit', (exitCode) => {

newTestsSubprocess.on('exit', (exitCode): void => {
const error = new E2edError(
`Tests subprocess with label "${runLabel}" exit with non-zero exit code ${String(
exitCode,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/valueToString/wrapStringForLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function toMultipleString(this: StringForLogs): string {

/**
* If the text consists of several lines, replaces the text with an object
* with a more beautiful presentation through nodejs `inspect`.
* with a more beautiful presentation through `nodejs` `inspect`.
* @internal
*/
export const wrapStringForLogs = (text: string, options?: Options): StringForLogs | string => {
Expand Down

0 comments on commit cf47ec3

Please sign in to comment.