Skip to content

Commit

Permalink
Merge branch 'main' into metadata-linking-for-second-id
Browse files Browse the repository at this point in the history
  • Loading branch information
halprin authored May 15, 2024
2 parents 3e674cd + 82e0652 commit 40b7c30
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ running...
```

This will run the API for you, so no need to run it manually.
**If you are already running the API, stop it before running the load tests or the cleanup steps won't work.**
The load tests will also spin up (and clean up) a local test DB on port 5434 that should not interfere with the local dev DB.

The `locustfile.py` that specifies the load test is located at
[`./operations/locustfile.py`](./operations/locustfile.py).
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.postgres-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.7"

services:
postgresql-test:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_DB: "intermediary-test"
POSTGRES_PASSWORD: "changeIT!" # pragma: allowlist secret
POSTGRES_USER: "intermediary"
ports:
- 5434:5432
volumes:
- ti_postgres_test_data:/var/lib/postgresql/data

volumes:
ti_postgres_test_data:
14 changes: 7 additions & 7 deletions load-execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -e
start_api() {
echo 'Starting API'
export DB_URL=localhost
export DB_PORT=5433
export DB_NAME=intermediary
export DB_PORT=5434
export DB_NAME=intermediary-test
export DB_USER=intermediary
export DB_PASS=changeIT!
export DB_SSL=require
Expand All @@ -16,14 +16,14 @@ start_api() {

start_database() {
echo 'Starting database'
docker compose -f docker-compose.postgres.yml up -d
docker compose -f docker-compose.postgres-test.yml up -d
sleep 2
echo "Database started"
}

migrate_database() {
echo 'Migrating database'
liquibase update --changelog-file ./etor/databaseMigrations/root.yml --url jdbc:postgresql://localhost:5433/intermediary --username intermediary --password 'changeIT!' --label-filter '!azure'
liquibase update --changelog-file ./etor/databaseMigrations/root.yml --url jdbc:postgresql://localhost:5434/intermediary-test --username intermediary --password 'changeIT!' --label-filter '!azure'
echo "Database migrated"
}

Expand Down Expand Up @@ -54,9 +54,9 @@ cleanup() {
kill "${API_PID}"
echo "PID ${API_PID} killed"
echo "Stopping and deleting database"
docker stop trusted-intermediary-postgresql-1
docker rm -f trusted-intermediary-postgresql-1
docker volume rm trusted-intermediary_ti_postgres_data
docker stop trusted-intermediary-postgresql-test-1
docker rm -f trusted-intermediary-postgresql-test-1
docker volume rm trusted-intermediary_ti_postgres_test_data
echo "Database stopped and deleted"
}

Expand Down
2 changes: 1 addition & 1 deletion operations/environments/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.103.0"
version = "3.103.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion operations/environments/internal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.103.0"
version = "3.103.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion operations/environments/pr/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.103.0"
version = "3.103.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion operations/environments/prd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.103.0"
version = "3.103.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion operations/environments/stg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.103.0"
version = "3.103.1"
}
}

Expand Down
2 changes: 1 addition & 1 deletion shared/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.5'

// azure sdk
implementation 'com.azure:azure-security-keyvault-secrets:4.8.2'
implementation 'com.azure:azure-security-keyvault-secrets:4.8.3'
implementation 'com.azure:azure-identity:1.12.1'

testImplementation 'org.apache.groovy:groovy:4.0.21'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.azure.core.credential.TokenRequestContext;
import com.azure.identity.DefaultAzureCredentialBuilder;
import gov.hhs.cdc.trustedintermediary.wrappers.Logger;
import gov.hhs.cdc.trustedintermediary.wrappers.database.DatabaseCredentialsProvider;
import javax.inject.Inject;

/**
* AzureDatabaseCredentialsProvider is a class responsible for providing credentials for a database
Expand All @@ -19,8 +21,13 @@ public static AzureDatabaseCredentialsProvider getInstance() {

private AzureDatabaseCredentialsProvider() {}

@Inject Logger logger;

@Override
public String getPassword() {

logger.logInfo("Fetching credentials from Azure");

return new DefaultAzureCredentialBuilder()
.build()
.getTokenSync(
Expand Down

0 comments on commit 40b7c30

Please sign in to comment.