Skip to content

CNTRLPLANE-3609: update TestEtcdDBScaling to also include the validation check for BackendQuotaGiB#1656

Open
atiratree wants to merge 1 commit into
openshift:mainfrom
atiratree:TestEtcdDBScaling-validation
Open

CNTRLPLANE-3609: update TestEtcdDBScaling to also include the validation check for BackendQuotaGiB#1656
atiratree wants to merge 1 commit into
openshift:mainfrom
atiratree:TestEtcdDBScaling-validation

Conversation

@atiratree

@atiratree atiratree commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Tests
    • Added end-to-end validation for backend quota limits.
    • Confirmed that values below or above the supported range are rejected.
    • Preserved coverage for valid quota updates and verified resulting pod configuration.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The database scaling end-to-end test now verifies that backend quota values below and above the allowed range are rejected before continuing with the existing valid quota update and pod environment checks.

Changes

Backend quota validation

Layer / File(s) Summary
Validate backend quota updates
test/e2e/scaling_dbsize.go
The test attempts invalid low and high BackendQuotaGiB updates, requires errors for both, then re-fetches the Etcd resource before applying the valid database size quota.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning TestEtcdDBScaling makes cluster API calls with context.Background() and uses bare require.Error/NoError, so waits are unbounded and failures lack context. Use one timeout context for Get/Update/List calls, assert apierrors.IsInvalid on rejected updates, and add brief failure messages to the expectations.
Microshift Test Compatibility ⚠️ Warning TestEtcdDBScaling talks to the etcd operator API and openshift-etcd namespace, which MicroShift doesn't serve, and there's no MicroShift skip/tag. Add [Skipped:MicroShift] or [apigroup:etcd.operator.openshift.io] to the test, or guard it with exutil.IsMicroShiftCluster()+g.Skip().
✅ Passed checks (13 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The only Ginkgo title is static ('[Operator][Serial][Disruptive] TestEtcdDBScaling'); the PR changes test logic only, not dynamic or generated names.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The test only updates the Etcd CR and waits for etcd pods to stabilize; it doesn't count nodes, require distinct hosts, or assume HA topology.
Topology-Aware Scheduling Compatibility ✅ Passed Only test/e2e/scaling_dbsize.go changed; no manifests, operator code, or controller scheduling logic was modified.
Ote Binary Stdout Contract ✅ Passed PASS: the change only adds validation/update logic inside a Ginkgo It; no main/init/TestMain/suite-level stdout writes or logging were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed test/e2e/scaling_dbsize.go only updates Etcd CR validation; it has no IPv4 literals, localhost IPs, IP parsing, or external network calls.
No-Weak-Crypto ✅ Passed The touched test file adds only Etcd validation logic; it contains no MD5/SHA1/DES/RC4/ECB/custom crypto, and its equality check is for a non-secret env value.
Container-Privileges ✅ Passed PR only edits an e2e Go test; no privileged, hostPID/Network/IPC, or allowPrivilegeEscalation settings appear in changed files.
No-Sensitive-Data-In-Logs ✅ Passed Touched test code adds no logging or sensitive literals; scan found no print/log calls and the diff only updates Etcd validation flow.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding BackendQuotaGiB validation to TestEtcdDBScaling.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from jubittajohn and tjungblu July 23, 2026 14:01
@openshift-ci

openshift-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tjungblu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@test/e2e/scaling_dbsize.go`:
- Around line 42-56: Update the scaling test’s Kubernetes API calls around the
Etcd validation and valid-update flow to create one timeout context and reuse it
for every Get, Update, and List operation, including pod-listing calls. Replace
each context.Background() passed to these client methods while preserving the
existing assertions and test behavior.
- Around line 45-52: Update the invalid Etcd update assertions in the scaling
test to verify apierrors.IsInvalid(err) for both validation failures, rather
than only requiring a generic error. For the BackendQuotaGiB case, also inspect
the invalid-field cause and confirm it identifies the BackendQuotaGiB field.
🪄 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: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5f615bc8-8a61-452e-a762-ab714e3bed61

📥 Commits

Reviewing files that changed from the base of the PR and between 1fe5873 and 98f2e77.

📒 Files selected for processing (1)
  • test/e2e/scaling_dbsize.go

Comment on lines 42 to +56
etcdCR, err := opClientSet.OperatorV1().Etcds().Get(context.Background(), etcdCRName, metav1.GetOptions{})
require.NoError(t, err)
etcdCR.Spec.BackendQuotaGiB = invalidLowDBSizeGB
etcdCR, err = opClientSet.OperatorV1().Etcds().Update(context.Background(), etcdCR, metav1.UpdateOptions{})
require.Error(t, err)

etcdCR, err = opClientSet.OperatorV1().Etcds().Get(context.Background(), etcdCRName, metav1.GetOptions{})
require.NoError(t, err)
etcdCR.Spec.BackendQuotaGiB = invalidHighDBSizeGB
etcdCR, err = opClientSet.OperatorV1().Etcds().Update(context.Background(), etcdCR, metav1.UpdateOptions{})
require.Error(t, err)

// valid update
etcdCR, err = opClientSet.OperatorV1().Etcds().Get(context.Background(), etcdCRName, metav1.GetOptions{})
require.NoError(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show relevant file and surrounding lines
sed -n '1,160p' test/e2e/scaling_dbsize.go

Repository: openshift/cluster-etcd-operator

Length of output: 3021


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map functions in the file for context
ast-grep outline test/e2e/scaling_dbsize.go --view expanded

Repository: openshift/cluster-etcd-operator

Length of output: 573


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find all uses of context.Background in the e2e test file
rg -n "context\.Background\(\)|WithTimeout|WithCancel" test/e2e/scaling_dbsize.go

Repository: openshift/cluster-etcd-operator

Length of output: 953


Bound all Kubernetes API calls in this test. The Get/Update/List calls use context.Background(), so a stalled API server can hang the e2e job until the outer runner kills it. Create one timeout context and reuse it for the validation, update, and pod-listing calls.

🤖 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 `@test/e2e/scaling_dbsize.go` around lines 42 - 56, Update the scaling test’s
Kubernetes API calls around the Etcd validation and valid-update flow to create
one timeout context and reuse it for every Get, Update, and List operation,
including pod-listing calls. Replace each context.Background() passed to these
client methods while preserving the existing assertions and test behavior.

Source: Path instructions

Comment on lines +45 to +52
etcdCR, err = opClientSet.OperatorV1().Etcds().Update(context.Background(), etcdCR, metav1.UpdateOptions{})
require.Error(t, err)

etcdCR, err = opClientSet.OperatorV1().Etcds().Get(context.Background(), etcdCRName, metav1.GetOptions{})
require.NoError(t, err)
etcdCR.Spec.BackendQuotaGiB = invalidHighDBSizeGB
etcdCR, err = opClientSet.OperatorV1().Etcds().Update(context.Background(), etcdCR, metav1.UpdateOptions{})
require.Error(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant test file with line numbers
sed -n '1,140p' test/e2e/scaling_dbsize.go | cat -n

# Find other uses of the same assertion style in nearby tests
rg -n "require\.(Error|True\(t, apierrors\.IsInvalid|NoError)" test/e2e -g '*.go'

Repository: openshift/cluster-etcd-operator

Length of output: 7216


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate validation for BackendQuotaGiB / Etcd CRD schema references
rg -n "BackendQuotaGiB|Etcds\(\)\.Update|validation.*BackendQuota|Invalid" \
  test pkg config install manifests . -g '*.go' -g '*.yaml' -g '*.yml' -g '*.json'

# Map the API type/validation implementation files
fd -a '.*etcd.*\.go|.*validation.*\.go|.*types.*\.go' pkg api test | head -n 50

Repository: openshift/cluster-etcd-operator

Length of output: 50388


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for the API type and any validation logic around BackendQuotaGiB
rg -n "BackendQuotaGiB|Validate.*Etcd|validation.*Etcd|+kubebuilder|openapi|minimum|max" \
  pkg api test config install manifests . -g '*.go' -g '*.yaml' -g '*.yml' -g '*.json'

# Show the Etcd API type if present
fd -a 'etcd.*\.go' pkg api | sed -n '1,20p'

Repository: openshift/cluster-etcd-operator

Length of output: 384


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate repo-owned files that mention the field name
git ls-files | rg '(^|/)(api|pkg|config|manifests|test)/.*\.(go|ya?ml|json)$' | xargs rg -n -F "BackendQuotaGiB"

# Find the Etcd API type declaration with a small, focused search
git ls-files | rg '\.go$' | xargs rg -n -F "type EtcdSpec" -A 40 -B 10

Repository: openshift/cluster-etcd-operator

Length of output: 1186


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the exact file(s) containing the field and nearby context
files=$(git ls-files | rg '(^|/)(api|pkg)/.*\.go$' | xargs rg -l -F "BackendQuotaGiB" || true)
printf '%s\n' "$files" | sed '/^$/d'

for f in $files; do
  echo "### $f"
  sed -n '1,220p' "$f" | rg -n -C 4 "BackendQuotaGiB|type EtcdSpec|Validate|kubebuilder|OpenAPI|minimum|max"
done

Repository: openshift/cluster-etcd-operator

Length of output: 2854


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for the field in repo-owned Go files only, excluding vendor
rg -n -F "BackendQuotaGiB" -g '!vendor/**' -g '*.go' .

# Also search for generated schema markers around the field
rg -n -F "kubebuilder:validation" -g '!vendor/**' -g '*.go' .

Repository: openshift/cluster-etcd-operator

Length of output: 956


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the repo-owned definition(s) for BackendQuotaGiB and show tight context
rg -n -F "BackendQuotaGiB" -g '!vendor/**' -g '*.go' .

# Find the EtcdSpec type if present in non-vendor Go files
rg -n -F "type EtcdSpec" -g '!vendor/**' -g '*.go' . -A 60 -B 10

Repository: openshift/cluster-etcd-operator

Length of output: 956


Assert the expected validation error here. BackendQuotaGiB is schema-limited to 8–16, so these updates should fail with apierrors.IsInvalid(err) rather than any generic error. Checking the BackendQuotaGiB field cause would make the test even tighter.

🤖 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 `@test/e2e/scaling_dbsize.go` around lines 45 - 52, Update the invalid Etcd
update assertions in the scaling test to verify apierrors.IsInvalid(err) for
both validation failures, rather than only requiring a generic error. For the
BackendQuotaGiB case, also inspect the invalid-field cause and confirm it
identifies the BackendQuotaGiB field.

@atiratree atiratree changed the title update TestEtcdDBScaling to also include the validation check for BackendQuotaGiB CNTRLPLANE-3609: update TestEtcdDBScaling to also include the validation check for BackendQuotaGiB Jul 23, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 23, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 23, 2026

Copy link
Copy Markdown

@atiratree: This pull request references CNTRLPLANE-3609 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Tests
  • Added end-to-end validation for backend quota limits.
  • Confirmed that values below or above the supported range are rejected.
  • Preserved coverage for valid quota updates and verified resulting pod configuration.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@atiratree

Copy link
Copy Markdown
Member Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-agnostic-ovn
/test e2e-agnostic-ovn-upgrade
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-single-node
/test e2e-gcp-operator
/test e2e-gcp-operator-disruptive
/test e2e-metal-ipi-ovn-ipv6
/test e2e-operator

@openshift-ci

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@atiratree: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-agnostic-ovn-upgrade 98f2e77 link true /test e2e-agnostic-ovn-upgrade
ci/prow/e2e-aws-ovn-single-node 98f2e77 link true /test e2e-aws-ovn-single-node
ci/prow/e2e-agnostic-ovn 98f2e77 link true /test e2e-agnostic-ovn

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants