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

airbyte-ci: dynamic test step tree according to metadata #38281

Conversation

alafanechere
Copy link
Contributor

@alafanechere alafanechere commented May 16, 2024

What

Closes https://github.com/airbytehq/airbyte-internal-issues/issues/7552

Make airbyte-ci consume the connectorTestSuitesOptions from connector metadata to conditionally run test suites declared in there.

How

  • Implement a get_test_suites_to_run_according_to_metadata function taking the metadata and the optional steps to run
  • Call it at test step tree creation for python and java connectors

User Impact

After merging this we should ask all connector developers to update their branch so that they get the freshest connector metadata introduced in #38188 . Critical tests would be skipped otherwise...

Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview May 21, 2024 7:09am

Copy link
Contributor Author

alafanechere commented May 16, 2024

@alafanechere alafanechere force-pushed the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch 2 times, most recently from 5e8fa53 to 3fb8527 Compare May 16, 2024 07:59
@alafanechere alafanechere marked this pull request as ready for review May 16, 2024 07:59
@alafanechere alafanechere requested a review from a team as a code owner May 16, 2024 07:59
@@ -168,7 +163,6 @@ def get_test_steps(context: ConnectorContext) -> STEP_TREE:
normalization_steps = _get_normalization_steps(context)
steps.append(normalization_steps)

acceptance_test_steps = _get_acceptance_test_steps(context)
steps.append(acceptance_test_steps)
steps.append(optional_test_suites_to_run)
Copy link
Contributor

Choose a reason for hiding this comment

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

❗ I think this shows a case that were not supporting

  1. We want to remove a subset of tests from the step tree but those steps can occur in any location in the tree

A better approach is to either
1. Have a filter function you can apply to the tree that removes steps by id and outputs a new tree

def remove_steps(step_tree: STEP_TREE, remove_steps: List[str]) -> STEP_TREE:
    # ...

filtered_steps = remove_steps(step_tree, steps_to_remove)
run_steps(filtered_steps)

2. Make use of our skip step functionallity in run_steps
https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/pipelines/helpers/execution/run_steps.py#L81

I think #2 is the best approach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

❗ I think this shows a case that were not supporting

  1. We want to remove a subset of tests from the step tree but those steps can occur in any location in the tree

A better approach is to either 1. Have a filter function you can apply to the tree that removes steps by id and outputs a new tree

def remove_steps(step_tree: STEP_TREE, remove_steps: List[str]) -> STEP_TREE:
    # ...

filtered_steps = remove_steps(step_tree, steps_to_remove)
run_steps(filtered_steps)

2. Make use of our skip step functionallity in run_steps https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/pipelines/helpers/execution/run_steps.py#L81

I think #2 is the best approach

@bnchrch fair point!
I changed the logic to leverage RunStepsOptions. It's definitely cleaner as:

  • It allows us to not alter the concurrency settings we declare while building the STEP TREE
  • Skipped tests are still rendered in the report so user can be aware that these step could run if they're enabled.

Copy link
Contributor

@clnoll clnoll left a comment

Choose a reason for hiding this comment

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

LGTM!

@alafanechere alafanechere force-pushed the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch from 3fb8527 to bf644f4 Compare May 17, 2024 07:08
@alafanechere alafanechere requested a review from bnchrch May 17, 2024 07:09
Copy link
Contributor

@bnchrch bnchrch left a comment

Choose a reason for hiding this comment

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

Just needs a docstring and were good to go!

Preapproving

Added via Giphy

@@ -286,3 +295,12 @@ async def __aexit__(

def create_slack_message(self) -> str:
raise NotImplementedError

def _get_step_id_to_skip_according_to_metadata(self) -> List[CONNECTOR_TEST_STEP_ID]:
Copy link
Contributor

Choose a reason for hiding this comment

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

📚 We need a doc string here explaining the what and why.

I knew what were doing but even I struggled reading the list comprehension

enabled_test_suites = [option["suite"] for option in self.metadata.get("connectorTestSuitesOptions", [])]
return [step_id for test_suite_name, step_id in TEST_SUITE_NAME_TO_STEP_ID.items() if test_suite_name not in enabled_test_suites]

def _get_updated_run_step_options(self, run_step_options: RunStepOptions) -> RunStepOptions:
Copy link
Contributor

Choose a reason for hiding this comment

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

❗ The name of the function explains the how but not the what. I'd propose we change it to

Suggested change
def _get_updated_run_step_options(self, run_step_options: RunStepOptions) -> RunStepOptions:
def _skip_metadata_disabled_test_suites(self, run_step_options: RunStepOptions) -> RunStepOptions:

@alafanechere alafanechere force-pushed the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch from 82f85ff to 73e1c2c Compare May 21, 2024 06:40
@alafanechere alafanechere force-pushed the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch from 73e1c2c to 4832aa4 Compare May 21, 2024 06:45
@alafanechere alafanechere enabled auto-merge (squash) May 21, 2024 06:46
@alafanechere alafanechere force-pushed the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch from 4832aa4 to c980901 Compare May 21, 2024 07:08
@alafanechere alafanechere merged commit e669832 into master May 21, 2024
28 checks passed
@alafanechere alafanechere deleted the augustin/05-15-airbyte-ci_dynamic_test_step_tree_according_to_metadata branch May 21, 2024 07:25
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.

3 participants