Skip to content

Commit

Permalink
fix(e2e-tests): add --log-level flag for e2e tests (#703)
Browse files Browse the repository at this point in the history
* add --log-level flag for e2e tests

* update docs for scripts
  • Loading branch information
TarikGul committed Oct 11, 2021
1 parent 5861cb1 commit b9404ff
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
This script calls the local e2e-tests helper library in order to test the current branch or development environment against
a collection of different blocks, across different runtimes. It does this for Polkadot, Kusama, and Westend.

### Flags

`--chain`: This sets the specific chain to run the script against. Acceptable values are `['polkadot', 'westend', 'kusama']`. If no chain is selected it will default to run the e2e-tests against all chains.

`--log-level`: Acceptable values are `['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly']`. This will enable logging in Sidecar.



## Script `runYarnPack.ts`

Expand Down
14 changes: 13 additions & 1 deletion scripts/runChainTests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { ArgumentParser, Namespace } from 'argparse';

import { config, defaultSasBuildOpts } from './config';
import { killAll, launchProcess, setWsUrl } from './sidecarScriptApi';
import {
killAll,
launchProcess,
setLogLevel,
setWsUrl,
} from './sidecarScriptApi';
import { ProcsType, StatusCode } from './types';

// Stores all the processes
Expand Down Expand Up @@ -57,6 +62,10 @@ const checkTests = (...args: boolean[]) => {
const main = async (args: Namespace): Promise<void> => {
const { Failed } = StatusCode;

if (args.log_level) {
setLogLevel(args.log_level);
}

// Build sidecar
console.log('Building Sidecar...');
const sidecarBuild = await launchProcess('yarn', procs, defaultSasBuildOpts);
Expand Down Expand Up @@ -96,6 +105,9 @@ const parser = new ArgumentParser();
parser.add_argument('--chain', {
choices: ['polkadot', 'kusama', 'westend'],
});
parser.add_argument('--log-level', {
choices: ['error', 'warn', 'info', 'http', 'verbose', 'debug', 'silly'],
});

const args = parser.parse_args() as Namespace;

Expand Down
9 changes: 9 additions & 0 deletions scripts/sidecarScriptApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export const setWsUrl = (url: string): void => {
process.env.SAS_SUBSTRATE_WS_URL = url;
};

/**
* Sets the log level for sidecar
*
* @param level log-levels -> error, warn, info, http, verbose, debug, silly
*/
export const setLogLevel = (level: string): void => {
process.env.SAS_LOG_LEVEL = level;
};

/**
* Kill all processes
*
Expand Down

0 comments on commit b9404ff

Please sign in to comment.