Skip to content

Live tests: surface --should-read-with-state to GHAs #44173

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

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion .github/workflows/live_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on:
required: true
streams:
description: Streams to include in tests
should_read_with_state:
description: Whether to run tests against the read command with state
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you tell me more about how this is applied? Does it mean "with taking state in at the start of read", or something else?

default: "true"
type: boolean
use_local_cdk:
description: Use the local CDK when building the target connector
default: "false"
Expand Down Expand Up @@ -93,6 +97,15 @@ jobs:
echo "USE_LOCAL_CDK_FLAG=" >> $GITHUB_ENV
fi

- name: Setup State Flag
if: github.event_name == 'workflow_dispatch'
run: |
if ${{ github.event.inputs.should_read_with_state }}; then
echo "READ_WITH_STATE_FLAG=--connector_live_tests.should-read-with-state" >> $GITHUB_ENV
else
echo "READ_WITH_STATE_FLAG=" >> $GITHUB_ENV
fi

- name: Setup Connection Subset Option
if: github.event_name == 'workflow_dispatch'
run: |
Expand All @@ -114,4 +127,4 @@ jobs:
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: connectors ${{ env.USE_LOCAL_CDK_FLAG }} --name ${{ github.event.inputs.connector_name }} test --only-step connector_live_tests --connector_live_tests.test-suite=all --connector_live_tests.connection-id=${{ github.event.inputs.connection_id }} --connector_live_tests.pr-url=${{ github.event.inputs.pr_url }} ${{ env.STREAM_PARAMS }} ${{ env.CONNECTION_SUBSET }}
subcommand: connectors ${{ env.USE_LOCAL_CDK_FLAG }} --name ${{ github.event.inputs.connector_name }} test --only-step connector_live_tests --connector_live_tests.test-suite=live --connector_live_tests.connection-id=${{ github.event.inputs.connection_id }} --connector_live_tests.pr-url=${{ github.event.inputs.pr_url }} ${{ env.READ_WITH_STATE_FLAG }} ${{ env.STREAM_PARAMS }} ${{ env.CONNECTION_SUBSET }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is replacing "all" with "live" here intentional? I assume that all = regression + validation? what's live stand for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, so live stands for validation (looked up at the top of the file).

15 changes: 14 additions & 1 deletion .github/workflows/regression_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ on:
required: true
streams:
description: Streams to include in regression tests
should_read_with_state:
description: Whether to run tests against the read command with state
default: "true"
type: boolean
use_local_cdk:
description: Use the local CDK when building the target connector
default: "false"
Expand Down Expand Up @@ -93,6 +97,15 @@ jobs:
echo "USE_LOCAL_CDK_FLAG=" >> $GITHUB_ENV
fi

- name: Setup State Flag
if: github.event_name == 'workflow_dispatch'
run: |
if ${{ github.event.inputs.should_read_with_state }}; then
echo "READ_WITH_STATE_FLAG=--connector_live_tests.should-read-with-state" >> $GITHUB_ENV
else
echo "READ_WITH_STATE_FLAG=" >> $GITHUB_ENV
fi

- name: Setup Connection Subset Option
if: github.event_name == 'workflow_dispatch'
run: |
Expand All @@ -114,4 +127,4 @@ jobs:
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
subcommand: connectors ${{ env.USE_LOCAL_CDK_FLAG }} --name ${{ github.event.inputs.connector_name }} test --only-step connector_live_tests --connector_live_tests.test-suite=regression --connector_live_tests.connection-id=${{ github.event.inputs.connection_id }} --connector_live_tests.pr-url=${{ github.event.inputs.pr_url }} ${{ env.STREAM_PARAMS }} ${{ env.CONNECTION_SUBSET }} --global-status-check-context="Regression Tests" --global-status-check-description='Running regression tests'
subcommand: connectors ${{ env.USE_LOCAL_CDK_FLAG }} --name ${{ github.event.inputs.connector_name }} test --only-step connector_live_tests --connector_live_tests.test-suite=regression --connector_live_tests.connection-id=${{ github.event.inputs.connection_id }} --connector_live_tests.pr-url=${{ github.event.inputs.pr_url }} ${{ env.READ_WITH_STATE_FLAG }} ${{ env.STREAM_PARAMS }} ${{ env.CONNECTION_SUBSET }} --global-status-check-context="Regression Tests" --global-status-check-description='Running regression tests'
4 changes: 4 additions & 0 deletions airbyte-ci/connectors/live-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ The traffic recorded on the control connector is passed to the target connector

## Changelog

### 0.18.2

Allow live tests with or without state in CI.

### 0.18.1

Fix extra argument.
Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/live-tests/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "live-tests"
version = "0.18.1"
version = "0.18.2"
description = "Contains utilities for testing connectors against live data."
authors = ["Airbyte <[email protected]>"]
license = "MIT"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def pytest_configure(config: Config) -> None:
config.stash[stash_keys.TEST_EVALUATION_MODE] = TestEvaluationMode(config.getoption("--test-evaluation-mode", "strict"))

if config.stash[stash_keys.RUN_IN_AIRBYTE_CI]:
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = bool(get_option_or_fail(config, "--should-read-with-state"))
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = bool(config.getoption("--should-read-with-state"))
elif _should_read_with_state := config.getoption("--should-read-with-state"):
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = _should_read_with_state
else:
Expand Down
1 change: 1 addition & 0 deletions airbyte-ci/connectors/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ airbyte-ci connectors --language=low-code migrate-to-manifest-only

| Version | PR | Description |
|---------| ---------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------|
| 4.32.5 | [#44173](https://github.com/airbytehq/airbyte/pull/44173) | Bug fix for live tests' --should-read-with-state handling. |
| 4.32.4 | [#44025](https://github.com/airbytehq/airbyte/pull/44025) | Ignore third party connectors on `publish`. |
| 4.32.3 | [#44118](https://github.com/airbytehq/airbyte/pull/44118) | Improve error handling in live tests. |
| 4.32.2 | [#43970](https://github.com/airbytehq/airbyte/pull/43970) | Make `connectors publish` early exit if no connectors are selected. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def _get_command_options(self) -> List[str]:
if self.run_id:
command_options += ["--run-id", self.run_id]
if self.should_read_with_state:
command_options += ["--should-read-with-state", self.should_read_with_state]
command_options += ["--should-read-with-state=1"]
if self.test_evaluation_mode:
command_options += ["--test-evaluation-mode", self.test_evaluation_mode]
if self.selected_streams:
Expand Down Expand Up @@ -565,7 +565,7 @@ def __init__(self, context: ConnectorContext) -> None:
self.test_dir = self.test_suite_to_dir[LiveTestSuite(self.test_suite)]
self.control_version = self.context.run_step_options.get_item_or_default(options, "control-version", None)
self.target_version = self.context.run_step_options.get_item_or_default(options, "target-version", "dev")
self.should_read_with_state = self.context.run_step_options.get_item_or_default(options, "should-read-with-state", "1")
self.should_read_with_state = "should-read-with-state" in options
self.selected_streams = self.context.run_step_options.get_item_or_default(options, "selected-streams", None)
self.test_evaluation_mode = "strict" if self.context.connector.metadata.get("supportLevel") == "certified" else "diagnostic"
self.connection_subset = self.context.run_step_options.get_item_or_default(options, "connection-subset", "sandboxes")
Expand Down Expand Up @@ -644,7 +644,9 @@ async def _run(self, connector_under_test_container: Container) -> StepResult:
)

container = await self._build_test_container(await connector_under_test_container.id())
container = container.with_(hacks.never_fail_exec(self._run_command_with_proxy(" ".join(self._test_command()))))
command = self._run_command_with_proxy(" ".join(self._test_command()))
main_logger.info(f"Running command {command}")
container = container.with_(hacks.never_fail_exec(command))
tests_artifacts_dir = str(self.local_tests_artifacts_dir)
path_to_report = f"{tests_artifacts_dir}/session_{self.run_id}/report.html"

Expand Down
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/pipelines/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "pipelines"
version = "4.32.4"
version = "4.32.5"
description = "Packaged maintained by the connector operations team to perform CI for connectors' pipelines"
authors = ["Airbyte <[email protected]>"]

Expand Down
Loading