Skip to content

Commit f86b1ca

Browse files
authored
Live tests: surface --should-read-with-state to GHAs (#44173)
1 parent cdedd93 commit f86b1ca

File tree

8 files changed

+41
-8
lines changed

8 files changed

+41
-8
lines changed

.github/workflows/live_tests.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
required: true
2626
streams:
2727
description: Streams to include in tests
28+
should_read_with_state:
29+
description: Whether to run tests against the read command with state
30+
default: "true"
31+
type: boolean
2832
use_local_cdk:
2933
description: Use the local CDK when building the target connector
3034
default: "false"
@@ -93,6 +97,15 @@ jobs:
9397
echo "USE_LOCAL_CDK_FLAG=" >> $GITHUB_ENV
9498
fi
9599
100+
- name: Setup State Flag
101+
if: github.event_name == 'workflow_dispatch'
102+
run: |
103+
if ${{ github.event.inputs.should_read_with_state }}; then
104+
echo "READ_WITH_STATE_FLAG=--connector_live_tests.should-read-with-state" >> $GITHUB_ENV
105+
else
106+
echo "READ_WITH_STATE_FLAG=" >> $GITHUB_ENV
107+
fi
108+
96109
- name: Setup Connection Subset Option
97110
if: github.event_name == 'workflow_dispatch'
98111
run: |
@@ -114,4 +127,4 @@ jobs:
114127
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
115128
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
116129
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
117-
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 }}
130+
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 }}

.github/workflows/regression_tests.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
required: true
2626
streams:
2727
description: Streams to include in regression tests
28+
should_read_with_state:
29+
description: Whether to run tests against the read command with state
30+
default: "true"
31+
type: boolean
2832
use_local_cdk:
2933
description: Use the local CDK when building the target connector
3034
default: "false"
@@ -93,6 +97,15 @@ jobs:
9397
echo "USE_LOCAL_CDK_FLAG=" >> $GITHUB_ENV
9498
fi
9599
100+
- name: Setup State Flag
101+
if: github.event_name == 'workflow_dispatch'
102+
run: |
103+
if ${{ github.event.inputs.should_read_with_state }}; then
104+
echo "READ_WITH_STATE_FLAG=--connector_live_tests.should-read-with-state" >> $GITHUB_ENV
105+
else
106+
echo "READ_WITH_STATE_FLAG=" >> $GITHUB_ENV
107+
fi
108+
96109
- name: Setup Connection Subset Option
97110
if: github.event_name == 'workflow_dispatch'
98111
run: |
@@ -114,4 +127,4 @@ jobs:
114127
github_token: ${{ secrets.GH_PAT_MAINTENANCE_OSS }}
115128
s3_build_cache_access_key_id: ${{ secrets.SELF_RUNNER_AWS_ACCESS_KEY_ID }}
116129
s3_build_cache_secret_key: ${{ secrets.SELF_RUNNER_AWS_SECRET_ACCESS_KEY }}
117-
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'
130+
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'

airbyte-ci/connectors/live-tests/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ The traffic recorded on the control connector is passed to the target connector
279279

280280
## Changelog
281281

282+
### 0.18.2
283+
284+
Allow live tests with or without state in CI.
285+
282286
### 0.18.1
283287

284288
Fix extra argument.

airbyte-ci/connectors/live-tests/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "live-tests"
7-
version = "0.18.1"
7+
version = "0.18.2"
88
description = "Contains utilities for testing connectors against live data."
99
authors = ["Airbyte <[email protected]>"]
1010
license = "MIT"

airbyte-ci/connectors/live-tests/src/live_tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def pytest_configure(config: Config) -> None:
143143
config.stash[stash_keys.TEST_EVALUATION_MODE] = TestEvaluationMode(config.getoption("--test-evaluation-mode", "strict"))
144144

145145
if config.stash[stash_keys.RUN_IN_AIRBYTE_CI]:
146-
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = bool(get_option_or_fail(config, "--should-read-with-state"))
146+
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = bool(config.getoption("--should-read-with-state"))
147147
elif _should_read_with_state := config.getoption("--should-read-with-state"):
148148
config.stash[stash_keys.SHOULD_READ_WITH_STATE] = _should_read_with_state
149149
else:

airbyte-ci/connectors/pipelines/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ airbyte-ci connectors --language=low-code migrate-to-manifest-only
790790

791791
| Version | PR | Description |
792792
|---------| ---------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------|
793+
| 4.32.5 | [#44173](https://github.com/airbytehq/airbyte/pull/44173) | Bug fix for live tests' --should-read-with-state handling. |
793794
| 4.32.4 | [#44025](https://github.com/airbytehq/airbyte/pull/44025) | Ignore third party connectors on `publish`. |
794795
| 4.32.3 | [#44118](https://github.com/airbytehq/airbyte/pull/44118) | Improve error handling in live tests. |
795796
| 4.32.2 | [#43970](https://github.com/airbytehq/airbyte/pull/43970) | Make `connectors publish` early exit if no connectors are selected. |

airbyte-ci/connectors/pipelines/pipelines/airbyte_ci/connectors/test/steps/common.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def _get_command_options(self) -> List[str]:
511511
if self.run_id:
512512
command_options += ["--run-id", self.run_id]
513513
if self.should_read_with_state:
514-
command_options += ["--should-read-with-state", self.should_read_with_state]
514+
command_options += ["--should-read-with-state=1"]
515515
if self.test_evaluation_mode:
516516
command_options += ["--test-evaluation-mode", self.test_evaluation_mode]
517517
if self.selected_streams:
@@ -565,7 +565,7 @@ def __init__(self, context: ConnectorContext) -> None:
565565
self.test_dir = self.test_suite_to_dir[LiveTestSuite(self.test_suite)]
566566
self.control_version = self.context.run_step_options.get_item_or_default(options, "control-version", None)
567567
self.target_version = self.context.run_step_options.get_item_or_default(options, "target-version", "dev")
568-
self.should_read_with_state = self.context.run_step_options.get_item_or_default(options, "should-read-with-state", "1")
568+
self.should_read_with_state = "should-read-with-state" in options
569569
self.selected_streams = self.context.run_step_options.get_item_or_default(options, "selected-streams", None)
570570
self.test_evaluation_mode = "strict" if self.context.connector.metadata.get("supportLevel") == "certified" else "diagnostic"
571571
self.connection_subset = self.context.run_step_options.get_item_or_default(options, "connection-subset", "sandboxes")
@@ -644,7 +644,9 @@ async def _run(self, connector_under_test_container: Container) -> StepResult:
644644
)
645645

646646
container = await self._build_test_container(await connector_under_test_container.id())
647-
container = container.with_(hacks.never_fail_exec(self._run_command_with_proxy(" ".join(self._test_command()))))
647+
command = self._run_command_with_proxy(" ".join(self._test_command()))
648+
main_logger.info(f"Running command {command}")
649+
container = container.with_(hacks.never_fail_exec(command))
648650
tests_artifacts_dir = str(self.local_tests_artifacts_dir)
649651
path_to_report = f"{tests_artifacts_dir}/session_{self.run_id}/report.html"
650652

airbyte-ci/connectors/pipelines/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
44

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

0 commit comments

Comments
 (0)