Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.

Commit 3c46faa

Browse files
flochazFlorian Chazal
and
Florian Chazal
authored
fix: db-shema-manager e2e test fix working around stack deletion issue (#336)
* fix db schema manager e2e tests Co-authored-by: Florian Chazal <[email protected]>
1 parent 9312675 commit 3c46faa

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

core/.projen/tasks.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/.projenrc.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,20 @@ const gradleBuildTask = project.addTask('gradle-build', {
191191
description: './gradlew shadowJar all folders in lib that has requirements.txt',
192192
});
193193

194-
for (const dirPath of findAllGradleLambdaDir('src')) {
194+
for (const gradlePath of findAllGradleLambdaDir('src')) {
195195
console.log('loop over gradle dir');
196-
// Assume that all folders with 'requirements.txt' have been copied to lib
197-
// by the task 'copy-resources'
198-
const dirPathInLib = dirname(dirPath.replace('src', 'lib'));
199-
const gradleCmd = `cd ${dirPathInLib} && ./gradlew shadowJar && cp build/libs/*.jar ./ 2> /dev/null`;
196+
const dirPath = dirname(gradlePath);
197+
const gradleCmd = `cd ${dirPath} && ./gradlew shadowJar && cp build/libs/*.jar ./ 2> /dev/null`;
200198

201199
gradleBuildTask.exec(gradleCmd);
202200
}
203201

204202
/**
205203
* Run `copy-resources` and `pip-install` as part of compile
206204
*/
205+
project.compileTask.exec('npx projen gradle-build');
207206
project.compileTask.exec('npx projen copy-resources');
208207
project.compileTask.exec('npx projen pip-install');
209-
project.compileTask.exec('npx projen gradle-build');
210208

211209
/**
212210
* Find all directory that has a Python package.

core/src/db-schema-manager/flyway-runner.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ export class FlywayRunner extends cdk.Construct {
170170
assetHash: (migrationFilesDeployment.node.findChild('Asset1') as Asset).assetHash,
171171
},
172172
});
173-
173+
for(const subnet of props.vpc.privateSubnets) {
174+
flywayLambda.node.addDependency(subnet);
175+
}
174176
flywayCustomResourceProvider.node.addDependency(migrationFilesDeployment);
175177
}
176178
}

core/src/db-schema-manager/resources/flyway-lambda/.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ gradle-app.setting
99
!gradle-wrapper.jar
1010

1111
# Cache of project
12-
.gradletasknamecache
12+
.gradletasknamecache
13+
14+
15+
flyway-all.jar

core/test/e2e/db-schema-manager.test.ts

+20-9
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ const cluster = new redshift.Cluster(stack, 'Redshift', {
3232
defaultDatabaseName: dbName,
3333
});
3434

35-
const tokenizedValue = new cdk.CfnOutput(stack, "tokenizedValue", {
36-
value: "second_table"
37-
})
35+
const tokenizedValue = new cdk.CfnOutput(stack, 'tokenizedValue', {
36+
value: 'second_table',
37+
});
3838

3939
const runner = new FlywayRunner(stack, 'testMigration', {
4040
migrationScriptsFolderAbsolutePath: path.join(__dirname, './resources/sql'),
4141
cluster: cluster,
4242
vpc: vpc,
4343
databaseName: dbName,
44-
replaceDictionary: {TABLE_NAME: tokenizedValue.value},
44+
replaceDictionary: { TABLE_NAME: tokenizedValue.value },
4545
});
4646

4747
new cdk.CfnOutput(stack, 'schemaVersion', {
@@ -50,7 +50,7 @@ new cdk.CfnOutput(stack, 'schemaVersion', {
5050
});
5151

5252
describe('deploy succeed', () => {
53-
it.skip('can be deploy succcessfully', async () => {
53+
it('can be deploy succcessfully', async () => {
5454
// GIVEN
5555
const stackArtifact = integTestApp.synth().getStackByName(stack.stackName);
5656

@@ -77,7 +77,18 @@ afterAll(async () => {
7777
});
7878
const cloudFormation = new CloudFormationDeployments({ sdkProvider });
7979

80-
await cloudFormation.destroyStack({
81-
stack: stackArtifact,
82-
});
83-
});
80+
let retryCount = 1;
81+
while (retryCount >= 0) {
82+
try {
83+
await cloudFormation.destroyStack({
84+
stack: stackArtifact,
85+
});
86+
} catch (e) {
87+
console.error(`Fail to delete stack retrying`);
88+
if(retryCount == 0) {
89+
throw e;
90+
}
91+
}
92+
retryCount--;
93+
}
94+
}, 9000000);

0 commit comments

Comments
 (0)