@rulebricks/cli 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +3 -3
  2. package/benchmarks/README.md +98 -0
  3. package/benchmarks/Test Flow.rbf +4088 -0
  4. package/benchmarks/benchmark-flow.json +26 -0
  5. package/benchmarks/lib/payload.js +101 -0
  6. package/benchmarks/lib/report.js +929 -0
  7. package/benchmarks/qps-test.js +136 -0
  8. package/benchmarks/run-qps-test.sh +115 -0
  9. package/benchmarks/run-throughput-test.sh +123 -0
  10. package/benchmarks/throughput-report.html +632 -0
  11. package/benchmarks/throughput-results.json +298 -0
  12. package/benchmarks/throughput-test.js +159 -0
  13. package/dist/commands/benchmark.d.ts +11 -0
  14. package/dist/commands/benchmark.js +173 -0
  15. package/dist/commands/deploy.js +15 -4
  16. package/dist/commands/destroy.js +2 -2
  17. package/dist/commands/logs.js +1 -0
  18. package/dist/components/Wizard/steps/BenchmarkSteps.d.ts +31 -0
  19. package/dist/components/Wizard/steps/BenchmarkSteps.js +304 -0
  20. package/dist/components/Wizard/steps/DatabaseStep.js +49 -35
  21. package/dist/index.js +42 -6
  22. package/dist/lib/benchmark.d.ts +63 -0
  23. package/dist/lib/benchmark.js +466 -0
  24. package/dist/lib/dns.d.ts +3 -1
  25. package/dist/lib/dns.js +138 -56
  26. package/dist/lib/helm.d.ts +14 -1
  27. package/dist/lib/helm.js +36 -1
  28. package/dist/lib/kubernetes.js +2 -0
  29. package/dist/types/index.d.ts +90 -0
  30. package/dist/types/index.js +51 -0
  31. package/package.json +8 -6
  32. package/terraform/aws/main.tf +22 -0
  33. package/terraform/azure/main.tf +45 -0
  34. package/terraform/gcp/main.tf +34 -0
  35. /package/{email-templates → templates}/email_change.html +0 -0
  36. /package/{email-templates → templates}/invite.html +0 -0
  37. /package/{email-templates → templates}/password_change.html +0 -0
  38. /package/{email-templates → templates}/verify.html +0 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "_readme": "This is a placeholder file. Replace this with the actual benchmark flow JSON provided by Rulebricks.",
3
+ "_instructions": [
4
+ "1. Download the benchmark flow from your Rulebricks documentation or support",
5
+ "2. Replace the contents of this file with the actual flow JSON",
6
+ "3. Import this flow into your Rulebricks instance via the dashboard",
7
+ "4. Note the flow ID from the URL after import",
8
+ "5. Use that flow ID in the API_URL when running benchmarks"
9
+ ],
10
+ "_expected_schema": {
11
+ "description": "The benchmark flow expects payloads with the following structure:",
12
+ "input": {
13
+ "req_id": "string - Unique request identifier for tracking",
14
+ "alpha": "number - Numeric value (0-100)",
15
+ "beta": "string - String value (can be empty)",
16
+ "charlie": "boolean - Boolean flag"
17
+ },
18
+ "example": {
19
+ "req_id": "req_1_0_1234567890",
20
+ "alpha": 42,
21
+ "beta": "test",
22
+ "charlie": true
23
+ }
24
+ }
25
+ }
26
+
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Shared payload generation utilities for Rulebricks benchmarking
3
+ *
4
+ * This module provides consistent payload generation across all benchmark tests.
5
+ * The payload structure matches the expected input for the benchmark flow.
6
+ */
7
+
8
+ import {
9
+ randomIntBetween,
10
+ randomString,
11
+ } from "https://jslib.k6.io/k6-utils/1.2.0/index.js";
12
+
13
+ /**
14
+ * Generate a single test payload
15
+ *
16
+ * The payload structure is designed to exercise various rule conditions:
17
+ * - alpha: numeric value (sometimes small 0-9, sometimes larger 10-100)
18
+ * - beta: string value (sometimes empty, sometimes random)
19
+ * - charlie: boolean value
20
+ *
21
+ * @param {string} [id] - Optional request ID for tracking
22
+ * @returns {Object} Generated payload
23
+ */
24
+ export function generatePayload(id) {
25
+ return {
26
+ req_id: id || `req_${__VU}_${__ITER}_${Date.now()}`,
27
+ alpha:
28
+ Math.random() < 0.5 ? randomIntBetween(0, 9) : randomIntBetween(10, 100),
29
+ beta: Math.random() < 0.5 ? "" : randomString(randomIntBetween(1, 10)),
30
+ charlie: Math.random() < 0.5,
31
+ };
32
+ }
33
+
34
+ /**
35
+ * Generate a bulk payload (array of payloads)
36
+ *
37
+ * @param {number} size - Number of payloads to generate
38
+ * @param {string} [prefix] - Optional prefix for request IDs
39
+ * @returns {Array<Object>} Array of generated payloads
40
+ */
41
+ export function generateBulkPayload(size, prefix = "bulk") {
42
+ const payloads = [];
43
+ for (let i = 0; i < size; i++) {
44
+ payloads.push(generatePayload(`${prefix}_${__VU}_${__ITER}_${i}`));
45
+ }
46
+ return payloads;
47
+ }
48
+
49
+ /**
50
+ * Validate required environment variables
51
+ *
52
+ * @throws {Error} If required variables are missing
53
+ */
54
+ export function validateConfig() {
55
+ if (!__ENV.API_URL) {
56
+ throw new Error(
57
+ "API_URL is required. Usage: k6 run -e API_URL=https://your-instance.com/api/v1/flows/flow_id ..."
58
+ );
59
+ }
60
+ if (!__ENV.API_KEY) {
61
+ throw new Error(
62
+ "API_KEY is required. Usage: k6 run -e API_KEY=your-api-key ..."
63
+ );
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Get configuration from environment variables with defaults
69
+ *
70
+ * @param {Object} defaults - Default values for configuration
71
+ * @returns {Object} Configuration object
72
+ */
73
+ export function getConfig(defaults = {}) {
74
+ validateConfig();
75
+
76
+ return {
77
+ apiUrl: __ENV.API_URL,
78
+ apiKey: __ENV.API_KEY,
79
+ testDuration: __ENV.TEST_DURATION || defaults.testDuration || "4m",
80
+ targetRps: parseInt(__ENV.TARGET_RPS) || defaults.targetRps || 500,
81
+ bulkSize: parseInt(__ENV.BULK_SIZE) || defaults.bulkSize || 50,
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Create HTTP request parameters
87
+ *
88
+ * @param {string} apiKey - API key for authentication
89
+ * @param {string} [timeout] - Request timeout
90
+ * @returns {Object} HTTP request parameters for k6
91
+ */
92
+ export function createRequestParams(apiKey, timeout = "10s") {
93
+ return {
94
+ headers: {
95
+ "Content-Type": "application/json",
96
+ "x-api-key": apiKey,
97
+ },
98
+ timeout: timeout,
99
+ insecureSkipTLSVerify: true,
100
+ };
101
+ }