Skip to content

Commit

Permalink
Adding nightly testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Bradley committed Jan 7, 2025
1 parent 1b24dd8 commit 32ef68d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Start DynamoDB Local
run: docker run -d -p 8000:8000 amazon/dynamodb-local

- name: Create Rooms table for testing
run: node scripts/create-local-table.js

- name: Set up env vars
run: |
echo "AWS_ACCESS_KEY_ID=FAKE_KEY" >> $GITHUB_ENV
Expand Down
42 changes: 42 additions & 0 deletions test/integration-tests/scripts/create-local-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// scripts/create-local-table.js
// This is used to create a test table in our local copy of DynamoDB when the tests run
// This is not used if deploying infrastructure to AWS
const { DynamoDBClient, CreateTableCommand } = require('@aws-sdk/client-dynamodb');

(async () => {
try {
const client = new DynamoDBClient({
region: process.env.AWS_REGION || "us-west-2",
endpoint: process.env.DYNAMODB_ENDPOINT || "http://localhost:8000",
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID || "FAKE_KEY",
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || "FAKE_SECRET",
},
});

const tableName = process.env.DYNAMODB_TABLE_NAME || "RoomsTest";

const command = new CreateTableCommand({
TableName: tableName,
AttributeDefinitions: [
{ AttributeName: 'id', AttributeType: 'N' },
],
KeySchema: [
{ AttributeName: 'id', KeyType: 'HASH' },
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5,
},
SSESpecification: {
Enabled: true, // server-side encryption
},
});

const result = await client.send(command);
console.log(`Created table '${tableName}' locally.`, result.TableDescription?.TableStatus);
} catch (err) {
console.error('Error creating table locally:', err);
process.exit(1);
}
})();

0 comments on commit 32ef68d

Please sign in to comment.