This repository was archived by the owner on Jul 16, 2024. It is now read-only.
generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathsynchronous-crawler.test.ts
More file actions
100 lines (86 loc) · 2.75 KB
/
synchronous-crawler.test.ts
File metadata and controls
100 lines (86 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
/**
* Tests SyncrhonousCrawler
*
* @group integ/synchronous/synchronous-crawler
*/
import * as cdk from 'aws-cdk-lib';
import { deployStack, destroyStack } from './utils';
import { Database } from '@aws-cdk/aws-glue-alpha';
import { CfnCrawler } from 'aws-cdk-lib/aws-glue';
import { ManagedPolicy, PolicyStatement, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
import { SynchronousCrawler } from '../../src/synchronous-crawler';
import { LakeFormationAdmin } from '../../src';
jest.setTimeout(300000);
// GIVEN
const integTestApp = new cdk.App();
const stack = new cdk.Stack(integTestApp, 'SynchronousCrawlerE2eTest');
LakeFormationAdmin.addCdkExecRole(stack, 'SynchronousCrawlerLfAdmin');
const testDb = new Database(stack, 'TestDb', {
databaseName: 'sync_crawler_test_db',
})
const crawlerRole = new Role(stack, 'CrawlerRole', {
assumedBy: new ServicePrincipal('glue.amazonaws.com'),
managedPolicies: [
new ManagedPolicy(stack, 'CrawlerPolicy',{
statements: [
new PolicyStatement({
actions: ['glue:GetTable'],
resources: [
stack.formatArn({
account: cdk.Aws.ACCOUNT_ID,
region: cdk.Aws.REGION,
service: 'glue',
resource: 'table',
resourceName: 'sampledb/elb_logs',
}),
stack.formatArn({
account: cdk.Aws.ACCOUNT_ID,
region: cdk.Aws.REGION,
service: 'glue',
resource: 'catalog',
}),
stack.formatArn({
account: cdk.Aws.ACCOUNT_ID,
region: cdk.Aws.REGION,
service: 'glue',
resource: 'database',
resourceName: 'sampledb',
}),
],
}),
]
}),
ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSGlueServiceRole'),
]
})
const crawler = new CfnCrawler(stack, 'Crawler', {
role: crawlerRole.roleName,
targets: {
s3Targets: [{
path: `s3://athena-examples-${cdk.Aws.REGION}/elb/plaintext`,
sampleSize: 1,
}],
},
name: 'test-crawler',
databaseName: testDb.databaseName,
});
const synchronousCrawler = new SynchronousCrawler(stack, 'SynchronousCrawler', {
crawlerName: crawler.name || 'test-crawler',
});
new cdk.CfnOutput(stack, 'SynchronousCrawlerResource', {
value: synchronousCrawler.toString(),
exportName: 'SynchronousCrawlerResource',
});
describe('deploy succeed', () => {
it('can be deploy succcessfully', async () => {
// GIVEN
await deployStack(integTestApp, stack);
// THEN
expect(true);
}, 9000000);
});
afterAll(async () => {
await destroyStack(integTestApp, stack);
});