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

SAT: improve check_if_cursor_field_was_changed to make it less strict #15835

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented Aug 22, 2022

What

Closing #15692

The current implementation of check_if_cursor_field_was_changed is too strict: it fails if a new stream is added to the catalog:.

How

  • Add a test case to make sure adding a stream to a catalog does not fail
  • Explicitly fail if a diff exists for specific changes:
    def check_if_cursor_field_was_changed(self, diff: DeepDiff):
    """Check if a default cursor field value was changed."""
    invalid_changes = {"values_changed", "iterable_item_added", "iterable_item_removed"}
    if diff and set(diff.keys()).issubset(invalid_changes):
    self._raise_error("The value of 'default_cursor_field' was changed", diff)

Recommended reading order

  1. test_backward_compatibility.py
  2. backward_compatibility.py

🚨 User Impact 🚨

PRs adding new streams to a connector catalog should have their acceptance test pass now.

@alafanechere alafanechere changed the title improve 'check_if_cursor_field_was_changed' to make it less radical SAT: improve 'check_if_cursor_field_was_changed' to make it less radical Aug 22, 2022
@alafanechere alafanechere changed the title SAT: improve 'check_if_cursor_field_was_changed' to make it less radical SAT: improve check_if_cursor_field_was_changed to make it less radical Aug 22, 2022
@alafanechere alafanechere marked this pull request as ready for review August 22, 2022 10:03
@alafanechere alafanechere changed the title SAT: improve check_if_cursor_field_was_changed to make it less radical SAT: improve check_if_cursor_field_was_changed to make it less strict Aug 22, 2022
@alafanechere alafanechere requested review from a team and marcosmarxm August 22, 2022 10:04
@@ -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 not any([transition.should_fail for transition in VALID_SPEC_TRANSITIONS])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion was not working correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps assert all([not transition.should_fail for transition in VALID_SPEC_TRANSITIONS]) is more readable?

@alafanechere alafanechere linked an issue Aug 22, 2022 that may be closed by this pull request
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainly just one Q and then a nit 👍

@@ -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 diff and set(diff.keys()).issubset(invalid_changes):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this now pass in a case where we have a new stream but also breaking cursor field change on another stream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the suggestion, I added a corresponding test case and discovered the check was not robust enough: improved in 3231e6d

@@ -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 not any([transition.should_fail for transition in VALID_SPEC_TRANSITIONS])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps assert all([not transition.should_fail for transition in VALID_SPEC_TRANSITIONS]) is more readable?

@@ -1197,7 +1223,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 not any([transition.should_fail for transition in VALID_CATALOG_TRANSITIONS])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alafanechere alafanechere requested a review from Phlair August 22, 2022 13:17
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice one 👍

@alafanechere
Copy link
Contributor Author

alafanechere commented Aug 22, 2022

/publish connector=bases/source-acceptance-test auto-bump-version=false

🕑 Publishing the following connectors:
bases/source-acceptance-test
https://github.com/airbytehq/airbyte/actions/runs/2904210178


Connector Did it publish? Were definitions generated?
bases/source-acceptance-test

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

@alafanechere alafanechere merged commit 3ba8276 into master Aug 22, 2022
@alafanechere alafanechere deleted the augustin/sat/fix-test-discovery-backward-compat branch August 22, 2022 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in test_backward_compatibility
2 participants