Skip to content

[Tests] Add Kafka, Redis - #1077

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feature-app-tests
Jun 24, 2025
Merged

[Tests] Add Kafka, Redis#1077
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feature-app-tests

Conversation

@gwynbleidd2106

@gwynbleidd2106 gwynbleidd2106 commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Add extra tests into e2e apps

Summary by CodeRabbit

  • Tests
    • Added automated end-to-end tests for Kafka and Redis resources in Kubernetes, including creation, readiness verification, and cleanup. These tests ensure that the Kafka and Redis clusters are properly deployed and their components are functioning as expected.
    • Updated PostgreSQL test to improve cleanup by removing initialization jobs after resource deletion.
  • Chores
    • Expanded the pull request testing workflow to include Kafka and Redis applications in the test matrix for broader coverage.

@coderabbitai

coderabbitai Bot commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

"""

Walkthrough

Two new BATS test scripts have been added to automate end-to-end testing of Kafka and Redis custom resources in a Kubernetes environment. These scripts create the resources, verify their readiness and associated components, and perform cleanup by deleting the resources after the tests complete. Additionally, the GitHub Actions workflow was updated to include Kafka and Redis in the test matrix for pull request validation. The Postgres test script was also updated to delete an associated init job during cleanup.

Changes

File(s) Change Summary
hack/e2e-apps/kafka.bats Added automated BATS test for Kafka CR creation, readiness, service port checks, and cleanup.
hack/e2e-apps/redis.bats Added automated BATS test for Redis CR creation, readiness, and cleanup.
hack/e2e-apps/postgres.bats Updated Postgres test to delete associated init job during cleanup.
.github/workflows/pull-requests.yaml Expanded test matrix to include Kafka and Redis applications in PR test workflow.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant Kubernetes
    participant Kafka/Redis Operator

    Tester->>Kubernetes: Create Kafka/Redis resource manifest
    Kubernetes->>Kafka/Redis Operator: Notify of new resource
    Kafka/Redis Operator->>Kubernetes: Create required components (PVC, StatefulSet, Service, etc.)
    Tester->>Kubernetes: Poll for resource readiness and component status
    Kubernetes->>Tester: Respond with status
    Tester->>Kubernetes: Delete Kafka/Redis resource after test
Loading

Possibly related PRs

Suggested labels

enhancement, size:L, lgtm

Suggested reviewers

  • klinch0

Poem

A rabbit hops through clusters bright,
Testing Kafka, Redis, day and night.
With scripts anew, it checks each state,
Ensuring all components integrate.
When tests are done, it cleans the scene—
The happiest hare you’ve ever seen!
🐇✨
"""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 74d4502 and c0b7f4e.

📒 Files selected for processing (4)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/e2e-apps/kafka.bats (1 hunks)
  • hack/e2e-apps/postgres.bats (1 hunks)
  • hack/e2e-apps/redis.bats (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • hack/e2e-apps/postgres.bats
  • hack/e2e-apps/kafka.bats
  • hack/e2e-apps/redis.bats
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@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

🧹 Nitpick comments (1)
hack/e2e-apps.bats (1)

404-407: Redis bootstrap may exceed 20 s/70 s – raise the ceilings

Initial PVC binding plus sentinel & redis-server rollout often crosses the current limits, causing flaky red builds. Suggest increasing to 2-3 minutes each to stabilise 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 3ce6dbe and 0178c34.

📒 Files selected for processing (1)
  • hack/e2e-apps.bats (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pre-commit
  • GitHub Check: Build

Comment thread hack/e2e-apps.bats Outdated
Comment thread hack/e2e-apps.bats Outdated
Comment thread hack/e2e-apps.bats Outdated

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

🧹 Nitpick comments (1)
hack/e2e-apps/kafka.bats (1)

24-24: Clarify empty resources field.

The resources: field is empty, which might be intentional but could be confusing.

Consider making it explicit:

-    resources:
+    resources: {}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0178c34 and ebae746.

📒 Files selected for processing (2)
  • hack/e2e-apps/kafka.bats (1 hunks)
  • hack/e2e-apps/redis.bats (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: pre-commit
  • GitHub Check: Build

Comment thread hack/e2e-apps/redis.bats
Comment thread hack/e2e-apps/redis.bats
Comment thread hack/e2e-apps/redis.bats
Comment thread hack/e2e-apps/kafka.bats
Comment thread hack/e2e-apps/kafka.bats
Comment on lines +3 to +51
@test "Create Kafka" {
name='test'
kubectl create -f- <<EOF
apiVersion: apps.cozystack.io/v1alpha1
kind: Kafka
metadata:
name: $name
namespace: tenant-test
spec:
external: false
kafka:
size: 10Gi
replicas: 2
storageClass: ""
resources: {}
resourcesPreset: "nano"
zookeeper:
size: 5Gi
replicas: 2
storageClass: ""
resources:
resourcesPreset: "nano"
topics:
- name: testResults
partitions: 1
replicas: 2
config:
min.insync.replicas: 2
- name: testOrders
config:
cleanup.policy: compact
segment.ms: 3600000
max.compaction.lag.ms: 5400000
min.insync.replicas: 2
partitions: 1
replicas: 2
EOF
sleep 5
kubectl -n tenant-test wait hr kafka-$name --timeout=30s --for=condition=ready
kubectl -n tenant-test wait pvc data-kafka-$name-zookeeper-0 --timeout=30s --for=jsonpath='{.status.phase}'=Bound
timeout 40 sh -ec "until kubectl -n tenant-test get svc kafka-$name-zookeeper-client -o jsonpath='{.spec.ports[0].port}' | grep -q '2181'; do sleep 10; done"
timeout 40 sh -ec "until kubectl -n tenant-test get svc kafka-$name-zookeeper-nodes -o jsonpath='{.spec.ports[*].port}' | grep -q '2181 2888 3888'; do sleep 10; done"
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints kafka-$name-zookeeper-nodes -o jsonpath='{.subsets[*].addresses[0].ip}' | grep -q '[0-9]'; do sleep 10; done"
}

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

Add cleanup and consistent error handling.

Like the Redis test, this needs proper cleanup and consistent error handling throughout.

Add cleanup trap at the beginning of the test:

 @test "Create Kafka" {
   name="test-$(date +%s)-$$"
+  
+  # Cleanup function
+  cleanup() {
+    kubectl delete kafka $name -n tenant-test --ignore-not-found=true || true
+  }
+  trap cleanup EXIT
+  
   kubectl create -f- <<EOF

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In hack/e2e-apps/kafka.bats around lines 3 to 46, the Kafka creation test lacks
cleanup and consistent error handling. Add a cleanup trap at the start of the
test to delete the Kafka resource and related PVCs after the test finishes or
fails. Also, ensure all kubectl commands and waits handle errors consistently,
for example by checking command success and failing the test early if any step
fails.

Comment thread hack/e2e-apps/kafka.bats
Comment thread hack/e2e-apps/kafka.bats
@gwynbleidd2106
gwynbleidd2106 force-pushed the feature-app-tests branch 2 times, most recently from 24d3d95 to d5f6983 Compare June 24, 2025 09:55

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

🧹 Nitpick comments (1)
.github/workflows/pull-requests.yaml (1)

158-158: Insert spaces after commas in the app matrix list for YAML lint compliance

YAML-lint is already flagging the line; adding a single space after each comma restores conventional YAML style and silences the warning.

-       app: [clickhouse,kafka,kubernetes,mysql,postgres,redis,virtualmachine,vminstance]
+       app: [clickhouse, kafka, kubernetes, mysql, postgres, redis, virtualmachine, vminstance]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24d3d95 and d5f6983.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/e2e-apps/kafka.bats (1 hunks)
  • hack/e2e-apps/redis.bats (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • hack/e2e-apps/redis.bats
  • hack/e2e-apps/kafka.bats
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)

🔇 Additional comments (1)
.github/workflows/pull-requests.yaml (1)

155-175: ```shell
#!/bin/bash

Check for a generic catch-all rule for test-apps in the core testing Makefile

grep -nH -E 'test-apps-%:' packages/core/testing/Makefile || echo "No explicit pattern rule 'test-apps-%:' found"
grep -nH -E '.PHONY:.*test-apps-%' packages/core/testing/Makefile || echo "No .PHONY entry for 'test-apps-%' found"


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

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

🧹 Nitpick comments (1)
packages/apps/clickhouse/values.yaml (1)

60-62: Default preset bumped to “small” – verify cluster quotas & update docs

Raising the default resourcesPreset from "nano" to "small" will increase CPU/memory requests for every deployment that does not override this value. Before merging, please confirm:

• All CI/demo/production clusters have sufficient quota.
• CHANGELOG / user docs highlight the new default.
• Workloads depending on minimal footprints (e.g., local dev) explicitly override back to "nano" if needed.

Quick scan to locate charts/manifests that rely on the implicit default:

#!/bin/bash
# Finds ClickHouse releases with no explicit resourcesPreset override
rg -n --no-heading $'resourcesPreset:' | grep -i clickhouse | grep -v '"nano"' | grep -v '"small"'
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d5f6983 and 0eb4759.

📒 Files selected for processing (4)
  • hack/e2e-apps/clickhouse.bats (1 hunks)
  • packages/apps/clickhouse/Chart.yaml (1 hunks)
  • packages/apps/clickhouse/values.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/apps/clickhouse/Chart.yaml
  • hack/e2e-apps/clickhouse.bats
  • packages/apps/versions_map
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

@gwynbleidd2106
gwynbleidd2106 force-pushed the feature-app-tests branch 2 times, most recently from d4c49b8 to 4b1051c Compare June 24, 2025 10:57

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

🧹 Nitpick comments (1)
.github/workflows/pull-requests.yaml (1)

158-158: Style: add spaces after commas to silence YAMLlint & improve readability

YAMLlint flags the current line for “too few spaces after comma.”
Although syntactically valid, keeping consistent spacing avoids CI style warnings and makes the matrix easier to scan.

-        app: [clickhouse,kafka,kubernetes,mysql,postgres,redis,virtualmachine,vminstance]
+        app: [clickhouse, kafka, kubernetes, mysql, postgres, redis, virtualmachine, vminstance]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d4c49b8 and 4b1051c.

📒 Files selected for processing (3)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/e2e-apps/kafka.bats (1 hunks)
  • hack/e2e-apps/redis.bats (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • hack/e2e-apps/redis.bats
  • hack/e2e-apps/kafka.bats
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build
🔇 Additional comments (1)
.github/workflows/pull-requests.yaml (1)

171-175: Verify Makefile targets for the newly-added kafka & redis apps

Each matrix job ultimately runs:

make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-apps-${{ matrix.app }}

If test-apps-kafka or test-apps-redis targets are missing (or mis-named) the job will fail at runtime.

#!/bin/bash
# Confirm that the expected Makefile targets exist.
fd -I Makefile | xargs grep -nE 'test-apps-(kafka|redis)' || {
  echo "::error ::Missing Makefile targets: test-apps-kafka / test-apps-redis"
  exit 1
}

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4b1051c and 2fec259.

📒 Files selected for processing (4)
  • .github/workflows/pull-requests.yaml (1 hunks)
  • hack/e2e-apps/kafka.bats (1 hunks)
  • hack/e2e-apps/postgres.bats (1 hunks)
  • hack/e2e-apps/redis.bats (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • hack/e2e-apps/redis.bats
  • hack/e2e-apps/kafka.bats
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/pull-requests.yaml

[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)

🔇 Additional comments (1)
hack/e2e-apps/postgres.bats (1)

53-53: LGTM! Good cleanup improvement.

The addition of explicit init job deletion ensures proper cleanup of all resources created during the PostgreSQL test, preventing resource leakage in the test environment.

strategy:
matrix:
app: [clickhouse,kubernetes,mysql,postgres,virtualmachine,vminstance]
app: [clickhouse,kafka,kubernetes,mysql,postgres,redis,virtualmachine,vminstance]

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

🧩 Verification correct

Fix YAML formatting and verify test files exist.

The addition of kafka and redis to the test matrix aligns with the PR objectives. However, there are YAML formatting issues that need to be addressed.

Apply this diff to fix the comma spacing:

-        app: [clickhouse,kafka,kubernetes,mysql,postgres,redis,virtualmachine,vminstance]
+        app: [clickhouse, kafka, kubernetes, mysql, postgres, redis, virtualmachine, vminstance]

Please verify that the corresponding test files exist:


🏁 Script executed:

#!/bin/bash
# Description: Verify that kafka.bats and redis.bats test files exist
# Expected: Both files should exist in the hack/e2e-apps/ directory

echo "Checking for Kafka and Redis test files..."
fd "kafka.bats" hack/e2e-apps/
fd "redis.bats" hack/e2e-apps/

echo "Listing all .bats files in hack/e2e-apps/ for context:"
fd "*.bats" hack/e2e-apps/

Length of output: 640


Fix YAML formatting and verify test files exist.

The addition of kafka and redis to the test matrix aligns with the PR objectives. However, there are YAML formatting issues that need to be addressed.

Apply this diff to fix the comma spacing:

-        app: [clickhouse,kafka,kubernetes,mysql,postgres,redis,virtualmachine,vminstance]
+        app: [clickhouse, kafka, kubernetes, mysql, postgres, redis, virtualmachine, vminstance]

Please verify that the corresponding test files exist:

#!/bin/bash
# Description: Verify that kafka.bats and redis.bats test files exist
# Expected: Both files should exist in the hack/e2e-apps/ directory

echo "Checking for Kafka and Redis test files..."
fd "kafka.bats" hack/e2e-apps/
fd "redis.bats" hack/e2e-apps/

echo "Listing all .bats files in hack/e2e-apps/ for context:"
fd "*.bats" hack/e2e-apps/
🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)


[warning] 158-158: too few spaces after comma

(commas)

🤖 Prompt for AI Agents
In .github/workflows/pull-requests.yaml at line 158, fix the YAML formatting by
ensuring proper spacing after commas in the app list to comply with YAML syntax.
Additionally, verify that the test files kafka.bats and redis.bats exist in the
hack/e2e-apps/ directory by running the provided shell commands or equivalent
checks, and confirm their presence before finalizing the changes.

@kvaps
Andrei Kvapil (kvaps) force-pushed the feature-app-tests branch 2 times, most recently from 74d4502 to d948980 Compare June 24, 2025 15:12
Remove postgres job after completion

Signed-off-by: Ahmad Murzahmatov <gwynbleidd2106@yandex.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
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