mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 22:19:09 -05:00
simplify playbooks and api
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import encoding from 'k6/encoding';
|
||||
import * as types from '../types';
|
||||
import * as defaults from "../defaults";
|
||||
import {merge} from 'lodash';
|
||||
import http, {RefinedParams, RefinedResponse, RequestBody, ResponseType} from "k6/http";
|
||||
|
||||
export const headersDefault = ({credential}: { credential: types.Credential }): { [key: string]: string } => {
|
||||
export const buildHeaders = ({credential}: { credential: types.Credential }): { [key: string]: string } => {
|
||||
const isOIDCGuard = (credential as types.Token).tokenType !== undefined;
|
||||
const authOIDC = credential as types.Token;
|
||||
const authBasic = credential as types.Account;
|
||||
@@ -9,4 +12,30 @@ export const headersDefault = ({credential}: { credential: types.Credential }):
|
||||
return {
|
||||
Authorization: isOIDCGuard ? `${authOIDC.tokenType} ${authOIDC.accessToken}` : `Basic ${encoding.b64encode(`${authBasic.login}:${authBasic.password}`)}`,
|
||||
}
|
||||
}
|
||||
|
||||
export const buildURL = ({path}: { path: string }): string => {
|
||||
return [
|
||||
defaults.ENV.HOST,
|
||||
...path.split('/').filter(Boolean)
|
||||
].join('/')
|
||||
}
|
||||
|
||||
export const request = ({method, path, body = {}, params = {}, credential}: {
|
||||
method: 'PROPFIND' | 'PUT' | 'GET' | 'DELETE' | 'MKCOL',
|
||||
path: string,
|
||||
credential: types.Credential;
|
||||
body?: RequestBody | null,
|
||||
params?: RefinedParams<ResponseType> | null
|
||||
}): RefinedResponse<ResponseType> => {
|
||||
return http.request(
|
||||
method,
|
||||
buildURL({path}),
|
||||
body,
|
||||
merge({
|
||||
headers: {
|
||||
...buildHeaders({credential})
|
||||
}
|
||||
}, params)
|
||||
);
|
||||
}
|
||||
+26
-117
@@ -1,150 +1,59 @@
|
||||
import http, {RefinedResponse, ResponseType} from 'k6/http';
|
||||
import {RefinedResponse, ResponseType} from 'k6/http';
|
||||
import * as api from './api'
|
||||
import * as defaults from '../defaults';
|
||||
import * as types from '../types';
|
||||
|
||||
export const fileUpload = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path = '',
|
||||
asset,
|
||||
tags,
|
||||
}: {
|
||||
export class Upload {
|
||||
public static exec({credential, userName, path = '', asset, tags}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
asset: types.Asset;
|
||||
path?: string;
|
||||
tags?: { [key: string]: string };
|
||||
tags?: types.Tags;
|
||||
}): RefinedResponse<ResponseType> {
|
||||
return api.request({method: 'PUT', credential, path: `/remote.php/dav/files/${userName}/${path}/${asset.name}`, params: {tags}, body: asset.bytes as any})
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
|
||||
return http.put(
|
||||
[
|
||||
defaults.ENV.HOST,
|
||||
...`/remote.php/dav/files/${userName}/${path}/${asset.name}`.split('/').filter(Boolean)
|
||||
].join('/'),
|
||||
asset.bytes as any,
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const fileDownload = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
export class Download {
|
||||
public static exec({credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
tags?: types.Tags;
|
||||
}): RefinedResponse<ResponseType> {
|
||||
return api.request({method: 'GET', credential, path: `/remote.php/dav/files/${userName}/${path}`, params: {tags}})
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
return http.get(
|
||||
[
|
||||
defaults.ENV.HOST,
|
||||
...`/remote.php/dav/files/${userName}/${path}`.split('/').filter(Boolean)
|
||||
].join('/'),
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const fileDelete = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
export class Delete {
|
||||
public static exec({credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
tags?: types.Tags;
|
||||
}): RefinedResponse<ResponseType> {
|
||||
return api.request({method: 'DELETE', credential, path: `/remote.php/dav/files/${userName}/${path}`, params: {tags}})
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
return http.del(
|
||||
[
|
||||
defaults.ENV.HOST,
|
||||
...`/remote.php/dav/files/${userName}/${path}`.split('/').filter(Boolean)
|
||||
].join('/'),
|
||||
{},
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const folderCreate = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
export class Create {
|
||||
public static exec({credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
tags?: types.Tags;
|
||||
}): RefinedResponse<ResponseType> {
|
||||
return api.request({method: 'MKCOL', credential, path: `/remote.php/dav/files/${userName}/${path}`, params: {tags}})
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
return http.request(
|
||||
'MKCOL',
|
||||
[
|
||||
defaults.ENV.HOST,
|
||||
...`/remote.php/dav/files/${userName}/${path}`.split('/').filter(Boolean)
|
||||
].join('/'),
|
||||
{},
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export const folderDelete = fileDelete
|
||||
|
||||
export const propfind = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path = '',
|
||||
tags,
|
||||
}: {
|
||||
export class Propfind {
|
||||
public static exec({credential, userName, path = '', tags}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path?: string;
|
||||
tags?: { [key: string]: string };
|
||||
tags?: types.Tags;
|
||||
}): RefinedResponse<ResponseType> {
|
||||
return api.request({method: 'PROPFIND', credential, path: `/remote.php/dav/files/${userName}/${path}`, params: {tags}})
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
return http.request(
|
||||
'PROPFIND',
|
||||
[
|
||||
defaults.ENV.HOST,
|
||||
...`/remote.php/dav/files/${userName}/${path}`.split('/').filter(Boolean)
|
||||
].join('/'),
|
||||
{},
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
export * as api from './api'
|
||||
export * as dav from './dav'
|
||||
export * as users from './users'
|
||||
@@ -1,26 +0,0 @@
|
||||
import http, {RefinedResponse, ResponseType} from 'k6/http';
|
||||
import * as api from './api'
|
||||
import * as defaults from '../defaults';
|
||||
import * as types from '../types';
|
||||
|
||||
export const userInfo = (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
tags?: { [name: string]: string };
|
||||
}
|
||||
): RefinedResponse<ResponseType> => {
|
||||
return http.get(
|
||||
`${defaults.ENV.HOST}/ocs/v1.php/cloud/users/${userName}`,
|
||||
{
|
||||
tags,
|
||||
headers: {
|
||||
...api.headersDefault({credential})
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
+116
-283
@@ -1,308 +1,141 @@
|
||||
import {Gauge, Trend} from 'k6/metrics';
|
||||
import * as api from '../api';
|
||||
import {check} from 'k6';
|
||||
import * as types from '../types';
|
||||
import {RefinedResponse, ResponseType} from 'k6/http';
|
||||
import {Play} from "./playbook";
|
||||
|
||||
export const fileUpload = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_file_upload`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
asset,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
path?: string;
|
||||
userName: string;
|
||||
asset: types.Asset;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.fileUpload({
|
||||
credential: credential as types.Credential,
|
||||
asset,
|
||||
userName,
|
||||
tags,
|
||||
path,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'file upload status is 201': () => response.status === 201,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
}
|
||||
export class Upload extends Play {
|
||||
constructor({name, metricID = 'default'}: { name?: string; metricID?: string; }) {
|
||||
super({name: name || `oc_${metricID}_play_dav_upload`});
|
||||
}
|
||||
};
|
||||
|
||||
export const fileDelete = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_file_delete`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.fileDelete({
|
||||
credential: credential as types.Credential,
|
||||
path,
|
||||
userName,
|
||||
tags,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'file delete status is 204': () => response.status === 204,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
public exec(
|
||||
{credential, userName, path, asset, tags}: {
|
||||
credential: types.Credential;
|
||||
path?: string;
|
||||
userName: string;
|
||||
asset: types.Asset;
|
||||
tags?: types.Tags;
|
||||
}
|
||||
): { response: RefinedResponse<ResponseType>; tags: types.Tags; } {
|
||||
tags = {...this.tags, ...tags};
|
||||
|
||||
const response = api.dav.Upload.exec({credential: credential as types.Credential, asset, userName, tags, path});
|
||||
|
||||
check(response, {
|
||||
'upload status is 201': () => response.status === 201,
|
||||
}, tags) || this.metricErrorRate.add(1, tags);
|
||||
|
||||
this.metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {response, tags}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const fileDownload = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_file_download`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
export class Delete extends Play {
|
||||
constructor({name, metricID = 'default'}: { name?: string; metricID?: string; }) {
|
||||
super({name: name || `oc_${metricID}_play_dav_delete`});
|
||||
}
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.fileDownload({
|
||||
credential: credential as types.Credential,
|
||||
path,
|
||||
userName,
|
||||
tags,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'file download status is 200': () => response.status === 200,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
public exec(
|
||||
{credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
path: string;
|
||||
userName: string;
|
||||
tags?: types.Tags;
|
||||
}
|
||||
): { response: RefinedResponse<ResponseType>; tags: types.Tags; } {
|
||||
tags = {...this.tags, ...tags};
|
||||
|
||||
const response = api.dav.Delete.exec({credential: credential as types.Credential, userName, tags, path});
|
||||
|
||||
check(response, {
|
||||
'delete status is 204': () => response.status === 204,
|
||||
}, tags) || this.metricErrorRate.add(1, tags);
|
||||
|
||||
this.metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {response, tags}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const folderCreate = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_folder_create`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
export class Download extends Play {
|
||||
constructor({name, metricID = 'default'}: { name?: string; metricID?: string; }) {
|
||||
super({name: name || `oc_${metricID}_play_dav_download`});
|
||||
}
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.folderCreate({
|
||||
credential: credential as types.Credential,
|
||||
path,
|
||||
userName,
|
||||
tags,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'folder create status is 201': () => response.status === 201,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
public exec(
|
||||
{credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
path: string;
|
||||
userName: string;
|
||||
tags?: types.Tags;
|
||||
}
|
||||
): { response: RefinedResponse<ResponseType>; tags: types.Tags; } {
|
||||
tags = {...this.tags, ...tags};
|
||||
|
||||
const response = api.dav.Download.exec({credential: credential as types.Credential, userName, tags, path});
|
||||
|
||||
check(response, {
|
||||
'download status is 200': () => response.status === 200,
|
||||
}, tags) || this.metricErrorRate.add(1, tags);
|
||||
|
||||
this.metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {response, tags}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const folderDelete = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_folder_delete`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
export class Create extends Play {
|
||||
constructor({name, metricID = 'default'}: { name?: string; metricID?: string; }) {
|
||||
super({name: name || `oc_${metricID}_play_dav_create`});
|
||||
}
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path: string;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.folderDelete({
|
||||
credential: credential as types.Credential,
|
||||
path,
|
||||
userName,
|
||||
tags,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'folder delete status is 204': () => response.status === 204,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
public exec(
|
||||
{credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
path: string;
|
||||
userName: string;
|
||||
tags?: types.Tags;
|
||||
}
|
||||
): { response: RefinedResponse<ResponseType>; tags: types.Tags; } {
|
||||
tags = {...this.tags, ...tags};
|
||||
|
||||
const response = api.dav.Create.exec({credential: credential as types.Credential, userName, tags, path});
|
||||
|
||||
check(response, {
|
||||
'create status is 201': () => response.status === 201,
|
||||
}, tags) || this.metricErrorRate.add(1, tags);
|
||||
|
||||
this.metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {response, tags}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const propfind = ({name, metricID = 'default'}: { name?: string; metricID?: string; }) => {
|
||||
const playName = name || `oc_${metricID}_play_dav_propfind`;
|
||||
const metricTrendName = `${playName}_trend`;
|
||||
const metricTrend = new Trend(metricTrendName, true);
|
||||
const metricErrorRateName = `${playName}_error_rate`;
|
||||
const metricErrorRate = new Gauge(metricErrorRateName);
|
||||
export class Propfind extends Play {
|
||||
constructor({name, metricID = 'default'}: { name?: string; metricID?: string; }) {
|
||||
super({name: name || `oc_${metricID}_play_dav_propfind`});
|
||||
}
|
||||
|
||||
return {
|
||||
playName,
|
||||
metricTrendName,
|
||||
metricErrorRateName,
|
||||
exec: (
|
||||
{
|
||||
credential,
|
||||
userName,
|
||||
path,
|
||||
tags,
|
||||
}: {
|
||||
credential: types.Credential;
|
||||
userName: string;
|
||||
path?: string;
|
||||
tags?: { [key: string]: string };
|
||||
}
|
||||
): {
|
||||
response: RefinedResponse<ResponseType>;
|
||||
tags: { [key: string]: string };
|
||||
} => {
|
||||
tags = {play: playName, ...tags};
|
||||
|
||||
const response = api.dav.propfind({
|
||||
credential: credential as types.Credential,
|
||||
path,
|
||||
userName,
|
||||
tags,
|
||||
});
|
||||
|
||||
check(response, {
|
||||
'propfind status is 207': () => response.status === 207,
|
||||
}, tags) || metricErrorRate.add(1, tags);
|
||||
|
||||
metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {
|
||||
response,
|
||||
tags,
|
||||
}
|
||||
public exec(
|
||||
{credential, userName, path, tags}: {
|
||||
credential: types.Credential;
|
||||
path?: string;
|
||||
userName: string;
|
||||
tags?: types.Tags;
|
||||
}
|
||||
): { response: RefinedResponse<ResponseType>; tags: types.Tags; } {
|
||||
tags = {...this.tags, ...tags};
|
||||
|
||||
const response = api.dav.Propfind.exec({credential: credential as types.Credential, userName, tags, path});
|
||||
|
||||
check(response, {
|
||||
'propfind status is 207': () => response.status === 207,
|
||||
}, tags) || this.metricErrorRate.add(1, tags);
|
||||
|
||||
this.metricTrend.add(response.timings.duration, tags)
|
||||
|
||||
return {response, tags}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import {Gauge, Trend} from "k6/metrics";
|
||||
|
||||
export class Play {
|
||||
public readonly name: string;
|
||||
public readonly metricTrendName: string;
|
||||
public readonly metricErrorRateName: string;
|
||||
public readonly metricTrend: Trend;
|
||||
public readonly metricErrorRate: Gauge;
|
||||
protected tags: { [key: string]: string };
|
||||
|
||||
constructor({name}: { name: string; }) {
|
||||
this.name = name;
|
||||
this.metricTrendName = `${this.name}_trend`;
|
||||
this.metricErrorRateName = `${this.name}_error_rate`;
|
||||
this.metricTrend = new Trend(this.metricTrendName, true);
|
||||
this.metricErrorRate = new Gauge(this.metricErrorRateName);
|
||||
this.tags = {play: this.name}
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,6 @@ export interface AuthProvider {
|
||||
credential: Credential
|
||||
}
|
||||
|
||||
export type AssetUnit = 'KB' | 'MB' | 'GB'
|
||||
export type AssetUnit = 'KB' | 'MB' | 'GB'
|
||||
|
||||
export type Tags = { [key: string]: string }
|
||||
@@ -10,18 +10,18 @@ const files: {
|
||||
}[] = times(1000, () => ({size: 1, unit: 'KB'}))
|
||||
const authFactory = new auth.default(utils.buildAccount({login: defaults.ACCOUNTS.EINSTEIN}));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload({}),
|
||||
propfind: playbook.dav.propfind({}),
|
||||
fileDelete: playbook.dav.fileDelete({}),
|
||||
davUpload: new playbook.dav.Upload({}),
|
||||
davPropfind: new playbook.dav.Propfind({}),
|
||||
davDelete: new playbook.dav.Delete({}),
|
||||
}
|
||||
export const options: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
iterations: 3,
|
||||
vus: 1,
|
||||
thresholds: files.reduce((acc: any, c) => {
|
||||
acc[`${plays.fileUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.propfind.metricTrendName}`] = []
|
||||
acc[`${plays.fileDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davPropfind.metricTrendName}`] = []
|
||||
acc[`${plays.davDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
return acc
|
||||
}, {}),
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export default (): void => {
|
||||
size: f.size,
|
||||
})
|
||||
|
||||
plays.fileUpload.exec({
|
||||
plays.davUpload.exec({
|
||||
credential,
|
||||
asset,
|
||||
userName: account.login,
|
||||
@@ -48,13 +48,13 @@ export default (): void => {
|
||||
filesUploaded.push({id, name: asset.name})
|
||||
})
|
||||
|
||||
plays.propfind.exec({
|
||||
plays.davPropfind.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.fileDelete.exec({
|
||||
plays.davDelete.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.name,
|
||||
|
||||
@@ -10,20 +10,20 @@ const files: {
|
||||
}[] = times(1000, () => ({size: 1, unit: 'KB'}))
|
||||
const authFactory = new auth.default(utils.buildAccount({login: defaults.ACCOUNTS.EINSTEIN}));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload({}),
|
||||
propfind: playbook.dav.propfind({}),
|
||||
folderCreate: playbook.dav.folderCreate({}),
|
||||
folderDelete: playbook.dav.folderDelete({}),
|
||||
davUpload: new playbook.dav.Upload({}),
|
||||
davPropfind: new playbook.dav.Propfind({}),
|
||||
davCreate: new playbook.dav.Create({}),
|
||||
davDelete: new playbook.dav.Delete({}),
|
||||
}
|
||||
export const options: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
iterations: 3,
|
||||
vus: 1,
|
||||
thresholds: files.reduce((acc: any, c) => {
|
||||
acc[`${plays.fileUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.propfind.metricTrendName}`] = []
|
||||
acc[`${plays.folderCreate.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.folderDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davPropfind.metricTrendName}`] = []
|
||||
acc[`${plays.davCreate.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
return acc
|
||||
}, {}),
|
||||
};
|
||||
@@ -43,7 +43,7 @@ export default (): void => {
|
||||
const folder = times(utils.randomNumber({min: 1, max: 10}), () => utils.randomString()).reduce((acc: string[], c) => {
|
||||
acc.push(c)
|
||||
|
||||
plays.folderCreate.exec({
|
||||
plays.davCreate.exec({
|
||||
credential,
|
||||
path: acc.join('/'),
|
||||
userName: account.login,
|
||||
@@ -54,7 +54,7 @@ export default (): void => {
|
||||
}, []).join('/')
|
||||
|
||||
|
||||
plays.fileUpload.exec({
|
||||
plays.davUpload.exec({
|
||||
credential,
|
||||
asset,
|
||||
path: folder,
|
||||
@@ -65,13 +65,13 @@ export default (): void => {
|
||||
filesUploaded.push({id, name: asset.name, folder})
|
||||
})
|
||||
|
||||
plays.propfind.exec({
|
||||
plays.davPropfind.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.folderDelete.exec({
|
||||
plays.davDelete.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.folder.split('/')[0],
|
||||
|
||||
@@ -14,18 +14,18 @@ const files: {
|
||||
]
|
||||
const authFactory = new auth.default(utils.buildAccount({login: defaults.ACCOUNTS.EINSTEIN}));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload({}),
|
||||
fileDownload: playbook.dav.fileDownload({}),
|
||||
fileDelete: playbook.dav.fileDelete({}),
|
||||
davUpload: new playbook.dav.Upload({}),
|
||||
davDownload: new playbook.dav.Download({}),
|
||||
davDelete: new playbook.dav.Delete({}),
|
||||
}
|
||||
export const options: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
iterations: 3,
|
||||
vus: 1,
|
||||
thresholds: files.reduce((acc: any, c) => {
|
||||
acc[`${plays.fileUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.fileDownload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.fileDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davDownload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
return acc
|
||||
}, {}),
|
||||
};
|
||||
@@ -42,7 +42,7 @@ export default (): void => {
|
||||
size: f.size,
|
||||
})
|
||||
|
||||
plays.fileUpload.exec({
|
||||
plays.davUpload.exec({
|
||||
credential,
|
||||
asset,
|
||||
userName: account.login,
|
||||
@@ -53,7 +53,7 @@ export default (): void => {
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.fileDownload.exec({
|
||||
plays.davDownload.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.name,
|
||||
@@ -62,7 +62,7 @@ export default (): void => {
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.fileDelete.exec({
|
||||
plays.davDelete.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.name,
|
||||
|
||||
@@ -16,18 +16,18 @@ const files: {
|
||||
]
|
||||
const authFactory = new auth.default(utils.buildAccount({login: defaults.ACCOUNTS.EINSTEIN}));
|
||||
const plays = {
|
||||
fileUpload: playbook.dav.fileUpload({}),
|
||||
fileDownload: playbook.dav.fileDownload({}),
|
||||
fileDelete: playbook.dav.fileDelete({}),
|
||||
davUpload: new playbook.dav.Upload({}),
|
||||
davDownload: new playbook.dav.Download({}),
|
||||
davDelete: new playbook.dav.Delete({}),
|
||||
}
|
||||
export const options: Options = {
|
||||
insecureSkipTLSVerify: true,
|
||||
iterations: 3,
|
||||
vus: 1,
|
||||
thresholds: files.reduce((acc: any, c) => {
|
||||
acc[`${plays.fileUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.fileDownload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.fileDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davUpload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davDownload.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
acc[`${plays.davDelete.metricTrendName}{asset:${c.unit + c.size.toString()}`] = []
|
||||
return acc
|
||||
}, {}),
|
||||
};
|
||||
@@ -45,7 +45,7 @@ export default (): void => {
|
||||
size: f.size,
|
||||
})
|
||||
|
||||
plays.fileUpload.exec({
|
||||
plays.davUpload.exec({
|
||||
credential,
|
||||
asset,
|
||||
userName: account.login,
|
||||
@@ -56,7 +56,7 @@ export default (): void => {
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.fileDownload.exec({
|
||||
plays.davDownload.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.name,
|
||||
@@ -65,7 +65,7 @@ export default (): void => {
|
||||
})
|
||||
|
||||
filesUploaded.forEach(f => {
|
||||
plays.fileDelete.exec({
|
||||
plays.davDelete.exec({
|
||||
credential,
|
||||
userName: account.login,
|
||||
path: f.name,
|
||||
|
||||
Reference in New Issue
Block a user