|
| 1 | +import * as path from 'path'; |
| 2 | +import * as fs from 'fs-extra'; |
| 3 | +import { integTest, withDefaultFixture } from '../../../lib'; |
| 4 | + |
| 5 | +jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime |
| 6 | + |
| 7 | +integTest( |
| 8 | + 'cdk synth with telemetry data', |
| 9 | + withDefaultFixture(async (fixture) => { |
| 10 | + const telemetryFile = path.join(fixture.integTestDir, `telemetry-${Date.now()}.json`); |
| 11 | + await fixture.cdk(['synth', fixture.fullStackName('test-1'), '--unstable=telemetry', `--telemetry-file=${telemetryFile}`]); |
| 12 | + const json = fs.readJSONSync(telemetryFile); |
| 13 | + expect(json).toEqual([ |
| 14 | + expect.objectContaining({ |
| 15 | + event: expect.objectContaining({ |
| 16 | + command: expect.objectContaining({ |
| 17 | + path: ['synth', '$STACKS_1'], |
| 18 | + parameters: { |
| 19 | + verbose: 1, |
| 20 | + unstable: '<redacted>', |
| 21 | + ['telemetry-file']: '<redacted>', |
| 22 | + lookups: true, |
| 23 | + ['ignore-errors']: false, |
| 24 | + json: false, |
| 25 | + debug: false, |
| 26 | + staging: true, |
| 27 | + notices: true, |
| 28 | + ['no-color']: false, |
| 29 | + ci: expect.anything(), // changes based on where this is called |
| 30 | + validation: true, |
| 31 | + quiet: false, |
| 32 | + }, |
| 33 | + config: { |
| 34 | + context: {}, |
| 35 | + }, |
| 36 | + }), |
| 37 | + state: 'SUCCEEDED', |
| 38 | + eventType: 'SYNTH', |
| 39 | + }), |
| 40 | + // some of these can change; but we assert that some value is recorded |
| 41 | + identifiers: expect.objectContaining({ |
| 42 | + installationId: expect.anything(), |
| 43 | + sessionId: expect.anything(), |
| 44 | + telemetryVersion: '1.0', |
| 45 | + cdkCliVersion: expect.anything(), |
| 46 | + cdkLibraryVersion: fixture.library.requestedVersion(), |
| 47 | + region: expect.anything(), |
| 48 | + eventId: expect.stringContaining(':1'), |
| 49 | + timestamp: expect.anything(), |
| 50 | + }), |
| 51 | + environment: { |
| 52 | + ci: expect.anything(), |
| 53 | + os: { |
| 54 | + platform: expect.anything(), |
| 55 | + release: expect.anything(), |
| 56 | + }, |
| 57 | + nodeVersion: expect.anything(), |
| 58 | + }, |
| 59 | + project: {}, |
| 60 | + duration: { |
| 61 | + total: expect.anything(), |
| 62 | + }, |
| 63 | + }), |
| 64 | + expect.objectContaining({ |
| 65 | + event: expect.objectContaining({ |
| 66 | + command: expect.objectContaining({ |
| 67 | + path: ['synth', '$STACKS_1'], |
| 68 | + parameters: { |
| 69 | + verbose: 1, |
| 70 | + unstable: '<redacted>', |
| 71 | + ['telemetry-file']: '<redacted>', |
| 72 | + lookups: true, |
| 73 | + ['ignore-errors']: false, |
| 74 | + json: false, |
| 75 | + debug: false, |
| 76 | + staging: true, |
| 77 | + notices: true, |
| 78 | + ['no-color']: false, |
| 79 | + ci: expect.anything(), // changes based on where this is called |
| 80 | + validation: true, |
| 81 | + quiet: false, |
| 82 | + }, |
| 83 | + config: { |
| 84 | + context: {}, |
| 85 | + }, |
| 86 | + }), |
| 87 | + state: 'SUCCEEDED', |
| 88 | + eventType: 'INVOKE', |
| 89 | + }), |
| 90 | + identifiers: expect.objectContaining({ |
| 91 | + installationId: expect.anything(), |
| 92 | + sessionId: expect.anything(), |
| 93 | + telemetryVersion: '1.0', |
| 94 | + cdkCliVersion: expect.anything(), |
| 95 | + cdkLibraryVersion: fixture.library.requestedVersion(), |
| 96 | + region: expect.anything(), |
| 97 | + eventId: expect.stringContaining(':2'), |
| 98 | + timestamp: expect.anything(), |
| 99 | + }), |
| 100 | + environment: { |
| 101 | + ci: expect.anything(), |
| 102 | + os: { |
| 103 | + platform: expect.anything(), |
| 104 | + release: expect.anything(), |
| 105 | + }, |
| 106 | + nodeVersion: expect.anything(), |
| 107 | + }, |
| 108 | + project: {}, |
| 109 | + duration: { |
| 110 | + total: expect.anything(), |
| 111 | + }, |
| 112 | + }), |
| 113 | + ]); |
| 114 | + fs.unlinkSync(telemetryFile); |
| 115 | + }), |
| 116 | +); |
| 117 | + |
0 commit comments