From 6f6c079f71b21bc186b775f0fb0633aaab179bc3 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:23:14 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 15 ++ README.md | 3 + commands/lb-test.md | 37 ++++ plugin.lock.json | 73 +++++++ skills/load-balancer-tester/SKILL.md | 56 +++++ skills/load-balancer-tester/assets/README.md | 7 + .../assets/example_config.conf | 74 +++++++ .../assets/report_template.html | 204 ++++++++++++++++++ .../assets/test_template.json | 62 ++++++ .../load-balancer-tester/references/README.md | 7 + skills/load-balancer-tester/scripts/README.md | 7 + 11 files changed, 545 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/lb-test.md create mode 100644 plugin.lock.json create mode 100644 skills/load-balancer-tester/SKILL.md create mode 100644 skills/load-balancer-tester/assets/README.md create mode 100644 skills/load-balancer-tester/assets/example_config.conf create mode 100644 skills/load-balancer-tester/assets/report_template.html create mode 100644 skills/load-balancer-tester/assets/test_template.json create mode 100644 skills/load-balancer-tester/references/README.md create mode 100644 skills/load-balancer-tester/scripts/README.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..3dd7ac6 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "load-balancer-tester", + "description": "Test load balancing strategies with traffic distribution validation and failover testing", + "version": "1.0.0", + "author": { + "name": "Claude Code Plugin Hub", + "email": "[email protected]" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..64e2223 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# load-balancer-tester + +Test load balancing strategies with traffic distribution validation and failover testing diff --git a/commands/lb-test.md b/commands/lb-test.md new file mode 100644 index 0000000..a91b4cc --- /dev/null +++ b/commands/lb-test.md @@ -0,0 +1,37 @@ +--- +description: Test load balancer traffic distribution and failover strategies +shortcut: lbt +--- + +# Load Balancer Tester + +Test load balancing strategies including round-robin, least connections, weighted distribution, sticky sessions, and failover scenarios. + +## What You Do + +1. **Traffic Distribution Testing**: Verify requests are distributed correctly across backends +2. **Failover Testing**: Test behavior when backends fail +3. **Sticky Session Validation**: Ensure session affinity works +4. **Health Check Testing**: Verify health checks remove unhealthy backends + +## Output Example + +```javascript +describe('Load Balancer Tests', () => { + it('distributes traffic evenly with round-robin', async () => { + const requests = 100; + const backends = ['backend1', 'backend2', 'backend3']; + const distribution = await sendRequests(requests); + + backends.forEach(backend => { + expect(distribution[backend]).toBeCloseTo(requests / backends.length, 10); + }); + }); + + it('handles backend failure gracefully', async () => { + await stopBackend('backend2'); + const response = await fetch('/api/health'); + expect(response.status).toBe(200); + }); +}); +``` diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..5a9ef3e --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,73 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/testing/load-balancer-tester", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "7cb134ab9ac6d569100d47786c370c9f8532afb7", + "treeHash": "edf24c22c97c71d7e6879bfe7593d8bdd8f40095e85342d0c191077949d199ad", + "generatedAt": "2025-11-28T10:18:32.205885Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "load-balancer-tester", + "description": "Test load balancing strategies with traffic distribution validation and failover testing", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "1c31944165237064cb723cda00d62ea6296d639db2c9b883a7796d4214c9d404" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "97a2a6c1c63f796a8de48ae5e4f4115825507aa0afc8499140b4d88433da5ac1" + }, + { + "path": "commands/lb-test.md", + "sha256": "99ac7560e4ebd8225a1dc93e6727e4f20ed5137da5d8da85097e6b114c1abf21" + }, + { + "path": "skills/load-balancer-tester/SKILL.md", + "sha256": "60f5f090bdf1183ea32cfc5eec34622d17154926659f5367d1394c3b7cd2ba6f" + }, + { + "path": "skills/load-balancer-tester/references/README.md", + "sha256": "0f0ff2482815fabc198f9ab84fd759735c402d7c417c908cb08320950723b0bd" + }, + { + "path": "skills/load-balancer-tester/scripts/README.md", + "sha256": "22a5964e8757cb2243da12a358622c06a8d4a3ce82d7e25d1580f56e2cf87996" + }, + { + "path": "skills/load-balancer-tester/assets/README.md", + "sha256": "5d99211170f74a12e47217159a3c17dcfd64c0aa65ad503d0f90e582991c4d49" + }, + { + "path": "skills/load-balancer-tester/assets/example_config.conf", + "sha256": "ffe098389fc6917522ec51501caa5eab4c06e81cabd16180bb3e6e103c176552" + }, + { + "path": "skills/load-balancer-tester/assets/report_template.html", + "sha256": "4fb0bed0ac8292acdc3431abb1b5bafc9869ce92fea537993d191dbdc983a858" + }, + { + "path": "skills/load-balancer-tester/assets/test_template.json", + "sha256": "f05b94a11dd7949f43d9c87392df9ae55aa5d0c723e4c22c188dec545dc1feb5" + } + ], + "dirSha256": "edf24c22c97c71d7e6879bfe7593d8bdd8f40095e85342d0c191077949d199ad" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/load-balancer-tester/SKILL.md b/skills/load-balancer-tester/SKILL.md new file mode 100644 index 0000000..9f9a662 --- /dev/null +++ b/skills/load-balancer-tester/SKILL.md @@ -0,0 +1,56 @@ +--- +name: testing-load-balancers +description: | + This skill enables Claude to test load balancing strategies. It validates traffic distribution across backend servers, tests failover scenarios when servers become unavailable, verifies sticky sessions, and assesses health check functionality. Use this skill when the user asks to "test load balancer", "validate traffic distribution", "test failover", "verify sticky sessions", or "test health checks". It is specifically designed for testing load balancing configurations using the `load-balancer-tester` plugin. +allowed-tools: Read, Bash, Grep, Glob +version: 1.0.0 +--- + +## Overview + +This skill empowers Claude to thoroughly test load balancing configurations, ensuring high availability and optimal performance. It automates the process of validating traffic distribution, simulating server failures, and verifying session persistence. + +## How It Works + +1. **Initiating the Test**: Claude receives a request to test the load balancer. +2. **Executing the Test Suite**: Claude uses the `load-balancer-tester` plugin to run a series of tests, including traffic distribution validation, failover testing, sticky session verification, and health check testing. +3. **Presenting the Results**: Claude provides a summary of the test results, highlighting any issues or areas for improvement. + +## When to Use This Skill + +This skill activates when you need to: +- Validate traffic distribution across backend servers. +- Test the load balancer's ability to handle server failures. +- Verify that sticky sessions are functioning correctly. +- Ensure that health checks are effectively removing unhealthy servers from the pool. + +## Examples + +### Example 1: Validating Traffic Distribution + +User request: "Test load balancer traffic distribution for even distribution across servers." + +The skill will: +1. Execute the `lb-test` command. +2. Analyze the traffic distribution across the backend servers. +3. Report whether the traffic is evenly distributed. + +### Example 2: Simulating a Failover Scenario + +User request: "Test failover when one of the backend servers becomes unavailable." + +The skill will: +1. Execute the `lb-test` command. +2. Simulate a server failure. +3. Verify that traffic is redirected to the remaining healthy servers. +4. Report on the success of the failover process. + +## Best Practices + +- **Configuration**: Ensure the load balancer is properly configured before testing. +- **Realistic Scenarios**: Test with realistic traffic patterns and failure scenarios. +- **Comprehensive Testing**: Test all aspects of the load balancer, including traffic distribution, failover, sticky sessions, and health checks. + +## Integration + +This skill works independently using the `load-balancer-tester` plugin. It can be used in conjunction with other skills to configure and manage the load balancer before testing. \ No newline at end of file diff --git a/skills/load-balancer-tester/assets/README.md b/skills/load-balancer-tester/assets/README.md new file mode 100644 index 0000000..f254dc3 --- /dev/null +++ b/skills/load-balancer-tester/assets/README.md @@ -0,0 +1,7 @@ +# Assets + +Bundled resources for load-balancer-tester skill + +- [ ] test_template.json: JSON template for defining load balancer test configurations. +- [ ] report_template.html: HTML template for generating load balancer test reports. +- [ ] example_config.conf: Example load balancer configuration file. diff --git a/skills/load-balancer-tester/assets/example_config.conf b/skills/load-balancer-tester/assets/example_config.conf new file mode 100644 index 0000000..6941418 --- /dev/null +++ b/skills/load-balancer-tester/assets/example_config.conf @@ -0,0 +1,74 @@ +# Example Load Balancer Configuration File +# This file provides a template for configuring the load balancer settings +# to be used with the load-balancer-tester plugin. + +# --- General Configuration --- +# Name of the load balancer (used for identification) +load_balancer_name = "my-load-balancer" + +# Load balancing strategy: +# Options: round-robin, weighted-round-robin, least-connections, ip-hash +load_balancing_strategy = "round-robin" + +# --- Backend Server Configuration --- +# List of backend servers with their respective weights (if applicable) +# Format: "server_address:port:weight" +# Example: "192.168.1.10:8080:10", "192.168.1.11:8080:20", "192.168.1.12:8080" (default weight is 1) +backend_servers = [ + "server1.example.com:80:1", + "server2.example.com:80:1", + "server3.example.com:80:1" +] + +# --- Health Check Configuration --- +# Health check endpoint for backend servers +health_check_endpoint = "/health" + +# Health check interval (in seconds) +health_check_interval = 5 + +# Health check timeout (in seconds) +health_check_timeout = 2 + +# Number of consecutive successful health checks required to mark a server as healthy +healthy_threshold = 3 + +# Number of consecutive failed health checks required to mark a server as unhealthy +unhealthy_threshold = 3 + +# --- Session Persistence (Sticky Sessions) Configuration --- +# Enable or disable sticky sessions +sticky_sessions_enabled = false + +# Cookie name for session persistence (if sticky sessions are enabled) +sticky_session_cookie_name = "LB_SESSION" + +# --- Failover Configuration --- +# Time to wait before considering a server as failed (in seconds) +failover_timeout = 10 + +# --- Traffic Distribution Validation --- +# Number of requests to send for traffic distribution validation +number_of_requests = 1000 + +# --- Advanced Configuration (Optional) --- +# Custom headers to be added to the requests +# Format: "header_name:header_value" +# Example: "X-Custom-Header:MyValue" +custom_headers = [ + # "X-Request-ID: $RANDOM_UUID" # Example - replace with your desired logic +] + +# Request method to use for testing (GET, POST, PUT, DELETE, etc.) +request_method = "GET" + +# URL path to request. Defaults to "/" if not provided. +request_path = "/" + +# --- Notes --- +# - Replace the placeholder values with your actual load balancer configuration. +# - Ensure that the backend servers are accessible from the machine running the plugin. +# - Adjust the health check parameters based on your application's health check requirements. +# - For weighted round-robin, ensure that the weights are integers. +# - Remember to save this file with a `.conf` extension (e.g., `my_load_balancer.conf`). +# - The plugin will read this file to configure the load balancer testing. \ No newline at end of file diff --git a/skills/load-balancer-tester/assets/report_template.html b/skills/load-balancer-tester/assets/report_template.html new file mode 100644 index 0000000..49263cc --- /dev/null +++ b/skills/load-balancer-tester/assets/report_template.html @@ -0,0 +1,204 @@ + + + + + + Load Balancer Test Report + + + +
+

Load Balancer Test Report

+ +
+

Test Summary

+

Test ID: {{test_id}}

+

Date: {{test_date}}

+

Load Balancer URL: {{load_balancer_url}}

+

Overall Status: {{overall_status}}

+
+ +
+

Traffic Distribution Validation

+

Expected Distribution:

+

{{expected_distribution}}

+

Actual Distribution:

+

{{actual_distribution}}

+

Distribution Status: {{distribution_status}}

+

{{distribution_details}}

+
+ +
+

Failover Testing

+

Failover Status: {{failover_status}}

+

{{failover_details}}

+ + + + + + + + + + + {{failover_table_rows}} + +
InstanceStatus Before FailoverStatus After FailoverResponse Time (ms)
+
+ +
+

Sticky Session Verification

+

Sticky Session Status: {{sticky_session_status}}

+

{{sticky_session_details}}

+
+ +
+

Health Check Testing

+

Health Check Status: {{health_check_status}}

+

{{health_check_details}}

+ + + + + + + + + + + {{health_check_table_rows}} + +
InstanceHealth Check EndpointStatus CodeResponse Time (ms)
+
+ +
+

Detailed Logs

+

{{detailed_logs}}

+
+ +
+

Recommendations

+

{{recommendations}}

+
+ + +
+ + \ No newline at end of file diff --git a/skills/load-balancer-tester/assets/test_template.json b/skills/load-balancer-tester/assets/test_template.json new file mode 100644 index 0000000..e1d1ee8 --- /dev/null +++ b/skills/load-balancer-tester/assets/test_template.json @@ -0,0 +1,62 @@ +{ + "_comment": "Load Balancer Test Configuration Template", + "test_name": "Example Load Balancer Test", + "description": "Tests traffic distribution and failover capabilities of the load balancer.", + "target_url": "http://your-load-balancer-url.com", + "num_requests": 1000, + "concurrency": 10, + "request_type": "GET", + "request_headers": { + "_comment": "Optional headers to include in each request", + "Content-Type": "application/json", + "X-Test-Header": "lb-tester" + }, + "request_body": null, + "distribution_validation": { + "_comment": "Configuration for validating traffic distribution across backend servers", + "enabled": true, + "server_count": 3, + "expected_distribution_tolerance": 0.1, + "distribution_method": "request_count", + "server_identifiers": [ + "server1", + "server2", + "server3" + ], + "identifier_extraction_method": "header", + "identifier_extraction_header": "X-Server-ID" + }, + "failover_testing": { + "_comment": "Configuration for testing failover capabilities", + "enabled": true, + "server_to_fail": "server2", + "failover_wait_time": 10, + "requests_after_failover": 200 + }, + "sticky_session_verification": { + "_comment": "Configuration for verifying sticky sessions", + "enabled": false, + "session_cookie_name": "JSESSIONID", + "requests_per_session": 10 + }, + "health_check_testing": { + "_comment": "Configuration for testing health check behavior", + "enabled": false, + "health_check_endpoint": "/health", + "expected_status_code": 200, + "interval": 5, + "duration": 60 + }, + "assertions": { + "_comment": "Custom assertions to validate the response", + "response_time_max": 200, + "status_code_min": 200, + "status_code_max": 299, + "response_contains": null + }, + "reporting": { + "_comment": "Reporting configuration", + "report_format": "json", + "output_file": "lb_test_report.json" + } +} \ No newline at end of file diff --git a/skills/load-balancer-tester/references/README.md b/skills/load-balancer-tester/references/README.md new file mode 100644 index 0000000..55a425e --- /dev/null +++ b/skills/load-balancer-tester/references/README.md @@ -0,0 +1,7 @@ +# References + +Bundled resources for load-balancer-tester skill + +- [ ] load_balancer_api_docs.md: API documentation for interacting with various load balancer types (e.g., AWS ELB, Nginx, HAProxy). +- [ ] test_case_examples.md: Examples of different test cases for load balancer testing, including configuration and expected results. +- [ ] health_check_best_practices.md: Best practices for configuring and monitoring load balancer health checks. diff --git a/skills/load-balancer-tester/scripts/README.md b/skills/load-balancer-tester/scripts/README.md new file mode 100644 index 0000000..2492caf --- /dev/null +++ b/skills/load-balancer-tester/scripts/README.md @@ -0,0 +1,7 @@ +# Scripts + +Bundled resources for load-balancer-tester skill + +- [ ] load_balancer_test.py: Script to execute load balancer tests, including traffic distribution, failover, sticky sessions, and health checks. +- [ ] report_generator.py: Script to generate a detailed report of the load balancer test results. +- [ ] config_parser.py: Script to parse load balancer configuration files.