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

EDSC-3612, make search results export asynchronous #1588

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ef5786e
EDSC-3612: moved and refactored jsonToCsv.js
DanielJDufour Feb 13, 2023
73eefad
EDSC-3612: removed old version of jsonToCsv
DanielJDufour Feb 13, 2023
e57d59b
EDSC-3612: added exportSearchRequest
DanielJDufour Feb 13, 2023
59018aa
EDSC-3612: added deleteBucket.js
DanielJDufour Feb 13, 2023
b1aa728
EDSC-3612: refactored exportSearch to only work when triggered by SQS…
DanielJDufour Feb 13, 2023
2831db4
EDSC-3612: added papaparse and sendero to dependencies
DanielJDufour Feb 13, 2023
ba41042
EDSC-3612: added database support to exportSearchRequest
DanielJDufour Feb 14, 2023
0246617
EDSC-3612: added pg support to exportSearch and cleaned up exportSear…
DanielJDufour Feb 14, 2023
b23ef3a
EDSC-3612: added clearBucket.js
DanielJDufour Feb 15, 2023
f495642
EDSC-3612: added doesObjectExist.js to serverless/src/util/aws
DanielJDufour Feb 15, 2023
dbefb40
EDSC-3612: updated deleteBucket to use clearBucket
DanielJDufour Feb 15, 2023
2a604fc
EDSC-3612: added exportSearchCheck lambda
DanielJDufour Feb 15, 2023
56050f6
EDSC-3612: removed extra import from serverless/src/exportSearch/__t…
DanielJDufour Feb 15, 2023
5785311
EDSC-3612: updated package.json, adding pg-mem and serverless-offline…
DanielJDufour Feb 23, 2023
461830e
EDSC-3612: added elasticmq-server-1.3.9.jar to .gitignore
DanielJDufour Feb 23, 2023
a501304
EDSC-3612: added sleep and retry
DanielJDufour Feb 23, 2023
8a7de7f
EDSC-3612: updated README.md with S3 and SQS simulations
DanielJDufour Feb 23, 2023
8b5c505
EDSC-3612: added doesBucketExist
DanielJDufour Feb 23, 2023
91fd4b1
EDSC-3612: added serverless/src/util/aws/getSearchExportBucket.js
DanielJDufour Feb 23, 2023
fddda4e
EDSC-3612: added serverless/src/util/aws/getSearchExportQueueUrl.js
DanielJDufour Feb 23, 2023
3bde7a4
EDSC-3612: added getSearchExportS3Endpoint
DanielJDufour Feb 23, 2023
4eb6a26
EDSC-3612: added getS3Config.js
DanielJDufour Feb 23, 2023
4d8f1a5
EDSC-3612: added custom serverless-offline plugin for creating defaul…
DanielJDufour Feb 23, 2023
bf4fcd3
EDSC-3612: created migration for search exports table
DanielJDufour Feb 23, 2023
5177805
EDSC-3612: added exportStatusRefreshTime to static.config.json
DanielJDufour Feb 23, 2023
53a2046
EDSC-3612: added SearchExportBucket and SearchExportQueue to serverle…
DanielJDufour Feb 23, 2023
54305ee
EDSC-3612: updated serveless-configs/aws-functions.yml with search ex…
DanielJDufour Feb 23, 2023
666aeaa
EDSC-3612: require user to be logged-in in order to export search res…
DanielJDufour Feb 23, 2023
450dc53
EDSC-3612: updated GraphQlRequest search function to accept extra params
DanielJDufour Feb 23, 2023
7cb67e5
EDSC-3612: updated exportSearchRequest handler and tests, including m…
DanielJDufour Feb 23, 2023
b5a3c82
EDSC-3612: updated exportSearch and made running S3 optional for deve…
DanielJDufour Feb 23, 2023
b145791
EDSC-3612: updated exportSearchCheck
DanielJDufour Feb 23, 2023
eb6779e
EDSC-3612: updated actions/exportSearch.js
DanielJDufour Feb 23, 2023
23f2576
EDSC-3612: updated serverless.yml
DanielJDufour Feb 23, 2023
cada0e7
EDSC-3612: updated package-lock.json
DanielJDufour Feb 23, 2023
5abf6a5
EDSC-3612: updated exportSearch action and test
DanielJDufour Feb 24, 2023
b48ee26
EDSC-3612: updated export search tests to work async and added s3:res…
DanielJDufour Feb 24, 2023
4171a9f
EDSC-3612: updated github ci workflow to install and run ElasticMQ an…
DanielJDufour Feb 24, 2023
9951e41
EDSC-3612: install moto with pip
DanielJDufour Feb 24, 2023
384c9ff
EDSC-3612: hopefully fixed edge cases around disabling/enabling net c…
DanielJDufour Feb 25, 2023
7336562
EDSC-3612: clear nock interceptors before each search export-related …
DanielJDufour Feb 25, 2023
c9bd85c
EDSC-3612: updated getSearchExportQueueUrl to return 0.0.0.0 when doi…
DanielJDufour Feb 25, 2023
7ad1d17
EDSC-3612: make sure testSearchExportQueueUrl uses 0.0.0.0 not localhost
DanielJDufour Feb 25, 2023
7a2b558
Merge branch 'master' into EDSC-3612
DanielJDufour Feb 27, 2023
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
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@ jobs:
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- uses: actions/setup-python@v4
- name: Install local S3
run: pip install moto[server]
- name: Install local SQS
run: npm run sqs:install
- name: Copy secrets example file
run: npm run copy-secrets
- name: Run Jest tests
run: npm run silent-test -- --shard=${{ matrix.shard }}
run: |
npm run s3 &
npm run sqs &
sleep 5
npm run silent-test -- --shard=${{ matrix.shard }}
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
cypress:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ cypress/videos
overrideStatic.config.json
cypress-coverage
.nyc_output
elasticmq-server-1.3.9.jar
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ It builds upon several public-facing services provided by EOSDIS, including the

## Application Installation and Usage

The Earthdata Search application uses Node v14 and Webpack 5 to generate static assets. The serverless application utilizes the following AWS services (important to note if deploying to an AWS environment):
The Earthdata Search application uses Node.js and Webpack to generate static assets. The serverless application utilizes the following AWS services (important to note if deploying to an AWS environment):

- S3
- We highly recommend using CloudFront in front of S3.
- We highly recommend using CloudFront in front of S3. We use [moto](https://github.com/getmoto/moto) to simulate S3 during local development. If you have [homebrew](https://brew.sh/) installed, you can install moto by running `npm s3:install` or by following the guide [here](http://docs.getmoto.org/en/latest/docs/getting_started.html#installing-moto).
- SQS
- We use [ElasticMQ](https://github.com/softwaremill/elasticmq) to simulate SQS during local development. If you have curl installed, you can install ElasticMQ by running `npm sqs:install` or by following the instructions [here](https://github.com/softwaremill/elasticmq)
- API Gateway
- Lambda
- Cloudwatch (Events)
Expand Down Expand Up @@ -62,6 +63,7 @@ Earthdata Search utilizes the [Serverless Framework](https://serverless.com/) fo
##### PostgreSQL

Earthdata Search uses PostgreSQL in production on AWS RDS. If you don't already have it installed, [download](https://www.postgresql.org/download/) and install it to your development environment.
We also use [pg-mem](https://github.com/oguimbal/pg-mem) for some tests and may roll it out to more tests in the future. pg-mem is automatically installed along with all the other dependencies when you run `npm install`.

**Recommended:** Use Homebrew

Expand Down Expand Up @@ -131,15 +133,13 @@ The [serverless framework](https://serverless.com/framework/docs/providers/aws/)

- SQS

While there is an sqs-offline plugin for serverless it still requires an actual queue be running, we may investigate this in the future but for now sqs functionality isn't available while developing locally which means the following pieces of functionality will not operate locally:

- Generating Colormaps
We are currently using [ElasticMQ](https://github.com/softwaremill/elasticmq) to simulate SQS during local development. However we haven't yet rolled this functionality out to colormap generation and other parts of the code.

#### Running API Gateway and Lambda Locally

Running the following command will spin up API Gateway and Lambda locally which will open up a vast majority of the functionality the backend offers.

serverless offline
npm run api

This will provide access to API Gateway at [http://localhost:3001](http://localhost:3001)

Expand All @@ -151,6 +151,8 @@ Once the project is built, you must ensure that the automated unit tests pass:

npm run test

You must run `npm run s3` and `npm run sqs` before running the Jest tests for exporting search results.

### Run the Automated [Cypress](https://www.cypress.io/) tests

You must also ensure that the automated integration tests pass:
Expand Down
6 changes: 6 additions & 0 deletions __mocks__/crypto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// copy properties of the built-in crypto module to the mock crypto
const crypto = Object.assign({}, require("node:crypto"))

crypto.randomUUID = () => '00000000-0000-0000-0000-000000000000'

module.exports = crypto
36 changes: 36 additions & 0 deletions migrations/1676386726943_exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
exports.shorthands = undefined

exports.up = (pgm) => {
pgm.createTable('exports', {
id: 'id',
user_id: {
type: 'integer',
references: 'users'
},
key: {
type: 'varchar(1000)',
notNull: true
},
state: {
type: 'varchar(1000)' // 'REQUESTED', 'PROCESSING', 'DONE', or 'FAILED'
},
filename: {
type: 'varchar(1000)',
notNull: true
},
updated_at: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp')
},
created_at: {
type: 'timestamp',
notNull: true,
default: pgm.func('current_timestamp')
}
})
}

exports.down = (pgm) => {
pgm.dropTable('exports')
}
Loading