|
| 1 | +# Load Testing for DevWorkspace Operator |
| 2 | + |
| 3 | +This directory contains load testing tools for the DevWorkspace Operator using k6. The tests create multiple DevWorkspaces concurrently to measure the operator's performance under load. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- `kubectl` (version >= 1.24.0) |
| 8 | +- `curl` (version >= 7.0.0) |
| 9 | +- `k6` (version >= 1.1.0) - Required when using `--mode binary` |
| 10 | +- Access to a Kubernetes cluster with DevWorkspace Operator installed |
| 11 | +- Proper RBAC permissions to create DevWorkspaces, ConfigMaps, Secrets, and Namespaces |
| 12 | + |
| 13 | +## Running Load Tests |
| 14 | + |
| 15 | +The load tests can be run using the `make test_load` target with various arguments. The tests support two modes: |
| 16 | +- **binary mode**: Runs k6 locally (default) |
| 17 | +- **operator mode**: Runs k6 using the k6-operator in the cluster |
| 18 | + |
| 19 | +### Running with Eclipse Che |
| 20 | + |
| 21 | +When running with Eclipse Che, the script automatically provisions additional ConfigMaps for certificates that are required for Che workspaces to function properly. |
| 22 | + |
| 23 | +```bash |
| 24 | +make test_load ARGS=" \ |
| 25 | + --mode binary \ |
| 26 | + --run-with-eclipse-che true \ |
| 27 | + --max-vus ${MAX_VUS} \ |
| 28 | + --create-automount-resources true \ |
| 29 | + --max-devworkspaces ${MAX_DEVWORKSPACES} \ |
| 30 | + --devworkspace-ready-timeout-seconds 3600 \ |
| 31 | + --delete-devworkspace-after-ready false \ |
| 32 | + --separate-namespaces false \ |
| 33 | + --test-duration-minutes 40" |
| 34 | +``` |
| 35 | + |
| 36 | +**Note**: When `--run-with-eclipse-che true` is set, the script will: |
| 37 | +- Provision a workspace namespace compatible with Eclipse Che |
| 38 | +- Create additional certificate ConfigMaps required by Che |
| 39 | + |
| 40 | +### Running without Eclipse Che |
| 41 | + |
| 42 | +When running without Eclipse Che, the standard namespace setup is used without additional certificate ConfigMaps. |
| 43 | + |
| 44 | +```bash |
| 45 | +make test_load ARGS=" \ |
| 46 | + --mode binary \ |
| 47 | + --max-vus ${MAX_VUS} \ |
| 48 | + --create-automount-resources true \ |
| 49 | + --max-devworkspaces ${MAX_DEVWORKSPACES} \ |
| 50 | + --devworkspace-ready-timeout-seconds 3600 \ |
| 51 | + --delete-devworkspace-after-ready false \ |
| 52 | + --separate-namespaces false \ |
| 53 | + --test-duration-minutes 40" |
| 54 | +``` |
| 55 | + |
| 56 | +## Available Parameters |
| 57 | + |
| 58 | +| Parameter | Description | Default | Example | |
| 59 | +|-----------|-------------|---------|---------| |
| 60 | +| `--mode` | Execution mode: `binary` or `operator` | `binary` | `--mode binary` | |
| 61 | +| `--max-vus` | Maximum number of virtual users (concurrent DevWorkspace creations) | `100` | `--max-vus 50` | |
| 62 | +| `--max-devworkspaces` | Maximum number of DevWorkspaces to create (-1 for unlimited) | `-1` | `--max-devworkspaces 200` | |
| 63 | +| `--separate-namespaces` | Create each DevWorkspace in its own namespace | `false` | `--separate-namespaces true` | |
| 64 | +| `--delete-devworkspace-after-ready` | Delete DevWorkspace once it becomes Ready | `true` | `--delete-devworkspace-after-ready false` | |
| 65 | +| `--devworkspace-ready-timeout-seconds` | Timeout in seconds for workspace to become ready | `1200` | `--devworkspace-ready-timeout-seconds 3600` | |
| 66 | +| `--devworkspace-link` | URL to external DevWorkspace JSON to use instead of default | (empty) | `--devworkspace-link https://...` | |
| 67 | +| `--create-automount-resources` | Create automount ConfigMap and Secret for testing | `false` | `--create-automount-resources true` | |
| 68 | +| `--dwo-namespace` | DevWorkspace Operator namespace | `openshift-operators` | `--dwo-namespace devworkspace-controller` | |
| 69 | +| `--logs-dir` | Directory for DevWorkspace and event logs | `logs` | `--logs-dir /tmp/test-logs` | |
| 70 | +| `--test-duration-minutes` | Duration in minutes for the load test | `25` | `--test-duration-minutes 40` | |
| 71 | +| `--run-with-eclipse-che` | Enable Eclipse Che integration (adds certificate ConfigMaps) | `false` | `--run-with-eclipse-che true` | |
| 72 | +| `--che-cluster-name` | Eclipse Che cluster name (when using Che) | `eclipse-che` | `--che-cluster-name my-che` | |
| 73 | +| `--che-namespace` | Eclipse Che namespace (when using Che) | `eclipse-che` | `--che-namespace my-che-ns` | |
| 74 | + |
| 75 | +## What the Tests Do |
| 76 | + |
| 77 | +1. **Setup**: Creates a test namespace, ServiceAccount, and RBAC resources |
| 78 | +2. **Eclipse Che Setup** (if enabled): Provisions Che-compatible namespace and certificate ConfigMaps |
| 79 | +3. **Load Generation**: Creates DevWorkspaces concurrently based on `--max-devworkspaces` |
| 80 | +4. **Monitoring**: |
| 81 | + - Watches DevWorkspace status until Ready |
| 82 | + - Monitors operator CPU and memory usage |
| 83 | + - Tracks etcd metrics |
| 84 | + - Logs events and DevWorkspace state changes |
| 85 | +5. **Cleanup**: Removes all created resources and test namespace |
| 86 | + |
| 87 | +## Test Metrics |
| 88 | + |
| 89 | +The tests track the following metrics: |
| 90 | +- DevWorkspace creation duration |
| 91 | +- DevWorkspace ready duration |
| 92 | +- DevWorkspace deletion duration |
| 93 | +- Operator CPU and memory usage |
| 94 | +- etcd CPU and memory usage |
| 95 | +- Success/failure rates |
| 96 | + |
| 97 | +## Output |
| 98 | + |
| 99 | +- **Logs**: Stored in the `logs/` directory (or custom directory specified by `--logs-dir`) |
| 100 | + - `{timestamp}_events.log`: Kubernetes events |
| 101 | + - `{timestamp}_dw_watch.log`: DevWorkspace watch logs |
| 102 | + - `dw_failure_report.csv`: Failed DevWorkspaces report |
| 103 | +- **HTML Report**: Generated when running in binary mode (outside cluster) |
| 104 | +- **Console Output**: Real-time test progress and summary |
| 105 | + |
| 106 | +## Troubleshooting |
| 107 | + |
| 108 | +- **Permission errors**: Ensure your kubeconfig has sufficient RBAC permissions |
| 109 | +- **Timeout errors**: Increase `--devworkspace-ready-timeout-seconds` for slower clusters |
| 110 | +- **Resource exhaustion**: Reduce `--max-vus` or `--max-devworkspaces` if cluster resources are limited |
| 111 | +- **k6 not found**: Install k6 from https://k6.io/docs/getting-started/installation/ |
| 112 | + |
| 113 | +## Additional Notes |
| 114 | + |
| 115 | +- The tests use an opinionated minimal DevWorkspace by default, or you can provide a custom one via `--devworkspace-link` |
| 116 | +- When `--separate-namespaces true` is used, each DevWorkspace gets its own namespace |
| 117 | +- The `--delete-devworkspace-after-ready false` option is useful for testing sustained load scenarios |
| 118 | +- Certificate ConfigMaps are only created when `--run-with-eclipse-che true` is set |
| 119 | + |
0 commit comments