@datadog/datadog-ci 2.40.3 → 2.41.0

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 (252) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/deployment/cli.js +2 -1
  3. package/dist/commands/deployment/cli.js.map +1 -1
  4. package/dist/commands/deployment/correlate.d.ts +18 -0
  5. package/dist/commands/deployment/correlate.js +154 -0
  6. package/dist/commands/deployment/correlate.js.map +1 -0
  7. package/dist/commands/dsyms/utils.js +2 -4
  8. package/dist/commands/dsyms/utils.js.map +1 -1
  9. package/dist/helpers/git/get-git-data.d.ts +2 -0
  10. package/dist/helpers/git/get-git-data.js +11 -1
  11. package/dist/helpers/git/get-git-data.js.map +1 -1
  12. package/package.json +3 -2
  13. package/dist/__tests__/cli.test.d.ts +0 -1
  14. package/dist/__tests__/cli.test.js +0 -41
  15. package/dist/__tests__/cli.test.js.map +0 -1
  16. package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
  17. package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
  18. package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
  19. package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
  20. package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
  21. package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
  22. package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
  23. package/dist/commands/deployment/__tests__/mark.test.js +0 -47
  24. package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
  25. package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
  26. package/dist/commands/dora/__tests__/deployment.test.js +0 -201
  27. package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
  28. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  29. package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
  30. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  31. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  32. package/dist/commands/dsyms/__tests__/utils.test.js +0 -103
  33. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  34. package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
  35. package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -813
  36. package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
  37. package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
  38. package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -249
  39. package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
  40. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  41. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
  42. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  43. package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
  44. package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
  45. package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
  46. package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
  47. package/dist/commands/gate/__tests__/scope.test.js +0 -29
  48. package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
  49. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  50. package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
  51. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  52. package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
  53. package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
  54. package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
  55. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  56. package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
  57. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  58. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  59. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
  60. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  61. package/dist/commands/junit/__tests__/id.test.d.ts +0 -1
  62. package/dist/commands/junit/__tests__/id.test.js +0 -24
  63. package/dist/commands/junit/__tests__/id.test.js.map +0 -1
  64. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  65. package/dist/commands/junit/__tests__/upload.test.js +0 -495
  66. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  67. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
  68. package/dist/commands/lambda/__tests__/fixtures.js +0 -146
  69. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  70. package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
  71. package/dist/commands/lambda/__tests__/flare.test.js +0 -730
  72. package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
  73. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  74. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
  75. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  76. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  77. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -386
  78. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  79. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  80. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -721
  81. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  82. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  83. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -513
  84. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  85. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  86. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  87. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  88. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  89. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1511
  90. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  91. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  92. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
  93. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  94. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  95. package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
  96. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  97. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  98. package/dist/commands/lambda/__tests__/tags.test.js +0 -305
  99. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  100. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  101. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -722
  102. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  103. package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
  104. package/dist/commands/measure/__tests__/measure.test.js +0 -110
  105. package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
  106. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  107. package/dist/commands/react-native/__tests__/codepush.test.js +0 -161
  108. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  109. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  110. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
  111. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  112. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  113. package/dist/commands/react-native/__tests__/upload.test.js +0 -238
  114. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  115. package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
  116. package/dist/commands/react-native/__tests__/utils.test.js +0 -27
  117. package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
  118. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  119. package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
  120. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  121. package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
  122. package/dist/commands/sarif/__tests__/upload.test.js +0 -228
  123. package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
  124. package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
  125. package/dist/commands/sbom/__tests__/payload.test.js +0 -262
  126. package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
  127. package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
  128. package/dist/commands/sbom/__tests__/validation.test.js +0 -41
  129. package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
  130. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  131. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  132. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  133. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  134. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  135. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  136. package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
  137. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -192
  138. package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
  139. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
  140. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
  141. package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
  142. package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
  143. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
  144. package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
  145. package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
  146. package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -205
  147. package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
  148. package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
  149. package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
  150. package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
  151. package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
  152. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
  153. package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
  154. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  155. package/dist/commands/synthetics/__tests__/api.test.js +0 -422
  156. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  157. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  158. package/dist/commands/synthetics/__tests__/cli.test.js +0 -1325
  159. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  160. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -149
  161. package/dist/commands/synthetics/__tests__/fixtures.js +0 -507
  162. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  163. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  164. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
  165. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  166. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  167. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -354
  168. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  169. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  170. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -353
  171. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  172. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
  173. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
  174. package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
  175. package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
  176. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -735
  177. package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
  178. package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
  179. package/dist/commands/synthetics/__tests__/test.test.js +0 -33
  180. package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
  181. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  182. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  183. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  184. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  185. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  186. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  187. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  188. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
  189. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  190. package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
  191. package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -186
  192. package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
  193. package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
  194. package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -1526
  195. package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
  196. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  197. package/dist/commands/tag/__tests__/tag.test.js +0 -75
  198. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  199. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  200. package/dist/commands/trace/__tests__/trace.test.js +0 -145
  201. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  202. package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
  203. package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
  204. package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
  205. package/dist/helpers/__tests__/app.test.d.ts +0 -1
  206. package/dist/helpers/__tests__/app.test.js +0 -31
  207. package/dist/helpers/__tests__/app.test.js.map +0 -1
  208. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  209. package/dist/helpers/__tests__/ci.test.js +0 -252
  210. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  211. package/dist/helpers/__tests__/fixtures.d.ts +0 -33
  212. package/dist/helpers/__tests__/fixtures.js +0 -71
  213. package/dist/helpers/__tests__/fixtures.js.map +0 -1
  214. package/dist/helpers/__tests__/flare.test.d.ts +0 -1
  215. package/dist/helpers/__tests__/flare.test.js +0 -226
  216. package/dist/helpers/__tests__/flare.test.js.map +0 -1
  217. package/dist/helpers/__tests__/fs.test.d.ts +0 -1
  218. package/dist/helpers/__tests__/fs.test.js +0 -189
  219. package/dist/helpers/__tests__/fs.test.js.map +0 -1
  220. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  221. package/dist/helpers/__tests__/plist.test.js +0 -43
  222. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  223. package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
  224. package/dist/helpers/__tests__/prompt.test.js +0 -71
  225. package/dist/helpers/__tests__/prompt.test.js.map +0 -1
  226. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  227. package/dist/helpers/__tests__/retry.test.js +0 -99
  228. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  229. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  230. package/dist/helpers/__tests__/tags.test.js +0 -71
  231. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  232. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  233. package/dist/helpers/__tests__/upload.test.js +0 -231
  234. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  235. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  236. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  237. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  238. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  239. package/dist/helpers/__tests__/utils.test.js +0 -429
  240. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  241. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  242. package/dist/helpers/__tests__/validation.test.js +0 -25
  243. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  244. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  245. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
  246. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  247. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  248. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
  249. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  250. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  251. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
  252. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_sfn_1 = require("@aws-sdk/client-sfn");
4
- const helpers_1 = require("../helpers");
5
- const aws_resources_1 = require("./fixtures/aws-resources");
6
- describe('stepfunctions command helpers tests', () => {
7
- describe('shouldUpdateStepForTracesMerging test', () => {
8
- test('already has JsonMerge added to payload field', () => {
9
- const step = {
10
- Type: 'Task',
11
- Resource: 'arn:aws:states:::lambda:invoke',
12
- Parameters: {
13
- FunctionName: 'arn:aws:lambda:sa-east-1:425362991234:function:unit-test-lambda-function',
14
- 'Payload.$': 'States.JsonMerge($$, $, false)',
15
- },
16
- End: true,
17
- };
18
- expect((0, helpers_1.shouldUpdateStepForTracesMerging)(step)).toBeFalsy();
19
- });
20
- test('no payload field', () => {
21
- const step = {
22
- Type: 'Task',
23
- Resource: 'arn:aws:states:::lambda:invoke',
24
- Parameters: {
25
- FunctionName: 'arn:aws:lambda:sa-east-1:425362991234:function:unit-test-lambda-function',
26
- },
27
- End: true,
28
- };
29
- expect((0, helpers_1.shouldUpdateStepForTracesMerging)(step)).toBeTruthy();
30
- });
31
- test('default payload field of $', () => {
32
- const step = {
33
- Type: 'Task',
34
- Resource: 'arn:aws:states:::lambda:invoke',
35
- Parameters: {
36
- FunctionName: 'arn:aws:lambda:sa-east-1:425362991234:function:unit-test-lambda-function',
37
- 'Payload.$': '$',
38
- },
39
- End: true,
40
- };
41
- expect((0, helpers_1.shouldUpdateStepForTracesMerging)(step)).toBeTruthy();
42
- });
43
- test('none-lambda step should not be updated', () => {
44
- const step = {
45
- Type: 'Task',
46
- Resource: 'arn:aws:states:::dynamodb:updateItem',
47
- Parameters: {
48
- TableName: 'step-functions-tracing-self-monitoring-table-staging',
49
- },
50
- End: true,
51
- };
52
- expect((0, helpers_1.shouldUpdateStepForTracesMerging)(step)).toBeFalsy();
53
- });
54
- test('legacy lambda api should not be updated', () => {
55
- const step = {
56
- Type: 'Task',
57
- Resource: 'arn:aws:lambda:sa-east-1:601427271234:function:hello-function',
58
- End: true,
59
- };
60
- expect((0, helpers_1.shouldUpdateStepForTracesMerging)(step)).toBeFalsy();
61
- });
62
- });
63
- describe('buildArn', () => {
64
- test('builds log group arn', () => {
65
- const partition = 'aws';
66
- const service = 'logs';
67
- const region = 'us-east-1';
68
- const accountId = '000000000000';
69
- const resourceType = 'log-group';
70
- const resourceId = '/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*';
71
- const logGroupArn = (0, helpers_1.buildArn)(partition, service, region, accountId, resourceType, resourceId);
72
- expect(logGroupArn).toBe('arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*');
73
- });
74
- });
75
- describe('buildLogGroupName', () => {
76
- test('builds log group name from step function name with env', () => {
77
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
78
- const env = 'test';
79
- const logGroupName = (0, helpers_1.buildLogGroupName)(stepFunction.name, env);
80
- expect(logGroupName).toBe('/aws/vendedlogs/states/ExampleStepFunction-Logs-test');
81
- });
82
- test('builds log group name from step function name without env', () => {
83
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
84
- let env;
85
- const logGroupName = (0, helpers_1.buildLogGroupName)(stepFunction.name, env);
86
- expect(logGroupName).toBe('/aws/vendedlogs/states/ExampleStepFunction-Logs');
87
- });
88
- });
89
- describe('buildSubscriptionFilterName', () => {
90
- test('builds subscription filter name from step function name', () => {
91
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
92
- const subscriptionFilterName = (0, helpers_1.buildSubscriptionFilterName)(stepFunction.name);
93
- expect(subscriptionFilterName).toBe('ExampleStepFunction-DdCiLogGroupSubscription');
94
- });
95
- });
96
- describe('isValidArn', () => {
97
- test('returns true for valid step function arn', () => {
98
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
99
- expect((0, helpers_1.isValidArn)(stepFunction.stateMachineArn)).toBe(true);
100
- });
101
- test('returns true for valid lambda function arn', () => {
102
- const lambdaFunctionArn = 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder';
103
- expect((0, helpers_1.isValidArn)(lambdaFunctionArn)).toBe(true);
104
- });
105
- test('returns false for invalid arn', () => {
106
- const arn = '';
107
- expect((0, helpers_1.isValidArn)(arn)).toBe(false);
108
- });
109
- });
110
- describe('getStepFunctionLogGroupArn', () => {
111
- test('returns step function log group arn when it is set', () => {
112
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
113
- const logGroupArn = (0, helpers_1.getStepFunctionLogGroupArn)(stepFunction);
114
- expect(logGroupArn).toBe('arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*');
115
- });
116
- test('returns undefined when step function logging is off', () => {
117
- const loggingConfiguration = {
118
- level: client_sfn_1.LogLevel.OFF,
119
- includeExecutionData: false,
120
- };
121
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
122
- const logGroupArn = (0, helpers_1.getStepFunctionLogGroupArn)(stepFunction);
123
- expect(logGroupArn).toBe(undefined);
124
- });
125
- });
126
- describe('parseArn', () => {
127
- test('parses step function arn', () => {
128
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)();
129
- const arnObject = (0, helpers_1.parseArn)(stepFunction.stateMachineArn);
130
- expect(arnObject.partition).toBe('aws');
131
- expect(arnObject.region).toBe('us-east-1');
132
- expect(arnObject.accountId).toBe('000000000000');
133
- expect(arnObject.resourceName).toBe('ExampleStepFunction');
134
- });
135
- });
136
- describe('shouldUpdateStepForStepFunctionContextInjection', () => {
137
- test('is true for an empty object', () => {
138
- const step = {
139
- Type: 'Task',
140
- Resource: 'arn:aws:states:::states:startExecution.sync:2',
141
- Parameters: {
142
- StateMachineArn: 'arn:aws:states:us-east-1:425362996713:stateMachine:agocs_inner_state_machine',
143
- Input: {},
144
- },
145
- End: true,
146
- };
147
- expect((0, helpers_1.shouldUpdateStepForStepFunctionContextInjection)(step)).toBeTruthy();
148
- });
149
- test('is true for undefined', () => {
150
- const step = {
151
- Type: 'Task',
152
- Resource: 'arn:aws:states:::states:startExecution.sync:2',
153
- Parameters: {
154
- StateMachineArn: 'arn:aws:states:us-east-1:425362996713:stateMachine:agocs_inner_state_machine',
155
- },
156
- End: true,
157
- };
158
- expect((0, helpers_1.shouldUpdateStepForStepFunctionContextInjection)(step)).toBeTruthy();
159
- });
160
- test('is false when Input is an object that contains a CONTEXT key', () => {
161
- const step = {
162
- Type: 'Task',
163
- Resource: 'arn:aws:states:::states:startExecution.sync:2',
164
- Parameters: {
165
- StateMachineArn: 'arn:aws:states:us-east-1:425362996713:stateMachine:agocs_inner_state_machine',
166
- Input: { 'CONTEXT.$': 'blah' },
167
- },
168
- End: true,
169
- };
170
- expect((0, helpers_1.shouldUpdateStepForStepFunctionContextInjection)(step)).toBeFalsy();
171
- });
172
- });
173
- describe('inject context for StepFunctions', () => {
174
- test('injects context into a step function invocation', () => {
175
- var _a;
176
- const step = {
177
- Type: 'Task',
178
- Resource: 'arn:aws:states:::states:startExecution.sync:2',
179
- Parameters: {
180
- StateMachineArn: 'arn:aws:states:us-east-1:425362996713:stateMachine:agocs_inner_state_machine',
181
- Input: {},
182
- },
183
- End: true,
184
- };
185
- const changed = (0, helpers_1.injectContextForStepFunctions)(step);
186
- expect(changed).toBeTruthy();
187
- expect((_a = step.Parameters) === null || _a === void 0 ? void 0 : _a.Input).toEqual({ 'CONTEXT.$': 'States.JsonMerge($$, $, false)' });
188
- });
189
- });
190
- test('buildLogAccessPolicyName test', () => {
191
- const fakeStateMachineName = 'fakeStateMachineName';
192
- const describeStateMachineCommandOutput = {
193
- $metadata: {},
194
- creationDate: undefined,
195
- definition: undefined,
196
- roleArn: undefined,
197
- type: undefined,
198
- stateMachineArn: 'fakeStepFunctionArn',
199
- name: fakeStateMachineName,
200
- };
201
- const actual = (0, helpers_1.buildLogAccessPolicyName)(describeStateMachineCommandOutput);
202
- expect(actual).toEqual(`LogsDeliveryAccessPolicy-${fakeStateMachineName}`);
203
- });
204
- });
205
- //# sourceMappingURL=helpers.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.test.js","sourceRoot":"","sources":["../../../../src/commands/stepfunctions/__tests__/helpers.test.ts"],"names":[],"mappings":";;AAAA,oDAA+E;AAE/E,wCAYmB;AAEnB,4DAAoE;AAEpE,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACrD,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACxD,MAAM,IAAI,GAAa;gBACrB,IAAI,EAAE,MA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;IAEF,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAChD,IAAI,CAAC,iDAAiD,EAAE,GAAG,EAAE;;YAC3D,MAAM,IAAI,GAAa;gBACrB,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,+CAA+C;gBACzD,UAAU,EAAE;oBACV,eAAe,EAAE,8EAA8E;oBAC/F,KAAK,EAAE,EAAE;iBACV;gBACD,GAAG,EAAE,IAAI;aACV,CAAA;YAED,MAAM,OAAO,GAAG,IAAA,uCAA6B,EAAC,IAAI,CAAC,CAAA;YACnD,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAA;YAC5B,MAAM,CAAC,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,CAAC,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,gCAAgC,EAAC,CAAC,CAAA;QACzF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACzC,MAAM,oBAAoB,GAAG,sBAAsB,CAAA;QACnD,MAAM,iCAAiC,GAAsC;YAC3E,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,SAAS;YACvB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,SAAS;YAClB,IAAI,EAAE,SAAS;YACf,eAAe,EAAE,qBAAqB;YACtC,IAAI,EAAE,oBAAoB;SAC3B,CAAA;QACD,MAAM,MAAM,GAAG,IAAA,kCAAwB,EAAC,iCAAiC,CAAC,CAAA;QAC1E,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,4BAA4B,oBAAoB,EAAE,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,431 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const client_sfn_1 = require("@aws-sdk/client-sfn");
13
- const advanced_1 = require("clipanion/lib/advanced");
14
- const instrument_1 = require("../instrument");
15
- const aws_resources_1 = require("./fixtures/aws-resources");
16
- const cli_1 = require("./fixtures/cli");
17
- jest.mock('../../../../package.json', () => ({ version: '2.0.0' }));
18
- describe('stepfunctions instrument test', () => {
19
- let aws;
20
- let cli;
21
- let context;
22
- let helpers;
23
- beforeAll(() => {
24
- aws = require('../awsCommands');
25
- helpers = require('../helpers');
26
- helpers.applyChanges = jest.fn().mockImplementation(() => false);
27
- helpers.injectContextIntoTasks = jest.fn().mockImplementation();
28
- cli = new advanced_1.Cli();
29
- cli.register(instrument_1.InstrumentStepFunctionsCommand);
30
- });
31
- beforeEach(() => {
32
- context = (0, cli_1.contextFixture)();
33
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)();
34
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
35
- const stepFunctionTagList = [{ key: 'env', value: 'test' }];
36
- aws.listTagsForResource = jest.fn().mockImplementation(() => ({ tags: stepFunctionTagList }));
37
- aws.tagResource = jest.fn().mockImplementation(() => ({}));
38
- aws.createLogGroup = jest.fn().mockImplementation(() => ({}));
39
- aws.putSubscriptionFilter = jest.fn().mockImplementation(() => ({}));
40
- aws.createLogsAccessPolicy = jest.fn().mockImplementation(() => ({}));
41
- aws.attachPolicyToStateMachineIamRole = jest.fn().mockImplementation(() => ({}));
42
- aws.enableStepFunctionLogs = jest.fn().mockImplementation(() => ({}));
43
- aws.putSubscriptionFilter = jest.fn().mockImplementation(() => ({}));
44
- });
45
- describe('parameter validation', () => {
46
- test('errors if forwarder arn is not set', () => __awaiter(void 0, void 0, void 0, function* () {
47
- const exitCode = yield cli.run(['stepfunctions', 'instrument'], context);
48
- expect(exitCode).toBe(1);
49
- expect(context.toString()).toMatch('[Error] `--forwarder` is required');
50
- }));
51
- test('errors if forwarder arn is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
52
- const exitCode = yield cli.run(['stepfunctions', 'instrument', '--forwarder', 'bla:'], context);
53
- expect(exitCode).toBe(1);
54
- expect(context.toString()).toMatch('[Error] Invalid arn format for `--forwarder` bla:\n');
55
- }));
56
- test('errors if no step function arn', () => __awaiter(void 0, void 0, void 0, function* () {
57
- const exitCode = yield cli.run(['stepfunctions', 'instrument', '--forwarder', 'arn:aws:lambda:sa-east-1:601427279990:function:hello'], context);
58
- expect(exitCode).toBe(1);
59
- expect(context.toString()).toMatch('[Error] Must specify at least one `--step-function`');
60
- }));
61
- test('errors if any step function arn is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
62
- const exitCode = yield cli.run([
63
- 'stepfunctions',
64
- 'instrument',
65
- '--forwarder',
66
- 'arn:aws:lambda:sa-east-1:601427279990:function:hello',
67
- '--step-function',
68
- 'bla',
69
- ], context);
70
- expect(exitCode).toBe(1);
71
- expect(context.toString()).toMatch('[Error] Invalid arn format for `--step-function` bla');
72
- }));
73
- test('errors if no env tag on step function and env parameter not set', () => __awaiter(void 0, void 0, void 0, function* () {
74
- aws.listTagsForResource = jest.fn().mockImplementation(() => ({ tags: [] }));
75
- const exitCode = yield cli.run([
76
- 'stepfunctions',
77
- 'instrument',
78
- '--forwarder',
79
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
80
- '--step-function',
81
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
82
- ], context);
83
- expect(exitCode).toBe(1);
84
- expect(context.toString()).toMatch('[Error] --env is required when a Step Function has no env tag');
85
- }));
86
- });
87
- describe('stepfunctions command overall test', () => {
88
- test('all aws commands are called when log level is OFF', () => __awaiter(void 0, void 0, void 0, function* () {
89
- const loggingConfiguration = {
90
- level: client_sfn_1.LogLevel.OFF,
91
- includeExecutionData: false,
92
- };
93
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
94
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
95
- const exitCode = yield cli.run([
96
- 'stepfunctions',
97
- 'instrument',
98
- '--forwarder',
99
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
100
- '--step-function',
101
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
102
- '--env',
103
- 'test',
104
- ], context);
105
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
106
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
107
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
108
- expect(aws.createLogGroup).toHaveBeenCalledTimes(1);
109
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
110
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(1);
111
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(1);
112
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(1);
113
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
114
- expect(exitCode).toBe(0);
115
- }));
116
- test('all aws commands are called the same times when as log-level-off state machines', () => __awaiter(void 0, void 0, void 0, function* () {
117
- const loggingConfiguration = {
118
- level: client_sfn_1.LogLevel.OFF,
119
- includeExecutionData: false,
120
- };
121
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
122
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
123
- const exitCode = yield cli.run([
124
- 'stepfunctions',
125
- 'instrument',
126
- '--forwarder',
127
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
128
- '--step-function',
129
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
130
- '--step-function',
131
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction222',
132
- '--env',
133
- 'test',
134
- ], context);
135
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(2);
136
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(2);
137
- expect(aws.tagResource).toHaveBeenCalledTimes(2);
138
- expect(aws.createLogGroup).toHaveBeenCalledTimes(2);
139
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(2);
140
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(2);
141
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(2);
142
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(2);
143
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(2);
144
- expect(exitCode).toBe(0);
145
- }));
146
- test('removes duplicate step function arns', () => __awaiter(void 0, void 0, void 0, function* () {
147
- const exitCode = yield cli.run([
148
- 'stepfunctions',
149
- 'instrument',
150
- '--forwarder',
151
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
152
- '--step-function',
153
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
154
- '--step-function',
155
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
156
- ], context);
157
- expect(exitCode).toBe(0);
158
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
159
- }));
160
- });
161
- describe('step function tags', () => {
162
- test('sets dd_sls_ci tag if not already set', () => __awaiter(void 0, void 0, void 0, function* () {
163
- const exitCode = yield cli.run([
164
- 'stepfunctions',
165
- 'instrument',
166
- '--forwarder',
167
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
168
- '--step-function',
169
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
170
- '--env',
171
- 'test',
172
- ], context);
173
- expect(exitCode).toBe(0);
174
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
175
- }));
176
- test('sets dd_sls_ci tag if changed', () => __awaiter(void 0, void 0, void 0, function* () {
177
- const stepFunctionTagList = (0, aws_resources_1.stepFunctionTagListFixture)([{ key: 'dd_sls_ci', value: 'v1.0.0' }]);
178
- aws.listTagsForResource = jest.fn().mockImplementation(() => ({ tags: stepFunctionTagList }));
179
- const exitCode = yield cli.run([
180
- 'stepfunctions',
181
- 'instrument',
182
- '--forwarder',
183
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
184
- '--step-function',
185
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
186
- '--env',
187
- 'test',
188
- ], context);
189
- expect(exitCode).toBe(0);
190
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
191
- }));
192
- test('sets env tag if not already set', () => __awaiter(void 0, void 0, void 0, function* () {
193
- aws.listTagsForResource = jest.fn().mockImplementation(() => ({ tags: [{ key: 'dd_sls_ci', value: 'v2.0.0' }] }));
194
- const exitCode = yield cli.run([
195
- 'stepfunctions',
196
- 'instrument',
197
- '--forwarder',
198
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
199
- '--step-function',
200
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
201
- '--env',
202
- 'test',
203
- ], context);
204
- expect(exitCode).toBe(0);
205
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
206
- }));
207
- test('sets service tag if not already set', () => __awaiter(void 0, void 0, void 0, function* () {
208
- const stepFunctionTagList = (0, aws_resources_1.stepFunctionTagListFixture)([{ key: 'dd_sls_ci', value: 'v2.0.0' }]);
209
- aws.listTagsForResource = jest.fn().mockImplementation(() => ({ tags: stepFunctionTagList }));
210
- const exitCode = yield cli.run([
211
- 'stepfunctions',
212
- 'instrument',
213
- '--forwarder',
214
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
215
- '--step-function',
216
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
217
- '--env',
218
- 'test',
219
- '--service',
220
- 'test-service',
221
- ], context);
222
- expect(exitCode).toBe(0);
223
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
224
- }));
225
- });
226
- describe('step function logging disabled', () => {
227
- test('creates step function log group, subscribes it to forwarder, and adds it to step function logging config', () => __awaiter(void 0, void 0, void 0, function* () {
228
- const loggingConfiguration = {
229
- level: client_sfn_1.LogLevel.OFF,
230
- includeExecutionData: false,
231
- };
232
- const stepFunction = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
233
- aws.describeStateMachine = jest.fn().mockImplementation(() => stepFunction);
234
- const exitCode = yield cli.run([
235
- 'stepfunctions',
236
- 'instrument',
237
- '--forwarder',
238
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
239
- '--step-function',
240
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
241
- ], context);
242
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
243
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
244
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
245
- expect(aws.createLogGroup).toHaveBeenCalledTimes(1);
246
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
247
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(1);
248
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(1);
249
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(1);
250
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
251
- expect(exitCode).toBe(0);
252
- }));
253
- });
254
- describe('step function logging enabled', () => {
255
- test('subscribes log group in step function logging config to forwarder', () => __awaiter(void 0, void 0, void 0, function* () {
256
- const exitCode = yield cli.run([
257
- 'stepfunctions',
258
- 'instrument',
259
- '--forwarder',
260
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
261
- '--step-function',
262
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
263
- ], context);
264
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
265
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
266
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
267
- expect(aws.createLogGroup).toHaveBeenCalledTimes(0);
268
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(0);
269
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(0);
270
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(0); // already has logging properly set
271
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
272
- expect(exitCode).toBe(0);
273
- }));
274
- test('log level is not ALL, should call enableStepFunctionLogs', () => __awaiter(void 0, void 0, void 0, function* () {
275
- const loggingConfiguration = {
276
- level: client_sfn_1.LogLevel.FATAL,
277
- includeExecutionData: true,
278
- destinations: [
279
- {
280
- cloudWatchLogsLogGroup: {
281
- logGroupArn: 'arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*',
282
- },
283
- },
284
- ],
285
- };
286
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
287
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
288
- const exitCode = yield cli.run([
289
- 'stepfunctions',
290
- 'instrument',
291
- '--forwarder',
292
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
293
- '--step-function',
294
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
295
- ], context);
296
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
297
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
298
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
299
- expect(aws.createLogGroup).toHaveBeenCalledTimes(0);
300
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(0);
301
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(0);
302
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(1);
303
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
304
- expect(exitCode).toBe(0);
305
- }));
306
- test('log level is ALL but includeExecutionData is false. Should call enableStepFunctionLogs', () => __awaiter(void 0, void 0, void 0, function* () {
307
- const loggingConfiguration = {
308
- level: client_sfn_1.LogLevel.ALL,
309
- includeExecutionData: false,
310
- destinations: [
311
- {
312
- cloudWatchLogsLogGroup: {
313
- logGroupArn: 'arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*',
314
- },
315
- },
316
- ],
317
- };
318
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
319
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
320
- const exitCode = yield cli.run([
321
- 'stepfunctions',
322
- 'instrument',
323
- '--forwarder',
324
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
325
- '--step-function',
326
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
327
- ], context);
328
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
329
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
330
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
331
- expect(aws.createLogGroup).toHaveBeenCalledTimes(0);
332
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(0);
333
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(0);
334
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(1);
335
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
336
- expect(exitCode).toBe(0);
337
- }));
338
- test('log level is not ALL but includeExecutionData is false. Should call enableStepFunctionLogs', () => __awaiter(void 0, void 0, void 0, function* () {
339
- const loggingConfiguration = {
340
- level: client_sfn_1.LogLevel.FATAL,
341
- includeExecutionData: false,
342
- destinations: [
343
- {
344
- cloudWatchLogsLogGroup: {
345
- logGroupArn: 'arn:aws:logs:us-east-1:000000000000:log-group:/aws/vendedlogs/states/ExampleStepFunction-Logs-test:*',
346
- },
347
- },
348
- ],
349
- };
350
- const describeStateMachineCommandOutput = (0, aws_resources_1.describeStateMachineFixture)({ loggingConfiguration });
351
- aws.describeStateMachine = jest.fn().mockImplementation(() => describeStateMachineCommandOutput);
352
- const exitCode = yield cli.run([
353
- 'stepfunctions',
354
- 'instrument',
355
- '--forwarder',
356
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
357
- '--step-function',
358
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
359
- ], context);
360
- expect(aws.describeStateMachine).toHaveBeenCalledTimes(1);
361
- expect(aws.listTagsForResource).toHaveBeenCalledTimes(1);
362
- expect(aws.tagResource).toHaveBeenCalledTimes(1);
363
- expect(aws.createLogGroup).toHaveBeenCalledTimes(0);
364
- expect(aws.createLogsAccessPolicy).toHaveBeenCalledTimes(0);
365
- expect(aws.attachPolicyToStateMachineIamRole).toHaveBeenCalledTimes(0);
366
- expect(aws.enableStepFunctionLogs).toHaveBeenCalledTimes(1);
367
- expect(aws.putSubscriptionFilter).toHaveBeenCalledTimes(1);
368
- expect(exitCode).toBe(0);
369
- }));
370
- });
371
- describe('mergeStepFunctionAndLambdaTraces enabled', () => {
372
- test('mergeStepFunctionAndLambdaTraces flag is set (to true)', () => __awaiter(void 0, void 0, void 0, function* () {
373
- const exitCode = yield cli.run([
374
- 'stepfunctions',
375
- 'instrument',
376
- '--forwarder',
377
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
378
- '--step-function',
379
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
380
- '--merge-lambda-traces',
381
- ], context);
382
- expect(helpers.injectContextIntoTasks).toHaveBeenCalledTimes(1);
383
- expect(exitCode).toBe(0);
384
- }));
385
- test('mergeStepFunctionAndLambdaTraces flag is not set (default to false)', () => __awaiter(void 0, void 0, void 0, function* () {
386
- const exitCode = yield cli.run([
387
- 'stepfunctions',
388
- 'instrument',
389
- '--forwarder',
390
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
391
- '--step-function',
392
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
393
- ], context);
394
- expect(helpers.injectContextIntoTasks).toHaveBeenCalledTimes(0);
395
- expect(exitCode).toBe(0);
396
- }));
397
- });
398
- describe('aws error handling', () => {
399
- test('errors if unable to fetch step function', () => __awaiter(void 0, void 0, void 0, function* () {
400
- aws.describeStateMachine = jest.fn().mockImplementation(() => {
401
- throw new Error('mock describeStateMachine error');
402
- });
403
- const exitCode = yield cli.run([
404
- 'stepfunctions',
405
- 'instrument',
406
- '--forwarder',
407
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
408
- '--step-function',
409
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
410
- ], context);
411
- expect(exitCode).toBe(1);
412
- expect(context.toString()).toMatch('[Error] mock describeStateMachine error. Unable to describe state machine arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction');
413
- }));
414
- test('errors if unable to fetch step function tags', () => __awaiter(void 0, void 0, void 0, function* () {
415
- aws.listTagsForResource = jest.fn().mockImplementation(() => {
416
- throw new Error('mock listTagsForResource error');
417
- });
418
- const exitCode = yield cli.run([
419
- 'stepfunctions',
420
- 'instrument',
421
- '--forwarder',
422
- 'arn:aws:lambda:us-east-1:000000000000:function:DatadogForwarder',
423
- '--step-function',
424
- 'arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction',
425
- ], context);
426
- expect(exitCode).toBe(1);
427
- expect(context.toString()).toMatch('[Error] mock listTagsForResource error. Unable to fetch tags for Step Function arn:aws:states:us-east-1:000000000000:stateMachine:ExampleStepFunction');
428
- }));
429
- });
430
- });
431
- //# sourceMappingURL=instrument.test.js.map