@grafana/k6-test-builder 0.5.4 → 0.5.5-alpha.1

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 (4) hide show
  1. package/dist/index.d.ts +263 -19
  2. package/dist/index.js +2796 -1578
  3. package/dist/module.js +2795 -1580
  4. package/package.json +16 -11
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { FocusEventHandler, AnchorHTMLAttributes, ReactNode, ElementType, ReactElement, FunctionComponent } from "react";
2
2
  import { InvalidArchiveError } from "har-to-k6";
3
3
  import { ThemeOptions } from "@material-ui/core/styles/createTheme";
4
+ import { GrafanaTheme2 } from "@grafana/data";
4
5
  /** @todo move this type */
5
6
  interface K6LoadZone {
6
7
  k6_load_zone_id: string;
@@ -13,6 +14,7 @@ export interface RampingStage {
13
14
  target: '' | number | null;
14
15
  duration: string;
15
16
  }
17
+ type RequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'OPTIONS' | 'DELETE' | 'HEAD';
16
18
  declare const ScenarioExecutor: {
17
19
  readonly SharedIterations: "shared-iterations";
18
20
  readonly PerVUIterations: "per-vu-iterations";
@@ -70,6 +72,17 @@ interface RampingArrivalRateOptions extends ScenarioCommonOptions {
70
72
  maxVUs?: number;
71
73
  }
72
74
  type ScenarioOptions = SharedIterationsOptions | PerVUIterationsOptions | ConstantVUsOptions | RampingVUsOptions | ConstantArrivalRateOptions | RampingArrivalRateOptions;
75
+ enum CheckType {
76
+ Text = 0,
77
+ JSONPathValue = 1,
78
+ JSONPath = 2,
79
+ RegEx = 3
80
+ }
81
+ enum VariableType {
82
+ JSONPath = 0,
83
+ RegEx = 1,
84
+ CSSSelector = 2
85
+ }
73
86
  interface PrometheusTokenCredentials {
74
87
  token: string;
75
88
  }
@@ -130,8 +143,48 @@ interface ScriptScenarioConfig<T = ScenarioOptions> extends ConfigObject<T> {
130
143
  imports: string[];
131
144
  body: string;
132
145
  }
146
+ export const DEFAULT_OPTIONS: {
147
+ vus: number;
148
+ duration: string;
149
+ ext: {
150
+ loadimpact: {
151
+ distribution: {
152
+ 'amazon:us:ashburn': {
153
+ loadZone: string;
154
+ percent: number;
155
+ };
156
+ };
157
+ };
158
+ };
159
+ };
133
160
  export const DOCS_ARTICLE_LINKS: {
161
+ root: string;
162
+ 'error-codes': string;
163
+ start: string;
164
+ notifications: string;
165
+ 'script-examples': string;
166
+ 'ramp-up': string;
167
+ 'insights-smart-results': string;
168
+ 'interpret-test': string;
169
+ 'concepts.checks': string;
170
+ 'concepts.thresholds': string;
171
+ 'concepts.performance-alerts': string;
172
+ 'performance-alerts.too-many-urls': string;
173
+ 'performance-alerts.third-party-content': string;
174
+ checks: string;
134
175
  thresholds: string;
176
+ metrics: string;
177
+ 'metrics.built-in': string;
178
+ 'metrics.custom': string;
179
+ scenarios: string;
180
+ tutorials: string;
181
+ 'tutorials.automated-performance-testing.local-vs-cloud-execution': string;
182
+ 'compare-results': string;
183
+ 'insights-help': string;
184
+ 'how-to-do-browser-recording': string;
185
+ 'user-token': string;
186
+ 'organization-help': string;
187
+ 'project-help': string;
135
188
  'request-builder': string;
136
189
  'cloud-logs': string;
137
190
  'cloud-apm': string;
@@ -140,7 +193,60 @@ export const DOCS_ARTICLE_LINKS: {
140
193
  'cloud-apm-grafana-cloud': string;
141
194
  'cloud-apm-new-relic': string;
142
195
  'results-visualization/cloud': string;
196
+ 'options.discard-response-bodies': string;
197
+ 'groups-help': string;
198
+ 'url-grouping-help': string;
199
+ 'tags-help': string;
200
+ 'websockets-help': string;
201
+ 'http-requests-help': string;
202
+ 'recording-help': string;
203
+ 'data-retention-policy': string;
204
+ 'usage-reports': string;
205
+ 'manage-thresholds': string;
206
+ faq: string;
207
+ 'getting-started': string;
208
+ 'run-test': string;
209
+ 'product-overview': string;
210
+ 'javascript-api': string;
211
+ 'javascript-api.metrics': string;
212
+ 'javascript-api.http.set-response-callback': string;
213
+ 'javascript-api.sleep': string;
214
+ 'api-load-testing': string;
215
+ scripting: string;
216
+ 'test-running': string;
217
+ 'what-is-vus': string;
218
+ 'filter-domains': string;
219
+ debuggin: string;
220
+ 'schedule-help': string;
221
+ 'request-builder.basic': string;
222
+ 'request-builder.advanced': string;
223
+ 'request-builder.payload': string;
224
+ 'request-builder.scripting': string;
225
+ 'request-builder.query-params': string;
226
+ 'request-builder.variables': string;
227
+ 'request-builder.checks': string;
228
+ 'request-builder.headers': string;
229
+ 'request-builder.importing': string;
143
230
  'cloud-tests-from-cli.load-zones': string;
231
+ 'http-requests.url-grouping': string;
232
+ 'http-requests.tags': string;
233
+ 'modules.local-filesystem-modules': string;
234
+ 'performance-insights.too-many-groups': string;
235
+ 'performance-insights.too-many-metrics': string;
236
+ 'performance-insights.too-many-urls': string;
237
+ 'performance-insights.too-many-time-series': string;
238
+ 'performance-insights.third-party-content': string;
239
+ 'performance-insights.high-load-generator-cpu-usage': string;
240
+ 'performance-insights.high-load-generator-memory-usage': string;
241
+ 'performance-insights.high-http-failure-rate': string;
242
+ 'performance-insights.increased-http-failure-rate': string;
243
+ 'performance-insights.throughput-limit': string;
244
+ 'performance-insights.disabling-performance-insights': string;
245
+ 'performance-insights.abort-reason-user': string;
246
+ 'performance-insights.abort-reason-threshold': string;
247
+ 'performance-insights.abort-reason-system': string;
248
+ 'performance-insights.abort-reason-limit': string;
249
+ 'performance-insights.abort-reason-script-error': string;
144
250
  };
145
251
  type DocsArticleLink = keyof typeof DOCS_ARTICLE_LINKS;
146
252
  interface ImportItemChoice {
@@ -187,6 +293,76 @@ export interface LogOptions {
187
293
  thresholds: Thresholds;
188
294
  scenarios: Record<string, ScenarioOptions>;
189
295
  }
296
+ enum SleepType {
297
+ Before = "before",
298
+ After = "after"
299
+ }
300
+ type Sleep = Partial<Record<SleepType, number>>;
301
+ interface Page {
302
+ id: string;
303
+ name: string;
304
+ title: string;
305
+ sleep?: Sleep[];
306
+ startedDateTime: string;
307
+ }
308
+ type NameValueRecord = Record<'name' | 'value', string>;
309
+ interface EntryCheck {
310
+ type: CheckType;
311
+ expression?: string;
312
+ subject?: number;
313
+ condition?: number;
314
+ value?: string;
315
+ }
316
+ type PostDataType = 'keyValuePairs' | 'json' | 'text' | 'file' | string;
317
+ interface PostData {
318
+ mimeType: string;
319
+ comment: PostDataType;
320
+ text?: string;
321
+ params?: NameValueRecord[];
322
+ }
323
+ interface EntryRequest {
324
+ headers: NameValueRecord[];
325
+ method: RequestMethod;
326
+ queryString: NameValueRecord[];
327
+ postData?: PostData;
328
+ url: string;
329
+ sleep?: Sleep[];
330
+ }
331
+ interface EntryVariable {
332
+ type: VariableType;
333
+ name: string;
334
+ expression: string;
335
+ attribute?: string;
336
+ }
337
+ interface Entry {
338
+ pageref: string;
339
+ checks: EntryCheck[];
340
+ comment: string;
341
+ request: EntryRequest;
342
+ variables: EntryVariable[];
343
+ sleep?: Sleep[];
344
+ startedDateTime: string;
345
+ }
346
+ interface LogCreator {
347
+ name: string;
348
+ version: string;
349
+ }
350
+ interface ArchiveLog {
351
+ entries: Array<Entry>;
352
+ id?: string;
353
+ name?: string;
354
+ version?: string;
355
+ creator?: LogCreator;
356
+ options?: LogOptions;
357
+ pages?: Array<Page>;
358
+ exportAs?: string;
359
+ namedExport?: boolean;
360
+ comment?: string;
361
+ }
362
+ export interface Archive {
363
+ log: ArchiveLog;
364
+ optionsPlaceholder?: boolean;
365
+ }
190
366
  export function convertDurationToSeconds(duration?: string): number;
191
367
  export function isDurationValid(duration: string): boolean;
192
368
  export function isStageTargetValid(target: any): boolean;
@@ -234,6 +410,25 @@ interface StagesVirtualizationComponentProps {
234
410
  type LoadZoneDataItem = {
235
411
  id: number;
236
412
  } & K6LoadZone;
413
+ interface BaseBuilderContextValue {
414
+ ScriptEditorComponent?: (props: ScriptEditorProps) => ReactElement;
415
+ enableViewLinkHref?: boolean;
416
+ openImportModal?: () => Promise<Archive | null>;
417
+ openRecordModal?: () => void;
418
+ onViewChange?: (view: string) => void;
419
+ DocsLinkComponent?: ElementType<DocsLinkProps>;
420
+ k6Test?: TestBuilderTest;
421
+ readonlyScriptScenarios: boolean;
422
+ TestBuilderIconComponent: typeof TestBuilderIcon;
423
+ }
424
+ interface TestBuilderContextValue extends BaseBuilderContextValue {
425
+ StagesVirtualizationComponent?: (props: StagesVirtualizationComponentProps) => ReactElement;
426
+ availableLoadZones: LoadZoneDataItem[];
427
+ hasCloudExecution?: boolean;
428
+ apmConfigs?: APMConfig[];
429
+ hasCloudAPM?: boolean;
430
+ disableAPM?: boolean;
431
+ }
237
432
  interface TestBuilderInternalContextProviderProps {
238
433
  children?: ReactNode;
239
434
  }
@@ -262,27 +457,36 @@ interface TestBuilderStandaloneProps {
262
457
  apmConfigs?: APMConfig[];
263
458
  hasCloudAPM?: boolean;
264
459
  disableAPM?: boolean;
460
+ openImportModal?: TestBuilderContextValue['openImportModal'];
461
+ openRecordModal?: TestBuilderContextValue['openRecordModal'];
265
462
  }
266
- export function TestBuilder({ loading, saving, k6Test, hasCloudExecution, availableLoadZones, DocsLinkComponent, onViewChange, StagesVirtualizationComponent, ScriptEditorComponent, TestBuilderIconComponent, readonlyScriptScenarios, apmConfigs, hasCloudAPM, disableAPM, }: TestBuilderStandaloneProps): JSX.Element;
267
- interface TestMetaInformationProps {
268
- className?: string;
269
- }
270
- export const TestMetaInformation: FunctionComponent<TestMetaInformationProps>;
271
- interface StatusMessageProps {
272
- text?: string | ReactNode;
273
- level: TestBuilderStatus;
463
+ export function TestBuilder({ loading, saving, k6Test, hasCloudExecution, availableLoadZones, DocsLinkComponent, onViewChange, StagesVirtualizationComponent, ScriptEditorComponent, TestBuilderIconComponent, readonlyScriptScenarios, apmConfigs, hasCloudAPM, openImportModal, openRecordModal, disableAPM, }: TestBuilderStandaloneProps): JSX.Element;
464
+ interface Label {
465
+ name: string;
466
+ value: string;
274
467
  }
275
- export const StatusMessage: FunctionComponent<StatusMessageProps>;
276
- export const StatusBar: FunctionComponent<{
277
- className?: string;
278
- }>;
279
- export function useTestBuilderName(): [string, (name: string) => void];
280
- interface MuiThemeProviderProps {
281
- children: ReactNode;
282
- inherit?: boolean;
283
- theme?: ThemeOptions;
468
+ interface Probe {
469
+ id: number;
470
+ tenantId: number;
471
+ commit: string;
472
+ buildstamp: string;
473
+ name: string;
474
+ created: number;
475
+ modified: number;
476
+ public: boolean;
477
+ latitude: number;
478
+ longitude: number;
479
+ region: string;
480
+ online: boolean;
481
+ onlineChange: number;
482
+ labels: Label[];
483
+ version: string;
484
+ deprecated: boolean;
284
485
  }
285
- export function TestBuilderThemeProvider({ children, theme: _theme }: MuiThemeProviderProps): JSX.Element;
486
+ export type SyntheticsBuilderSubmit = (values: TestBuilderTest & {
487
+ script: string;
488
+ }, errors: Error | InvalidArchiveError | undefined) => void;
489
+ export function useGetUnsavedChanges(): [boolean, (value: boolean) => void];
286
490
  declare const grafanaThemeDark: {
287
491
  name: string;
288
492
  isDark: boolean;
@@ -1335,6 +1539,46 @@ declare const grafanaThemeLight: {
1335
1539
  };
1336
1540
  type GrafanaTheme = typeof grafanaThemeDark | typeof grafanaThemeLight;
1337
1541
  export const grafanaThemeToMuiTheme: (theme: GrafanaTheme) => ThemeOptions;
1542
+ interface SyntheticsBuilderStandaloneProps {
1543
+ loading?: boolean;
1544
+ saving: boolean;
1545
+ onSubmit: (values: any, errors: any) => void;
1546
+ k6Test?: TestBuilderTest;
1547
+ availableProbes?: Probe[];
1548
+ DocsLinkComponent?: ElementType<DocsLinkProps>;
1549
+ onViewChange?: (view: string) => void;
1550
+ ScriptEditorComponent?: (props: ScriptEditorProps) => ReactElement;
1551
+ TestBuilderIconComponent?: typeof TestBuilderIcon;
1552
+ readonlyScriptScenarios?: boolean;
1553
+ theme: GrafanaTheme2;
1554
+ }
1555
+ export function SyntheticsBuilder({ loading, saving, k6Test, availableProbes, DocsLinkComponent, onViewChange, ScriptEditorComponent, TestBuilderIconComponent, readonlyScriptScenarios, theme, onSubmit, }: SyntheticsBuilderStandaloneProps): JSX.Element;
1556
+ interface TestMetaInformationProps {
1557
+ className?: string;
1558
+ }
1559
+ export const TestMetaInformation: FunctionComponent<TestMetaInformationProps>;
1560
+ interface StatusMessageProps {
1561
+ text?: string | ReactNode;
1562
+ level: TestBuilderStatus;
1563
+ }
1564
+ export const StatusMessage: FunctionComponent<StatusMessageProps>;
1565
+ export const StatusBar: FunctionComponent<{
1566
+ className?: string;
1567
+ }>;
1568
+ export function useTestBuilderName(): [string, (name: string) => void];
1569
+ interface MuiThemeProviderProps {
1570
+ children: ReactNode;
1571
+ inherit?: boolean;
1572
+ theme?: ThemeOptions;
1573
+ }
1574
+ export function TestBuilderThemeProvider({ children, theme: _theme }: MuiThemeProviderProps): JSX.Element;
1338
1575
  type SetImportsHandler = (value: string[]) => void;
1339
1576
  export function useScriptImports(): [string[] | undefined, SetImportsHandler];
1340
- export function useGetUnsavedChanges(): [boolean, (value: boolean) => void];
1577
+ interface ImportModalProps {
1578
+ onChange: (files: File | null) => void;
1579
+ errors?: string[];
1580
+ content?: JSX.Element;
1581
+ heading?: string;
1582
+ lead?: string;
1583
+ }
1584
+ export const ImportModal: FunctionComponent<ImportModalProps>;