Skip to content

Commit

Permalink
fix: use _one/_two prefix for tenant db names
Browse files Browse the repository at this point in the history
fix(ci): use new env variable for first tenant db
fix(ci): we need both env vars now
fix(ci): move away from TENANT_TEST
  • Loading branch information
leostera committed Nov 17, 2023
1 parent 21e1631 commit 5fa0794
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"runServices": [
"dev",
"database-root",
"database-tenant"
"database-tenant",
"phpmyadmin" // uncomment if adminer should run to see the database
"phpmyadmin"
],
"workspaceFolder": "/workspace",
"postCreateCommand": "/bin/bash .devcontainer/wait-for-database.sh -d db-root/test -d db-tenant/dev_zhaw -d db-tenant/test_econ .devcontainer/postCreate.sh",
Expand Down
19 changes: 17 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# all these settings are configured for the DevContainer by default. Use this example file to override the defaults.
ECON_PACKAGE_REGISTRY_READ_TOKEN=1234
DATABASE_URL_TENANT_TEST=mariadb://root:<password>@database-tenant:3306/test_econ
SIHL_ENV=development
VERSION=dev
PUBLIC_URL=http://localhost:3000

ECON_PACKAGE_REGISTRY_READ_TOKEN=<token>

DATABASE_URL=mariadb://root@0.0.0.0:3316/development
DATABASE_URL_TENANT_ONE=mariadb://root@0.0.0.0:3317/test_econ
DATABASE_URL_TENANT_TWO=mariadb://root@0.0.0.0:3317/test_zhaw

DATABASE_SKIP_DEFAULT_POOL_CREATION=true
DATABASE_CHOOSE_POOL=root
OPAMSOLVERTIMEOUT=180
EMAIL_RATE_LIMIT=100
MATCHER_MAX_CAPACITY=80
MATCHER_RUN=false

# Mail intercept
SMTP_SENDER=test@econ.uzh.ch
TEST_EMAIL=test@econ.uzh.ch

# Matcher service
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ jobs:
uses: addnab/docker-run-action@v3
env:
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-root:3306/${{ env.MYSQL_DATABASE }}
DATABASE_URL_TENANT_TEST: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-tenant:3306/${{ env.MYSQL_DATABASE }}
DATABASE_URL_TENANT_ONE: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-tenant:3306/${{ env.MYSQL_DATABASE }}
SIHL_ENV: test
SMTP_SENDER: test@econ.uzh.ch
TEST_EMAIL: test@econ.uzh.ch
with:
image: ocaml/opam:debian-10-ocaml-4.14
options: -v ${{ github.workspace }}:/app -w /app -e DATABASE_URL -e DATABASE_URL_TENANT_TEST -e TEST_EMAIL -e SMTP_SENDER -e SIHL_ENV -e EMAIL_RATE_LIMIT -e MATCHER_MAX_CAPACITY
options: -v ${{ github.workspace }}:/app -w /app -e DATABASE_URL -e DATABASE_URL_TENANT_ONE -e TEST_EMAIL -e SMTP_SENDER -e SIHL_ENV -e EMAIL_RATE_LIMIT -e MATCHER_MAX_CAPACITY
run: |
# Reclaim required directory permissions
sudo chown -R opam .
Expand Down
8 changes: 4 additions & 4 deletions pool/database/seed/seed_tenant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ let create () =
if Sihl.Configuration.is_test ()
then (
let database_url =
Sihl.Configuration.read_string "DATABASE_URL_TENANT_TEST"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_TEST undefined"
Sihl.Configuration.read_string "DATABASE_URL_TENANT_ONE"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_ONE undefined"
in
[ ( "Econ test"
, "description"
Expand All @@ -46,7 +46,7 @@ let create () =
[ ( "Econ UZH"
, "description"
, "localhost:3017"
, Sihl.Configuration.read_string "DATABASE_URL_TENANT_TEST"
, Sihl.Configuration.read_string "DATABASE_URL_TENANT_ONE"
|> Option.value
~default:"mariadb://root@database-tenant:3306/dev_econ"
, "econ-uzh"
Expand All @@ -57,7 +57,7 @@ let create () =
; ( "ZHAW"
, "description"
, "pool.zhaw.ch"
, Sihl.Configuration.read_string "DATABASE_URL_TENANT_TEST_ZHAW"
, Sihl.Configuration.read_string "DATABASE_URL_TENANT_TWO"
|> Option.value
~default:"mariadb://root@database-tenant:3306/dev_zhaw"
, "zhaw"
Expand Down
4 changes: 2 additions & 2 deletions pool/test/database_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Data = struct

let database =
let url =
Sihl.Configuration.read_string "DATABASE_URL_TENANT_TEST"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_TEST undefined"
Sihl.Configuration.read_string "DATABASE_URL_TENANT_ONE"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_ONE undefined"
|> Url.create
|> get_exn
in
Expand Down
4 changes: 2 additions & 2 deletions pool/test/tenant_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module Data = struct
let url = "pool.econ.uzh.ch"

let database_url =
Sihl.Configuration.read_string "DATABASE_URL_TENANT_TEST"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_TEST undefined"
Sihl.Configuration.read_string "DATABASE_URL_TENANT_ONE"
|> CCOption.get_exn_or "DATABASE_URL_TENANT_ONE undefined"
;;

let database_label = "econ-test"
Expand Down

0 comments on commit 5fa0794

Please sign in to comment.