Skip to content
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 s3 task #3910

Open
wants to merge 348 commits into
base: feature/CUMULUS-3751
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
348 commits
Select commit Hold shift + click to select a range
7b118f0
more linting
etcart Dec 6, 2024
b5eeba5
Merge branch 'master' into cbanh/CUMULUS-3916
cqbanh Dec 7, 2024
4a6bb01
different package structure to satisfy scriptless bootstrap
etcart Dec 9, 2024
e8346ea
feedback
Nnaga1 Dec 9, 2024
406e791
don't lint compiled js files
etcart Dec 9, 2024
6cba814
Merge remote-tracking branch 'origin/CUMULUS-3757-move-granule' into …
etcart Dec 9, 2024
6a0d618
small feedback change
Nnaga1 Dec 9, 2024
65f4456
updated tests
etcart Dec 9, 2024
294fe22
fix package script
etcart Dec 9, 2024
8342a02
adding jsdoc
Nnaga1 Dec 9, 2024
1853e54
From nsidc CUMULUS-3948/CUMULUS-3936: Update Cumulus EC2 Clusters for…
jennyhliu Dec 9, 2024
b0571af
Merge branch 'master' into cbanh/CUMULUS-3916
cqbanh Dec 10, 2024
70b09b7
Merge branch 'master' into CUMULUS-3757-move-granule
Nnaga1 Dec 10, 2024
7b4fe05
linter fixes
etcart Dec 10, 2024
98f2af9
Merge pull request #3860 from nasa/cbanh/CUMULUS-3916
cqbanh Dec 10, 2024
414851a
first pass at calling the lambda in integration tests and bugfix in t…
etcart Dec 10, 2024
9a800b8
Merge branch 'master' into CUMULUS-3757-move-granule
Nnaga1 Dec 10, 2024
3583293
linting
etcart Dec 10, 2024
3133cc2
more to int tests and why is output format getting flagged
etcart Dec 10, 2024
096b713
mistaken name from old move granules
etcart Dec 10, 2024
25cd0a7
still need to point to the right file
etcart Dec 10, 2024
4a18e38
naming cleanup
etcart Dec 11, 2024
0c1c36c
more movin stuff around
etcart Dec 11, 2024
1bad8c3
point webpack right
etcart Dec 11, 2024
6e7ce70
[CUMULUS-3955] Update migration to remove vacuum statements (#3881)
npauzenga Dec 11, 2024
acb681c
unsure what's wrong I'm closer imitating another that works
etcart Dec 11, 2024
a3db811
corrected pathing in tf
etcart Dec 12, 2024
96f7c20
corrected pthing in package
etcart Dec 12, 2024
462a65e
cont to massage configuration
etcart Dec 12, 2024
a835a6a
PR feedback--naming
Nnaga1 Dec 12, 2024
4834f68
PR feedback - transactions
Nnaga1 Dec 16, 2024
c8bc308
Merge branch 'CUMULUS-3757-move-granule' of https://github.com/nasa/c…
Nnaga1 Dec 16, 2024
2d15b5f
PR feedback
Nnaga1 Dec 16, 2024
5c81cf4
Merge branch 'master' into CUMULUS-3757-move-granule
Nnaga1 Dec 16, 2024
a2efe77
Merge branch 'CUMULUS-3757-move-granule' of https://github.com/nasa/c…
Nnaga1 Dec 18, 2024
fcd1c5b
backport changelog changes (#3884)
Nnaga1 Dec 18, 2024
5f29b66
Merge branch 'master' into CUMULUS-3757-move-granule
Nnaga1 Dec 18, 2024
0e05f81
Merge branch 'CUMULUS-3757-move-granule' of https://github.com/nasa/c…
Nnaga1 Dec 18, 2024
03237e0
converting to PATCH endpoint
Nnaga1 Dec 18, 2024
bae3a87
CUMULUS-3759:Migrated ECS Autoscaling group from launch configuration…
jennyhliu Dec 19, 2024
dfef9e1
Merge branch 'CUMULUS-3757-move-granule' into ecarton/cumulus-3751-us…
etcart Dec 19, 2024
8756769
Merge remote-tracking branch 'origin/master' into ecarton/cumulus-375…
etcart Dec 19, 2024
c4b76f6
api client for this endpoint
etcart Dec 19, 2024
a840ed1
Merge branch 'CUMULUS-3757-move-granule' into ecarton/cumulus-3751-us…
etcart Dec 19, 2024
fa73c4d
update to use and mock for testing the api-client
etcart Dec 19, 2024
9aad83a
lint fixes
etcart Dec 19, 2024
76f6756
some mistakes brought over from old version
etcart Dec 19, 2024
c1c3ff2
mistaken config require
etcart Dec 20, 2024
ff76289
linting and proper environment variable
etcart Dec 20, 2024
8ae5ee3
should expect 200
etcart Dec 20, 2024
2075500
linting fixes and test for presence in cumulus according to api
etcart Dec 20, 2024
833fb5f
move to task declared as ecs in the example directory
etcart Dec 30, 2024
8b5bac4
unneeded duplicate
etcart Dec 30, 2024
5c27fa4
mistake in naming the task id
etcart Dec 30, 2024
949fed1
add the task into the module outputs
etcart Dec 30, 2024
7d06ba3
first commit
Nnaga1 Dec 31, 2024
31812a3
Merge branch 'release-18.5.x' into CUMULUS-3757
Nnaga1 Dec 31, 2024
6ba70e5
Merge branch 'CUMULUS-3757' of https://github.com/nasa/cumulus into C…
Nnaga1 Dec 31, 2024
9c53d78
fixing CHANGELOG
Nnaga1 Dec 31, 2024
56287ad
get from module.ingest
etcart Dec 31, 2024
82de20f
need this to be in cumulus outputs
etcart Dec 31, 2024
ae96f3d
gottta get it from cumulus duh
etcart Dec 31, 2024
75bb1d3
mistake updated in ecs naming
etcart Dec 31, 2024
080441f
slightly misnamed
etcart Jan 1, 2025
d61d2f6
adding api-client tests + removing extraneous changes
Nnaga1 Jan 1, 2025
0850a6c
naming fix
Nnaga1 Jan 1, 2025
8bf1f4e
update to id name
etcart Jan 2, 2025
dfd5192
small indexer change
Nnaga1 Jan 2, 2025
32acc20
pmap concurrency limited
etcart Jan 2, 2025
cc02bfd
reverting some changes
Nnaga1 Jan 2, 2025
55232b3
reduce memory size to see if it needs to scale down to fit
etcart Jan 2, 2025
e6992e0
redefinition of workflow with a usable payload in
etcart Jan 3, 2025
adedba0
json typo
etcart Jan 3, 2025
f1964c6
see if this is a helpful debug output
etcart Jan 3, 2025
9d62575
WIP
etcart Jan 3, 2025
440e084
Jk/cumulus 3940 to main from #3877 (#3877) (#3890)
Jkovarik Jan 3, 2025
c6777ca
adding changes from code review
Nnaga1 Jan 3, 2025
9de367f
removing parent from esUpdate
Nnaga1 Jan 3, 2025
cb39dad
commenting out some es temp. + some PR feedback for formatting
Nnaga1 Jan 4, 2025
d8bccf0
commenting out more ES
Nnaga1 Jan 4, 2025
f218ffc
adding back in ES update after some changes
Nnaga1 Jan 4, 2025
668542f
changes to get ES working + linting
Nnaga1 Jan 4, 2025
0839c3d
chaging back from 2 to 50 in tests
Nnaga1 Jan 4, 2025
548fda5
PR feedback (zod) + fixing concurrency
Nnaga1 Jan 5, 2025
18d5353
decreasing num granules 50 -> 25 for test
Nnaga1 Jan 5, 2025
76975a6
removing res.send for batchPatch
Nnaga1 Jan 5, 2025
93756a8
adding back in res.send + lowering numbers
Nnaga1 Jan 5, 2025
0fa0015
adding console.log for test
Nnaga1 Jan 6, 2025
879d146
added more error logging
Nnaga1 Jan 6, 2025
76cb9a1
removing all console.log
Nnaga1 Jan 6, 2025
8bd526c
bumping concurrency
Nnaga1 Jan 6, 2025
4d1af36
lowering nums
Nnaga1 Jan 6, 2025
a699239
WIP moving to some standard data for ease of maintenance
etcart Jan 6, 2025
cc3d440
refactor of workflow spec to use common functions
etcart Jan 6, 2025
688aaf9
PR feedback (1/6/25)
Nnaga1 Jan 6, 2025
3f9928f
bumping up numGranules 5 -> 25
Nnaga1 Jan 6, 2025
df73eaf
bumping numGranules 25 -> 50
Nnaga1 Jan 6, 2025
fa44f4e
correcting names
Nnaga1 Jan 7, 2025
a3c3dcc
small formatting fix
Nnaga1 Jan 7, 2025
eb7e2f1
fixing linting
Nnaga1 Jan 7, 2025
2027237
CUMULUS-3965:Update launch templates to require IMDSv2 (#3894)
jennyhliu Jan 7, 2025
30d16db
integration finally works
etcart Jan 7, 2025
a5ddcdb
try these memory reservation
etcart Jan 7, 2025
ab74050
Merge remote-tracking branch 'origin/master' into ecarton/cumulus-375…
etcart Jan 7, 2025
d2f3b2b
reduce memory footprints
etcart Jan 8, 2025
59a44c8
Merge branch 'ecarton/cumulus-3751-ecs_task_in_example' into ecarton/…
etcart Jan 8, 2025
425e157
corrected versioning
etcart Jan 8, 2025
492ddb3
missed changes meant to rbing in
etcart Jan 8, 2025
08816c8
PR feedback minus (adding tests to db/lib + tests/endpoints)
Nnaga1 Jan 8, 2025
740c22c
missing funcs
etcart Jan 8, 2025
06e0193
get webpack in
etcart Jan 8, 2025
77a177f
import fix for test-granules endpoints test
Nnaga1 Jan 8, 2025
2827f3f
PR feedback
Nnaga1 Jan 9, 2025
6ec79e5
PR feedback part-1 1/9/2025
Nnaga1 Jan 9, 2025
6b255a7
add doc inline
etcart Jan 9, 2025
93b5fcb
Merge remote-tracking branch 'origin/CUMULUS-3757' into ecarton/cumul…
etcart Jan 9, 2025
7f595cd
maybe too much mocking
etcart Jan 10, 2025
10b27d0
de-nesting try's
etcart Jan 10, 2025
1980d12
much better mocking
etcart Jan 10, 2025
1d63122
PR feedback - remaining
Nnaga1 Jan 10, 2025
23ab63c
fixing some jsdocs + PR feedback
Nnaga1 Jan 10, 2025
a493469
WIP dependency cycles and cleanup in tests
etcart Jan 10, 2025
1e969f9
fixing lint errors
etcart Jan 10, 2025
6aced05
changelog
etcart Jan 10, 2025
ae59a50
adding CHANGELOG linking
Nnaga1 Jan 10, 2025
1873adb
removing extraneous string
Nnaga1 Jan 10, 2025
ce1ed8d
fix to error checking from aws latest
etcart Jan 10, 2025
e9c6768
typo fix in error check
etcart Jan 10, 2025
cb3c7ad
Merge branch 'CUMULUS-3757' of https://github.com/nasa/cumulus into C…
Nnaga1 Jan 13, 2025
6677cfc
reverting AWS changes in anticipation for cherry-pick and fixing a co…
Nnaga1 Jan 13, 2025
c24d218
Merge branch 'CUMULUS-3757' into ecarton/cumulus-3751-from-18.5.2
etcart Jan 13, 2025
cb5c950
Merge remote-tracking branch 'origin/CUMULUS-3757' into ecarton/cumul…
etcart Jan 13, 2025
5a5798b
correct new name for endpoints and functions
etcart Jan 13, 2025
261e9de
Merge remote-tracking branch 'origin/release-18.5.x' into ecarton/cum…
etcart Jan 13, 2025
412382c
cleanup leftover api endpoitn from previous format
etcart Jan 13, 2025
ccead63
some typing cleanup
etcart Jan 13, 2025
2d494ba
correct api return values and needed data file for int tests
etcart Jan 15, 2025
dd1a0f3
api-client should expect 200 from test-granules.js
etcart Jan 15, 2025
53e4ddb
fix changelog and tasks.md extra entries
etcart Jan 15, 2025
44e3ec1
testing for ummg and iso
etcart Jan 16, 2025
392aa85
Update CHANGELOG.md
etcart Jan 18, 2025
06f5f68
WIP still figuring out the right way to update the cmr file
etcart Jan 19, 2025
8ce2e2e
Merge branch 'ecarton_rebase-3751' into ecarton/cumulus-3751-from-18.5.2
etcart Jan 19, 2025
db8c1da
move to using api to get granule data from ID
etcart Jan 21, 2025
6c9fa7a
shift tests to using granuleId as input
etcart Jan 21, 2025
cae4527
test files have granule id payload instead of granule payload
etcart Jan 21, 2025
ab0f609
sourceCollection in code and tests to allow update with details befor…
etcart Jan 21, 2025
0134166
small format fix
etcart Jan 21, 2025
4a59394
config and linter errors
etcart Jan 21, 2025
65f4673
more linting
etcart Jan 21, 2025
148a291
fix input configuration
etcart Jan 21, 2025
21fe9f9
double check my inputs
etcart Jan 21, 2025
dacde25
let me make sure the config is right
etcart Jan 22, 2025
762b655
CUMULUS-3967 -- Forward port of release fix -- Pin @aws-sdk/client-s3…
Jkovarik Jan 21, 2025
d46049b
think this needs to be corected
etcart Jan 22, 2025
707e101
remove unnecessary eslints
etcart Jan 23, 2025
6bd075e
moving to non-hardcoded buckets
etcart Jan 24, 2025
5180b4a
CL for memory reservation
etcart Jan 24, 2025
534a951
remove gitignore from task
etcart Jan 24, 2025
49295be
appears to be workign bu tstill need to test cmr udates
etcart Jan 26, 2025
456df87
remove unneeded import o CMRFile
etcart Jan 26, 2025
f7965e9
Merge remote-tracking branch 'origin/release-18.5.x' into ecarton/cum…
etcart Jan 26, 2025
220ea3c
accidentally commited mangled ts output
etcart Jan 26, 2025
8b8d863
move in s3 functionality
etcart Jan 27, 2025
f5f65c0
name scheme change over to s3 specific
etcart Jan 27, 2025
c18424e
removing iso references along with linting and more naming
etcart Jan 27, 2025
646d9b0
typo in copypasta
etcart Jan 27, 2025
37487c7
testing and fixing some issues encountered
etcart Jan 28, 2025
17d3c16
fxed lambda integration. fixed naming in workflow
etcart Jan 28, 2025
f8a06ae
linter fixes
etcart Jan 28, 2025
21b06a3
name cleanup and point to module.ingest
etcart Jan 28, 2025
641cce1
typo in config names
etcart Jan 28, 2025
2330aa2
fixed naming in workflow
etcart Jan 28, 2025
02a1301
should get taks from module.cumulus
etcart Jan 28, 2025
dc6286a
right name
etcart Jan 28, 2025
d2fda6e
small cleanyups for review
etcart Jan 28, 2025
bc03705
corrected configuration
etcart Jan 29, 2025
b9fea47
getting cmrURLType and distribution url configured
etcart Jan 29, 2025
45ab8e6
cleaning up collections to name/version collection basebones
etcart Jan 29, 2025
ee76a2b
linting
etcart Jan 29, 2025
f7849a2
add in tests for url replacement behavior
etcart Jan 29, 2025
153edae
fix pathing in package
etcart Jan 29, 2025
d361ff5
remove es from testing
etcart Jan 29, 2025
cba472e
how are there still more of these typos to find?
etcart Jan 29, 2025
bba0316
full resources by default
etcart Jan 29, 2025
9cc2ae2
didn't mean to commit htat here
etcart Jan 29, 2025
77731b3
Update CHANGELOG.md
etcart Jan 30, 2025
aca0611
distribution_endpoint is not a config
etcart Jan 30, 2025
852c954
fixing changelog entries
etcart Jan 30, 2025
6e97afa
type isntead of interface
etcart Jan 30, 2025
23edb7d
Update packages/aws-client/src/S3.ts
etcart Jan 30, 2025
a303c56
use copyObject low case
etcart Jan 30, 2025
9889560
getting config values right
etcart Jan 30, 2025
701d318
but *what* is undefined
etcart Jan 30, 2025
7db7c73
shift to correctly using "granuleIds" input
etcart Jan 30, 2025
3cca60c
update workflow definition and call
etcart Jan 30, 2025
3a721c3
remove unnecessary etag return
etcart Jan 30, 2025
4369f0d
migration of some code to cmr-utils
etcart Jan 30, 2025
b68d5cb
adding and updating tests
etcart Jan 30, 2025
374065b
typo in asl
etcart Jan 30, 2025
df3b8d9
Move 'move_granule_collections_workflow' from example to /tf-modules/…
Jkovarik Jan 30, 2025
a8f9f77
move workflow over
etcart Jan 30, 2025
b863f7a
fix s3 spec
etcart Jan 31, 2025
ef56b2b
WIP updating to use ingested granule
etcart Jan 31, 2025
ef1ddaf
two typo fixes
etcart Jan 31, 2025
ab3cbf5
0one int test using ingest Granule to stage
etcart Feb 1, 2025
bfd8347
let me check better what the outputs are
etcart Feb 2, 2025
a75a3c1
get this better
etcart Feb 3, 2025
f77207b
move integration tests to ingested "true" granule
etcart Feb 3, 2025
8277e80
I slightly hate this solution but
etcart Feb 3, 2025
02ddb59
linting and naming
etcart Feb 3, 2025
d51b882
cleanup and cmr-utils nyc fix
etcart Feb 4, 2025
564ba47
fix isObject
etcart Feb 4, 2025
ffde50d
expanded tests and nycconfig
etcart Feb 4, 2025
98d474e
linter fixes
etcart Feb 4, 2025
73a0221
fixes to cmr collection parsing and testing
etcart Feb 4, 2025
4bcd9f4
debug log for weird collection version
etcart Feb 4, 2025
8d64657
Revert "debug log for weird collection version"
etcart Feb 4, 2025
edd642b
corrected naming in worklfow spec
etcart Feb 4, 2025
d07e659
fixed int test cleanup
etcart Feb 4, 2025
f7161ba
linting and int test cleanup
etcart Feb 4, 2025
874b8e7
output config
etcart Feb 4, 2025
5ff6b39
cmrjs test fixes
etcart Feb 4, 2025
d2b74c1
smol test data cleanup
etcart Feb 5, 2025
7a438b6
remove some unnedded tf changes
etcart Feb 5, 2025
0e73c45
one more memory reversion
etcart Feb 5, 2025
6d8a0a6
docstrings and ts-check
etcart Feb 5, 2025
6753e17
you can't fix all the typing in one pr
etcart Feb 5, 2025
d533cea
simplify the s3CredsEndpoint weirdness
etcart Feb 5, 2025
d050a49
pared down dependencies
etcart Feb 6, 2025
41e50bf
more fix to dependencies
etcart Feb 6, 2025
2b44b61
cleanup type hints in ts file
etcart Feb 6, 2025
0aac0d2
further type cleanup
etcart Feb 6, 2025
a233fe8
cleanup some typing in S3.ts
etcart Feb 6, 2025
f59551a
mistake in typing changes
etcart Feb 6, 2025
8713d72
removing recursive cmr data search relying instead on spec
etcart Feb 6, 2025
b1c825a
linting fixes
etcart Feb 6, 2025
7dfa694
move from alter in place to copy and alter behavior
etcart Feb 6, 2025
32f4015
fix some of the Object typings
etcart Feb 6, 2025
6d511de
typing distributionBucketMap
etcart Feb 7, 2025
c8041fa
some linting
etcart Feb 7, 2025
c416f1e
descriptive docstrings
etcart Feb 7, 2025
0867fcf
fixing some things in cmr-utils
etcart Feb 7, 2025
d1eddfe
coverage lowered with the removal of covered code
etcart Feb 7, 2025
8307d3d
Update tasks/change-granule-collection-s3/src/index.ts
etcart Feb 7, 2025
6ab4ddb
Update tasks/change-granule-collection-s3/src/index.ts
etcart Feb 7, 2025
4d65179
validating file collisions or not using checksums
etcart Feb 7, 2025
07448ee
retry behavior
etcart Feb 7, 2025
8ce5e3c
remove unnecessary async/await
etcart Feb 7, 2025
cb5fff1
improved import structure/blocking
etcart Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## Unreleased

### Added

- **CUMULUS-3751**
- Added `change-granule-collection-s3` to move granules to a different collection.
- expects a list of granuleIds along with a new (target) collection
- moves those granule files in S3 according to pathing of target collection
- update CMR metadata file according to new collection information

## [v18.5.3] 2025-01-21

**Please note** changes in v18.5.3 may not yet be released in future versions, as this
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "MOD09GQ",
"version": "007",
"dataType": "MOD09GQ",
"process": "modis",
"duplicateHandling": "replace",
"granuleId": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}$",
"granuleIdExtraction": "(MOD09GQ\\..*)(\\.hdf|\\.cmr|_ndvi\\.jpg)",
"reportToEms": false,
"url_path": "changedCollectionPath/{cmrMetadata.Granule.Collection.ShortName}___{cmrMetadata.Granule.Collection.VersionId}",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.hdf",
"meta": {
"granuleRecoveryWorkflow": "OrcaRecoveryAdapterWorkflow",
"orca": {
"excludedFileExtensions": [".met"]
},
"s3MultipartChunksizeMb": 16
},
"files": [
{
"bucket": "protected",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.hdf$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.hdf"
},
{
"bucket": "protected",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.hdf.md5$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.hdf.md5",
"checksumFor": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.hdf$"
},
{
"bucket": "private",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.hdf\\.met$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.hdf.met"
},
{
"bucket": "protected-2",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.cmr\\.xml$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.cmr.xml"
},
{
"bucket": "public",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}_ndvi\\.jpg$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104_ndvi.jpg",
"lzards": { "backup": true }
},
{
"bucket": "private",
"regex": "^MOD09GQ\\.A[\\d]{7}\\.[\\S]{6}\\.006\\.[\\d]{13}\\.hdf\\.md5$",
"sampleFileName": "MOD09GQ.A2017025.h21v00.006.2017034065104.hdf.md5"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('The S3 Ingest Granules workflow', () => {
} catch (error) {
if (error.statusCode !== 404 &&
// remove from CMR throws a 400 when granule is missing
(error.statusCode !== 400 && !error.apiMessage.includes('No record found'))) {
!error.apiMessage.includes('No record found')) {
throw error;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
'use strict';

const { InvokeCommand } = require('@aws-sdk/client-lambda');
const { lambda } = require('@cumulus/aws-client/services');
const fs = require('fs');
const {
deleteS3Object,
s3ObjectExists,
} = require('@cumulus/aws-client/S3');
const { waitForListObjectsV2ResultCount, addCollections, addProviders } = require('@cumulus/integration-tests');

const { getGranule, deleteGranule, removePublishedGranule } = require('@cumulus/api-client/granules');
const { constructCollectionId } = require('@cumulus/message/Collections');
const { deleteExecution } = require('@cumulus/api-client/executions');
const { setupTestGranuleForIngest } = require('../../helpers/granuleUtils');
const { waitForApiStatus } = require('../../helpers/apiUtils');
const { buildAndStartWorkflow } = require('../../helpers/workflowUtils');
const { loadConfig, createTimestampedTestId, createTestSuffix, createTestDataPath, uploadTestDataToBucket } = require('../../helpers/testUtils');

describe('when ChangeGranuleCollectionS3 is called', () => {
let stackName;
let config;
let inputPayload;
let provider;
let testDataFolder;
let granuleId;
let startingFiles;
let finalFiles;
let collection;
let targetCollection;
let ingestExecutionArn;
let cleanupCollectionId;
afterAll(async () => {
try {
await removePublishedGranule({
prefix: config.stackName,
granuleId,
collectionId: cleanupCollectionId,
});
let cleanup = finalFiles.map((fileObj) => deleteS3Object(
fileObj.bucket,
fileObj.key
));
cleanup.concat(startingFiles.map((fileObj) => deleteS3Object(
fileObj.bucket,
fileObj.key
)));
cleanup = cleanup.concat([
deleteExecution({ prefix: config.stackName, executionArn: ingestExecutionArn }),
deleteGranule({ prefix: config.stackName, granuleId: granuleId }),
]);

await Promise.all(cleanup);
} catch (error) {
console.log('cleanup failed with error', error);
}
});
beforeAll(async () => {
const inputPayloadFilename = './spec/parallel/ingestGranule/IngestGranule.input.payload.json';
const providersDir = './data/providers/s3/';
const s3data = [
'@cumulus/test-data/granules/MOD09GQ.A2016358.h13v04.006.2016360104606.hdf.met',
'@cumulus/test-data/granules/MOD09GQ.A2016358.h13v04.006.2016360104606.hdf',
'@cumulus/test-data/granules/MOD09GQ.A2016358.h13v04.006.2016360104606_ndvi.jpg',
];

const collectionsDir = './data/collections/s3_MOD09GQ_006_full_ingest';
const targetCollectionsDir = './data/collections/s3_MOD09GQ_007_full_ingest_move';
const granuleRegex = '^MOD09GQ\\.A[\\d]{7}\\.[\\w]{6}\\.006\\.[\\d]{13}$';
config = await loadConfig();
stackName = config.stackName;
const testId = createTimestampedTestId(stackName, 'IngestGranuleSuccess');
const testSuffix = createTestSuffix(testId);
testDataFolder = createTestDataPath(testId);

collection = { name: `MOD09GQ${testSuffix}`, version: '006' };
targetCollection = { name: `MOD09GQ${testSuffix}`, version: '007' };
provider = { id: `s3_provider${testSuffix}` };

// populate collections, providers and test data
await Promise.all([
uploadTestDataToBucket(config.bucket, s3data, testDataFolder),
addCollections(stackName, config.bucket, collectionsDir, testSuffix, testId),
addCollections(stackName, config.bucket, targetCollectionsDir, testSuffix, testId),
addProviders(stackName, config.bucket, providersDir, config.bucket, testSuffix),
]);

const inputPayloadJson = fs.readFileSync(inputPayloadFilename, 'utf8');
// update test data filepaths
inputPayload = await setupTestGranuleForIngest(
config.bucket,
JSON.stringify({ ...JSON.parse(inputPayloadJson), pdr: undefined }),
granuleRegex,
testSuffix,
testDataFolder
);
granuleId = inputPayload.granules[0].granuleId;

ingestExecutionArn = await buildAndStartWorkflow(
stackName,
config.bucket,
'IngestAndPublishGranuleWithOrca',
collection,
provider,
inputPayload
);

await waitForApiStatus(
getGranule,
{
prefix: stackName,
granuleId: inputPayload.granules[0].granuleId,
collectionId: constructCollectionId(collection.name, collection.version),
},
'completed'
);
});

describe('under normal circumstances', () => {
let beforeAllFailed = false;
beforeAll(async () => {
startingFiles = (await getGranule({
prefix: stackName,
granuleId: granuleId,
})).files;
//upload to cumulus
try {
const { $metadata, Payload } = await lambda().send(new InvokeCommand({
FunctionName: `${stackName}-ChangeGranuleCollectionS3`,
InvocationType: 'RequestResponse',
Payload: JSON.stringify({
cma: {
meta: {
targetCollection,
collection,
buckets: config.buckets,
},
task_config: {
buckets: '{$.meta.buckets}',
collection: '{$.meta.collection}',
targetCollection: '{$.meta.targetCollection}',
},
event: {
payload: { granuleIds: [granuleId] },
},
},
}),
}));
const outputGranule = JSON.parse(new TextDecoder('utf-8').decode(Payload)).payload.granules[0];
if ($metadata.httpStatusCode >= 400) {
console.log(`lambda invocation to set up failed, code ${$metadata.httpStatusCode}`);
}
finalFiles = outputGranule.files;
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('updates the granule data in s3', async () => {
if (beforeAllFailed) fail('beforeAllFailed');
await Promise.all(finalFiles.map(async (file) => {
expect(await s3ObjectExists({ Bucket: file.bucket, Key: file.key })).toEqual(true);
}));
});
it('keeps old s3 files as well', async () => {
if (beforeAllFailed) fail('beforeAllFailed');
await Promise.all(startingFiles.map(async (file) => {
expect(await s3ObjectExists({ Bucket: file.bucket, Key: file.key })).toEqual(true);
}));
});
});
});
Loading