Local test environment: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
|||
| Line 16: | Line 16: | ||
= DynamoDB Local = | = DynamoDB Local = | ||
... | * https://www.npmjs.com/package/serverless-dynamodb-local | ||
* have setting in powertools dynamo client, if IS_LOCAL (set by serverless offline running) then will add connection settings below | |||
DynamoDB local connection settings are hardcoded, if need to change things like port maybe we can find some hack like local environment variable, rather than polluting serverless.yml etc.. | |||
* Serverless have a small module to work with this, we could copy its code if needed: | |||
* https://github.com/99xt/serverless-dynamodb-client/blob/master/index.js | |||
* thinking if starting multiple services together on local can use the same dynamodb local database, just placing multiple tables in it | |||
* default is to store data in memory, which gets destroyed each time we stop, if this becomes unmanageable or if we want to maintain state it is possible to save to file | |||
* all resource serverless.yml have below code, used only for DynamoDB local | |||
* (not sure) we do not migrate or seed here because we want to do that per service (eg in a script), and might have different seeds for different situations | |||
<syntaxhighlight lang="JavaScript"> | |||
custom: | |||
dynamodb: | |||
# If you only want to use DynamoDB Local in some stages, declare them here | |||
stages: | |||
- Dev | |||
start: | |||
port: 8000 | |||
inMemory: true | |||
heapInitial: 200m #not sure correct setting, can leave off | |||
heapMax: 1g #not sure correct setting, can leave off | |||
migrate: true | |||
seed: true | |||
seed: | |||
default: | |||
sources: | |||
- table: ${self:service}${self:provider.stage}Config | |||
sources: [./__test__/dynamodb_seed_data/default/Config.json] | |||
</syntaxhighlight> | |||
to install into a project, in resource dir: | |||
<syntaxhighlight lang="Bash">npm install --save-dev serverless-dynamodb-local</syntaxhighlight> | |||
= See also = | = See also = | ||
* [[2019-01-01 - Mocking AWS resources in local test environment]] | * [[2019-01-01 - Mocking AWS resources in local test environment]] | ||
Revision as of 04:39, 11 November 2020
Overview
Each repository is a micro-service that performs has responsibility for one part of the The Izara Project, although each is meant to be used as part of a network of interconnected micro-services when a single repository is cloned the first level of testing is at the self contained local level.
Unit tests
Most local tests will be unit tests, these tests are built in two ways:
- created in the __test__/unit directory for each serverless project in the repository
- generated from integration tests defined in the Integration Test Config service
Serverless Local (?)
...
DynamoDB Local
- https://www.npmjs.com/package/serverless-dynamodb-local
- have setting in powertools dynamo client, if IS_LOCAL (set by serverless offline running) then will add connection settings below
DynamoDB local connection settings are hardcoded, if need to change things like port maybe we can find some hack like local environment variable, rather than polluting serverless.yml etc..
- Serverless have a small module to work with this, we could copy its code if needed:
- https://github.com/99xt/serverless-dynamodb-client/blob/master/index.js
- thinking if starting multiple services together on local can use the same dynamodb local database, just placing multiple tables in it
- default is to store data in memory, which gets destroyed each time we stop, if this becomes unmanageable or if we want to maintain state it is possible to save to file
- all resource serverless.yml have below code, used only for DynamoDB local
- (not sure) we do not migrate or seed here because we want to do that per service (eg in a script), and might have different seeds for different situations
custom:
dynamodb:
# If you only want to use DynamoDB Local in some stages, declare them here
stages:
- Dev
start:
port: 8000
inMemory: true
heapInitial: 200m #not sure correct setting, can leave off
heapMax: 1g #not sure correct setting, can leave off
migrate: true
seed: true
seed:
default:
sources:
- table: ${self:service}${self:provider.stage}Config
sources: [./__test__/dynamodb_seed_data/default/Config.json]
to install into a project, in resource dir:
npm install --save-dev serverless-dynamodb-local