Skip to content

Commit 3765c1a

Browse files
plcplcSamirTalwar
andauthored
Add tests of composite types to Aurora (#259)
### What This PR extends the tests of composite types to cover Aurora. This is a follow-up to #257, and will be rebased once that is merged. ### How In order to standardise the (rare) management we need to be able to do on our Aurora test instance this PR adds a script that inserts all the test data currently in use. Currently, this means: The chinook dataset, and definitions of composite types. --------- Co-authored-by: Samir Talwar <[email protected]>
1 parent 992e816 commit 3765c1a

6 files changed

+140
-4
lines changed

crates/tests/databases-tests/src/aurora/query_tests.rs

-4
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,24 @@ mod basic {
4040
}
4141

4242
#[tokio::test]
43-
#[ignore = "Pending update of aurora test database"]
4443
async fn select_composite_column_simple() {
4544
let result = run_query(create_router().await, "select_composite_column_simple").await;
4645
insta::assert_json_snapshot!(result);
4746
}
4847

4948
#[tokio::test]
50-
#[ignore = "Pending update of aurora test database"]
5149
async fn select_composite_column_complex() {
5250
let result = run_query(create_router().await, "select_composite_column_complex").await;
5351
insta::assert_json_snapshot!(result);
5452
}
5553

5654
#[tokio::test]
57-
#[ignore = "Pending update of aurora test database"]
5855
async fn select_composite_variable_simple() {
5956
let result = run_query(create_router().await, "select_composite_variable_simple").await;
6057
insta::assert_json_snapshot!(result);
6158
}
6259

6360
#[tokio::test]
64-
#[ignore = "Pending update of aurora test database"]
6561
async fn select_composite_variable_complex() {
6662
let result = run_query(create_router().await, "select_composite_variable_complex").await;
6763
insta::assert_json_snapshot!(result);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: crates/tests/databases-tests/src/aurora/query_tests.rs
3+
expression: result
4+
---
5+
[
6+
{
7+
"rows": [
8+
{
9+
"result": {
10+
"name": {
11+
"first_name": "John",
12+
"last_name": "Doe"
13+
},
14+
"address": {
15+
"address_line_1": "Somstreet 159",
16+
"address_line_2": "Second door to the right"
17+
}
18+
}
19+
}
20+
]
21+
}
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: crates/tests/databases-tests/src/aurora/query_tests.rs
3+
expression: result
4+
---
5+
[
6+
{
7+
"rows": [
8+
{
9+
"result": {
10+
"address_line_1": "Somstreet 159",
11+
"address_line_2": "Second door to the right"
12+
}
13+
}
14+
]
15+
}
16+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
source: crates/tests/databases-tests/src/aurora/query_tests.rs
3+
expression: result
4+
---
5+
[
6+
{
7+
"rows": [
8+
{
9+
"result": {
10+
"name": {
11+
"first_name": "John",
12+
"last_name": "Doe"
13+
},
14+
"address": {
15+
"address_line_1": "Somstreet 159",
16+
"address_line_2": "Second door to the right"
17+
}
18+
}
19+
}
20+
]
21+
},
22+
{
23+
"rows": [
24+
{
25+
"result": {
26+
"name": {
27+
"first_name": "Jane",
28+
"last_name": "Doe"
29+
},
30+
"address": {
31+
"address_line_1": "Somstreet 159",
32+
"address_line_2": "Second door to the right"
33+
}
34+
}
35+
}
36+
]
37+
}
38+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
source: crates/tests/databases-tests/src/aurora/query_tests.rs
3+
expression: result
4+
---
5+
[
6+
{
7+
"rows": [
8+
{
9+
"result": {
10+
"address_line_1": "Somstreet 159",
11+
"address_line_2": "Second door to the right"
12+
}
13+
}
14+
]
15+
},
16+
{
17+
"rows": [
18+
{
19+
"result": {
20+
"address_line_1": "Somstreet 159",
21+
"address_line_2": "Second door to the right"
22+
}
23+
}
24+
]
25+
}
26+
]

scripts/reinitialize-aurora.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -e -u -o pipefail
3+
4+
# This shell script reinitializes the aurora test database.
5+
# The environment variable AURORA_CONNECTION_STRING (typically set in
6+
# .envrc.local) is assumed to hold the authenticated connection string to the
7+
# writable aurora instance to act on.
8+
9+
# In order to avoid accidental loss of data the database must be suitably empty before proceeding.
10+
11+
number_of_existing_relations="$(
12+
psql "$AURORA_CONNECTION_STRING" -t <<QUERY
13+
SELECT
14+
COUNT(*)
15+
FROM pg_class
16+
WHERE
17+
relnamespace = 'public'::regnamespace
18+
QUERY
19+
)"
20+
21+
if [ "$number_of_existing_relations" != 0 ];
22+
then
23+
echo "There appears to be ${number_of_existing_relations} relations still left in the \"public\" namespace."
24+
echo 'Bailing out.'
25+
exit 1
26+
fi
27+
28+
psql "$AURORA_CONNECTION_STRING" <<DOC
29+
30+
-- Ingesting the Chinook dataset takes about 15 minutes on my machine. I put
31+
-- this down to the file using one INSERT statement per row of data rather than
32+
-- the more efficient COPY command.
33+
-- \i static/chinook-postgres.sql
34+
35+
\i static/composite-types-simple.sql
36+
\i static/composite-types-complex.sql
37+
38+
DOC

0 commit comments

Comments
 (0)