@axinom/mosaic-testing 0.1.0-rc.4

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 (69) hide show
  1. package/README.md +16 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +18 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/performance/index.d.ts +3 -0
  7. package/dist/performance/index.d.ts.map +1 -0
  8. package/dist/performance/index.js +19 -0
  9. package/dist/performance/index.js.map +1 -0
  10. package/dist/performance/plugins/inbox-outbox-report-endpoint-plugin.d.ts +22 -0
  11. package/dist/performance/plugins/inbox-outbox-report-endpoint-plugin.d.ts.map +1 -0
  12. package/dist/performance/plugins/inbox-outbox-report-endpoint-plugin.js +71 -0
  13. package/dist/performance/plugins/inbox-outbox-report-endpoint-plugin.js.map +1 -0
  14. package/dist/performance/plugins/inbox-outbox-state-endpoint-plugin.d.ts +23 -0
  15. package/dist/performance/plugins/inbox-outbox-state-endpoint-plugin.d.ts.map +1 -0
  16. package/dist/performance/plugins/inbox-outbox-state-endpoint-plugin.js +81 -0
  17. package/dist/performance/plugins/inbox-outbox-state-endpoint-plugin.js.map +1 -0
  18. package/dist/performance/plugins/index.d.ts +3 -0
  19. package/dist/performance/plugins/index.d.ts.map +1 -0
  20. package/dist/performance/plugins/index.js +8 -0
  21. package/dist/performance/plugins/index.js.map +1 -0
  22. package/dist/performance/scripts/index.d.ts +4 -0
  23. package/dist/performance/scripts/index.d.ts.map +1 -0
  24. package/dist/performance/scripts/index.js +20 -0
  25. package/dist/performance/scripts/index.js.map +1 -0
  26. package/dist/performance/scripts/make-graphql-request.d.ts +29 -0
  27. package/dist/performance/scripts/make-graphql-request.d.ts.map +1 -0
  28. package/dist/performance/scripts/make-graphql-request.js +23 -0
  29. package/dist/performance/scripts/make-graphql-request.js.map +1 -0
  30. package/dist/performance/scripts/run-inbox-outbox-scenario.d.ts +97 -0
  31. package/dist/performance/scripts/run-inbox-outbox-scenario.d.ts.map +1 -0
  32. package/dist/performance/scripts/run-inbox-outbox-scenario.js +178 -0
  33. package/dist/performance/scripts/run-inbox-outbox-scenario.js.map +1 -0
  34. package/dist/performance/scripts/run-scenario.d.ts +54 -0
  35. package/dist/performance/scripts/run-scenario.d.ts.map +1 -0
  36. package/dist/performance/scripts/run-scenario.js +37 -0
  37. package/dist/performance/scripts/run-scenario.js.map +1 -0
  38. package/dist/performance/utils/colorize-text.d.ts +3 -0
  39. package/dist/performance/utils/colorize-text.d.ts.map +1 -0
  40. package/dist/performance/utils/colorize-text.js +8 -0
  41. package/dist/performance/utils/colorize-text.js.map +1 -0
  42. package/dist/performance/utils/index.d.ts +4 -0
  43. package/dist/performance/utils/index.d.ts.map +1 -0
  44. package/dist/performance/utils/index.js +20 -0
  45. package/dist/performance/utils/index.js.map +1 -0
  46. package/dist/performance/utils/report-generation.d.ts +14 -0
  47. package/dist/performance/utils/report-generation.d.ts.map +1 -0
  48. package/dist/performance/utils/report-generation.js +245 -0
  49. package/dist/performance/utils/report-generation.js.map +1 -0
  50. package/dist/performance/utils/stub-helpers.d.ts +12 -0
  51. package/dist/performance/utils/stub-helpers.d.ts.map +1 -0
  52. package/dist/performance/utils/stub-helpers.js +38 -0
  53. package/dist/performance/utils/stub-helpers.js.map +1 -0
  54. package/package.json +59 -0
  55. package/src/index.ts +1 -0
  56. package/src/performance/index.ts +2 -0
  57. package/src/performance/plugins/inbox-outbox-report-endpoint-plugin.spec.ts +1135 -0
  58. package/src/performance/plugins/inbox-outbox-report-endpoint-plugin.ts +92 -0
  59. package/src/performance/plugins/inbox-outbox-state-endpoint-plugin.spec.ts +99 -0
  60. package/src/performance/plugins/inbox-outbox-state-endpoint-plugin.ts +101 -0
  61. package/src/performance/plugins/index.ts +2 -0
  62. package/src/performance/scripts/index.ts +3 -0
  63. package/src/performance/scripts/make-graphql-request.ts +50 -0
  64. package/src/performance/scripts/run-inbox-outbox-scenario.ts +279 -0
  65. package/src/performance/scripts/run-scenario.ts +96 -0
  66. package/src/performance/utils/colorize-text.ts +4 -0
  67. package/src/performance/utils/index.ts +3 -0
  68. package/src/performance/utils/report-generation.ts +408 -0
  69. package/src/performance/utils/stub-helpers.ts +41 -0
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @axinom/mosaic-testing
2
+
3
+ ## About the Package
4
+
5
+ This package is part of the Axinom Mosaic development platform. More information
6
+ can be found at https://portal.axinom.com/mosaic.
7
+
8
+ ## License
9
+
10
+ This package can be licensed under the
11
+ [Axinom Products Licensing Agreement](https://portal.axinom.com/mosaic/contracts/products-licensing-agreement)
12
+ or evaluated under the
13
+ [Axinom Products Evaluation Agreement](https://portal.axinom.com/mosaic/contracts/products-evaluation-agreement).
14
+ No part of Axinom's software may be copied, modified, propagated, or distributed
15
+ except in accordance with the terms contained in the Axinom Products Licensing
16
+ Agreement and Axinom Products Evaluation Agreement.
@@ -0,0 +1,2 @@
1
+ export * from './performance';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./performance"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
@@ -0,0 +1,3 @@
1
+ export * from './plugins';
2
+ export * from './scripts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/performance/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./plugins"), exports);
18
+ __exportStar(require("./scripts"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/performance/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
@@ -0,0 +1,22 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ import { Pool } from 'pg';
3
+ /**
4
+ * Returns a postgraphile plugin function that generates a performance report
5
+ * for inbox and/or outbox entries for a specific testId. Undefined will be
6
+ * returned for a report value that is not explicitly requested.
7
+ */
8
+ export declare const getInboxOutboxReportFunction: (ownerPool: Pool) => (_query: unknown, { input: { testId } }: {
9
+ input: {
10
+ testId: string;
11
+ };
12
+ }, _context: unknown, { fieldNodes }: GraphQLResolveInfo) => Promise<Record<string, unknown>>;
13
+ /**
14
+ * Plugin that adds a custom graphql endpoint `inboxOutboxReport` which uses
15
+ * inbox and/or outbox entries with the specific test ID and generates a
16
+ * performance report for said entries. Test ID is expected to be passed as
17
+ * `message_context: { testId: "test ID value"}` with the message and is a
18
+ * expected to be string. `ownerPool` must be available as part of the
19
+ * postgraphile `graphileBuildOptions`.
20
+ */
21
+ export declare const InboxOutboxReportEndpointPlugin: import("graphile-build").Plugin;
22
+ //# sourceMappingURL=inbox-outbox-report-endpoint-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-outbox-report-endpoint-plugin.d.ts","sourceRoot":"","sources":["../../../src/performance/plugins/inbox-outbox-report-endpoint-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AA2B1B;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,cAAe,IAAI,cAEhD,OAAO;;gBAC2B,MAAM;;aACtC,OAAO,kBACD,kBAAkB,KACjC,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,CAmBnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,iCAsB3C,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InboxOutboxReportEndpointPlugin = exports.getInboxOutboxReportFunction = void 0;
4
+ const graphile_utils_1 = require("graphile-utils");
5
+ const utils_1 = require("../utils");
6
+ const inboxReport = 'inboxReport';
7
+ const outboxReport = 'outboxReport';
8
+ const inboxOutboxReport = 'inboxOutboxReport';
9
+ const getReport = async (table, testId, ownerPool) => {
10
+ const entries = await (0, utils_1.getReportRows)(table, testId, ownerPool);
11
+ if (entries.length === 0) {
12
+ return `No ${table} entries found.`;
13
+ }
14
+ const generalReport = (0, utils_1.getGeneralReport)(entries, testId);
15
+ const storedReport = (0, utils_1.getStoredReport)(entries, table);
16
+ const processedReport = (0, utils_1.getProcessedReport)(entries, table);
17
+ return `${generalReport}\n\n${storedReport}\n\n${processedReport}`;
18
+ };
19
+ /**
20
+ * Returns a postgraphile plugin function that generates a performance report
21
+ * for inbox and/or outbox entries for a specific testId. Undefined will be
22
+ * returned for a report value that is not explicitly requested.
23
+ */
24
+ const getInboxOutboxReportFunction = (ownerPool) => {
25
+ return async (_query, { input: { testId } }, _context, { fieldNodes }) => {
26
+ var _a, _b, _c;
27
+ const selectedProperties = (_c = (_b = (_a = fieldNodes
28
+ .find((node) => node.name.value === inboxOutboxReport)) === null || _a === void 0 ? void 0 : _a.selectionSet) === null || _b === void 0 ? void 0 : _b.selections.map((s) => s.name.value)) !== null && _c !== void 0 ? _c : [];
29
+ const inboxResult = selectedProperties.includes(inboxReport)
30
+ ? await getReport('inbox', testId, ownerPool)
31
+ : undefined;
32
+ const outboxResult = selectedProperties.includes(outboxReport)
33
+ ? await getReport('outbox', testId, ownerPool)
34
+ : undefined;
35
+ return {
36
+ [inboxReport]: inboxResult,
37
+ [outboxReport]: outboxResult,
38
+ };
39
+ };
40
+ };
41
+ exports.getInboxOutboxReportFunction = getInboxOutboxReportFunction;
42
+ /**
43
+ * Plugin that adds a custom graphql endpoint `inboxOutboxReport` which uses
44
+ * inbox and/or outbox entries with the specific test ID and generates a
45
+ * performance report for said entries. Test ID is expected to be passed as
46
+ * `message_context: { testId: "test ID value"}` with the message and is a
47
+ * expected to be string. `ownerPool` must be available as part of the
48
+ * postgraphile `graphileBuildOptions`.
49
+ */
50
+ exports.InboxOutboxReportEndpointPlugin = (0, graphile_utils_1.makeExtendSchemaPlugin)((_, { ownerPool }) => {
51
+ return {
52
+ typeDefs: (0, graphile_utils_1.gql) `
53
+ input InboxOutboxReportInput {
54
+ testId: String!
55
+ }
56
+ type InboxOutboxReportPayload {
57
+ ${inboxReport}: String!
58
+ ${outboxReport}: String!
59
+ }
60
+ extend type Query {
61
+ ${inboxOutboxReport}(input: InboxOutboxReportInput!): InboxOutboxReportPayload
62
+ }
63
+ `,
64
+ resolvers: {
65
+ Query: {
66
+ [inboxOutboxReport]: (0, exports.getInboxOutboxReportFunction)(ownerPool),
67
+ },
68
+ },
69
+ };
70
+ });
71
+ //# sourceMappingURL=inbox-outbox-report-endpoint-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-outbox-report-endpoint-plugin.js","sourceRoot":"","sources":["../../../src/performance/plugins/inbox-outbox-report-endpoint-plugin.ts"],"names":[],"mappings":";;;AAAA,mDAA6D;AAG7D,oCAKkB;AAElB,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,SAAS,GAAG,KAAK,EACrB,KAAyB,EACzB,MAAc,EACd,SAAe,EACE,EAAE;IACnB,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAa,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,MAAM,KAAK,iBAAiB,CAAC;KACrC;IACD,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,IAAA,uBAAe,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,IAAA,0BAAkB,EAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3D,OAAO,GAAG,aAAa,OAAO,YAAY,OAAO,eAAe,EAAE,CAAC;AACrE,CAAC,CAAC;A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C,iBAAiB,CAAC,EAAE,IAAA,oCAA4B,EAAC,SAAS,CAAC;aAC7D;SACF;KACF,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ import { Pool } from 'pg';
3
+ /**
4
+ * Returns a postgraphile plugin function that returns the counts of inbox
5
+ * and/or outbox entries that are still not completed and not abandoned for a
6
+ * specified testId. Undefined will be returned for a count value that is not
7
+ * explicitly requested.
8
+ */
9
+ export declare const getInboxOutboxStateFunction: (ownerPool: Pool) => (_query: unknown, { input: { testId } }: {
10
+ input: {
11
+ testId: string;
12
+ };
13
+ }, _context: unknown, { fieldNodes }: GraphQLResolveInfo) => Promise<Record<string, unknown>>;
14
+ /**
15
+ * Plugin that adds a custom graphql endpoint `inboxOutboxState` which checks if
16
+ * inbox and/or outbox entries with the specific test ID are still being
17
+ * processed and returns the count of such entries. Test ID is expected to be
18
+ * passed as `message_context: { testId: "test ID value"}` with the message and
19
+ * is a expected to be string. `ownerPool` must be available as part of the
20
+ * postgraphile `graphileBuildOptions`.
21
+ */
22
+ export declare const InboxOutboxStateEndpointPlugin: import("graphile-build").Plugin;
23
+ //# sourceMappingURL=inbox-outbox-state-endpoint-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-outbox-state-endpoint-plugin.d.ts","sourceRoot":"","sources":["../../../src/performance/plugins/inbox-outbox-state-endpoint-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAmC1B;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,cAAe,IAAI,cAE/C,OAAO;;gBAC2B,MAAM;;aACtC,OAAO,kBACD,kBAAkB,KACjC,QAAQ,OAAO,MAAM,EAAE,OAAO,CAAC,CAmBnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,iCAsB1C,CAAC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InboxOutboxStateEndpointPlugin = exports.getInboxOutboxStateFunction = void 0;
4
+ const graphile_utils_1 = require("graphile-utils");
5
+ const inboxActiveCount = 'inboxActiveCount';
6
+ const outboxActiveCount = 'outboxActiveCount';
7
+ const inboxOutboxState = 'inboxOutboxState';
8
+ /**
9
+ * Queries for the count of rows of either inbox or outbox table for not
10
+ * processed and not abandoned rows for a specified testId.
11
+ */
12
+ const getRowsCount = async (table, testId, ownerPool) => {
13
+ const client = await ownerPool.connect();
14
+ try {
15
+ const testIdPath = table === 'inbox'
16
+ ? `metadata->'messageContext'->>'testId'`
17
+ : `metadata->'envelopeOverrides'->'message_context'->>'testId'`;
18
+ const result = await client.query(`SELECT COUNT(id) FROM app_hidden.${table}
19
+ WHERE ${testIdPath} = $1 AND
20
+ processed_at is NULL AND
21
+ abandoned_at is NULL;`, [testId]);
22
+ return result.rows[0].count;
23
+ }
24
+ finally {
25
+ client.release();
26
+ }
27
+ };
28
+ /**
29
+ * Returns a postgraphile plugin function that returns the counts of inbox
30
+ * and/or outbox entries that are still not completed and not abandoned for a
31
+ * specified testId. Undefined will be returned for a count value that is not
32
+ * explicitly requested.
33
+ */
34
+ const getInboxOutboxStateFunction = (ownerPool) => {
35
+ return async (_query, { input: { testId } }, _context, { fieldNodes }) => {
36
+ var _a, _b, _c;
37
+ const selectedProperties = (_c = (_b = (_a = fieldNodes
38
+ .find((node) => node.name.value === inboxOutboxState)) === null || _a === void 0 ? void 0 : _a.selectionSet) === null || _b === void 0 ? void 0 : _b.selections.map((s) => s.name.value)) !== null && _c !== void 0 ? _c : [];
39
+ const inboxResult = selectedProperties.includes(inboxActiveCount)
40
+ ? await getRowsCount('inbox', testId, ownerPool)
41
+ : undefined;
42
+ const outboxResult = selectedProperties.includes(outboxActiveCount)
43
+ ? await getRowsCount('outbox', testId, ownerPool)
44
+ : undefined;
45
+ return {
46
+ [inboxActiveCount]: inboxResult,
47
+ [outboxActiveCount]: outboxResult,
48
+ };
49
+ };
50
+ };
51
+ exports.getInboxOutboxStateFunction = getInboxOutboxStateFunction;
52
+ /**
53
+ * Plugin that adds a custom graphql endpoint `inboxOutboxState` which checks if
54
+ * inbox and/or outbox entries with the specific test ID are still being
55
+ * processed and returns the count of such entries. Test ID is expected to be
56
+ * passed as `message_context: { testId: "test ID value"}` with the message and
57
+ * is a expected to be string. `ownerPool` must be available as part of the
58
+ * postgraphile `graphileBuildOptions`.
59
+ */
60
+ exports.InboxOutboxStateEndpointPlugin = (0, graphile_utils_1.makeExtendSchemaPlugin)((_, { ownerPool }) => {
61
+ return {
62
+ typeDefs: (0, graphile_utils_1.gql) `
63
+ input InboxOutboxStateInput {
64
+ testId: String!
65
+ }
66
+ type InboxOutboxStatePayload {
67
+ ${inboxActiveCount}: Int!
68
+ ${outboxActiveCount}: Int!
69
+ }
70
+ extend type Query {
71
+ ${inboxOutboxState}(input: InboxOutboxStateInput!): InboxOutboxStatePayload
72
+ }
73
+ `,
74
+ resolvers: {
75
+ Query: {
76
+ [inboxOutboxState]: (0, exports.getInboxOutboxStateFunction)(ownerPool),
77
+ },
78
+ },
79
+ };
80
+ });
81
+ //# sourceMappingURL=inbox-outbox-state-endpoint-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbox-outbox-state-endpoint-plugin.js","sourceRoot":"","sources":["../../../src/performance/plugins/inbox-outbox-state-endpoint-plugin.ts"],"names":[],"mappings":";;;AAAA,mDAA6D;AAI7D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAC9C,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C;;;GAGG;AACH,MAAM,YAAY,GAAG,KAAK,EACxB,KAAyB,EACzB,MAAc,EACd,SAAe,EACE,EAAE;IACnB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAA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E,WAAW;YAC/B,CAAC,iBAAiB,CAAC,EAAE,YAAY;SAClC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,2BAA2B,+BAyBtC;AAEF;;;;;;;GAOG;AACU,QAAA,8BAA8B,GAAG,IAAA,uCAAsB,EAClE,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IACnB,OAAO;QACL,QAAQ,EAAE,IAAA,oBAAG,EAAA;;;;;UAKT,gBAAgB;UAChB,iBAAiB;;;UAGjB,gBAAgB;;KAErB;QACC,SAAS,EAAE;YACT,KAAK,EAAE;gBACL,CAAC,gBAAgB,CAAC,EAAE,IAAA,mCAA2B,EAAC,SAAS,CAAC;aAC3D;SACF;KACF,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { InboxOutboxReportEndpointPlugin } from './inbox-outbox-report-endpoint-plugin';
2
+ export { InboxOutboxStateEndpointPlugin } from './inbox-outbox-state-endpoint-plugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/performance/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InboxOutboxStateEndpointPlugin = exports.InboxOutboxReportEndpointPlugin = void 0;
4
+ var inbox_outbox_report_endpoint_plugin_1 = require("./inbox-outbox-report-endpoint-plugin");
5
+ Object.defineProperty(exports, "InboxOutboxReportEndpointPlugin", { enumerable: true, get: function () { return inbox_outbox_report_endpoint_plugin_1.InboxOutboxReportEndpointPlugin; } });
6
+ var inbox_outbox_state_endpoint_plugin_1 = require("./inbox-outbox-state-endpoint-plugin");
7
+ Object.defineProperty(exports, "InboxOutboxStateEndpointPlugin", { enumerable: true, get: function () { return inbox_outbox_state_endpoint_plugin_1.InboxOutboxStateEndpointPlugin; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/performance/plugins/index.ts"],"names":[],"mappings":";;;AAAA,6FAAwF;AAA/E,sJAAA,+BAA+B,OAAA;AACxC,2FAAsF;AAA7E,oJAAA,8BAA8B,OAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './make-graphql-request';
2
+ export * from './run-inbox-outbox-scenario';
3
+ export * from './run-scenario';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/performance/scripts/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./make-graphql-request"), exports);
18
+ __exportStar(require("./run-inbox-outbox-scenario"), exports);
19
+ __exportStar(require("./run-scenario"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/performance/scripts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,8DAA4C;AAC5C,iDAA+B"}
@@ -0,0 +1,29 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { DocumentNode } from 'graphql';
3
+ /**
4
+ * Config to make a GraphQL request using `makeGraphQLRequest`
5
+ */
6
+ export interface MakeGraphQLRequestOptions {
7
+ /**
8
+ * Base URL that should be requested. `/graphql` will be attached to it to
9
+ * make a request.
10
+ */
11
+ baseUrl: string;
12
+ /**
13
+ * Operation to request. Use `graphql-tag` to wrap the operation string.
14
+ */
15
+ operation: DocumentNode;
16
+ /**
17
+ * Optional GraphQL request variables.
18
+ */
19
+ variables?: Record<string, unknown>;
20
+ /**
21
+ * Bearer authorization token.
22
+ */
23
+ token: string;
24
+ }
25
+ /**
26
+ * Wrapper to make a GraphQL request with minimal input parameters
27
+ */
28
+ export declare const makeGraphQLRequest: ({ baseUrl, operation, variables, token, }: MakeGraphQLRequestOptions) => Promise<AxiosResponse<any, any>>;
29
+ //# sourceMappingURL=make-graphql-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-graphql-request.d.ts","sourceRoot":"","sources":["../../../src/performance/scripts/make-graphql-request.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,8CAM/B,yBAAyB,KAAG,QAAQ,cAAc,GAAG,EAAE,GAAG,CAAC,CAa1D,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.makeGraphQLRequest = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const printer_1 = require("graphql/language/printer");
9
+ /**
10
+ * Wrapper to make a GraphQL request with minimal input parameters
11
+ */
12
+ const makeGraphQLRequest = async ({ baseUrl, operation, variables, token, }) => {
13
+ return axios_1.default.post(new URL('graphql', baseUrl).href, {
14
+ query: (0, printer_1.print)(operation),
15
+ variables,
16
+ }, {
17
+ headers: {
18
+ Authorization: `Bearer ${token}`,
19
+ },
20
+ });
21
+ };
22
+ exports.makeGraphQLRequest = makeGraphQLRequest;
23
+ //# sourceMappingURL=make-graphql-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-graphql-request.js","sourceRoot":"","sources":["../../../src/performance/scripts/make-graphql-request.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAE7C,sDAAiD;AAyBjD;;GAEG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,OAAO,EACP,SAAS,EACT,SAAS,EACT,KAAK,GAEkB,EAAoC,EAAE;IAC7D,OAAO,eAAK,CAAC,IAAI,CACf,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,EAChC;QACE,KAAK,EAAE,IAAA,eAAK,EAAC,SAAS,CAAC;QACvB,SAAS;KACV,EACD;QACE,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC;KACF,CACF,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,kBAAkB,sBAmB7B"}
@@ -0,0 +1,97 @@
1
+ import { Broker } from '@axinom/mosaic-message-bus';
2
+ import { MessagingSettings } from '@axinom/mosaic-message-bus-abstractions';
3
+ import { BasicConfig, BasicCustomizableConfig, BasicManagedServiceConfig, BasicRMQConfig, ShutdownAction } from '@axinom/mosaic-service-common';
4
+ import { RunnerConfig } from './run-scenario';
5
+ /**
6
+ * Configuration with all messaging-related environment variable values,
7
+ */
8
+ type InboxOutboxMessagingConfig = Pick<BasicConfig & BasicRMQConfig & BasicManagedServiceConfig & BasicCustomizableConfig, 'serviceId' | 'tenantId' | 'environmentId' | 'idServiceAuthBaseUrl' | 'managedServiceAccountClientId' | 'managedServiceAccountClientSecret' | 'isDev' | 'rmqHost' | 'rmqPort' | 'rmqProtocol' | 'rmqUser' | 'rmqVHost' | 'rmqPassword' | 'rmqVHostAssert'>;
9
+ /**
10
+ * Configuration to run `runInboxOutboxScenario` function.
11
+ */
12
+ interface InboxOutboxRunScenarioConfig {
13
+ /**
14
+ * Description of the scenario. Printed together with the report.
15
+ */
16
+ description?: string;
17
+ /**
18
+ * Configuration to fine-tune how scenario is executed.
19
+ */
20
+ runnerConfig?: RunnerConfig;
21
+ /**
22
+ * Messaging settings for the message that will be repeatedly sent.
23
+ */
24
+ messagingSettings: MessagingSettings;
25
+ /**
26
+ * Configuration to be able to send messages, e.g. RabbitMQ connection details.
27
+ */
28
+ config: InboxOutboxMessagingConfig;
29
+ /**
30
+ * Payload to be sent with each iteration.
31
+ */
32
+ payload: unknown | (() => unknown);
33
+ /**
34
+ * Base URL for the service. Used to request `inboxOutboxState` and
35
+ * `inboxOutboxReport` operations.
36
+ */
37
+ serviceBaseUrl: string;
38
+ }
39
+ /**
40
+ * Config that is created by the `setup` step of `getInboxOutboxSetup` and
41
+ * passed to each function/step of `runInboxOutboxScenario`
42
+ */
43
+ export interface InboxOutboxScenarioConfig {
44
+ /**
45
+ * Configuration to be able to send messages, e.g. RabbitMQ connection details.
46
+ */
47
+ config: InboxOutboxMessagingConfig;
48
+ /**
49
+ * Shutdown actions that are executed as part of the `teardown` step.
50
+ */
51
+ shutdownActions: ShutdownAction[];
52
+ /**
53
+ * Messaging broker to send RabbitMQ messages.
54
+ */
55
+ broker: Broker;
56
+ /**
57
+ * Authorization token to include in messages and GraphQL requests.
58
+ */
59
+ token: string;
60
+ /**
61
+ * Test identifier. Passed along with each sent message as part of
62
+ * `message_context` and used to retrieve the inbox/outbox state and report.
63
+ */
64
+ testId: string;
65
+ }
66
+ /**
67
+ * Generic setup function to produce all required components to run messaging
68
+ * tests for services using transactional inbox-outbox pattern.
69
+ */
70
+ export declare const getInboxOutboxSetup: <T extends InboxOutboxScenarioConfig>(messagingSettings: MessagingSettings, config: InboxOutboxMessagingConfig) => () => Promise<T>;
71
+ /**
72
+ * Generic iteration function to send RabbitMQ messages.
73
+ */
74
+ export declare const getInboxOutboxIteration: <T extends InboxOutboxScenarioConfig>(payload: unknown, messagingSettings: MessagingSettings) => ({ broker, token, testId, config }: T) => Promise<void>;
75
+ /**
76
+ * Generic hasScenarioCompleted function to check if all inbox and outbox
77
+ * messages have been processed.
78
+ */
79
+ export declare const getInboxOutboxHasScenarioCompleted: <T extends InboxOutboxScenarioConfig>(serviceBaseUrl: string) => (tc: T) => Promise<boolean>;
80
+ /**
81
+ * Generic function to request a report from the target service that scenario is
82
+ * running against.
83
+ */
84
+ export declare const getInboxOutboxGenerateReport: <T extends InboxOutboxScenarioConfig>(serviceBaseUrl: string) => ({ token, testId }: T) => Promise<string>;
85
+ /**
86
+ * Generic function to run all shutdown actions, e.g. dispose the broker.
87
+ */
88
+ export declare const inboxOutboxTeardown: <T extends InboxOutboxScenarioConfig>({ shutdownActions, }: T) => Promise<void>;
89
+ /**
90
+ * A wrapper function for the `runScenario` to send RabbitMQ messages for the
91
+ * service using transactional inbox-outbox pattern. Has limited configuration
92
+ * fitting for simple cases where sending a message with the same payload is
93
+ * acceptable. For more complex scenarios - consider using `runScenario` explicitly.
94
+ */
95
+ export declare const runInboxOutboxScenario: <T extends InboxOutboxScenarioConfig>({ runnerConfig, messagingSettings, config, payload, serviceBaseUrl, description, }: InboxOutboxRunScenarioConfig) => Promise<void>;
96
+ export {};
97
+ //# sourceMappingURL=run-inbox-outbox-scenario.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-inbox-outbox-scenario.d.ts","sourceRoot":"","sources":["../../../src/performance/scripts/run-inbox-outbox-scenario.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,MAAM,EAGP,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,yBAAyB,EACzB,cAAc,EAEd,cAAc,EAEf,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAE3D;;GAEG;AACH,KAAK,0BAA0B,GAAG,IAAI,CACpC,WAAW,GACT,cAAc,GACd,yBAAyB,GACzB,uBAAuB,EACvB,WAAW,GACX,UAAU,GACV,eAAe,GACf,sBAAsB,GACtB,+BAA+B,GAC/B,mCAAmC,GACnC,OAAO,GACP,SAAS,GACT,SAAS,GACT,aAAa,GACb,SAAS,GACT,UAAU,GACV,aAAa,GACb,gBAAgB,CACnB,CAAC;AAEF;;GAEG;AACH,UAAU,4BAA4B;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC;IACrC;;OAEG;IACH,MAAM,EAAE,0BAA0B,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,MAAM,EAAE,0BAA0B,CAAC;IACnC;;OAEG;IACH,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,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