Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update sandbox images and re-record fixtures #285

Merged
merged 3 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ Once you are finished, stop the sandbox:
make sandbox-down
```

#### Recording

Whenever tests require updating Metabase API fixtures, you need to "record" them from the running sandbox instance by executing:

```
RECORD=true make test
```

This will run tests against the actual Metabase instance, instead of fixtures, and write those responses to new fixtures. **Many tests will likely fail**, because of timestamps and other transient data, so you need to manually fix those assertions.

## Code of Conduct

All contributors are expected to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ python_version = "3.8"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"FIX001", # flake8-fixme
]
ignore = [
"E501", # line-too-long
Expand Down
2 changes: 1 addition & 1 deletion sandbox/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/metabase/metabase.db.trace.db
/metabase.db/metabase.db.trace.db
10 changes: 0 additions & 10 deletions sandbox/Dockerfile.metabase

This file was deleted.

11 changes: 3 additions & 8 deletions sandbox/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: dbt-metabase-sandbox

services:
postgres:
image: postgres:16
image: postgres:16.4
environment:
- POSTGRES_USER=${POSTGRES_USER:-}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-}
Expand All @@ -20,12 +20,7 @@ services:
restart: always

metabase:
# image: metabase/metabase:latest
build:
dockerfile: Dockerfile.metabase
args:
- MB_VERSION=0.50.5
- CURL_FLAGS=${CURL_FLAGS:-}
image: metabase/metabase:v0.50.29
environment:
- MB_SETUP_TOKEN=${MB_SETUP_TOKEN:-}
- MB_DB_FILE=/metabase-data/metabase.db
Expand All @@ -34,7 +29,7 @@ services:
networks:
- common
volumes:
- ./metabase:/metabase-data
- ./metabase.db:/metabase-data/metabase.db
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:3000/api/health"]
interval: 10s
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/27.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Orders and customers",
"archived": false,
"view_count": 425,
"view_count": 430,
"collection_position": null,
"table_id": 10,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -561,7 +561,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -578,7 +578,7 @@
"name": "Orders + Customers",
"last_query_start": "2024-06-20T05:55:59.014926Z",
"dashboard_count": 1,
"last_used_at": "2024-06-20T05:55:59.079272Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 107.22222222222223,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/28.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 212,
"view_count": 215,
"collection_position": null,
"table_id": 10,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -549,7 +549,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -566,7 +566,7 @@
"name": "Orders + Customers, Filtered by Status is completed",
"last_query_start": "2024-06-19T12:09:31.377224Z",
"dashboard_count": 1,
"last_used_at": "2024-06-19T12:09:31.689381Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 264.0,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/29.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 211,
"view_count": 214,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -58,7 +58,7 @@
"name": "Returned Order Count SQL",
"last_query_start": "2024-06-19T12:09:31.387065Z",
"dashboard_count": 1,
"last_used_at": "2024-06-19T12:09:31.486489Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 190.5,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/30.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Dummy 1",
"archived": false,
"view_count": 37,
"view_count": 39,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -58,7 +58,7 @@
"name": "Dummy",
"last_query_start": "2024-06-20T05:56:57.283068Z",
"dashboard_count": 0,
"last_used_at": "2024-06-20T05:56:57.295379Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 28.0,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/31.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Dummy 2",
"archived": false,
"view_count": 37,
"view_count": 39,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -58,7 +58,7 @@
"name": "Dummy",
"last_query_start": "2024-06-20T05:57:12.286765Z",
"dashboard_count": 0,
"last_used_at": "2024-06-20T05:57:12.297288Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 24.0,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/32.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "CTE SQL",
"archived": false,
"view_count": 28,
"view_count": 30,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -276,7 +276,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -293,7 +293,7 @@
"name": "Completed Orders CTE SQL",
"last_query_start": null,
"dashboard_count": 0,
"last_used_at": null,
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": null,
"creator_id": 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/api/card/33.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 9,
"view_count": 11,
"collection_position": null,
"table_id": 18,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -146,7 +146,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-10-12T02:16:15.081959Z",
"last_login": "2024-10-12T03:43:50.753203Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -163,7 +163,7 @@
"name": "Transactions",
"last_query_start": "2024-10-12T01:52:30.557471Z",
"dashboard_count": 0,
"last_used_at": "2024-10-12T01:52:30.585371Z",
"last_used_at": "2024-10-12T03:43:09.869884Z",
"type": "question",
"average_query_time": 58.0,
"creator_id": 1,
Expand Down
14 changes: 7 additions & 7 deletions tests/fixtures/api/collection/root/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "CTE SQL",
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Completed Orders CTE SQL",
"fully_parameterized": true,
Expand All @@ -26,7 +26,7 @@
"description": "Dummy 1",
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Dummy",
"fully_parameterized": true,
Expand All @@ -49,7 +49,7 @@
"description": "Dummy 2",
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Dummy",
"fully_parameterized": true,
Expand All @@ -72,7 +72,7 @@
"description": "Orders and customers",
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Orders + Customers",
"fully_parameterized": true,
Expand All @@ -95,7 +95,7 @@
"description": null,
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Orders + Customers, Filtered by Status is completed",
"fully_parameterized": true,
Expand All @@ -118,7 +118,7 @@
"description": null,
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Returned Order Count SQL",
"fully_parameterized": true,
Expand Down Expand Up @@ -160,7 +160,7 @@
"description": null,
"collection_position": null,
"can_write": true,
"database_id": null,
"database_id": 2,
"collection_id": null,
"name": "Transactions",
"fully_parameterized": true,
Expand Down
Loading