-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(amplify-table): describe ttl rate limit (#2410)
* fix(amplify-table): describe ttl rate limit * add e2e tests * add update e2e test * fix unit test * resolve conflict * add error name check * fix: address CRs * chore: update code comments * chore: add comments for custom ddb input
- Loading branch information
1 parent
045ece2
commit 0d2ea6a
Showing
12 changed files
with
807 additions
and
379 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/amplify-graphql-api-construct-tests/src/__tests__/amplify-table-4.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as path from 'path'; | ||
import { createNewProjectDir, deleteProjectDir, getDDBTable } from 'amplify-category-api-e2e-core'; | ||
import { cdkDestroy, initCDKProject, cdkDeploy, updateCDKAppWithTemplate } from '../commands'; | ||
|
||
jest.setTimeout(1000 * 60 * 60 /* 1 hour */); | ||
|
||
describe('CDK amplify table 4', () => { | ||
let projRoot: string; | ||
let projFolderName: string; | ||
|
||
beforeEach(async () => { | ||
projFolderName = 'cdkamplifytable4'; | ||
projRoot = await createNewProjectDir(projFolderName); | ||
}); | ||
|
||
afterEach(async () => { | ||
try { | ||
await cdkDestroy(projRoot, '--all'); | ||
} catch (_) { | ||
/* No-op */ | ||
} | ||
|
||
deleteProjectDir(projRoot); | ||
}); | ||
|
||
test('should not throw limit exceed error when creating a large number of tables with datastore enabled', async () => { | ||
const templatePath = path.resolve(path.join(__dirname, 'backends', 'amplify-table', 'rate-limit', 'createTableTtl')); | ||
await initCDKProject(projRoot, templatePath); | ||
await expect(cdkDeploy(projRoot, '--all')).resolves.not.toThrow(); | ||
}); | ||
test('should not throw limit exceed error when creating a large number of tables with datastore disabled at first and enabled in second deployment', async () => { | ||
const templatePath = path.resolve(path.join(__dirname, 'backends', 'amplify-table', 'rate-limit', 'updateTableTtl', 'disabled')); | ||
await initCDKProject(projRoot, templatePath); | ||
await expect(cdkDeploy(projRoot, '--all')).resolves.not.toThrow(); | ||
// deploy with datastore enabled | ||
let updateTemplatePath; | ||
updateTemplatePath = path.resolve(path.join(__dirname, 'backends', 'amplify-table', 'rate-limit', 'updateTableTtl', 'enabled')); | ||
updateCDKAppWithTemplate(projRoot, updateTemplatePath); | ||
await expect(cdkDeploy(projRoot, '--all')).resolves.not.toThrow(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
...api-construct-tests/src/__tests__/backends/amplify-table/rate-limit/createTableTtl/app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register'; | ||
import { App, Stack, Duration } from 'aws-cdk-lib'; | ||
// @ts-ignore | ||
import { AmplifyGraphqlApi, AmplifyGraphqlDefinition } from '@aws-amplify/graphql-api-construct'; | ||
|
||
const packageJson = require('../package.json'); | ||
|
||
const app = new App(); | ||
const stack = new Stack(app, packageJson.name.replace(/_/g, '-'), { | ||
env: { region: process.env.CLI_REGION || 'us-west-2' }, | ||
}); | ||
const schema = | ||
`input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n` + | ||
Array.from({ length: 60 }, (_, i) => i + 1) | ||
.map( | ||
(number) => | ||
`type Todo${number} @model { | ||
id: ID! | ||
} | ||
`, | ||
) | ||
.join('\n'); | ||
new AmplifyGraphqlApi(stack, 'GraphqlApi', { | ||
apiName: 'MyGraphQLApi', | ||
definition: AmplifyGraphqlDefinition.fromString(schema, { | ||
dbType: 'DYNAMODB', | ||
provisionStrategy: 'AMPLIFY_TABLE', | ||
}), | ||
dataStoreConfiguration: { | ||
project: { | ||
detectionType: 'VERSION', | ||
handlerType: 'AUTOMERGE', | ||
}, | ||
}, | ||
authorizationModes: { | ||
apiKeyConfig: { expires: Duration.days(7) }, | ||
}, | ||
}); |
33 changes: 33 additions & 0 deletions
33
...ruct-tests/src/__tests__/backends/amplify-table/rate-limit/updateTableTtl/disabled/app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register'; | ||
import { App, Stack, Duration } from 'aws-cdk-lib'; | ||
// @ts-ignore | ||
import { AmplifyGraphqlApi, AmplifyGraphqlDefinition } from '@aws-amplify/graphql-api-construct'; | ||
|
||
const packageJson = require('../package.json'); | ||
|
||
const app = new App(); | ||
const stack = new Stack(app, packageJson.name.replace(/_/g, '-'), { | ||
env: { region: process.env.CLI_REGION || 'us-west-2' }, | ||
}); | ||
const schema = | ||
`input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n` + | ||
Array.from({ length: 60 }, (_, i) => i + 1) | ||
.map( | ||
(number) => | ||
`type Todo${number} @model { | ||
id: ID! | ||
} | ||
`, | ||
) | ||
.join('\n'); | ||
new AmplifyGraphqlApi(stack, 'GraphqlApi', { | ||
apiName: 'MyGraphQLApi', | ||
definition: AmplifyGraphqlDefinition.fromString(schema, { | ||
dbType: 'DYNAMODB', | ||
provisionStrategy: 'AMPLIFY_TABLE', | ||
}), | ||
authorizationModes: { | ||
apiKeyConfig: { expires: Duration.days(7) }, | ||
}, | ||
}); |
39 changes: 39 additions & 0 deletions
39
...truct-tests/src/__tests__/backends/amplify-table/rate-limit/updateTableTtl/enabled/app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register'; | ||
import { App, Stack, Duration } from 'aws-cdk-lib'; | ||
// @ts-ignore | ||
import { AmplifyGraphqlApi, AmplifyGraphqlDefinition } from '@aws-amplify/graphql-api-construct'; | ||
|
||
const packageJson = require('../package.json'); | ||
|
||
const app = new App(); | ||
const stack = new Stack(app, packageJson.name.replace(/_/g, '-'), { | ||
env: { region: process.env.CLI_REGION || 'us-west-2' }, | ||
}); | ||
const schema = | ||
`input AMPLIFY { globalAuthRule: AuthRule = { allow: public } }\n` + | ||
Array.from({ length: 60 }, (_, i) => i + 1) | ||
.map( | ||
(number) => | ||
`type Todo${number} @model { | ||
id: ID! | ||
} | ||
`, | ||
) | ||
.join('\n'); | ||
new AmplifyGraphqlApi(stack, 'GraphqlApi', { | ||
apiName: 'MyGraphQLApi', | ||
definition: AmplifyGraphqlDefinition.fromString(schema, { | ||
dbType: 'DYNAMODB', | ||
provisionStrategy: 'AMPLIFY_TABLE', | ||
}), | ||
dataStoreConfiguration: { | ||
project: { | ||
detectionType: 'VERSION', | ||
handlerType: 'AUTOMERGE', | ||
}, | ||
}, | ||
authorizationModes: { | ||
apiKeyConfig: { expires: Duration.days(7) }, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,8 @@ | |
"src/**/*.ts" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/__tests__/" | ||
"/__tests__/", | ||
".d.ts" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.