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

[CT-2026] Add proto serialization to automated event testing #6852

Closed
jtcohen6 opened this issue Feb 3, 2023 · 1 comment · Fixed by #6995
Closed

[CT-2026] Add proto serialization to automated event testing #6852

jtcohen6 opened this issue Feb 3, 2023 · 1 comment · Fixed by #6995
Assignees
Labels
repo ci/cd Testing and continuous integration for dbt-core + adapter plugins tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Feb 3, 2023

Let's extend this test, so it validates serialization to proto (and thereby our proto schema definitions) in addition to JSON:

class TestEventJSONSerialization:
# attempts to test that every event is serializable to json.
# event types that take `Any` are not possible to test in this way since some will serialize
# just fine and others won't.
def test_all_serializable(self):
all_non_abstract_events = set(
get_all_subclasses(BaseEvent),
)
all_event_values_list = list(map(lambda x: x.__class__, sample_values))
diff = all_non_abstract_events.difference(set(all_event_values_list))
assert (
not diff
), f"test is missing concrete values in `sample_values`. Please add the values for the aforementioned event classes"
# make sure everything in the list is a value not a type
for event in sample_values:
assert type(event) != type
# if we have everything we need to test, try to serialize everything
for event in sample_values:
msg = msg_from_base_event(event)
msg_dict = msg_to_dict(msg)
try:
msg_json = msg_to_json(msg)
except Exception as e:
raise Exception(f"{event} is not serializable to json. Originating exception: {e}")

@jtcohen6 jtcohen6 added repo ci/cd Testing and continuous integration for dbt-core + adapter plugins tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality labels Feb 3, 2023
@github-actions github-actions bot changed the title Add proto serialization to automated event testing [CT-2026] Add proto serialization to automated event testing Feb 3, 2023
@emmyoop
Copy link
Member

emmyoop commented Feb 6, 2023

  • Need to set more values in the test events (dictionaries)
  • New test may surface errors that will need to be fixed

Time box this for now, and if there's more work to do create another ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repo ci/cd Testing and continuous integration for dbt-core + adapter plugins tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants