Skip to content

Commit b9575eb

Browse files
authored
avoid client config generation race condition (#2184)
* avoid client config generation race condition * remove rejectCleanupSandbox action * add changeset * try this * update deployment test template
1 parent 255ca18 commit b9575eb

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

.changeset/tall-singers-rest.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/integration-tests/src/process-controller/predicated_action_macros.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,6 @@ export const confirmDeleteSandbox = () =>
4040
)
4141
.sendYes();
4242

43-
/**
44-
* Reusable predicated action: Wait for sandbox to prompt on quitting to delete all the resource and respond with no
45-
*/
46-
export const rejectCleanupSandbox = () =>
47-
new PredicatedActionBuilder()
48-
.waitForLineIncludes(
49-
'Would you like to delete all the resources in your sandbox environment'
50-
)
51-
.sendNo();
52-
5343
/**
5444
* Reusable predicated action: Wait for sandbox to become idle,
5545
* then perform the specified file replacements in the backend code which will trigger sandbox again
@@ -59,9 +49,10 @@ export const replaceFiles = (replacements: CopyDefinition[]) => {
5949
};
6050

6151
/**
62-
* Reusable predicated action: Wait for sandbox to become idle and then quit it (CTRL-C)
52+
* Reusable predicated action: Wait for sandbox to become idle and config to be generated and then quit it (CTRL-C)
6353
*/
64-
export const interruptSandbox = () => waitForSandboxToBecomeIdle().sendCtrlC();
54+
export const interruptSandbox = () =>
55+
waitForConfigUpdateAfterDeployment().sendCtrlC();
6556

6657
/**
6758
* Reusable predicated action: Wait for sandbox to finish deployment and assert that the deployment time is less

packages/integration-tests/src/test-e2e/deployment/deployment.test.template.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ import { TestProjectBase } from '../../test-project-setup/test_project_base.js';
1111
import { PredicatedActionBuilder } from '../../process-controller/predicated_action_queue_builder.js';
1212
import { ampxCli } from '../../process-controller/process_controller.js';
1313
import path from 'path';
14-
import {
15-
interruptSandbox,
16-
rejectCleanupSandbox,
17-
} from '../../process-controller/predicated_action_macros.js';
14+
import { waitForSandboxToBecomeIdle } from '../../process-controller/predicated_action_macros.js';
1815
import assert from 'node:assert';
1916
import { TestBranch, amplifyAppPool } from '../../amplify_app_pool.js';
2017
import { BackendIdentifier } from '@aws-amplify/plugin-types';
@@ -127,17 +124,18 @@ export const defineDeploymentTest = (
127124

128125
void describe('in sequence', { concurrency: false }, () => {
129126
void it('in sandbox deploy', async () => {
127+
const predicatedActionBuilder = new PredicatedActionBuilder();
130128
await ampxCli(
131129
['sandbox', '--dirToWatch', 'amplify'],
132130
testProject.projectDirPath
133131
)
134132
.do(
135-
new PredicatedActionBuilder().waitForLineIncludes(
133+
predicatedActionBuilder.waitForLineIncludes(
136134
'TypeScript validation check failed'
137135
)
138136
)
139-
.do(interruptSandbox())
140-
.do(rejectCleanupSandbox())
137+
.do(waitForSandboxToBecomeIdle())
138+
.do(predicatedActionBuilder.sendCtrlC())
141139
.run();
142140
});
143141

packages/integration-tests/src/test-e2e/sandbox/sandbox.test.template.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { ampxCli } from '../../process-controller/process_controller.js';
1111
import {
1212
ensureDeploymentTimeLessThan,
1313
interruptSandbox,
14-
rejectCleanupSandbox,
1514
replaceFiles,
1615
waitForConfigUpdateAfterDeployment,
1716
} from '../../process-controller/predicated_action_macros.js';
@@ -98,10 +97,7 @@ export const defineSandboxTest = (testProjectCreator: TestProjectCreator) => {
9897
}
9998

10099
// Execute the process.
101-
await processController
102-
.do(interruptSandbox())
103-
.do(rejectCleanupSandbox())
104-
.run();
100+
await processController.do(interruptSandbox()).run();
105101

106102
await testProject.assertPostDeployment(sandboxBackendIdentifier);
107103
}

packages/integration-tests/src/test-live-dependency-health-checks/health_checks.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
import {
1515
confirmDeleteSandbox,
1616
interruptSandbox,
17-
rejectCleanupSandbox,
1817
waitForSandboxDeploymentToPrintTotalTime,
1918
} from '../process-controller/predicated_action_macros.js';
2019
import { BackendIdentifierConversions } from '@aws-amplify/platform-core';
@@ -123,7 +122,6 @@ void describe('Live dependency health checks', { concurrency: true }, () => {
123122
await ampxCli(['sandbox'], tempDir)
124123
.do(waitForSandboxDeploymentToPrintTotalTime())
125124
.do(interruptSandbox())
126-
.do(rejectCleanupSandbox())
127125
.run();
128126

129127
const clientConfigStats = await fs.stat(

packages/integration-tests/src/test-project-setup/test_project_base.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ampxCli } from '../process-controller/process_controller.js';
99
import {
1010
confirmDeleteSandbox,
1111
interruptSandbox,
12-
rejectCleanupSandbox,
1312
waitForSandboxDeploymentToPrintTotalTime,
1413
} from '../process-controller/predicated_action_macros.js';
1514

@@ -77,7 +76,6 @@ export abstract class TestProjectBase {
7776
})
7877
.do(waitForSandboxDeploymentToPrintTotalTime())
7978
.do(interruptSandbox())
80-
.do(rejectCleanupSandbox())
8179
.run();
8280
} else {
8381
await ampxCli(

0 commit comments

Comments
 (0)