-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ecarton/cumulus 3751 from 18.5.2 #3900
base: release-18.5.x
Are you sure you want to change the base?
Changes from all commits
92e41df
ef1dacc
0f0cd98
7bac340
67b6145
de355c9
3192e08
2b25cfa
82abf69
151ec9c
5342484
818f7ff
edb9f7b
820792b
a31481b
0f0b794
199cdcd
93ca477
02b42fb
c16fe6f
d1e0311
d919f16
d340f1e
adac427
5246281
9b51d05
2fe02e6
0923f4b
fcfe2db
7730d99
b8c9ae6
e8ea49b
8e75138
7e09e80
b459a32
1b7a2cc
449fdf9
1bc74e1
6135a6c
bab68e8
5d50eb5
26cbdc1
b89e616
302c325
b5f5132
40fa00a
b1bbc29
1e647c4
7bca627
bfbb9c6
3b22031
a539a85
67064c5
fd01576
ea735d6
cf58c1c
382bf94
2ec3548
7c08f37
96c2327
b1d0ddf
f4534b1
1517216
fa3f53f
553545e
d26a787
ddaa54d
eb330c2
ab21ee4
94cd0a2
ede6f84
ba98f0c
e46cfe7
2442b39
b1d0802
fa77bf3
5ed88d5
4e9bdc9
8b1132e
c1619c4
68a8b28
d36fc3b
41d407f
cf465a7
108e42d
b92ced4
c46187d
7b118f0
b5eeba5
4a6bb01
e8346ea
406e791
6cba814
6a0d618
65f4456
294fe22
8342a02
1853e54
b0571af
70b09b7
7b4fe05
98f2af9
414851a
9a800b8
3583293
3133cc2
096b713
25cd0a7
4a18e38
0c1c36c
1bad8c3
6e7ce70
acb681c
a3db811
96f7c20
462a65e
a835a6a
4834f68
c8bc308
2d15b5f
5c81cf4
a2efe77
fcd1c5b
5f29b66
0e05f81
03237e0
bae3a87
dfef9e1
8756769
c4b76f6
a840ed1
fa73c4d
9aad83a
76f6756
c1c3ff2
ff76289
8ae5ee3
2075500
833fb5f
8b5bac4
5c27fa4
949fed1
7d06ba3
31812a3
6ba70e5
9c53d78
56287ad
82de20f
ae96f3d
75bb1d3
080441f
d61d2f6
0850a6c
8bf1f4e
dfd5192
32acc20
cc02bfd
55232b3
e6992e0
adedba0
f1964c6
9d62575
440e084
c6777ca
9de367f
cb39dad
d8bccf0
f218ffc
668542f
0839c3d
548fda5
18d5353
76975a6
93756a8
0fa0015
879d146
76cb9a1
8bd526c
4d1af36
a699239
cc3d440
688aaf9
3f9928f
df73eaf
fa44f4e
a3c3dcc
eb7e2f1
2027237
30d16db
a5ddcdb
ab74050
d2f3b2b
59a44c8
425e157
492ddb3
08816c8
740c22c
06e0193
77a177f
2827f3f
6ec79e5
6b255a7
93b5fcb
7f595cd
10b27d0
1980d12
1d63122
23ab63c
a493469
1e969f9
6aced05
ae59a50
1873adb
ce1ed8d
e9c6768
cb3c7ad
6677cfc
c24d218
cb5c950
5a5798b
261e9de
412382c
ccead63
2d494ba
dd1a0f3
53e4ddb
44e3ec1
392aa85
06f5f68
8ce2e2e
db8c1da
6c9fa7a
cae4527
ab0f609
0134166
4a59394
65f4673
148a291
21fe9f9
dacde25
762b655
d46049b
707e101
6bd075e
5180b4a
534a951
49295be
456df87
f7965e9
220ea3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"Comment": "Moves granules across collections", | ||
"StartAt": "EcsTaskMoveGranuleCollections", | ||
"States": { | ||
"EcsTaskMoveGranuleCollections": { | ||
"Parameters": { | ||
"cma": { | ||
"event.$": "$", | ||
"task_config": { | ||
"buckets": "{$.meta.buckets}", | ||
"provider": "{$.meta.provider}", | ||
"sourceCollection": "{$.meta.sourceCollection}", | ||
"targetCollection": "{$.meta.targetCollection}" | ||
} | ||
} | ||
}, | ||
"Type": "Task", | ||
"Resource": "${ecs_task_move_granule_collections_id}", | ||
"TimeoutSeconds": 60, | ||
"Retry": [ | ||
{ | ||
"ErrorEquals": [ | ||
"States.Timeout" | ||
], | ||
"MaxAttempts": 1 | ||
} | ||
], | ||
"End": true | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
resource "aws_sfn_activity" "ecs_task_move_granule_collections" { | ||
name = "${var.prefix}-EcsTaskMoveGranuleCollections" | ||
tags = local.tags | ||
} | ||
|
||
module "move_granule_collections_services" { | ||
source = "../../tf-modules/cumulus_ecs_service" | ||
|
||
prefix = var.prefix | ||
name = "MoveGranuleCollections" | ||
tags = local.tags | ||
|
||
cluster_arn = module.cumulus.ecs_cluster_arn | ||
desired_count = 1 | ||
image = "${data.aws_ecr_repository.ecs_task_image.repository_url}:${var.ecs_task_image_version}" | ||
|
||
cpu = 400 | ||
memory_reservation = 700 | ||
default_log_retention_days = var.default_log_retention_days | ||
cloudwatch_log_retention_periods = var.cloudwatch_log_retention_periods | ||
|
||
environment = { | ||
AWS_DEFAULT_REGION = data.aws_region.current.name | ||
stackName = var.prefix | ||
} | ||
command = [ | ||
"cumulus-ecs-task", | ||
"--activityArn", | ||
aws_sfn_activity.ecs_task_move_granule_collections.id, | ||
"--lambdaArn", | ||
module.cumulus.move_granule_collections_task.task_arn, | ||
"--lastModified", | ||
module.cumulus.move_granule_collections_task.last_modified_date | ||
] | ||
} | ||
|
||
|
||
module "ecs_move_granule_collections" { | ||
source = "../../tf-modules/workflow" | ||
|
||
prefix = var.prefix | ||
name = "ECSMoveGranuleCollectionsWorkflow" | ||
workflow_config = module.cumulus.workflow_config | ||
system_bucket = var.system_bucket | ||
tags = local.tags | ||
|
||
|
||
state_machine_definition = templatefile( | ||
"${path.module}/ecs_move_granule_collections.asl.json", | ||
{ | ||
ecs_task_move_granule_collections_id: aws_sfn_activity.ecs_task_move_granule_collections.id | ||
} | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
const { deleteExecution } = require('@cumulus/api-client/executions'); | ||
const { ActivityStep } = require('@cumulus/integration-tests/sfnStep'); | ||
const fs = require('fs'); | ||
const { waitForListObjectsV2ResultCount } = require('@cumulus/integration-tests'); | ||
const { | ||
deleteS3Object, | ||
} = require('@cumulus/aws-client/S3'); | ||
const { createProvider } = require('@cumulus/api-client/providers'); | ||
const { deleteGranule } = require('@cumulus/api-client/granules'); | ||
const { buildAndStartWorkflow } = require('../../helpers/workflowUtils'); | ||
const { loadConfig, createTestSuffix, createTimestampedTestId } = require('../../helpers/testUtils'); | ||
const { setupInitialState, getTargetFiles, getTargetCollection, getSourceCollection } = require('./move-granule-collection-spec-utils'); | ||
|
||
const activityStep = new ActivityStep(); | ||
|
||
describe('The MoveGranuleCollection workflow using ECS', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the source and target collections? I can't tell from the specs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the difference between MoveGranuleCollectionWorkflowSpec and MoveGranuleCollectionsSpec? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intent is to run movegranulecollectionsSoec as a test of the functionality of the lambda, while the workflow is meant to run the workflow as it would exist with example data, to be added to with CMR, lizards etc when those tickets are done. Right now the only functional difference is that it tests the lambda in the ECS deployment |
||
let workflowExecutionArn; | ||
let config; | ||
let finalFiles; | ||
let beforeAllFailed = false; | ||
const granuleIds = ['MOD11A1.A2017200.h19v04.006.2017201090724']; | ||
afterAll(async () => { | ||
try { | ||
await Promise.all(finalFiles.map((fileObj) => deleteS3Object( | ||
fileObj.bucket, | ||
fileObj.key | ||
))); | ||
} catch { | ||
console.log('no need to delete s3 objects'); | ||
} | ||
try { | ||
await Promise.all(granuleIds.map((granuleId) => deleteGranule({ prefix: config.stackName, granuleId}))); | ||
} catch { | ||
console.log('no need to delete granules'); | ||
} | ||
|
||
try { | ||
await deleteExecution({ prefix: config.stackName, executionArn: workflowExecutionArn }); | ||
} catch { | ||
console.log('no need to delete execution'); | ||
} | ||
}); | ||
beforeAll(async () => { | ||
|
||
const sourceUrlPrefix = 'move-granule-collection-testing'; | ||
const targetUrlPrefix = 'move-granule-collection-testing-target'; | ||
config = await loadConfig(); | ||
const providersDir = './data/providers/s3/'; | ||
const stackName = config.stackName; | ||
const testId = createTimestampedTestId(config.stackName, 'MoveGranuleCollections'); | ||
const testSuffix = createTestSuffix(testId); | ||
const provider = { id: `s3_provider${testSuffix}` }; | ||
|
||
const providerJson = JSON.parse(fs.readFileSync(`${providersDir}/s3_provider.json`, 'utf8')); | ||
const providerData = { | ||
...providerJson, | ||
id: provider.id, | ||
host: config.bucket, | ||
}; | ||
await createProvider({ prefix: config.stackName, provider: providerData }) | ||
|
||
finalFiles = getTargetFiles(targetUrlPrefix, config); | ||
//upload to cumulus | ||
|
||
try { | ||
await setupInitialState(stackName, sourceUrlPrefix, targetUrlPrefix, config); | ||
|
||
workflowExecutionArn = await buildAndStartWorkflow( | ||
config.stackName, | ||
config.bucket, | ||
'ECSMoveGranuleCollectionsWorkflow', | ||
getSourceCollection(sourceUrlPrefix), | ||
provider, | ||
{ granules: ['MOD11A1.A2017200.h19v04.006.2017201090724'] }, | ||
{ | ||
targetCollection: getTargetCollection(targetUrlPrefix), | ||
sourceCollection: getSourceCollection(sourceUrlPrefix), | ||
buckets: config.buckets | ||
} | ||
); | ||
await Promise.all(finalFiles.map((file) => expectAsync( | ||
waitForListObjectsV2ResultCount({ | ||
bucket: file.bucket, | ||
prefix: file.key, | ||
desiredCount: 1, | ||
interval: 5 * 1000, | ||
timeout: 60 * 1000, | ||
}) | ||
).toBeResolved())); | ||
} catch (error) { | ||
console.log(`files do not appear to have been moved: error: ${error}`); | ||
beforeAllFailed = true; | ||
} | ||
}); | ||
|
||
it('executes successfully', () => { | ||
expect(beforeAllFailed).toEqual(false); | ||
}); | ||
|
||
it('outputs the updated granules', async () => { | ||
expect(beforeAllFailed).toEqual(false); | ||
const activityOutput = await activityStep.getStepOutput( | ||
workflowExecutionArn, | ||
'EcsTaskMoveGranuleCollections' | ||
); | ||
expect(activityOutput.payload.granules[0].files).toEqual([ | ||
{ | ||
key: 'move-granule-collection-testing-target/MOD11A1.A2017200.h19v04.006.2017201090724.hdf', | ||
bucket: config.buckets.protected.name, | ||
type: 'data', | ||
fileName: 'MOD11A1.A2017200.h19v04.006.2017201090724.hdf', | ||
}, | ||
{ | ||
key: 'move-granule-collection-testing-target/jpg/example2/MOD11A1.A2017200.h19v04.006.2017201090724_1.jpg', | ||
bucket: config.buckets.public.name, | ||
type: 'browse', | ||
fileName: 'MOD11A1.A2017200.h19v04.006.2017201090724_1.jpg', | ||
}, | ||
{ | ||
key: 'move-granule-collection-testing-target/MOD11A1.A2017200.h19v04.006.2017201090724_2.jpg', | ||
bucket: config.buckets.public.name, | ||
type: 'browse', | ||
fileName: 'MOD11A1.A2017200.h19v04.006.2017201090724_2.jpg', | ||
}, | ||
{ | ||
key: 'move-granule-collection-testing-target/MOD11A1.A2017200.h19v04.006.2017201090724.cmr.xml', | ||
bucket: config.buckets.public.name, | ||
type: 'metadata', | ||
fileName: 'MOD11A1.A2017200.h19v04.006.2017201090724.cmr.xml', | ||
}, | ||
]); | ||
expect(activityOutput.payload.granules[0].granuleId).toEqual('MOD11A1.A2017200.h19v04.006.2017201090724'); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
'use strict'; | ||
|
||
const { InvokeCommand } = require('@aws-sdk/client-lambda'); | ||
const { lambda } = require('@cumulus/aws-client/services'); | ||
const { | ||
deleteS3Object, | ||
} = require('@cumulus/aws-client/S3'); | ||
const { waitForListObjectsV2ResultCount } = require('@cumulus/integration-tests'); | ||
const { | ||
granules, | ||
} = require('@cumulus/api-client'); | ||
|
||
const { v4: uuidv4 } = require('uuid'); | ||
const { loadConfig } = require('../../helpers/testUtils'); | ||
const { constructCollectionId } = require('../../../../packages/message/Collections'); | ||
const { getTargetCollection, getProcessGranule, setupInitialState, getPayload, getTargetFiles } = require('./move-granule-collection-spec-utils'); | ||
describe('when moveGranulesCollection is called', () => { | ||
let stackName; | ||
const sourceUrlPrefix = `source_path/${uuidv4()}`; | ||
const targetUrlPrefix = `target_path/${uuidv4()}`; | ||
const targetCollection = getTargetCollection(targetUrlPrefix); | ||
let processGranule; | ||
let config; | ||
// let systemBucket; | ||
beforeAll(async () => { | ||
config = await loadConfig(); | ||
stackName = config.stackName; | ||
processGranule = getProcessGranule(sourceUrlPrefix, config); | ||
}); | ||
|
||
describe('under normal circumstances', () => { | ||
let beforeAllFailed = false; | ||
let finalFiles; | ||
afterAll(async () => { | ||
await Promise.all(finalFiles.map((fileObj) => deleteS3Object( | ||
fileObj.bucket, | ||
fileObj.key | ||
))); | ||
}); | ||
beforeAll(async () => { | ||
finalFiles = getTargetFiles(targetUrlPrefix, config); | ||
const payload = getPayload(sourceUrlPrefix, targetUrlPrefix, config); | ||
//upload to cumulus | ||
try { | ||
await setupInitialState(stackName, sourceUrlPrefix, targetUrlPrefix, config); | ||
const { $metadata } = await lambda().send(new InvokeCommand({ | ||
FunctionName: `${stackName}-MoveGranuleCollections`, | ||
InvocationType: 'RequestResponse', | ||
Payload: JSON.stringify({ | ||
cma: { | ||
meta: payload.meta, | ||
task_config: payload.config, | ||
event: { | ||
payload: payload.input, | ||
}, | ||
}, | ||
}), | ||
})); | ||
if ($metadata.httpStatusCode >= 400) { | ||
console.log(`lambda invocation to set up failed, code ${$metadata.httpStatusCode}`); | ||
beforeAllFailed = true; | ||
} | ||
await Promise.all(finalFiles.map((file) => expectAsync( | ||
waitForListObjectsV2ResultCount({ | ||
bucket: file.bucket, | ||
prefix: file.key, | ||
desiredCount: 1, | ||
interval: 5 * 1000, | ||
timeout: 60 * 1000, | ||
}) | ||
).toBeResolved())); | ||
} catch (error) { | ||
console.log(`files do not appear to have been moved: error: ${error}`); | ||
beforeAllFailed = true; | ||
} | ||
}); | ||
it('moves the granule data in s3', () => { | ||
if (beforeAllFailed) fail('beforeAllFailed'); | ||
}); | ||
it('updates the granule data in cumulus', async () => { | ||
if (beforeAllFailed) fail('beforeAllFailed'); | ||
const cumulusGranule = await granules.getGranule({ | ||
prefix: stackName, | ||
granuleId: processGranule.granuleId, | ||
}); | ||
expect(cumulusGranule.granuleId).toEqual(processGranule.granuleId); | ||
expect(cumulusGranule.collectionId).toEqual(constructCollectionId(targetCollection.name, targetCollection.version)); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a CL re: this change if possible