diff --git a/airbyte-integrations/bases/source-acceptance-test/CHANGELOG.md b/airbyte-integrations/bases/source-acceptance-test/CHANGELOG.md index e401fb627dc63..3a7c499728675 100644 --- a/airbyte-integrations/bases/source-acceptance-test/CHANGELOG.md +++ b/airbyte-integrations/bases/source-acceptance-test/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.2.2 +Backward compatibility tests: improve `check_if_cursor_field_was_changed` to make it less radical and allow stream addition to catalog.[#15835](https://github.com/airbytehq/airbyte/pull/15835/) + ## 0.2.1 Don't fail on updating `additionalProperties`: fix IndexError [#15532](https://github.com/airbytehq/airbyte/pull/15532/) diff --git a/airbyte-integrations/bases/source-acceptance-test/Dockerfile b/airbyte-integrations/bases/source-acceptance-test/Dockerfile index a885306672eb0..4d33655d92784 100644 --- a/airbyte-integrations/bases/source-acceptance-test/Dockerfile +++ b/airbyte-integrations/bases/source-acceptance-test/Dockerfile @@ -33,7 +33,7 @@ COPY pytest.ini setup.py ./ COPY source_acceptance_test ./source_acceptance_test RUN pip install . -LABEL io.airbyte.version=0.2.1 +LABEL io.airbyte.version=0.2.2 LABEL io.airbyte.name=airbyte/source-acceptance-test ENTRYPOINT ["python", "-m", "pytest", "-p", "source_acceptance_test.plugin", "-r", "fEsx"] diff --git a/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/utils/backward_compatibility.py b/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/utils/backward_compatibility.py index 84485c08bb77a..2968013995a50 100644 --- a/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/utils/backward_compatibility.py +++ b/airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/utils/backward_compatibility.py @@ -227,5 +227,6 @@ def check_if_stream_was_removed(self, diff: DeepDiff): def check_if_cursor_field_was_changed(self, diff: DeepDiff): """Check if a default cursor field value was changed.""" - if diff: + invalid_changes = {"values_changed", "iterable_item_added", "iterable_item_removed"} + if any([change in invalid_changes for change in diff.keys()]): self._raise_error("The value of 'default_cursor_field' was changed", diff) diff --git a/airbyte-integrations/bases/source-acceptance-test/unit_tests/test_backward_compatibility.py b/airbyte-integrations/bases/source-acceptance-test/unit_tests/test_backward_compatibility.py index 05a72e407d598..e9bc4dd341eef 100644 --- a/airbyte-integrations/bases/source-acceptance-test/unit_tests/test_backward_compatibility.py +++ b/airbyte-integrations/bases/source-acceptance-test/unit_tests/test_backward_compatibility.py @@ -944,7 +944,7 @@ def as_pytest_param(self): # Checking that all transitions in FAILING_SPEC_TRANSITIONS have should_fail == True to prevent typos assert all([transition.should_fail for transition in FAILING_SPEC_TRANSITIONS]) # Checking that all transitions in VALID_SPEC_TRANSITIONS have should_fail = False to prevent typos -assert not all([transition.should_fail for transition in VALID_SPEC_TRANSITIONS]) +assert all([not transition.should_fail for transition in VALID_SPEC_TRANSITIONS]) ALL_SPEC_TRANSITIONS_PARAMS = [transition.as_pytest_param() for transition in FAILING_SPEC_TRANSITIONS + VALID_SPEC_TRANSITIONS] @@ -1103,9 +1103,63 @@ def test_validate_previous_configs(previous_connector_spec, actual_connector_spe ), }, ), + Transition( + name="Adding a stream but changing cursor should fail.", + should_fail=True, + previous={ + "test_stream": AirbyteStream.parse_obj( + { + "name": "test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + "default_cursor_field": ["a"], + } + ), + }, + current={ + "test_stream": AirbyteStream.parse_obj( + { + "name": "test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + "default_cursor_field": ["b"], + } + ), + "other_test_stream": AirbyteStream.parse_obj( + { + "name": "other_test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + } + ), + }, + ), ] VALID_CATALOG_TRANSITIONS = [ + Transition( + name="Adding a stream to a catalog should not fail.", + should_fail=False, + previous={ + "test_stream": AirbyteStream.parse_obj( + { + "name": "test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + } + ) + }, + current={ + "test_stream": AirbyteStream.parse_obj( + { + "name": "test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + } + ), + "other_test_stream": AirbyteStream.parse_obj( + { + "name": "other_test_stream", + "json_schema": {"properties": {"user": {"type": "object", "properties": {"username": {"type": "string"}}}}}, + } + ), + }, + ), Transition( name="Making a field nullable should not fail.", should_fail=False, @@ -1197,7 +1251,7 @@ def test_validate_previous_configs(previous_connector_spec, actual_connector_spe # Checking that all transitions in FAILING_CATALOG_TRANSITIONS have should_fail == True to prevent typos assert all([transition.should_fail for transition in FAILING_CATALOG_TRANSITIONS]) # Checking that all transitions in VALID_CATALOG_TRANSITIONS have should_fail = False to prevent typos -assert not all([transition.should_fail for transition in VALID_CATALOG_TRANSITIONS]) +assert all([not transition.should_fail for transition in VALID_CATALOG_TRANSITIONS]) ALL_CATALOG_TRANSITIONS_PARAMS = [transition.as_pytest_param() for transition in FAILING_CATALOG_TRANSITIONS + VALID_CATALOG_TRANSITIONS]