Skip to content

rds test 22 better setup - #831

Merged
Sheeproid merged 2 commits into
masterfrom
rds-test-22-setup
Aug 12, 2025
Merged

Sheeproid merged 2 commits into
masterfrom
rds-test-22-setup

Conversation

@Sheeproid

Copy link
Copy Markdown
Collaborator

No description provided.

@Sheeproid
Sheeproid requested a review from moshemorad August 12, 2025 13:41
@coderabbitai

coderabbitai Bot commented Aug 12, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Updates a test fixture: switches the workflow to deploy a manifest in namespace app-22, validates DB secrets, stops an RDS instance, polls for RDS stopped status and MySQL connection errors in pod logs, and cleans up resources. The manifest adds namespace app-22 and removes commented monitoring resources.

Changes

Cohort / File(s) Summary
Kubernetes manifest adjustments
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
Added namespace app-22 to Deployment and Service; removed commented ServiceMonitor and PrometheusRule blocks.
Test workflow and expectations
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
Updated tags/description for DB-down scenario; added secret validation; replaced slow query with manifest-based deploy in app-22; stops RDS and polls until stopped/stopping; polls pod logs for MySQL connection error; expanded expected_output; updated cleanup to delete manifest.

Sequence Diagram(s)

sequenceDiagram
    participant TR as Test Runner
    participant K8s as Kubernetes API
    participant RDS as AWS RDS
    participant Pod as App Pod (logs)

    TR->>K8s: Verify secret db-secrets-for-medium in namespace app-22
    TR->>RDS: Check RDS instance status
    alt RDS running
        TR->>RDS: Stop instance
        TR->>RDS: Poll status until stopped/stopping (≤60s)
    end
    TR->>K8s: Apply manifest.yaml to app-22
    TR->>Pod: Poll logs for MySQL connection error (≤60s)
    Pod-->>TR: Emit connection error detected
    TR->>K8s: Delete applied manifest (cleanup)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rds-test-22-setup

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Sheeproid
Sheeproid enabled auto-merge (squash) August 12, 2025 13:41
@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 24/40 test cases were successful, 1 regressions, 2 skipped, 13 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe 🔧
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 20_long_log_file_search 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ↪️
ask 39_failed_toolset 🔧
ask 41_setup_argo ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 86_configmap_like_but_secret 🔧
ask 89_runbook_missing_cloudwatch ❌
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 97_logs_clarification_needed ✅
ask 110_k8s_events_image_pull 🔧
ask 24a_misconfigured_pvc_basic 🔧
ask 13a_pending_node_selector_basic 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@Sheeproid
Sheeproid merged commit e40e6fa into master Aug 12, 2025
@Sheeproid
Sheeproid deleted the rds-test-22-setup branch August 12, 2025 13:47

@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: 3

🔭 Outside diff range comments (1)
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml (1)

43-49: Inline shell script in PodSpec violates “ALWAYS use Secrets for scripts” guideline.

Replace the inline loop with a script mounted from a Secret or avoid a shell script entirely.

Apply this minimal change to call a mounted script instead of embedding it inline:

         - name: curl-sidecar
           image: curlimages/curl
-          args:
-            - /bin/sh
-            - -c
-            - while true; do curl -s http://localhost:8000; sleep 60; done
+          command: ["/bin/sh", "/scripts/curl-loop.sh"]

Additionally, add a volume mount and the Secret-backed volume elsewhere in this manifest:

# add under the curl-sidecar container
volumeMounts:
  - name: curl-loop-script
    mountPath: /scripts
    readOnly: true

# add at the pod spec level
volumes:
  - name: curl-loop-script
    secret:
      secretName: curl-loop-script
      defaultMode: 0555

And create a Secret (outside this manifest or as a separate doc) containing the script:

apiVersion: v1
kind: Secret
metadata:
  name: curl-loop-script
  namespace: app-22
type: Opaque
stringData:
  curl-loop.sh: |
    #!/bin/sh
    while true; do curl -sS http://localhost:8000 || true; sleep 60; done
🧹 Nitpick comments (6)
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml (1)

16-21: Add minimal resource requests/limits to keep test footprint low.

Tests should specify small resources to avoid cluster contention.

       containers:
         - name: fastapi-app
           image: us-central1-docker.pkg.dev/genuine-flight-317411/devel/rds-demo:v1
+          resources:
+            requests:
+              cpu: 25m
+              memory: 64Mi
+            limits:
+              cpu: 100m
+              memory: 128Mi
           ports:
             - containerPort: 8000
             - containerPort: 8001
         - name: curl-sidecar
           image: curlimages/curl
+          resources:
+            requests:
+              cpu: 5m
+              memory: 32Mi
+            limits:
+              cpu: 25m
+              memory: 64Mi

Also applies to: 43-45

tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml (5)

7-10: Small grammar tweak in description.

Fix “creating a the secret” → “creating the secret.”

-  This requires first creating a the secret 'db-secrets-for-medium' in namespace app-22 w/ credentials for the RDS database.
+  This requires first creating the secret 'db-secrets-for-medium' in namespace app-22 w/ credentials for the RDS database.

18-29: Avoid decoding secret values during validation; check base64 length instead.

Reduces exposure risk while still validating non-empty fields.

-  kubectl get secret db-secrets-for-medium -n app-22 -o json \
-  | jq -e '
-      [.data.username, .data.password, .data.host, .data.database]
-      | map(select(. != null) | @base64d | select(length > 0))
-      | length == 4
-    ' >/dev/null \
+  kubectl get secret db-secrets-for-medium -n app-22 -o json \
+  | jq -e '
+      [.data.username, .data.password, .data.host, .data.database]
+      | map(select(. != null and length > 0))
+      | length == 4
+    ' >/dev/null \

55-76: Make log match more robust.

Match a broader, stable substring and limit log span to reduce noise. Also handle multiple restarts.

-      if kubectl logs "$pod" -n app-22 2>/dev/null | grep -q "Can't connect to MySQL server on 'promotions-db-for-medium.cp8rwothwarq.us-east-2.rds.amazonaws.com"; then
+      if kubectl logs "$pod" -n app-22 --since=5m --max-log-requests=5 2>/dev/null | grep -q "Can't connect to MySQL server on"; then
         echo "Found MySQL connection error in logs"
         found=true
         break
       fi

33-35: Nit: -n flag is redundant when the manifest already specifies namespace.

Harmless to keep; safe to drop for clarity.

-  kubectl apply -f ./manifest.yaml -n app-22
+  kubectl apply -f ./manifest.yaml

78-79: Cleanup step looks good; optional: delete namespace to guarantee isolation.

Leaving it commented is fine if namespaces are reused by humans; consider enabling in CI.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0608ca and 49bd883.

📒 Files selected for processing (2)
  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml (2 hunks)
  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
tests/**

📄 CodeRabbit Inference Engine (CLAUDE.md)

Tests must match source structure under tests/

Files:

  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
**/*.yaml

📄 CodeRabbit Inference Engine (CLAUDE.md)

ALWAYS use Secrets for scripts, not inline manifests or ConfigMaps (prevents code visibility with kubectl describe)

Files:

  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
tests/**/*.yaml

📄 CodeRabbit Inference Engine (CLAUDE.md)

tests/**/*.yaml: Never use names that hint at the problem or expected behavior in resource names (e.g., avoid 'broken-pod', 'test-project-that-does-not-exist', 'crashloop-app'). Use neutral names that don't give away what the LLM should discover
Each test must use a dedicated namespace app- to prevent conflicts
All pod names must be unique across tests
Resource naming should be neutral, not hint at the problem
Use minimal resource footprints (e.g., reduce memory/CPU for Loki in tests)

Files:

  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
  • GitHub Check: Pre-commit checks
🔇 Additional comments (2)
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml (2)

5-5: Namespace selection aligns with test isolation guideline (app-22).

Good use of a dedicated namespace for this test.


54-54: Service namespace aligns with test isolation guideline (app-22).

Consistent with the Deployment’s namespace.

@@ -2,6 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: customer-orders-for-medium

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.

💡 Verification agent

🧩 Analysis chain

Consider namespacing resource names with the test ID to ensure cross-test uniqueness.

To satisfy “All pod names must be unique across tests,” consider suffixing with “-22” (e.g., customer-orders-for-medium-22).

Run this to check if names are reused elsewhere:

Also applies to: 53-53


🏁 Script executed:

#!/bin/bash
# Verify uniqueness of names across tests
rg -n $'name: *(customer-orders-for-medium|customer-orders-service-for-medium)\b' tests -A 2

Length of output: 92


🏁 Script executed:

#!/bin/bash
# Re-verify usage of pod names across all test manifests
rg -F -n "name: customer-orders-for-medium" -g "*.yaml" tests
rg -F -n "name: customer-orders-service-for-medium" -g "*.yaml" tests

Length of output: 366


Namespace resource names with the test ID for uniqueness

Although no other tests currently use these names, our convention requires every pod and service name to include the test ID. Please suffix both entries in this manifest with “-22”:

Files to update:

  • tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml

Proposed diff:

@@ tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
-  name: customer-orders-for-medium
+  name: customer-orders-for-medium-22

@@ tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
-  name: customer-orders-service-for-medium
+  name: customer-orders-service-for-medium-22
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: customer-orders-for-medium
@@ tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
- name: customer-orders-for-medium
+ name: customer-orders-for-medium-22
@@ tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml
- name: customer-orders-service-for-medium
+ name: customer-orders-service-for-medium-22
🤖 Prompt for AI Agents
tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/manifest.yaml around
line 4: the resource names must include the test ID for uniqueness; update the
manifest so any pod and service name values in this file (including the current
name value "customer-orders-for-medium") are suffixed with "-22" (e.g.
"customer-orders-for-medium-22") so both pod and service entries use the test ID
suffix.

Comment on lines +30 to +33
# Stop RDS instance if not already stopped
[ "$(aws rds describe-db-instances --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)" != "stopped" ] && aws rds stop-db-instance --db-instance-identifier promotions-db-for-medium || echo "RDS instance is already stopped."
kubectl apply -f ./slow-rds-query-for-medium.yaml
sleep 60

# Apply deployment

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.

🛠️ Refactor suggestion

Pin AWS region to avoid reliance on ambient configuration.

Add --region us-east-2 to both describe and stop calls.

-  [ "$(aws rds describe-db-instances --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)" != "stopped" ] && aws rds stop-db-instance --db-instance-identifier promotions-db-for-medium || echo "RDS instance is already stopped."
+  [ "$(aws rds describe-db-instances --region us-east-2 --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)" != "stopped" ] \
+    && aws rds stop-db-instance --region us-east-2 --db-instance-identifier promotions-db-for-medium \
+    || echo "RDS instance is already stopped."
🤖 Prompt for AI Agents
In tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
around lines 30 to 33, the AWS CLI calls rely on ambient AWS region
configuration; update both aws rds describe-db-instances and aws rds
stop-db-instance invocations to include the flag --region us-east-2 so they
explicitly target the us-east-2 region.

Comment on lines +36 to +54
echo "Verifying RDS instance status..."
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
status=$(aws rds describe-db-instances --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)
if [ "$status" = "stopped" ] || [ "$status" = "stopping" ]; then
echo "RDS instance is $status"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done

if [ "$status" != "stopped" ] && [ "$status" != "stopping" ]; then
echo "ERROR: RDS instance status is $status, expected stopped or stopping"
exit 1
fi

# Wait for MySQL connection error in logs instead of fixed sleep

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.

🛠️ Refactor suggestion

Also pin region in polling loop.

Ensures consistent behavior regardless of env defaults.

-    status=$(aws rds describe-db-instances --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)
+    status=$(aws rds describe-db-instances --region us-east-2 --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Verify RDS instance is stopped or stopping
echo "Verifying RDS instance status..."
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
status=$(aws rds describe-db-instances --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)
if [ "$status" = "stopped" ] || [ "$status" = "stopping" ]; then
echo "RDS instance is $status"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done
if [ "$status" != "stopped" ] && [ "$status" != "stopping" ]; then
echo "ERROR: RDS instance status is $status, expected stopped or stopping"
exit 1
fi
# Verify RDS instance is stopped or stopping
echo "Verifying RDS instance status..."
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
status=$(aws rds describe-db-instances --region us-east-2 --db-instance-identifier promotions-db-for-medium --query "DBInstances[0].DBInstanceStatus" --output text)
if [ "$status" = "stopped" ] || [ "$status" = "stopping" ]; then
echo "RDS instance is $status"
break
fi
sleep 2
elapsed=$((elapsed + 2))
done
if [ "$status" != "stopped" ] && [ "$status" != "stopping" ]; then
echo "ERROR: RDS instance status is $status, expected stopped or stopping"
exit 1
fi
🤖 Prompt for AI Agents
In tests/llm/fixtures/test_ask_holmes/22_high_latency_dbi_down/test_case.yaml
around lines 36 to 54, the AWS CLI describe-db-instances call in the polling
loop does not specify a region, which can yield inconsistent behavior; update
the command to explicitly pin the region (either by adding --region <REGION>
using the same region variable used elsewhere, e.g. --region "$AWS_REGION", or a
hardcoded region constant used by the test suite) so every invocation of aws rds
describe-db-instances uses the intended region.

@coderabbitai coderabbitai Bot mentioned this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants