Skip to content

Commit

Permalink
feat(integ-runner): additional debug output using verbosity level
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Aug 4, 2022
1 parent e9233fa commit 20a04da
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/integ-runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ to be a self contained CDK app. The runner will execute the following for each f
Destroy stacks after deploy (use `--no-clean` for debugging)
- `--verbose` (default=`false`)
verbose logging, including integration test metrics
repeat for additional output from the runners
- `--parallel-regions` (default=`us-east-1`,`us-east-2`, `us-west-2`)
List of regions to run tests in. If this is provided then all tests will
be run in parallel across these regions
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/integ-runner/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function main() {
.usage('Usage: integ-runner [TEST...]')
.option('list', { type: 'boolean', default: false, desc: 'List tests instead of running them' })
.option('clean', { type: 'boolean', default: true, desc: 'Skips stack clean up after test is completed (use --no-clean to negate)' })
.option('verbose', { type: 'boolean', default: false, alias: 'v', desc: 'Verbose logs and metrics on integration tests durations' })
.option('verbose', { type: 'boolean', default: false, alias: 'v', count: true, desc: 'Verbose logs and metrics on integration tests durations. Repeat for additional output from the runners' })
.option('dry-run', { type: 'boolean', default: false, desc: 'do not actually deploy the stack. just update the snapshot (not recommended!)' })
.option('update-on-failed', { type: 'boolean', default: false, desc: 'rerun integration tests and update snapshots for failed tests.' })
.option('force', { type: 'boolean', default: false, desc: 'Rerun all integration tests even if tests are passing' })
Expand Down Expand Up @@ -75,7 +75,7 @@ async function main() {
// failed snapshot tests
failedSnapshots = await runSnapshotTests(pool, testsFromArgs, {
retain: argv['inspect-failures'],
verbose: argv.verbose,
verbose: Boolean(argv.verbose),
});
for (const failure of failedSnapshots) {
destructiveChanges.push(...failure.destructiveChanges ?? []);
Expand All @@ -97,7 +97,7 @@ async function main() {
profiles,
clean: argv.clean,
dryRun: argv['dry-run'],
verbose: argv.verbose,
verbosity: argv.verbose,
updateWorkflow: !argv['disable-update-workflow'],
});
testsSucceeded = success;
Expand All @@ -107,7 +107,7 @@ async function main() {
logger.warning('Not cleaning up stacks since "--no-clean" was used');
}

if (argv.verbose) {
if (Boolean(argv.verbose)) {
printMetrics(metrics);
}

Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/integ-runner/lib/runner/integ-test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export interface RunOptions {
* @default true
*/
readonly updateWorkflow?: boolean;

/**
* The level of verbosity for logging.
*
* Maximum is 2.
*
* @default 0
*/
readonly verbosity?: number;
}

/**
Expand Down Expand Up @@ -148,13 +157,15 @@ export class IntegTestRunner extends IntegRunner {
const clean = options.clean ?? true;
const updateWorkflowEnabled = (options.updateWorkflow ?? true)
&& (actualTestCase.stackUpdateWorkflow ?? true);
const verbosity = options.verbosity ?? 0;
try {
if (!options.dryRun && (actualTestCase.cdkCommandOptions?.deploy?.enabled ?? true)) {
assertionResults = this.deploy(
{
...this.defaultArgs,
profile: this.profile,
requireApproval: RequireApproval.NEVER,
verbose: verbosity >= 2,
},
updateWorkflowEnabled,
options.testCaseName,
Expand All @@ -168,6 +179,7 @@ export class IntegTestRunner extends IntegRunner {
execCmd: this.cdkApp.split(' '),
env,
output: path.relative(this.directory, this.cdkOutDir),
verbose: verbosity >= 2,
});
}
// only create the snapshot if there are no assertion assertion results
Expand All @@ -189,6 +201,7 @@ export class IntegTestRunner extends IntegRunner {
output: path.relative(this.directory, this.cdkOutDir),
...actualTestCase.cdkCommandOptions?.destroy?.args,
context: this.getContext(actualTestCase.cdkCommandOptions?.destroy?.args?.context),
verbose: verbosity >= 2,
});
}
}
Expand Down
10 changes: 10 additions & 0 deletions packages/@aws-cdk/integ-runner/lib/workers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,19 @@ export interface IntegTestOptions {
* Whether to enable verbose logging
*
* @default false
* @deprecated - use `verbosity` instead
*/
readonly verbose?: boolean;

/**
* The level of verbosity for logging.
*
* Maximum is 2.
*
* @default 0
*/
readonly verbosity?: number;

/**
* If this is set to true then the stack update workflow will be disabled
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function integTestWorker(request: IntegTestBatchRequest): IntegTestWorker
clean: request.clean,
dryRun: request.dryRun,
updateWorkflow: request.updateWorkflow,
verbosity: request.verbosity,
});
if (results) {
failures.push(testInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function runIntegrationTestsInParallel(
tests: [test],
clean: options.clean,
dryRun: options.dryRun,
verbose: options.verbose,
verbosity: options.verbosity,
updateWorkflow: options.updateWorkflow,
}], {
on: printResults,
Expand Down
10 changes: 9 additions & 1 deletion packages/cdk-cli-wrapper/lib/cdk-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ export interface SynthFastOptions {
readonly context?: Record<string, string>,

/**
* Additiional environment variables to set in the
* Additional environment variables to set in the
* execution environment
*
* @default - no additional env
*/
readonly env?: { [name: string]: string }

/**
* show debug logs
*
* @default false
*/
readonly verbose?: boolean;
}

/**
Expand Down Expand Up @@ -206,6 +213,7 @@ export class CdkCliWrapper implements ICdk {
public synthFast(options: SynthFastOptions): void {
exec(options.execCmd, {
cwd: this.directory,
verbose: options.verbose,
env: {
CDK_CONTEXT_JSON: JSON.stringify(options.context),
CDK_OUTDIR: options.output,
Expand Down

0 comments on commit 20a04da

Please sign in to comment.