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

Expected Records to .jsonl format #20850

Merged
merged 5 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tests:
configured_catalog_path: "sample_files/configured_catalog.json"
empty_streams: []
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_empty_streams_fixture(mocker, test_strictness_level, basic_read_test_co
TEST_CONFIGURED_CATALOG,
{EmptyStreamConfiguration(name="test_stream_b"), EmptyStreamConfiguration(name="test_stream_c")},
[{"stream": "test_stream_a", "data": {"k": "foo"}, "emitted_at": 1634387507000}],
ExpectedRecordsConfig(path="expected_records.json"),
ExpectedRecordsConfig(path="expected_records.jsonl"),
False,
id="High strictness level: test_stream_b and test_stream_c are declared as empty streams, expected records only contains test_stream_a record -> Not failing",
),
Expand All @@ -106,7 +106,7 @@ def test_empty_streams_fixture(mocker, test_strictness_level, basic_read_test_co
TEST_CONFIGURED_CATALOG,
set(),
[{"stream": "test_stream_a", "data": {"k": "foo"}, "emitted_at": 1634387507000}],
ExpectedRecordsConfig(path="expected_records.json"),
ExpectedRecordsConfig(path="expected_records.jsonl"),
True,
id="High strictness level: test_stream_b and test_stream_c are not declared as empty streams, expected records only contains test_stream_a record -> Failing",
),
Expand All @@ -115,7 +115,7 @@ def test_empty_streams_fixture(mocker, test_strictness_level, basic_read_test_co
TEST_CONFIGURED_CATALOG,
{EmptyStreamConfiguration(name="test_stream_b")},
[{"stream": "test_stream_a", "data": {"k": "foo"}, "emitted_at": 1634387507000}],
ExpectedRecordsConfig(path="expected_records.json"),
ExpectedRecordsConfig(path="expected_records.jsonl"),
True,
id="High strictness level: test_stream_b is declared as an empty stream, test_stream_c is not declared as empty streams, expected records only contains test_stream_a record -> Failing",
),
Expand All @@ -142,7 +142,7 @@ def test_empty_streams_fixture(mocker, test_strictness_level, basic_read_test_co
TEST_CONFIGURED_CATALOG,
set(),
[{"stream": "test_stream_a", "data": {"k": "foo"}, "emitted_at": 1634387507000}],
ExpectedRecordsConfig(path="expected_records.json"),
ExpectedRecordsConfig(path="expected_records.jsonl"),
False,
id="Low strictness level, no empty stream, incomplete expected records -> Not failing",
),
Expand All @@ -154,7 +154,7 @@ def test_expected_records_by_stream_fixture(
mocker.patch.object(conftest.pytest, "fail")

base_path = tmp_path
with open(f"{base_path}/expected_records.json", "w") as expected_records_file:
with open(f"{base_path}/expected_records.jsonl", "w") as expected_records_file:
for record in expected_records:
expected_records_file.write(json.dumps(record) + "\n")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ acceptance_tests:
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ acceptance_tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
bypass_reason: "This connector does not implement incremental sync"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: no
Expand Down Expand Up @@ -47,4 +47,4 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog_report.json"
ignored_fields:
"sponsored_products_report_stream": ["updatedAt"]
timeout_seconds: 3600
timeout_seconds: 3600
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# expect_records:
# path: "integration_tests/expected_records.txt"
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental: # TODO if your connector does not implement incremental sync, remove this block
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ acceptance_tests:
- config_path: "secrets/sat-config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.json"
path: "integration_tests/expected_records.jsonl"
full_refresh:
tests:
- config_path: "secrets/sat-config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: ["subscription_stream"]
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ acceptance_tests:
- name: kpi_daily_active_users
bypass_reason: "no data"
expect_records:
# `cards_analytics` stream records are not included to `expected_records.txt`
# `cards_analytics` stream records are not included to `expected_records.jsonl`
# This stream returns summary by given `ending_at` date + `length`, and so
# as `ending_at` date depends on a day when tests run, we lose previous records in current response and tests fail.
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ acceptance_tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ acceptance_tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ acceptance_tests:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams:
empty_streams:
- name: formulas
bypass_reason: "no records"
- name: permissions
bypass_reason: "no records"
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
bypass_reason: "This connector does not implement incremental sync"
full_refresh:
tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ acceptance_tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
timeout_seconds: 1800
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
bypass_reason: "This connector does not implement incremental sync"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: yes
extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ acceptance_tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
bypass_reason: "This connector does not implement incremental sync"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
# TODO uncomment this block this block if your connector implements incremental sync:
# tests:
# - config_path: "secrets/config.json"
# configured_catalog_path: "integration_tests/configured_catalog.json"
# future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
timeout_seconds: 3600
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
full_refresh:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ acceptance_tests:
tests:
- config_path: "secrets/config.json"
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
incremental:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ acceptance_tests:
- name: page_insights
bypass_reason: "Data is not permanent"
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: no
extra_records: yes
Expand All @@ -42,4 +42,4 @@ acceptance_tests:
page:
- "posts/paging/next"
- "published_posts/paging/next"
- "feed/paging/next"
- "feed/paging/next"
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tests:
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
expect_records:
path: "integration_tests/expected_records.txt"
path: "integration_tests/expected_records.jsonl"
extra_fields: no
exact_order: yes
extra_records: no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,33 @@ Connector.
- `setup_database.fql`: Evaling this file with the fauna shell will setup the local database for
testing. See below for instructions on running the connector locally.
- `secret_config.json`: This is the config that should be placed in `secrets/config.json`, and
will produce the records at `integration_tests/expected_records.txt`. Note that if you run this
will produce the records at `integration_tests/expected_records.jsonl`. Note that if you run this
yourself, you will need to manually setup the database, and the `ts` field will be incorrect.

# Running locally

These examples use the Fauna Shell, which can be downloaded here: https://github.com/fauna/fauna-shell

First, start a local fauna container:

```
docker run --rm --name faunadb -p 8443:8443 fauna/faunadb
```

In another terminal, cd into the connector directory:

```
cd airbyte-integrations/connectors/source-fauna
```

Once started the container is up, setup the database:

```
fauna eval "$(cat examples/setup_database.fql)" --domain localhost --port 8443 --scheme http --secret secret
```

Finally, run the connector:

```
python main.py spec
python main.py check --config examples/config_localhost.json
Expand Down
Loading