Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct exit from docker after exit signals #68

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ rules:
- {blankLine: always, prev: '*', next: return}
- {blankLine: always, prev: throw, next: '*'}
- {blankLine: always, prev: '*', next: throw}
prefer-destructuring: off
simple-import-sort/exports: error
simple-import-sort/imports:
- error
Expand Down Expand Up @@ -206,7 +207,13 @@ rules:
'@typescript-eslint/no-unused-expressions': error
'@typescript-eslint/no-useless-empty-export': error
'@typescript-eslint/parameter-properties': error
'@typescript-eslint/prefer-destructuring':
[error, {VariableDeclarator: {array: false, object: true}}]
'@typescript-eslint/prefer-enum-initializers': error
'@typescript-eslint/prefer-find': error
'@typescript-eslint/prefer-for-of': error
'@typescript-eslint/quotes': [error, single, {avoidEscape: true}]
'@typescript-eslint/prefer-function-type': error
'@typescript-eslint/sort-type-constituents': [error, {checkIntersections: false}]
settings:
import/extensions: [.ts]
Expand Down
2 changes: 2 additions & 0 deletions autotests/bin/runDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ onExit() {
then
echo "Docker container from image $E2ED_DOCKER_IMAGE:$VERSION already stopped"
else
sleep 18

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

sleep 16
fi

restoreE2edPackage;
Expand Down
112 changes: 56 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"testcafe-without-typecheck": "3.5.0-rc.2"
},
"devDependencies": {
"@types/node": "20.11.21",
"@typescript-eslint/eslint-plugin": "7.1.0",
"@typescript-eslint/parser": "7.1.0",
"@types/node": "20.11.25",
"@typescript-eslint/eslint-plugin": "7.1.1",
"@typescript-eslint/parser": "7.1.1",
"assert-modules-support-case-insensitive-fs": "1.0.1",
"assert-package-lock-is-consistent": "1.0.0",
"devtools-protocol": "0.0.1266247",
"devtools-protocol": "0.0.1269399",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
Expand All @@ -47,7 +47,7 @@
"husky": "9.0.11",
"prettier": "3.2.5",
"testcafe": "3.5.0",
"typescript": "5.3.3"
"typescript": "5.4.2"
},
"peerDependencies": {
"@types/node": ">=16.11.1",
Expand Down
18 changes: 9 additions & 9 deletions src/constants/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export const enum LogEventStatus {
* Type of `LogEvent`.
*/
export const enum LogEventType {
Action,
Assert,
Entity,
Util,
InternalAction,
InternalAssert,
InternalCore,
InternalUtil,
Unspecified,
Action = 1,
Assert = 2,
Entity = 3,
Util = 4,
InternalAction = 5,
InternalAssert = 6,
InternalCore = 7,
InternalUtil = 8,
Unspecified = 9,
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface NodeRequire {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
<ModuleExports = import('./utils').Any>(modulePath: string): ModuleExports;
}

Expand All @@ -21,7 +22,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
8 changes: 2 additions & 6 deletions src/types/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ type ReplaceObjectSelectors<Obj extends object> = Readonly<{
(...args: A2): ReplaceSelector<R2>;
(...args: A1): ReplaceSelector<R1>;
}
: Obj[Key] extends {
(...args: infer A1): infer R1;
}
? {
(...args: A1): ReplaceSelector<R1>;
}
: Obj[Key] extends (...args: infer A1) => infer R1
? (...args: A1) => ReplaceSelector<R1>
: Obj[Key];
}>;

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`, `SIGUSR1`).
* @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
Loading
Loading