@griffin-app/griffin-plan-executor 0.1.13 → 0.1.15
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.
- package/README.md +14 -14
- package/dist/events/adapters/in-memory.test.js +25 -23
- package/dist/events/adapters/in-memory.test.js.map +1 -1
- package/dist/events/adapters/kinesis.d.ts.map +1 -1
- package/dist/events/adapters/kinesis.js.map +1 -1
- package/dist/events/adapters/kinesis.test.js +22 -20
- package/dist/events/adapters/kinesis.test.js.map +1 -1
- package/dist/events/emitter.test.js +15 -15
- package/dist/events/emitter.test.js.map +1 -1
- package/dist/events/types.d.ts +12 -12
- package/dist/events/types.d.ts.map +1 -1
- package/dist/events/types.js +1 -1
- package/dist/executor.d.ts +2 -2
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +33 -43
- package/dist/executor.js.map +1 -1
- package/dist/executor.test.js +102 -102
- package/dist/executor.test.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/secrets/index.d.ts +4 -4
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/index.js +4 -4
- package/dist/secrets/index.js.map +1 -1
- package/dist/secrets/providers/aws.d.ts.map +1 -1
- package/dist/secrets/providers/aws.js +4 -5
- package/dist/secrets/providers/aws.js.map +1 -1
- package/dist/secrets/providers/env.js +1 -1
- package/dist/secrets/providers/env.js.map +1 -1
- package/dist/secrets/providers/vault.js +7 -7
- package/dist/secrets/providers/vault.js.map +1 -1
- package/dist/secrets/registry.d.ts +11 -33
- package/dist/secrets/registry.d.ts.map +1 -1
- package/dist/secrets/registry.js +65 -113
- package/dist/secrets/registry.js.map +1 -1
- package/dist/secrets/resolver.d.ts +12 -12
- package/dist/secrets/resolver.d.ts.map +1 -1
- package/dist/secrets/resolver.js +21 -21
- package/dist/secrets/resolver.js.map +1 -1
- package/dist/secrets/secrets.test.js +96 -120
- package/dist/secrets/secrets.test.js.map +1 -1
- package/dist/secrets/types.d.ts +2 -5
- package/dist/secrets/types.d.ts.map +1 -1
- package/dist/secrets/types.js +1 -4
- package/dist/secrets/types.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +4 -4
- package/src/events/adapters/README.md +7 -7
- package/src/events/adapters/in-memory.test.ts +27 -23
- package/src/events/adapters/kinesis.test.ts +23 -21
- package/src/events/adapters/kinesis.ts +6 -3
- package/src/events/emitter.test.ts +15 -15
- package/src/events/types.ts +13 -13
- package/src/executor.test.ts +103 -103
- package/src/executor.ts +40 -48
- package/src/index.ts +7 -7
- package/src/secrets/index.ts +5 -5
- package/src/secrets/providers/aws.ts +4 -5
- package/src/secrets/providers/env.ts +1 -1
- package/src/secrets/providers/vault.ts +7 -7
- package/src/secrets/registry.ts +75 -142
- package/src/secrets/resolver.ts +28 -26
- package/src/secrets/secrets.test.ts +124 -155
- package/src/secrets/types.ts +4 -13
- package/src/{test-plan-types.ts → test-monitor-types.ts} +1 -1
- package/src/types.ts +2 -2
package/dist/executor.test.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import { executeMonitorV1 } from "./executor.js";
|
|
3
3
|
import { StubAdapter } from "./adapters/stub.js";
|
|
4
4
|
import { START, END } from "./types.js";
|
|
5
5
|
import { LocalEventEmitter } from "./events";
|
|
6
6
|
import { SecretProviderRegistry } from "./secrets/registry.js";
|
|
7
7
|
import { EnvSecretProvider } from "./secrets/providers/env.js";
|
|
8
|
-
describe("
|
|
8
|
+
describe("executeMonitorV1", () => {
|
|
9
9
|
let stubClient;
|
|
10
10
|
let options;
|
|
11
11
|
let organizationId = "test-org";
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
stubClient = new StubAdapter();
|
|
14
14
|
const secretRegistry = new SecretProviderRegistry();
|
|
15
|
-
secretRegistry.
|
|
15
|
+
secretRegistry.setProvider(new EnvSecretProvider());
|
|
16
16
|
options = {
|
|
17
17
|
mode: "local",
|
|
18
18
|
httpClient: stubClient,
|
|
@@ -22,8 +22,8 @@ describe("executePlanV1", () => {
|
|
|
22
22
|
});
|
|
23
23
|
describe("Single HttpRequest Execution", () => {
|
|
24
24
|
it("should execute a simple GET request successfully", async () => {
|
|
25
|
-
const
|
|
26
|
-
id: "test-
|
|
25
|
+
const monitor = {
|
|
26
|
+
id: "test-monitor-1",
|
|
27
27
|
project: "test-project",
|
|
28
28
|
frequency: { every: 1, unit: "MINUTE" },
|
|
29
29
|
name: "Simple GET Test",
|
|
@@ -58,7 +58,7 @@ describe("executePlanV1", () => {
|
|
|
58
58
|
data: { users: [{ id: 1, name: "Alice" }] },
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
|
-
const result = await
|
|
61
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
62
62
|
expect(result.success).toBe(true);
|
|
63
63
|
expect(result.errors).toHaveLength(0);
|
|
64
64
|
expect(result.results).toHaveLength(1);
|
|
@@ -70,8 +70,8 @@ describe("executePlanV1", () => {
|
|
|
70
70
|
expect(result.results[0].duration_ms).toBeGreaterThanOrEqual(0);
|
|
71
71
|
});
|
|
72
72
|
it("should execute a POST request with body and headers", async () => {
|
|
73
|
-
const
|
|
74
|
-
id: "test-
|
|
73
|
+
const monitor = {
|
|
74
|
+
id: "test-monitor-2",
|
|
75
75
|
name: "POST Test",
|
|
76
76
|
version: "1.0",
|
|
77
77
|
environment: "default",
|
|
@@ -111,7 +111,7 @@ describe("executePlanV1", () => {
|
|
|
111
111
|
data: { id: 2, name: "Bob", email: "bob@example.com" },
|
|
112
112
|
},
|
|
113
113
|
});
|
|
114
|
-
const result = await
|
|
114
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
115
115
|
expect(result.success).toBe(true);
|
|
116
116
|
expect(result.results[0].response).toEqual({
|
|
117
117
|
id: 2,
|
|
@@ -120,8 +120,8 @@ describe("executePlanV1", () => {
|
|
|
120
120
|
});
|
|
121
121
|
});
|
|
122
122
|
it("should handle JSON string responses by parsing them", async () => {
|
|
123
|
-
const
|
|
124
|
-
id: "test-
|
|
123
|
+
const monitor = {
|
|
124
|
+
id: "test-monitor-3",
|
|
125
125
|
name: "JSON String Response Test",
|
|
126
126
|
version: "1.0",
|
|
127
127
|
environment: "default",
|
|
@@ -156,13 +156,13 @@ describe("executePlanV1", () => {
|
|
|
156
156
|
data: '{"message":"hello"}',
|
|
157
157
|
},
|
|
158
158
|
});
|
|
159
|
-
const result = await
|
|
159
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
160
160
|
expect(result.success).toBe(true);
|
|
161
161
|
expect(result.results[0].response).toEqual({ message: "hello" });
|
|
162
162
|
});
|
|
163
163
|
it("should override endpoint_host with baseUrl option", async () => {
|
|
164
|
-
const
|
|
165
|
-
id: "test-
|
|
164
|
+
const monitor = {
|
|
165
|
+
id: "test-monitor-4",
|
|
166
166
|
name: "BaseUrl Override Test",
|
|
167
167
|
version: "1.0",
|
|
168
168
|
environment: "default",
|
|
@@ -197,14 +197,14 @@ describe("executePlanV1", () => {
|
|
|
197
197
|
data: { users: [] },
|
|
198
198
|
},
|
|
199
199
|
});
|
|
200
|
-
const result = await
|
|
200
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
201
201
|
expect(result.success).toBe(true);
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
describe("Multiple HTTP Methods", () => {
|
|
205
205
|
it("should handle PUT requests", async () => {
|
|
206
|
-
const
|
|
207
|
-
id: "test-
|
|
206
|
+
const monitor = {
|
|
207
|
+
id: "test-monitor-5",
|
|
208
208
|
project: "test-project",
|
|
209
209
|
frequency: { every: 1, unit: "MINUTE" },
|
|
210
210
|
name: "PUT Test",
|
|
@@ -240,7 +240,7 @@ describe("executePlanV1", () => {
|
|
|
240
240
|
data: { id: 1, name: "Updated Name" },
|
|
241
241
|
},
|
|
242
242
|
});
|
|
243
|
-
const result = await
|
|
243
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
244
244
|
expect(result.success).toBe(true);
|
|
245
245
|
expect(result.results[0].response).toEqual({
|
|
246
246
|
id: 1,
|
|
@@ -248,8 +248,8 @@ describe("executePlanV1", () => {
|
|
|
248
248
|
});
|
|
249
249
|
});
|
|
250
250
|
it("should handle DELETE requests", async () => {
|
|
251
|
-
const
|
|
252
|
-
id: "test-
|
|
251
|
+
const monitor = {
|
|
252
|
+
id: "test-monitor-6",
|
|
253
253
|
project: "test-project",
|
|
254
254
|
frequency: { every: 1, unit: "MINUTE" },
|
|
255
255
|
name: "DELETE Test",
|
|
@@ -284,13 +284,13 @@ describe("executePlanV1", () => {
|
|
|
284
284
|
data: null,
|
|
285
285
|
},
|
|
286
286
|
});
|
|
287
|
-
const result = await
|
|
287
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
288
288
|
expect(result.success).toBe(true);
|
|
289
289
|
expect(result.results[0].response).toBeNull();
|
|
290
290
|
});
|
|
291
291
|
it("should handle PATCH requests", async () => {
|
|
292
|
-
const
|
|
293
|
-
id: "test-
|
|
292
|
+
const monitor = {
|
|
293
|
+
id: "test-monitor-7",
|
|
294
294
|
project: "test-project",
|
|
295
295
|
frequency: { every: 1, unit: "MINUTE" },
|
|
296
296
|
name: "PATCH Test",
|
|
@@ -326,14 +326,14 @@ describe("executePlanV1", () => {
|
|
|
326
326
|
data: { id: 1, email: "newemail@example.com" },
|
|
327
327
|
},
|
|
328
328
|
});
|
|
329
|
-
const result = await
|
|
329
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
330
330
|
expect(result.success).toBe(true);
|
|
331
331
|
});
|
|
332
332
|
});
|
|
333
333
|
describe("Sequential Execution", () => {
|
|
334
334
|
it("should execute two endpoints in sequence", async () => {
|
|
335
|
-
const
|
|
336
|
-
id: "test-
|
|
335
|
+
const monitor = {
|
|
336
|
+
id: "test-monitor-8",
|
|
337
337
|
project: "test-project",
|
|
338
338
|
frequency: { every: 1, unit: "MINUTE" },
|
|
339
339
|
name: "Sequential Test",
|
|
@@ -389,7 +389,7 @@ describe("executePlanV1", () => {
|
|
|
389
389
|
data: { step: 2 },
|
|
390
390
|
},
|
|
391
391
|
});
|
|
392
|
-
const result = await
|
|
392
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
393
393
|
expect(result.success).toBe(true);
|
|
394
394
|
expect(result.results).toHaveLength(2);
|
|
395
395
|
expect(result.results[0].nodeId).toBe("first");
|
|
@@ -398,8 +398,8 @@ describe("executePlanV1", () => {
|
|
|
398
398
|
expect(result.results[1].response).toEqual({ step: 2 });
|
|
399
399
|
});
|
|
400
400
|
it("should execute a linear chain of multiple endpoints", async () => {
|
|
401
|
-
const
|
|
402
|
-
id: "test-
|
|
401
|
+
const monitor = {
|
|
402
|
+
id: "test-monitor-9",
|
|
403
403
|
project: "test-project",
|
|
404
404
|
frequency: { every: 1, unit: "MINUTE" },
|
|
405
405
|
name: "Multi-Step Linear Test",
|
|
@@ -479,7 +479,7 @@ describe("executePlanV1", () => {
|
|
|
479
479
|
match: /\/step4$/,
|
|
480
480
|
response: { status: 200, statusText: "OK", data: { step: 4 } },
|
|
481
481
|
});
|
|
482
|
-
const result = await
|
|
482
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
483
483
|
expect(result.success).toBe(true);
|
|
484
484
|
expect(result.results).toHaveLength(4);
|
|
485
485
|
expect(result.results[0].response).toEqual({ step: 1 });
|
|
@@ -490,8 +490,8 @@ describe("executePlanV1", () => {
|
|
|
490
490
|
});
|
|
491
491
|
describe("Wait Node", () => {
|
|
492
492
|
it("should execute a wait node successfully", async () => {
|
|
493
|
-
const
|
|
494
|
-
id: "test-
|
|
493
|
+
const monitor = {
|
|
494
|
+
id: "test-monitor-10",
|
|
495
495
|
project: "test-project",
|
|
496
496
|
frequency: { every: 1, unit: "MINUTE" },
|
|
497
497
|
name: "Wait Test",
|
|
@@ -516,7 +516,7 @@ describe("executePlanV1", () => {
|
|
|
516
516
|
],
|
|
517
517
|
};
|
|
518
518
|
const startTime = Date.now();
|
|
519
|
-
const result = await
|
|
519
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
520
520
|
const endTime = Date.now();
|
|
521
521
|
expect(result.success).toBe(true);
|
|
522
522
|
expect(result.results).toHaveLength(1);
|
|
@@ -526,8 +526,8 @@ describe("executePlanV1", () => {
|
|
|
526
526
|
expect(endTime - startTime).toBeGreaterThanOrEqual(100);
|
|
527
527
|
});
|
|
528
528
|
it("should execute endpoints with waits in between", async () => {
|
|
529
|
-
const
|
|
530
|
-
id: "test-
|
|
529
|
+
const monitor = {
|
|
530
|
+
id: "test-monitor-11",
|
|
531
531
|
project: "test-project",
|
|
532
532
|
frequency: { every: 1, unit: "MINUTE" },
|
|
533
533
|
name: "HttpRequest-Wait-HttpRequest Test",
|
|
@@ -584,7 +584,7 @@ describe("executePlanV1", () => {
|
|
|
584
584
|
match: /\/second$/,
|
|
585
585
|
response: { status: 200, statusText: "OK", data: { step: 2 } },
|
|
586
586
|
});
|
|
587
|
-
const result = await
|
|
587
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
588
588
|
expect(result.success).toBe(true);
|
|
589
589
|
expect(result.results).toHaveLength(3);
|
|
590
590
|
expect(result.results[1].nodeId).toBe("wait");
|
|
@@ -593,8 +593,8 @@ describe("executePlanV1", () => {
|
|
|
593
593
|
});
|
|
594
594
|
describe("Assertion Node", () => {
|
|
595
595
|
it("should execute an assertion node (currently no-op)", async () => {
|
|
596
|
-
const
|
|
597
|
-
id: "test-
|
|
596
|
+
const monitor = {
|
|
597
|
+
id: "test-monitor-12",
|
|
598
598
|
project: "test-project",
|
|
599
599
|
frequency: { every: 1, unit: "MINUTE" },
|
|
600
600
|
name: "Assertion Test",
|
|
@@ -638,7 +638,7 @@ describe("executePlanV1", () => {
|
|
|
638
638
|
data: { value: 42 },
|
|
639
639
|
},
|
|
640
640
|
});
|
|
641
|
-
const result = await
|
|
641
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
642
642
|
expect(result.success).toBe(true);
|
|
643
643
|
expect(result.results).toHaveLength(2);
|
|
644
644
|
expect(result.results[1].nodeId).toBe("assert");
|
|
@@ -647,8 +647,8 @@ describe("executePlanV1", () => {
|
|
|
647
647
|
});
|
|
648
648
|
describe("Error Handling", () => {
|
|
649
649
|
it("should handle failed HTTP requests gracefully", async () => {
|
|
650
|
-
const
|
|
651
|
-
id: "test-
|
|
650
|
+
const monitor = {
|
|
651
|
+
id: "test-monitor-13",
|
|
652
652
|
project: "test-project",
|
|
653
653
|
frequency: { every: 1, unit: "MINUTE" },
|
|
654
654
|
name: "Failed Request Test",
|
|
@@ -676,7 +676,7 @@ describe("executePlanV1", () => {
|
|
|
676
676
|
],
|
|
677
677
|
};
|
|
678
678
|
// Don't add a stub - this will cause the request to fail
|
|
679
|
-
const result = await
|
|
679
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
680
680
|
expect(result.success).toBe(false);
|
|
681
681
|
expect(result.errors).toHaveLength(1);
|
|
682
682
|
expect(result.errors[0]).toContain("failing-request");
|
|
@@ -685,8 +685,8 @@ describe("executePlanV1", () => {
|
|
|
685
685
|
expect(result.results[0].error).toBeDefined();
|
|
686
686
|
});
|
|
687
687
|
it("should handle disconnected nodes gracefully", async () => {
|
|
688
|
-
const
|
|
689
|
-
id: "test-
|
|
688
|
+
const monitor = {
|
|
689
|
+
id: "test-monitor-14",
|
|
690
690
|
project: "test-project",
|
|
691
691
|
frequency: { every: 1, unit: "MINUTE" },
|
|
692
692
|
name: "Disconnected Nodes Test",
|
|
@@ -724,14 +724,14 @@ describe("executePlanV1", () => {
|
|
|
724
724
|
data: {},
|
|
725
725
|
},
|
|
726
726
|
});
|
|
727
|
-
const result = await
|
|
727
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
728
728
|
// Graph can execute but disconnected nodes are not executed
|
|
729
729
|
expect(result.success).toBe(true);
|
|
730
730
|
expect(result.results).toHaveLength(0); // No nodes executed
|
|
731
731
|
});
|
|
732
732
|
it("should continue execution after a failed node", async () => {
|
|
733
|
-
const
|
|
734
|
-
id: "test-
|
|
733
|
+
const monitor = {
|
|
734
|
+
id: "test-monitor-15",
|
|
735
735
|
project: "test-project",
|
|
736
736
|
frequency: { every: 1, unit: "MINUTE" },
|
|
737
737
|
name: "Continue After Failure Test",
|
|
@@ -775,7 +775,7 @@ describe("executePlanV1", () => {
|
|
|
775
775
|
response: { status: 200, statusText: "OK", data: { ok: true } },
|
|
776
776
|
});
|
|
777
777
|
// No stub for /fail - it will fail
|
|
778
|
-
const result = await
|
|
778
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
779
779
|
expect(result.success).toBe(false);
|
|
780
780
|
expect(result.results).toHaveLength(2);
|
|
781
781
|
expect(result.results[0].success).toBe(true);
|
|
@@ -784,8 +784,8 @@ describe("executePlanV1", () => {
|
|
|
784
784
|
});
|
|
785
785
|
describe("Response Storage", () => {
|
|
786
786
|
it("should store successful responses for downstream nodes", async () => {
|
|
787
|
-
const
|
|
788
|
-
id: "test-
|
|
787
|
+
const monitor = {
|
|
788
|
+
id: "test-monitor-16",
|
|
789
789
|
project: "test-project",
|
|
790
790
|
frequency: { every: 1, unit: "MINUTE" },
|
|
791
791
|
name: "Response Storage Test",
|
|
@@ -841,14 +841,14 @@ describe("executePlanV1", () => {
|
|
|
841
841
|
data: { name: "John Doe", age: 30 },
|
|
842
842
|
},
|
|
843
843
|
});
|
|
844
|
-
const result = await
|
|
844
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
845
845
|
expect(result.success).toBe(true);
|
|
846
846
|
expect(result.results[0].response).toEqual({ userId: 123 });
|
|
847
847
|
expect(result.results[1].response).toEqual({ name: "John Doe", age: 30 });
|
|
848
848
|
});
|
|
849
849
|
it("should not store failed responses", async () => {
|
|
850
|
-
const
|
|
851
|
-
id: "test-
|
|
850
|
+
const monitor = {
|
|
851
|
+
id: "test-monitor-17",
|
|
852
852
|
project: "test-project",
|
|
853
853
|
frequency: { every: 1, unit: "MINUTE" },
|
|
854
854
|
name: "Failed Response Not Stored Test",
|
|
@@ -876,15 +876,15 @@ describe("executePlanV1", () => {
|
|
|
876
876
|
],
|
|
877
877
|
};
|
|
878
878
|
// No stub configured - will fail
|
|
879
|
-
const result = await
|
|
879
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
880
880
|
expect(result.success).toBe(false);
|
|
881
881
|
expect(result.results[0].response).toBeUndefined();
|
|
882
882
|
});
|
|
883
883
|
});
|
|
884
884
|
describe("Timing and Performance", () => {
|
|
885
885
|
it("should track total execution duration", async () => {
|
|
886
|
-
const
|
|
887
|
-
id: "test-
|
|
886
|
+
const monitor = {
|
|
887
|
+
id: "test-monitor-18",
|
|
888
888
|
name: "Timing Test",
|
|
889
889
|
version: "1.0",
|
|
890
890
|
environment: "default",
|
|
@@ -919,13 +919,13 @@ describe("executePlanV1", () => {
|
|
|
919
919
|
data: { test: true },
|
|
920
920
|
},
|
|
921
921
|
});
|
|
922
|
-
const result = await
|
|
922
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
923
923
|
expect(result.totalDuration_ms).toBeGreaterThanOrEqual(0);
|
|
924
924
|
expect(result.totalDuration_ms).toBeGreaterThanOrEqual(result.results[0].duration_ms);
|
|
925
925
|
});
|
|
926
926
|
it("should track individual node durations", async () => {
|
|
927
|
-
const
|
|
928
|
-
id: "test-
|
|
927
|
+
const monitor = {
|
|
928
|
+
id: "test-monitor-19",
|
|
929
929
|
project: "test-project",
|
|
930
930
|
frequency: { every: 1, unit: "MINUTE" },
|
|
931
931
|
name: "Node Duration Test",
|
|
@@ -982,7 +982,7 @@ describe("executePlanV1", () => {
|
|
|
982
982
|
match: /\/2$/,
|
|
983
983
|
response: { status: 200, statusText: "OK", data: {} },
|
|
984
984
|
});
|
|
985
|
-
const result = await
|
|
985
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
986
986
|
expect(result.success).toBe(true);
|
|
987
987
|
result.results.forEach((nodeResult) => {
|
|
988
988
|
expect(nodeResult.duration_ms).toBeGreaterThanOrEqual(0);
|
|
@@ -991,12 +991,12 @@ describe("executePlanV1", () => {
|
|
|
991
991
|
});
|
|
992
992
|
});
|
|
993
993
|
describe("Edge Cases", () => {
|
|
994
|
-
it("should handle empty
|
|
995
|
-
const
|
|
996
|
-
id: "test-
|
|
994
|
+
it("should handle empty monitor (no nodes)", async () => {
|
|
995
|
+
const monitor = {
|
|
996
|
+
id: "test-monitor-20",
|
|
997
997
|
project: "test-project",
|
|
998
998
|
frequency: { every: 1, unit: "MINUTE" },
|
|
999
|
-
name: "Empty
|
|
999
|
+
name: "Empty Monitor Test",
|
|
1000
1000
|
version: "1.0",
|
|
1001
1001
|
environment: "default",
|
|
1002
1002
|
nodes: [],
|
|
@@ -1007,15 +1007,15 @@ describe("executePlanV1", () => {
|
|
|
1007
1007
|
},
|
|
1008
1008
|
],
|
|
1009
1009
|
};
|
|
1010
|
-
const result = await
|
|
1011
|
-
// Empty
|
|
1010
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
1011
|
+
// Empty monitor with just START->END should succeed with no results
|
|
1012
1012
|
expect(result.success).toBe(true);
|
|
1013
1013
|
expect(result.results).toHaveLength(0);
|
|
1014
1014
|
expect(result.errors).toHaveLength(0);
|
|
1015
1015
|
});
|
|
1016
1016
|
it("should handle single node with no edges", async () => {
|
|
1017
|
-
const
|
|
1018
|
-
id: "test-
|
|
1017
|
+
const monitor = {
|
|
1018
|
+
id: "test-monitor-21",
|
|
1019
1019
|
project: "test-project",
|
|
1020
1020
|
frequency: { every: 1, unit: "MINUTE" },
|
|
1021
1021
|
name: "Single Node Test",
|
|
@@ -1050,13 +1050,13 @@ describe("executePlanV1", () => {
|
|
|
1050
1050
|
data: { alone: true },
|
|
1051
1051
|
},
|
|
1052
1052
|
});
|
|
1053
|
-
const result = await
|
|
1053
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
1054
1054
|
expect(result.success).toBe(true);
|
|
1055
1055
|
expect(result.results).toHaveLength(1);
|
|
1056
1056
|
});
|
|
1057
1057
|
it("should handle complex response data types", async () => {
|
|
1058
|
-
const
|
|
1059
|
-
id: "test-
|
|
1058
|
+
const monitor = {
|
|
1059
|
+
id: "test-monitor-22",
|
|
1060
1060
|
project: "test-project",
|
|
1061
1061
|
frequency: { every: 1, unit: "MINUTE" },
|
|
1062
1062
|
name: "Complex Data Test",
|
|
@@ -1103,7 +1103,7 @@ describe("executePlanV1", () => {
|
|
|
1103
1103
|
data: complexData,
|
|
1104
1104
|
},
|
|
1105
1105
|
});
|
|
1106
|
-
const result = await
|
|
1106
|
+
const result = await executeMonitorV1(monitor, organizationId, options);
|
|
1107
1107
|
expect(result.success).toBe(true);
|
|
1108
1108
|
expect(result.results[0].response).toEqual(complexData);
|
|
1109
1109
|
});
|
|
@@ -1116,12 +1116,12 @@ describe("executePlanV1", () => {
|
|
|
1116
1116
|
events = [];
|
|
1117
1117
|
emitter.subscribe((event) => events.push(event));
|
|
1118
1118
|
});
|
|
1119
|
-
it("should emit
|
|
1120
|
-
const
|
|
1119
|
+
it("should emit MONITOR_START and MONITOR_END events", async () => {
|
|
1120
|
+
const monitor = {
|
|
1121
1121
|
id: "event-test-1",
|
|
1122
1122
|
project: "test-project",
|
|
1123
1123
|
frequency: { every: 1, unit: "MINUTE" },
|
|
1124
|
-
name: "Event Test
|
|
1124
|
+
name: "Event Test Monitor",
|
|
1125
1125
|
version: "1.0",
|
|
1126
1126
|
environment: "default",
|
|
1127
1127
|
nodes: [
|
|
@@ -1149,33 +1149,33 @@ describe("executePlanV1", () => {
|
|
|
1149
1149
|
match: "https://api.example.com/test",
|
|
1150
1150
|
response: { status: 200, statusText: "OK", data: { ok: true } },
|
|
1151
1151
|
});
|
|
1152
|
-
await
|
|
1152
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1153
1153
|
...options,
|
|
1154
1154
|
eventEmitter: emitter,
|
|
1155
1155
|
});
|
|
1156
|
-
const planStartEvents = events.filter((e) => e.type === "
|
|
1157
|
-
const planEndEvents = events.filter((e) => e.type === "
|
|
1156
|
+
const planStartEvents = events.filter((e) => e.type === "MONITOR_START");
|
|
1157
|
+
const planEndEvents = events.filter((e) => e.type === "MONITOR_END");
|
|
1158
1158
|
expect(planStartEvents).toHaveLength(1);
|
|
1159
1159
|
expect(planEndEvents).toHaveLength(1);
|
|
1160
1160
|
const planStart = planStartEvents[0];
|
|
1161
1161
|
expect(planStart).toMatchObject({
|
|
1162
|
-
type: "
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1162
|
+
type: "MONITOR_START",
|
|
1163
|
+
monitorId: "event-test-1",
|
|
1164
|
+
monitorName: "Event Test Monitor",
|
|
1165
|
+
monitorVersion: "1.0",
|
|
1166
1166
|
nodeCount: 1,
|
|
1167
1167
|
edgeCount: 2,
|
|
1168
1168
|
});
|
|
1169
1169
|
const planEnd = planEndEvents[0];
|
|
1170
1170
|
expect(planEnd).toMatchObject({
|
|
1171
|
-
type: "
|
|
1171
|
+
type: "MONITOR_END",
|
|
1172
1172
|
success: true,
|
|
1173
1173
|
nodeResultCount: 1,
|
|
1174
1174
|
errorCount: 0,
|
|
1175
1175
|
});
|
|
1176
1176
|
});
|
|
1177
1177
|
it("should emit NODE_START and NODE_END events for each node", async () => {
|
|
1178
|
-
const
|
|
1178
|
+
const monitor = {
|
|
1179
1179
|
id: "event-test-2",
|
|
1180
1180
|
project: "test-project",
|
|
1181
1181
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1233,7 +1233,7 @@ describe("executePlanV1", () => {
|
|
|
1233
1233
|
match: /\/second$/,
|
|
1234
1234
|
response: { status: 200, statusText: "OK", data: { step: 2 } },
|
|
1235
1235
|
});
|
|
1236
|
-
await
|
|
1236
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1237
1237
|
...options,
|
|
1238
1238
|
eventEmitter: emitter,
|
|
1239
1239
|
});
|
|
@@ -1256,7 +1256,7 @@ describe("executePlanV1", () => {
|
|
|
1256
1256
|
});
|
|
1257
1257
|
});
|
|
1258
1258
|
it("should emit HTTP_REQUEST and HTTP_RESPONSE events for endpoint nodes", async () => {
|
|
1259
|
-
const
|
|
1259
|
+
const monitor = {
|
|
1260
1260
|
id: "event-test-3",
|
|
1261
1261
|
project: "test-project",
|
|
1262
1262
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1290,7 +1290,7 @@ describe("executePlanV1", () => {
|
|
|
1290
1290
|
match: "https://api.example.com/create",
|
|
1291
1291
|
response: { status: 201, statusText: "Created", data: { id: 123 } },
|
|
1292
1292
|
});
|
|
1293
|
-
await
|
|
1293
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1294
1294
|
...options,
|
|
1295
1295
|
eventEmitter: emitter,
|
|
1296
1296
|
});
|
|
@@ -1322,7 +1322,7 @@ describe("executePlanV1", () => {
|
|
|
1322
1322
|
expect(httpResponse.duration_ms).toBeGreaterThanOrEqual(0);
|
|
1323
1323
|
});
|
|
1324
1324
|
it("should emit WAIT_START event for wait nodes", async () => {
|
|
1325
|
-
const
|
|
1325
|
+
const monitor = {
|
|
1326
1326
|
id: "event-test-4",
|
|
1327
1327
|
project: "test-project",
|
|
1328
1328
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1347,7 +1347,7 @@ describe("executePlanV1", () => {
|
|
|
1347
1347
|
},
|
|
1348
1348
|
],
|
|
1349
1349
|
};
|
|
1350
|
-
await
|
|
1350
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1351
1351
|
...options,
|
|
1352
1352
|
eventEmitter: emitter,
|
|
1353
1353
|
});
|
|
@@ -1360,7 +1360,7 @@ describe("executePlanV1", () => {
|
|
|
1360
1360
|
});
|
|
1361
1361
|
});
|
|
1362
1362
|
it("should emit ERROR event on HTTP request failure", async () => {
|
|
1363
|
-
const
|
|
1363
|
+
const monitor = {
|
|
1364
1364
|
id: "event-test-5",
|
|
1365
1365
|
project: "test-project",
|
|
1366
1366
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1389,7 +1389,7 @@ describe("executePlanV1", () => {
|
|
|
1389
1389
|
],
|
|
1390
1390
|
};
|
|
1391
1391
|
// No stub - request will fail
|
|
1392
|
-
const result = await
|
|
1392
|
+
const result = await executeMonitorV1(monitor, organizationId, {
|
|
1393
1393
|
...options,
|
|
1394
1394
|
eventEmitter: emitter,
|
|
1395
1395
|
});
|
|
@@ -1398,7 +1398,7 @@ describe("executePlanV1", () => {
|
|
|
1398
1398
|
expect(result.errors.length).toBeGreaterThan(0);
|
|
1399
1399
|
});
|
|
1400
1400
|
it("should maintain monotonic sequence numbers", async () => {
|
|
1401
|
-
const
|
|
1401
|
+
const monitor = {
|
|
1402
1402
|
id: "event-test-6",
|
|
1403
1403
|
project: "test-project",
|
|
1404
1404
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1430,7 +1430,7 @@ describe("executePlanV1", () => {
|
|
|
1430
1430
|
match: "https://api.example.com/test",
|
|
1431
1431
|
response: { status: 200, statusText: "OK", data: {} },
|
|
1432
1432
|
});
|
|
1433
|
-
await
|
|
1433
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1434
1434
|
...options,
|
|
1435
1435
|
eventEmitter: emitter,
|
|
1436
1436
|
});
|
|
@@ -1447,7 +1447,7 @@ describe("executePlanV1", () => {
|
|
|
1447
1447
|
});
|
|
1448
1448
|
it("should use provided executionId if given", async () => {
|
|
1449
1449
|
const customExecutionId = "custom-exec-id-123";
|
|
1450
|
-
const
|
|
1450
|
+
const monitor = {
|
|
1451
1451
|
id: "event-test-7",
|
|
1452
1452
|
project: "test-project",
|
|
1453
1453
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1479,7 +1479,7 @@ describe("executePlanV1", () => {
|
|
|
1479
1479
|
match: "https://api.example.com/test",
|
|
1480
1480
|
response: { status: 200, statusText: "OK", data: {} },
|
|
1481
1481
|
});
|
|
1482
|
-
await
|
|
1482
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1483
1483
|
...options,
|
|
1484
1484
|
eventEmitter: emitter,
|
|
1485
1485
|
executionId: customExecutionId,
|
|
@@ -1490,7 +1490,7 @@ describe("executePlanV1", () => {
|
|
|
1490
1490
|
});
|
|
1491
1491
|
});
|
|
1492
1492
|
it("should emit events in correct order", async () => {
|
|
1493
|
-
const
|
|
1493
|
+
const monitor = {
|
|
1494
1494
|
id: "event-test-8",
|
|
1495
1495
|
project: "test-project",
|
|
1496
1496
|
frequency: { every: 1, unit: "MINUTE" },
|
|
@@ -1522,21 +1522,21 @@ describe("executePlanV1", () => {
|
|
|
1522
1522
|
match: "https://api.example.com/test",
|
|
1523
1523
|
response: { status: 200, statusText: "OK", data: {} },
|
|
1524
1524
|
});
|
|
1525
|
-
await
|
|
1525
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1526
1526
|
...options,
|
|
1527
1527
|
eventEmitter: emitter,
|
|
1528
1528
|
});
|
|
1529
1529
|
const eventTypes = events.map((e) => e.type);
|
|
1530
|
-
// Expected order:
|
|
1531
|
-
expect(eventTypes[0]).toBe("
|
|
1530
|
+
// Expected order: MONITOR_START, NODE_START, HTTP_REQUEST, HTTP_RESPONSE, NODE_END, MONITOR_END
|
|
1531
|
+
expect(eventTypes[0]).toBe("MONITOR_START");
|
|
1532
1532
|
expect(eventTypes[1]).toBe("NODE_START");
|
|
1533
1533
|
expect(eventTypes[2]).toBe("HTTP_REQUEST");
|
|
1534
1534
|
expect(eventTypes[3]).toBe("HTTP_RESPONSE");
|
|
1535
1535
|
expect(eventTypes[4]).toBe("NODE_END");
|
|
1536
|
-
expect(eventTypes[5]).toBe("
|
|
1536
|
+
expect(eventTypes[5]).toBe("MONITOR_END");
|
|
1537
1537
|
});
|
|
1538
1538
|
it("should handle failed HTTP requests correctly", async () => {
|
|
1539
|
-
const
|
|
1539
|
+
const monitor = {
|
|
1540
1540
|
id: "event-test-9",
|
|
1541
1541
|
name: "Failed Request Event Test",
|
|
1542
1542
|
version: "1.0",
|
|
@@ -1565,7 +1565,7 @@ describe("executePlanV1", () => {
|
|
|
1565
1565
|
],
|
|
1566
1566
|
};
|
|
1567
1567
|
// No stub - request will fail
|
|
1568
|
-
await
|
|
1568
|
+
await executeMonitorV1(monitor, organizationId, {
|
|
1569
1569
|
...options,
|
|
1570
1570
|
eventEmitter: emitter,
|
|
1571
1571
|
});
|