Skip to content
Open
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: 15 additions & 0 deletions test/e2e/scaling_dbsize.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,28 @@ const (

func TestEtcdDBScaling(t testing.TB) {
dbSizeGB := int32(16)
invalidLowDBSizeGB := int32(7)
invalidHighDBSizeGB := int32(17)
opClientSet := framework.NewOperatorClient(t)
clientSet := framework.NewClientSet("")
etcdPodsClient := clientSet.CoreV1Interface.Pods(operandNameSpace)

// first check the validation
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)
Comment on lines +45 to +52

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.


// valid update
etcdCR, err = opClientSet.OperatorV1().Etcds().Get(context.Background(), etcdCRName, metav1.GetOptions{})
require.NoError(t, err)
Comment on lines 42 to +56

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

etcdCR.Spec.BackendQuotaGiB = dbSizeGB
etcdCR, err = opClientSet.OperatorV1().Etcds().Update(context.Background(), etcdCR, metav1.UpdateOptions{})
require.NoError(t, err)
Expand Down