infra: Update dv_for_data_source to create the dv from public quay#5592
infra: Update dv_for_data_source to create the dv from public quay#5592RoniKishner wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughThe golden image update tests now create DataVolumes from Fedora registry sources, remove Artifactory resource handling, shorten referenced-volume verification waits, and construct scoped DataSource fixtures with ChangesGolden image data source updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Branch Management
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
Security Checks
💡 Tips
📌 Additional InformationCustom Commands:
For more information, please refer to the project documentation or contact the maintainers. |
|
/test-plan |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-tests > /tmp/pr.diff
echo "---- FILES CHANGED ----"
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-tests --name-only
echo "---- DIFF ----"
cat /tmp/pr.diffLength of output: 2270 🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-tests --name-only
echo "---- DIFF ----"
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-testsLength of output: 2207
Based on the PR objectives alone (without being able to inspect the actual diff/fixtures/markers), I can note:
Please check the sandbox's Git credentials/token configuration for this repository so I can retry cloning and produce the full inline Test Execution Plan. |
|
/verified |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "---- AUTH STATUS ----"
gh auth status 2>&1 || true
echo "---- PR DIFF ----"
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-tests --name-only 2>&1 || true
gh pr diff 5592 --repo RedHatQE/openshift-virtualization-tests 2>&1 || true
echo "---- LOCAL FILE CHECK ----"
fd test_ssp_data_sources.pyLength of output: 2355
Additionally, I should clarify: this chat-based response channel can only produce a text reply in this comment thread; it cannot submit a separate inline review comment on a specific diff line of the "Files Changed" tab. Posting an inline PR review comment requires the dedicated review flow (e.g., triggered via Given the PR objectives, here's the best-effort plan without repository access: Test Execution Plan
Real tests (cluster required) — recommended since this changes runtime image-pull behavior:
Please check the sandbox's Git credentials/token configuration for ✅ Action performedFull review finished. |
| source_dict=construct_datavolume_source_dict(source=REGISTRY_STR, url=DEFAULT_FEDORA_REGISTRY_URL), | ||
| size=Images.Fedora.DEFAULT_DV_SIZE, |
There was a problem hiding this comment.
Wouldn't it be better to clone from a golden image to reduce the dependency on quay?
There was a problem hiding this comment.
You mean from a DataSource?
It's not possible, the test idea is to create a DV while the boot sources are down, and then to bring them up again after the PVC is created.
So there no source to clone from when creating the DV.
| try: | ||
| for sample in TimeoutSampler( | ||
| wait_timeout=TIMEOUT_10MIN, | ||
| wait_timeout=TIMEOUT_5MIN, |
There was a problem hiding this comment.
wait_for_data_source_unchanged_referenced_volume is only used at one place under test_data_source_with_existing_golden_image_pvc.
Before we hit test body, fixtures already settles and verified
- disable disabled_common_boot_image_import
- manual DV succeeded, datasources ready on that pvc
- enabled_common_boot_image_import_feature_gate makes sure that ds, dic,ssp.hco all looks good.
inside test body ,
wait_for_condition_message_value waits for ready message which means it's stable so instead of wait_for_data_source_unchanged_referenced_volume , which is another wait , should we directly assert? wait_for_data_source_unchanged_referenced_volume will keep polling for 5 mins even if we get what we want . why we expect something would change in that 5 mins because everything is already stable when we run wait_for_data_source_unchanged_referenced_volume
There was a problem hiding this comment.
I have done some investigation, instead of waiting, lets trigger a reconcile.
If the reconcile doesn't change the reference then all is good.
There was a problem hiding this comment.
There are 2 parts to it.
- I am unsure why we need a second reconcile introducing new annotations? We already had a reconcile we waited and i believe after reconcile do we want to check other things too?
- if ssp really reconcile if that's our aim, we really don't check if that really happened nor we looks for cdi.kubevirt.io/dataImportCron (if that's not there) . However with this check you could hit https://redhat.atlassian.net/browse/CNV-86273
| ResourceEditor( | ||
| patches={ | ||
| data_source: {"metadata": {"annotations": {RECONCILE_TRIGGER_ANNOTATION: RECONCILE_TRIGGER_ANNOTATION}}} | ||
| } | ||
| ).update() |
There was a problem hiding this comment.
this should be context managed?
There was a problem hiding this comment.
At the end of this function the VM is deleted, so it makes no difference if the label is kept, making it context managed means it is calling an API call at the end, which doesn't effect the test.
There was a problem hiding this comment.
There are 2 parts to it.
- I am unsure why we need a second reconcile introducing new annotations? We already had a reconcile we waited and i believe after reconcile do we want to check other things too?
- if ssp really reconcile if that's our aim, we really don't check if that really happened nor we looks for cdi.kubevirt.io/dataImportCron (if that's not there) . However with this check you could hit redhat.atlassian.net/browse/CNV-86273
There was a problem hiding this comment.
context manager for clean exit
There was a problem hiding this comment.
We could check the reconcile action happened by changing a label and waiting for it to be reconciled, previously we didn't really had a reconcile action, we had an action to attach a DV, and just waited 10 minutes.
About the bug, you are correct, but this is a real bug, if we do run into something similar then it means there are issues in the product.
There was a problem hiding this comment.
reconcile did happen in test_data_source_with_existing_golden_image_pvc via enabled_common_boot_image_import_feature_gate when we re-enable it. ssp brings back dic is reconcile action. refer: https://github.com/kubevirt/ssp-operator/blob/main/internal/operands/data-sources/reconcile.go#L129-L132
There was a problem hiding this comment.
Yep, you are right, I guess even a timeout of 10 seconds should be enough then, the operator shouldn't really take that long to change anything if it's reconciling already.
There was a problem hiding this comment.
yeah theoretically but give it a try on real cluster similar to where we run scheduled runs.
There was a problem hiding this comment.
After some different tries it looks like the reconcile is called immediately, which takes it about 3-5 seconds to change the field.
I changed the value to 30 seconds, just to make sure, maybe on slow clusters it will take longer.
Signed-off-by: rkishner <rkishner@redhat.com>
84c0933 to
7b6f9c0
Compare
for more information, see https://pre-commit.ci
|
/verified |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py`:
- Around line 44-52: Move dv_for_data_source and
wait_for_data_source_unchanged_referenced_volume from
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
(lines 44-52 and 89-89) into
tests/infrastructure/golden_images/update_boot_source/utils.py, adding
Google-format docstrings; move the data_source_by_name_scope_function fixture
from
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
(lines 254-255) into
tests/infrastructure/golden_images/update_boot_source/conftest.py, and update
imports or fixture discovery so existing tests continue using them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a84deea5-c587-4d0e-9b92-b515ad9d56d5
📒 Files selected for processing (1)
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
RedHatQE/openshift-virtualization-tests-design-docs(manual)
| @contextmanager | ||
| def dv_for_data_source(name, data_source, admin_client): | ||
| artifactory_secret = get_artifactory_secret(namespace=data_source.namespace) | ||
| artifactory_config_map = get_artifactory_config_map(namespace=data_source.namespace) | ||
| with DataVolume( | ||
| client=admin_client, | ||
| name=name, | ||
| namespace=data_source.namespace, | ||
| source_dict=construct_datavolume_source_dict( | ||
| # underlying OS is not relevant | ||
| source="http", | ||
| url=get_http_image_url(image_directory=Images.Cirros.DIR, image_name=Images.Cirros.QCOW2_IMG), | ||
| secret_name=artifactory_secret.name, | ||
| cert_configmap_name=artifactory_config_map.name, | ||
| ), | ||
| size=Images.Cirros.DEFAULT_DV_SIZE, | ||
| # underlying OS is not relevant | ||
| source_dict=construct_datavolume_source_dict(source=REGISTRY_STR, url=DEFAULT_FEDORA_REGISTRY_URL), | ||
| size=Images.Fedora.DEFAULT_DV_SIZE, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Move local helpers and fixtures to dedicated modules.
HIGH severity. Defining helper functions and fixtures inside test_*.py files mixes test definitions with test infrastructure. To ensure clean test modules and reusability, they must be separated.
As per coding guidelines: "Do not define helper functions, utility functions, or classes in conftest.py or test_*.py; place them in dedicated utility modules... keep local helpers in <feature_dir>/utils.py, and local fixtures in <feature_dir>/conftest.py."
Please relocate these to their appropriate files. When moving the helpers, ensure they include Google-format docstrings as required for public functions.
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L44-L52: Move thedv_for_data_sourcehelper function to<feature_dir>/utils.py.tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L89-L89: Move thewait_for_data_source_unchanged_referenced_volumehelper function to<feature_dir>/utils.py.tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L254-L255: Move thedata_source_by_name_scope_functionfixture to<feature_dir>/conftest.py.
📍 Affects 1 file
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L44-L52(this comment)tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L89-L89tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py#L254-L255
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py`
around lines 44 - 52, Move dv_for_data_source and
wait_for_data_source_unchanged_referenced_volume from
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
(lines 44-52 and 89-89) into
tests/infrastructure/golden_images/update_boot_source/utils.py, adding
Google-format docstrings; move the data_source_by_name_scope_function fixture
from
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
(lines 254-255) into
tests/infrastructure/golden_images/update_boot_source/conftest.py, and update
imports or fixture discovery so existing tests continue using them.
Source: Coding guidelines
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
| get_artifactory_secret, | ||
| get_http_image_url, | ||
| ) | ||
| from utilities.constants import Images |
There was a problem hiding this comment.
Test Execution Plan
- Run smoke tests: False — the only changed module is marked
post_upgrade; it has nosmokemarker, and this PR does not modify sharedutilities/,libs/, orconftest.pycode that could transitively affect smoke coverage. - Run gating tests: False — the changed module has no
gatingmarker, and there are no shared-code changes that could affect gating tests. - Affected tests to run:
tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_upload_dv_for_auto_update_dangling_data_sources(post_upgrade) — exercisesdata_source_by_name_scope_function→uploaded_dv_for_dangling_data_source_scope_function→dv_for_data_source, including the new public-Quay Fedora registry import.tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_data_source_with_existing_golden_image_pvc(post_upgrade) — exercisesdata_source_by_name_scope_function→created_dv_for_data_import_cron_managed_data_source_scope_function→dv_for_data_sourceand the reduced unchanged-reference timeout.
Real tests (cluster required)
Error/fix path (public registry import):
pytest tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_upload_dv_for_auto_update_dangling_data_sources
Expected: the Fedora DataVolume imports from public Quay and the DataSource condition reaches the parameterized expected state.
Happy path (existing golden-image PVC):
pytest tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_data_source_with_existing_golden_image_pvc
Expected: the manually created Fedora DataVolume is consumed and the DataSource reference remains unchanged throughout the 30-second verification window.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== PR metadata =="
gh pr view 5592 --repo RedHatQE/openshift-virtualization-tests \
--json headRefOid,baseRefOid,files --jq '{headRefOid, baseRefOid, files: [.files[] | {path, additions, deletions}]}'
echo "== Changed files and zero-context diff =="
git diff --name-only HEAD^ HEAD
git diff --unified=0 HEAD^ HEAD -- tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py
echo "== Module outline =="
ast-grep outline tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py \
--items all --type function,class --view expanded
echo "== Smoke and gating marker files =="
rg -n -l '`@pytest`\.mark\.(smoke|gating)' tests/ || true
echo "== Existing PR review comments =="
gh api "repos/RedHatQE/openshift-virtualization-tests/pulls/5592/comments?per_page=100" \
--jq '.[] | {id, path, line, body, user: .user.login}' || trueLength of output: 1762 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="RedHatQE/openshift-virtualization-tests"
pr="5592"
sha="5b75ca9c378d3169461d5c1df760bb01a3b52a7c"
path="tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py"
echo "== PR file patch =="
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[] | select(.filename == "'"$path"'") | {filename, status, patch}'
echo "== Download head version for static inspection =="
gh api "repos/$repo/contents/$path?ref=$sha" \
-H 'Accept: application/vnd.github.raw' > /tmp/test_ssp_data_sources.py
echo "== AST outline =="
ast-grep outline /tmp/test_ssp_data_sources.py --items all --type function,class --view expanded
echo "== Relevant source (fixtures, test definitions, markers) =="
rg -n -C 4 '^(def |class |`@pytest`\.mark|`@pytest`\.fixture)|\bdv_for_data_source\b|data_source_by_name_scope_function|referenced.*volume|unchanged' \
/tmp/test_ssp_data_sources.py || true
echo "== Module markers =="
rg -n '`@pytest`\.mark\.(smoke|gating)' /tmp/test_ssp_data_sources.py || true
echo "== Marker files in working tree (continue if unavailable) =="
rg -n -l '`@pytest`\.mark\.smoke' tests/ 2>/dev/null || true
rg -n -l '`@pytest`\.mark\.gating' tests/ 2>/dev/null || true
echo "== Existing inline comments on this file =="
gh api "repos/$repo/pulls/$pr/comments?per_page=100" \
--jq '.[] | select(.path == "'"$path"'") | {id, commit_id, line, side, body, user: .user.login}' || trueLength of output: 38753 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="RedHatQE/openshift-virtualization-tests"
pr="5592"
sha="5b75ca9c378d3169461d5c1df760bb01a3b52a7c"
path="tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py"
body=$(cat <<'EOF'
## Test Execution Plan
- **Run smoke tests: False** — the only changed module is marked `post_upgrade`; it has no `smoke` marker, and this PR does not modify shared `utilities/`, `libs/`, or `conftest.py` code that could transitively affect smoke coverage.
- **Run gating tests: False** — the changed module has no `gating` marker, and there are no shared-code changes that could affect gating tests.
- **Affected tests to run:**
- `tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_upload_dv_for_auto_update_dangling_data_sources` (`post_upgrade`) — exercises `data_source_by_name_scope_function` → `uploaded_dv_for_dangling_data_source_scope_function` → `dv_for_data_source`, including the new public-Quay Fedora registry import.
- `tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_data_source_with_existing_golden_image_pvc` (`post_upgrade`) — exercises `data_source_by_name_scope_function` → `created_dv_for_data_import_cron_managed_data_source_scope_function` → `dv_for_data_source` and the reduced unchanged-reference timeout.
**Real tests (cluster required)**
Error/fix path (public registry import):
`pytest tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_upload_dv_for_auto_update_dangling_data_sources`
Expected: the Fedora DataVolume imports from public Quay and the DataSource condition reaches the parameterized expected state.
Happy path (existing golden-image PVC):
`pytest tests/infrastructure/golden_images/update_boot_source/test_ssp_data_sources.py::test_data_source_with_existing_golden_image_pvc`
Expected: the manually created Fedora DataVolume is consumed and the DataSource reference remains unchanged throughout the 30-second verification window.
EOF
)
gh api --method POST "repos/$repo/pulls/$pr/comments" \
-f body="$body" \
-f commit_id="$sha" \
-f path="$path" \
-F line=20 \
-f side=RIGHT \
--jq '{id, path, line, side, commit_id}'Length of output: 2608
|
| TESTS_AUTO_UPDATE_BOOT_SOURCE_NAME = [*py_config["auto_update_data_source_matrix"][0]][0] | ||
| DUMMY_VOLUME_NAME = "dummy" | ||
| DATA_SOURCE_MANAGED_BY_CDI_LABEL = f"{DataSource.ApiGroup.CDI_KUBEVIRT_IO}/dataImportCron" | ||
| RECONCILE_TRIGGER_ANNOTATION = "reconcile-trigger" |
What this PR does / why we need it:
dv_for_data_sourceintest_ssp_data_sources.pyto create theDataVolumefrom a public Quay registry (using Images.Fedora via DEFAULT_FEDORA_REGISTRY_URL) instead of an Artifactory-hosted HTTP image, removing the dependency on Artifactory.DataSourcedoes not change reference, since the testing environments are more stable now and can manage to finish the import in less then 5 minutes.Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:
https://redhat.atlassian.net/browse/CNV-86274
Summary by CodeRabbit