alan-turing-institute / data-safe-haven

https://data-safe-haven.readthedocs.io
BSD 3-Clause "New" or "Revised" License
60 stars 15 forks source link

Database smoke tests failing on Tier 3 SRE #2123

Closed craddm closed 2 months ago

craddm commented 2 months ago

:white_check_mark: Checklist

:computer: System information

:package: Packages

List of packages ```none Paste list of packages here ```

:no_entry_sign: Describe the problem

Smoke tests involving databases are failing for both Python and R

:deciduous_tree: Log messages

Relevant log messages ```none root@shm-green-sre-noteasybeing-vm-workspace-01:/usr/local/smoke_tests# bats run_all_tests.bats -f "database" ✗ MS SQL database (Python) (in test file run_all_tests.bats, line 101) `[ "$status" -eq 0 ]' failed ✗ MS SQL database (R) (in test file run_all_tests.bats, line 111) `[ "$status" -eq 0 ]' failed ✗ Postgres database (Python) (in test file run_all_tests.bats, line 119) `[ "$status" -eq 0 ]' failed ```

:recycle: To reproduce

jemrobinson commented 2 months ago

I just got this result from 3035d81 when running the smoke tests as root:

root@shm-pink-sre-fuschia-vm-workspace-02:/usr/local/smoke_tests# bats run_all_tests.bats 
 ✓ Mounted drives (/data) 
 ✓ Mounted drives (/home) 
 ✓ Mounted drives (/output) 
 ✓ Mounted drives (/shared) 
 ✓ Python package repository 
 ✓ R package repository 
 ✓ Python functionality 
 ✓ R functionality 
 ✓ MS SQL database (Python) 
 ✓ MS SQL database (R) 
 ✓ Postgres database (Python) 
 ✓ Postgres database (R) 

12 tests, 0 failures
jemrobinson commented 2 months ago

Is this the issue (in test_databases.sh):

https://github.com/alan-turing-institute/data-safe-haven/blob/develop/data_safe_haven/resources/workspace/ansible/files/usr/local/smoke_tests/test_databases.sh#L25-L30

we make this assumption about the database hostname

sre_prefix="$(hostname | cut -d "-" -f 1-4)"
hostname="${sre_prefix}-db-server-mssql"

while we should probably pass this in as a variable.

jemrobinson commented 2 months ago

It's not this - it's incorrect escaping when we write special characters to /etc/database_credential.

craddm commented 2 months ago

Fixed by #2125