@loadmill/executer 0.1.51 → 0.1.54

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 (39) hide show
  1. package/dist/mill-version.js +1 -1
  2. package/dist/sequence.d.ts +1 -1
  3. package/dist/sequence.js +12 -5
  4. package/dist/sequence.js.map +1 -1
  5. package/dist/single-runner.d.ts +1 -0
  6. package/dist/single-runner.js +1 -1
  7. package/dist/single-runner.js.map +1 -1
  8. package/package.json +3 -3
  9. package/src/asserter.ts +0 -137
  10. package/src/errors.ts +0 -10
  11. package/src/extraction-combiner.ts +0 -110
  12. package/src/failures.ts +0 -79
  13. package/src/message-creators.ts +0 -44
  14. package/src/mill-info.ts +0 -81
  15. package/src/mill-version.ts +0 -7
  16. package/src/post-script/ast-walker/index.ts +0 -160
  17. package/src/post-script/ast-walker/type-guard.ts +0 -73
  18. package/src/post-script/ast-walker/types.ts +0 -35
  19. package/src/post-script/console-log.ts +0 -24
  20. package/src/post-script/parser/acorn-js-parser.ts +0 -8
  21. package/src/post-script/parser/js-parser.ts +0 -22
  22. package/src/post-script/parser/parser.ts +0 -5
  23. package/src/post-script/post-script-executor.ts +0 -93
  24. package/src/post-script/virtual-machine/virtual-machine.ts +0 -15
  25. package/src/post-script/virtual-machine/vm2-virtual-machine.ts +0 -45
  26. package/src/report-types.ts +0 -127
  27. package/src/request-sequence-result.ts +0 -63
  28. package/src/request-stats.ts +0 -20
  29. package/src/res-keeper.ts +0 -53
  30. package/src/sampler.ts +0 -133
  31. package/src/sequence.ts +0 -1109
  32. package/src/single-runner.ts +0 -66
  33. package/src/test-run-event-emitter.ts +0 -25
  34. package/src/utils.ts +0 -8
  35. package/src/work.ts +0 -17
  36. package/src/ws.ts +0 -286
  37. package/test/post-script-console-log.spec.ts +0 -73
  38. package/test/post-script-executor.spec.ts +0 -685
  39. package/tsconfig.json +0 -9
@@ -1,63 +0,0 @@
1
- import { Failures } from './failures';
2
- import { PerRequestStats } from './request-stats';
3
- import { Parameters } from '@loadmill/core/dist/parameters';
4
- import {
5
- LoadmillHeaders,
6
- LoadmillRequest,
7
- PostFormData,
8
- RequestPostData,
9
- } from '@loadmill/core/dist/request';
10
-
11
- export function extendSequenceResult(
12
- result: RequestSequenceResult,
13
- requests: LoadmillRequest[]
14
- ): ExtendedSequenceResult {
15
- return {
16
- ...result,
17
- resolvedRequests: requests.map((request, index: number) => ({
18
- ...request,
19
- ...result.resolvedRequests[index],
20
- })),
21
- };
22
- }
23
-
24
- export interface ExtendedSequenceResult extends RequestSequenceResult {
25
- resolvedRequests: ExtendedRequest[];
26
- err?: string;
27
- }
28
-
29
- export interface RequestSequenceResult {
30
- failures: Failures;
31
- avgResTime: number;
32
- successfulHits: number;
33
- lastStartedIndex: number;
34
- requestStats: PerRequestStats;
35
- resolvedRequests: ResolvedRequest[];
36
- }
37
-
38
- export type ExtendedRequest = LoadmillRequest & ResolvedRequest;
39
-
40
- export interface ResolvedRequest {
41
- url?: string;
42
- headers?: LoadmillHeaders[];
43
- postData?: RequestPostData;
44
- postFormData?: PostFormData;
45
-
46
- response?: {
47
- type: string;
48
- text: string;
49
- status: number;
50
- statusText: string;
51
- headers: LoadmillHeaders[];
52
- };
53
-
54
- postParameters?: Parameters[];
55
- stdout?: string[];
56
- unexpectedError?: {
57
- stack: string;
58
- message: string;
59
- properties: string;
60
- };
61
-
62
- retried?: number;
63
- }
@@ -1,20 +0,0 @@
1
- export interface PerRequestStats {
2
- [index: number]: RequestStats;
3
- }
4
-
5
- export interface RequestStats {
6
- resTimes: number[];
7
- }
8
-
9
- export interface PerRequestResTime {
10
- [index: number]: { weight: number; avg: number };
11
- }
12
-
13
- export function setReqStats(
14
- reqStats: PerRequestStats,
15
- index,
16
- ...resTimes: number[]
17
- ) {
18
- const stats = reqStats[index] || (reqStats[index] = { resTimes: [] });
19
- stats.resTimes.push(...resTimes);
20
- }
package/src/res-keeper.ts DELETED
@@ -1,53 +0,0 @@
1
- import { ObjectMap } from '@loadmill/universal/dist/object-map';
2
- import * as promiseUtils from '@loadmill/universal/dist/promise-utils';
3
- import { getFailureKeys } from './failures';
4
- import { RequestSequenceResult } from './request-sequence-result';
5
-
6
- export class ResKeeper {
7
- knownKeysToResults: { [key: string]: string } = {};
8
- results = new ObjectMap<RequestSequenceResult>(this.generateResultKey);
9
-
10
- constructor(private generateResultKey?) {}
11
-
12
- getKnownKeys = () => Object.keys(this.knownKeysToResults);
13
-
14
- mapToResultIds = (failureKeys) => {
15
- const map: { [key: string]: string } = {};
16
- failureKeys.forEach((key) => (map[key] = this.knownKeysToResults[key]));
17
-
18
- return map;
19
- };
20
-
21
- keepIfNeeded = (result: RequestSequenceResult, keepFor?: number) => {
22
- const failureKeys = getFailureKeys(result.failures);
23
-
24
- if (failureKeys.find((key) => !this.knownKeysToResults[key])) {
25
- // We keep it:
26
- const id = this.results.add(result);
27
- failureKeys.forEach((key) => (this.knownKeysToResults[key] = id));
28
-
29
- if (keepFor) {
30
- promiseUtils.delay(keepFor).then(() => this.results.remove(id));
31
- }
32
- }
33
- };
34
-
35
- popForKeys = (failureKeys: string[], withIds = false) => {
36
- return failureKeys
37
- .map((key) => {
38
- const id = this.knownKeysToResults[key];
39
-
40
- if (id) {
41
- const res = this.results.get(id);
42
- this.results.remove(id);
43
-
44
- if (withIds && res) {
45
- res['id'] = id;
46
- }
47
-
48
- return res;
49
- }
50
- })
51
- .filter(Boolean);
52
- };
53
- }
package/src/sampler.ts DELETED
@@ -1,133 +0,0 @@
1
- import log from '@loadmill/universal/dist/log';
2
- import * as mathUtils from '@loadmill/universal/dist/math-utils';
3
- import * as promiseUtils from '@loadmill/universal/dist/promise-utils';
4
- import { minimalRemainingDuration, reportDelay } from '@loadmill/core/dist/conf';
5
- import { runSingleIteration } from './single-runner';
6
- import { Failures, mergeFailures } from './failures';
7
- import { PerRequestStats, setReqStats } from './request-stats';
8
- import { Work } from './work';
9
- import { messageCreators } from './message-creators';
10
- import { DEFAULT_DURATION, DEFAULT_ITERATION_DELAY } from '@loadmill/core/dist/conf/defaults';
11
-
12
- // 5 minutes:
13
- const RES_KEEP_TIME = 5 * 60 * 1000;
14
-
15
- export interface SamplerFaja {
16
- cancelWork(finished: boolean);
17
- send(obj: string);
18
- reportIntervalId;
19
- isStopped: boolean;
20
- keeper;
21
- }
22
-
23
- export class Sampler {
24
- avgResTime = 0;
25
- expired = false;
26
- successfulHits = 0;
27
- failedIterations = 0;
28
- startedIterations = 0;
29
- failures: Failures = {};
30
- successfulIterations = 0;
31
- requestStats: PerRequestStats = {};
32
-
33
- constructor(private samplerMill: SamplerFaja, private work: Work) {}
34
-
35
- startSampling = () => {
36
- this.samplerMill.cancelWork(false);
37
-
38
- promiseUtils.delay(this.work.duration || DEFAULT_DURATION).then(
39
- () => {
40
- if (!this.samplerMill.isStopped) {
41
- log.debug('Time\'s up!');
42
- this.expired = true;
43
- this.sendReport();
44
- }
45
- }
46
- );
47
-
48
- const requests = this.work.requests;
49
- const iterationDelay = this.work.iterationDelay || DEFAULT_ITERATION_DELAY;
50
-
51
- const reportDelayy = reportDelay(iterationDelay, requests);
52
- this.samplerMill.reportIntervalId = setInterval(
53
- this.sendReport,
54
- reportDelayy
55
- );
56
-
57
- this.samplerMill.isStopped = false;
58
- this.runAll();
59
- };
60
-
61
- runAll = async () => {
62
- while (!this.isDone()) {
63
- ++this.startedIterations;
64
- log.trace('Executing iteration: ', this.startedIterations);
65
-
66
- const res = await runSingleIteration(this.work);
67
- this.samplerMill.keeper.keepIfNeeded(res, RES_KEEP_TIME);
68
-
69
- const resFailures = res.failures;
70
-
71
- if (!resFailures || Object.keys(resFailures).length === 0) {
72
- ++this.successfulIterations;
73
- } else {
74
- ++this.failedIterations;
75
- mergeFailures(this.failures, resFailures);
76
- }
77
-
78
- this.avgResTime = mathUtils.calcAvg(
79
- this.avgResTime,
80
- this.successfulHits,
81
- res.avgResTime,
82
- res.successfulHits
83
- );
84
- this.successfulHits += res.successfulHits;
85
-
86
- Object.keys(res.requestStats).forEach(index => {
87
- setReqStats(this.requestStats, index, ...res.requestStats[index].resTimes);
88
- });
89
-
90
-
91
- if (!this.isDone()) {
92
- // We count only the delay of the requests that were NOT ATTEMPTED.
93
- // Note that the first request delay is always ignored:
94
- const skipCount = res.lastStartedIndex + 1;
95
- await promiseUtils.delay(
96
- minimalRemainingDuration(
97
- this.work.iterationDelay || DEFAULT_ITERATION_DELAY,
98
- this.work.requests,
99
- skipCount
100
- )
101
- );
102
- }
103
- }
104
-
105
- if (!this.samplerMill.isStopped) {
106
- log.debug('Finished last iteration:', this.startedIterations);
107
- this.sendReport();
108
- this.samplerMill.cancelWork(true);
109
- }
110
- };
111
-
112
- isDone = () => {
113
- return this.samplerMill.isStopped || this.expired || this.startedIterations >= this.work.iterations;
114
- };
115
-
116
- sendReport = () => {
117
- const report = {
118
- failures: this.failures,
119
- hits: this.successfulHits,
120
- avgResTime: this.avgResTime,
121
- requestStats: this.requestStats,
122
- failedIterations: this.failedIterations,
123
- successfulIterations: this.successfulIterations,
124
- };
125
-
126
- log.trace('Sending report:', report);
127
- this.samplerMill.send(messageCreators.report(report));
128
-
129
- this.failures = {};
130
- this.requestStats = {};
131
- this.successfulIterations = this.successfulHits = this.failedIterations = this.avgResTime = 0;
132
- };
133
- }