Skip to content

Commit e14424f

Browse files
authored
fix: cdk-assets@v2 test fails (#54)
There are two problems with this test: - In Verdaccio, we are only publishing one version of the `cdk-assets` package, so we can't be testing 2 different major versions at the same time. - Since we will never update the v2 version anymore, its test is unnecessary. In this change, we will only test a single `cdk-assets` version -- the "latest" one.
1 parent 0f4da11 commit e14424f

File tree

1 file changed

+63
-67
lines changed

1 file changed

+63
-67
lines changed

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cdk-assets/smoketest.integtest.ts

+63-67
Original file line numberDiff line numberDiff line change
@@ -7,80 +7,76 @@ import { integTest, withDefaultFixture } from '../../../lib';
77

88
jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime
99

10-
const MAJOR_VERSIONS = ['2', 'v3-latest'];
10+
integTest(
11+
`cdk-assets smoke test`,
12+
withDefaultFixture(async (fixture) => {
13+
await fixture.shell(['npm', 'init', '-y']);
14+
await fixture.shell(['npm', 'install', `cdk-assets@latest`]);
1115

12-
MAJOR_VERSIONS.forEach(MV => {
13-
integTest(
14-
`cdk-assets@${MV} smoke test`,
15-
withDefaultFixture(async (fixture) => {
16-
await fixture.shell(['npm', 'init', '-y']);
17-
await fixture.shell(['npm', 'install', `cdk-assets@${MV}`]);
16+
const account = await fixture.aws.account();
17+
const region = fixture.aws.region;
18+
const bucketName = `cdk-hnb659fds-assets-${account}-${region}`;
19+
const repositoryName = `cdk-hnb659fds-container-assets-${account}-${region}`;
1820

19-
const account = await fixture.aws.account();
20-
const region = fixture.aws.region;
21-
const bucketName = `cdk-hnb659fds-assets-${account}-${region}`;
22-
const repositoryName = `cdk-hnb659fds-container-assets-${account}-${region}`;
21+
const imageDir = 'imagedir';
22+
await fs.mkdir(path.join(fixture.integTestDir, imageDir), { recursive: true });
2323

24-
const imageDir = 'imagedir';
25-
await fs.mkdir(path.join(fixture.integTestDir, imageDir), { recursive: true });
24+
// Write an asset file and a data file for the Docker image
25+
const assetFile = 'testfile.txt';
26+
for (const toCreate of [assetFile, `${imageDir}/datafile.txt`]) {
27+
await fs.writeFile(path.join(fixture.integTestDir, toCreate), 'some asset file');
28+
}
2629

27-
// Write an asset file and a data file for the Docker image
28-
const assetFile = 'testfile.txt';
29-
for (const toCreate of [assetFile, `${imageDir}/datafile.txt`]) {
30-
await fs.writeFile(path.join(fixture.integTestDir, toCreate), 'some asset file');
31-
}
32-
33-
// Write a Dockerfile for the image build with a data file in it
34-
await fs.writeFile(path.join(fixture.integTestDir, imageDir, 'Dockerfile'), [
35-
'FROM scratch',
36-
'ADD datafile.txt datafile.txt',
37-
].join('\n'));
30+
// Write a Dockerfile for the image build with a data file in it
31+
await fs.writeFile(path.join(fixture.integTestDir, imageDir, 'Dockerfile'), [
32+
'FROM scratch',
33+
'ADD datafile.txt datafile.txt',
34+
].join('\n'));
3835

39-
// Write an asset JSON file to publish to the bootstrapped environment
40-
const assetsJson = {
41-
version: "38.0.1",
42-
files: {
43-
testfile: {
44-
source: {
45-
path: assetFile,
46-
packaging: 'file',
47-
},
48-
destinations: {
49-
current: {
50-
region,
51-
assumeRoleArn: `arn:\${AWS::Partition}:iam::${account}:role/cdk-hnb659fds-file-publishing-role-${account}-${region}`,
52-
bucketName,
53-
objectKey: `test-file-${Date.now()}.json`,
54-
}
36+
// Write an asset JSON file to publish to the bootstrapped environment
37+
const assetsJson = {
38+
version: "38.0.1",
39+
files: {
40+
testfile: {
41+
source: {
42+
path: assetFile,
43+
packaging: 'file',
44+
},
45+
destinations: {
46+
current: {
47+
region,
48+
assumeRoleArn: `arn:\${AWS::Partition}:iam::${account}:role/cdk-hnb659fds-file-publishing-role-${account}-${region}`,
49+
bucketName,
50+
objectKey: `test-file-${Date.now()}.json`,
5551
}
5652
}
57-
},
58-
dockerImages: {
59-
testimage: {
60-
source: {
61-
directory: imageDir,
62-
},
63-
destinations: {
64-
current: {
65-
region,
66-
assumeRoleArn: `arn:\${AWS::Partition}:iam::${account}:role/cdk-hnb659fds-image-publishing-role-${account}-${region}`,
67-
repositoryName,
68-
imageTag: `test-image`, // Not fresh on every run because we'll run out of tags too easily
69-
},
53+
}
54+
},
55+
dockerImages: {
56+
testimage: {
57+
source: {
58+
directory: imageDir,
59+
},
60+
destinations: {
61+
current: {
62+
region,
63+
assumeRoleArn: `arn:\${AWS::Partition}:iam::${account}:role/cdk-hnb659fds-image-publishing-role-${account}-${region}`,
64+
repositoryName,
65+
imageTag: `test-image`, // Not fresh on every run because we'll run out of tags too easily
7066
},
7167
},
72-
}
73-
};
74-
75-
await fs.writeFile(path.join(fixture.integTestDir, 'assets.json'), JSON.stringify(assetsJson, undefined, 2));
76-
await fixture.shell(['npx', 'cdk-assets', '--path', 'assets.json', '--verbose', 'publish'], {
77-
modEnv: {
78-
...fixture.cdkShellEnv(),
79-
// This is necessary for cdk-assets v2, if the credentials are supplied via
80-
// config file (which they are on the CodeBuild canaries).
81-
AWS_SDK_LOAD_CONFIG: '1',
8268
},
83-
});
84-
}),
85-
);
86-
});
69+
}
70+
};
71+
72+
await fs.writeFile(path.join(fixture.integTestDir, 'assets.json'), JSON.stringify(assetsJson, undefined, 2));
73+
await fixture.shell(['npx', 'cdk-assets', '--path', 'assets.json', '--verbose', 'publish'], {
74+
modEnv: {
75+
...fixture.cdkShellEnv(),
76+
// This is necessary for cdk-assets v2, if the credentials are supplied via
77+
// config file (which they are on the CodeBuild canaries).
78+
AWS_SDK_LOAD_CONFIG: '1',
79+
},
80+
});
81+
}),
82+
);

0 commit comments

Comments
 (0)