aurora
Intro
Depot-local Aurora mimics the depot-lambda gateway interface for Aurora. This gives the ability to test services locally that will use an actual Depot Aurora location in a live scenario.
Example
The depot.start() method, starts
- Each data store in its own container
- Local Depot configured with each data store
const depot = new DepotLocal({
depot: {
},
//dynamo db is required for aurora tests
dynamodb: {
},
postgres: {} //creates and starts postgres docker container (or custom connection to an external PostgreSQL host)
});
beforeAll(async () => {
await depot.start();
});
afterAll(async () => {
await depot.stop();
});
Once started, you can deploy a new Environment to your Depot local instance,
using depot.deploy(). Use a helper method to easily construct an environment,
for example from a namespace.
const namespace = Schemas.fromYamlFiles("test/schema/pet.yml");
const environment = new EnvironmentBuilder(namespace)
.location(LocationBuilder.postgresDb(depotLocal))
.build();
Each deployed dataset has its own DepotApi, for simple tests there will be only one.
const api = depot.deploy(environment).api(0);
the environment and api values should not be shared, but private to each individual test. This
will ensure Depot-Local provides an empty dataset at each execution.
Configuration
It is possible to re-point the Depot Local instance to an externally hosted PostgreSQL instance. By default Depot Local will start a PostgreSQL container which sits on the same Docker bridge network that Depot Local creates for each run.
To re-configure Depot Local to use your own PostgreSQL instance, you define the connection details in your depot.properties file. Using these connection override settings will cause Depot Local to bypass starting a PostgreSQL container and the details will used as the connection string and credentials for your custom host.
depot-local.pg.host=host.docker.internal
depot-local.pg.port=5433
depot-local.pg.db=custom_db # this database should already exist on your custom PostgreSQL instance
depot-local.pg.username=postgres
depot-local.pg.password=YourPassword
Because Depot Local runs inside a custom Docker bridge network, in order to 'talk back' to a custom PostgreSQL
instance running on your local Docker host machine, you should use the host.docker.internal hostname as the host.
- A custom PostgreSQL instance can be used as long as the Depot Local instance inside the Docker bridge network is able to reach it through the network. This means out of the bridge network, and through your host network.
- The database referred to by
depot-local.pg.dbshould already exist on your PostgreSQL instance before you execute a Depot Local run.
Requests
The api can then be used to make requests to your environment.
const create = await api.create({
schema: "pet.Pet",
data: {
name: "Ren",
age: 2
}
});
Transaction requests
Aurora transaction over Depot-local is not yet supported.