Skip to content

Commit

Permalink
Refactor propfind tests and add a new one (#18)
Browse files Browse the repository at this point in the history
add new propfind tests
restructure propfind tests
  • Loading branch information
fschade authored Feb 11, 2022
1 parent a81f744 commit 6b6669f
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 296 deletions.
14 changes: 10 additions & 4 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ This simulates a "normal" upload/download scenario with a common file set.

### Deep Propfind

Script: `/root/cdperf/tests/k6/test-issue-github-ocis-1018-propfind-deep.js`
Scripts:
* `/root/cdperf/tests/k6/test-issue-github-ocis-1018-propfind-deep-100-files-45-nested-folders.js`
* `/root/cdperf/tests/k6/test-issue-github-ocis-1018-propfind-deep-1000-files-5-nested-folders.js`

This test creates a nested directory structure that is five levels deep and distributes 1000 files within that tree.
This test creates a nested directory structure and puts some files into the folder.

The files are created and uploaded. After that, one PROPFIND on the top directory is done.
The depth and file count depends on the test that is running.

After provisioning is complete, the test does one propfind per folder

This simulates the ETag check of a large nested directory.

### Flat Propfind

Script: `/root/cdperf/tests/k6/test-issue-github-ocis-1018-propfind-flat.js`
Script: `/root/cdperf/tests/k6/test-issue-github-ocis-1018-propfind-flat-1000-files.js`

This test crates many (1000 a 1kB) files in the root of the cloud.

Expand Down Expand Up @@ -73,6 +77,8 @@ This reflects the behaviour of renames of folders.

### Share with User

Script: `/root/cdperf/tests/k6/test-issue-github-ocis-1399-share-with-new-user.js`

This script creates a folder and provisions the folder with some files right after.

Right after the the test folder is uploaded, it will be shared with a different user. With the share receiver, the files are downloaded. Finally the share is removed and the user and files are deleted.
Expand Down
2 changes: 1 addition & 1 deletion src/k6/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"singleQuote": true,
"printWidth": 120,
"tabWidth": 4
}
}
2 changes: 1 addition & 1 deletion src/k6/src/lib/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const request = ({
credential: types.Credential;
body?: RequestBody | bytes | null;
params?: RefinedParams<ResponseType> | null;
headers?: {[name: string]: string};
headers?: { [name: string]: string };
}): RefinedResponse<ResponseType> => {
return http.request(
method,
Expand Down
60 changes: 29 additions & 31 deletions src/k6/src/lib/api/share.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
import {RefinedResponse, ResponseType} from 'k6/http';
import { RefinedResponse, ResponseType } from 'k6/http';

import * as types from '../types';
import * as api from './api';

export class Create {
public static exec(
{
credential,
shareType,
shareWith,
path,
permissions,
tags,
}: {
credential: types.Credential;
shareType: string;
shareWith: string;
path: string;
permissions: string;
tags?: types.Tags;
}): RefinedResponse<ResponseType> {
public static exec({
credential,
shareType,
shareWith,
path,
permissions,
tags,
}: {
credential: types.Credential;
shareType: string;
shareWith: string;
path: string;
permissions: string;
tags?: types.Tags;
}): RefinedResponse<ResponseType> {
return api.request({
method: 'POST',
credential,
path: `/ocs/v1.php/apps/files_sharing/api/v1/shares`,
params: {tags},
body: {shareType, shareWith, path, permissions},
params: { tags },
body: { shareType, shareWith, path, permissions },
});
}
}

export class Accept {
public static exec(
{
credential,
id,
tags,
}: {
credential: types.Credential;
id: string;
tags?: types.Tags;
}): RefinedResponse<ResponseType> {
public static exec({
credential,
id,
tags,
}: {
credential: types.Credential;
id: string;
tags?: types.Tags;
}): RefinedResponse<ResponseType> {
return api.request({
method: 'POST',
credential,
path: `/ocs/v1.php/apps/files_sharing/api/v1/shares/pending/${id}`,
params: {tags},
params: { tags },
});
}
}
}
78 changes: 38 additions & 40 deletions src/k6/src/lib/playbook/share.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import {check} from 'k6';
import {RefinedResponse, ResponseType} from 'k6/http';
import { check } from 'k6';
import { RefinedResponse, ResponseType } from 'k6/http';

import * as api from '../api';
import * as types from '../types';
import {Play} from './playbook';
import { Play } from './playbook';

export class Create extends Play {
constructor({name, metricID = 'default'}: { name?: string; metricID?: string } = {}) {
super({name: name || `cloud_${metricID}_play_share_create`});
constructor({ name, metricID = 'default' }: { name?: string; metricID?: string } = {}) {
super({ name: name || `cloud_${metricID}_play_share_create` });
}

public exec(
{
credential,
shareType,
shareWith,
path,
permissions,
tags,
}: {
credential: types.Credential;
shareType: string;
shareWith: string;
path: string;
permissions: string;
tags?: types.Tags;
}): { response: RefinedResponse<ResponseType>; tags: types.Tags } {
tags = {...this.tags, ...tags};
public exec({
credential,
shareType,
shareWith,
path,
permissions,
tags,
}: {
credential: types.Credential;
shareType: string;
shareWith: string;
path: string;
permissions: string;
tags?: types.Tags;
}): { response: RefinedResponse<ResponseType>; tags: types.Tags } {
tags = { ...this.tags, ...tags };

const response = api.share.Create.exec({credential, shareType, shareWith, path, permissions, tags});
const response = api.share.Create.exec({ credential, shareType, shareWith, path, permissions, tags });

check(
response,
Expand All @@ -40,28 +39,27 @@ export class Create extends Play {

this.metricTrend.add(response.timings.duration, tags);

return {response, tags};
return { response, tags };
}
}

export class Accept extends Play {
constructor({name, metricID = 'default'}: { name?: string; metricID?: string } = {}) {
super({name: name || `cloud_${metricID}_play_share_accept`});
constructor({ name, metricID = 'default' }: { name?: string; metricID?: string } = {}) {
super({ name: name || `cloud_${metricID}_play_share_accept` });
}

public exec(
{
credential,
id,
tags,
}: {
credential: types.Credential;
id: string;
tags?: types.Tags;
}): { response: RefinedResponse<ResponseType>; tags: types.Tags } {
tags = {...this.tags, ...tags};
public exec({
credential,
id,
tags,
}: {
credential: types.Credential;
id: string;
tags?: types.Tags;
}): { response: RefinedResponse<ResponseType>; tags: types.Tags } {
tags = { ...this.tags, ...tags };

const response = api.share.Accept.exec({credential, id, tags});
const response = api.share.Accept.exec({ credential, id, tags });

check(
response,
Expand All @@ -73,6 +71,6 @@ export class Accept extends Play {

this.metricTrend.add(response.timings.duration, tags);

return {response, tags};
return { response, tags };
}
}
}
7 changes: 4 additions & 3 deletions src/k6/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { bytes } from 'k6';
import { randomBytes as k6_randomBytes } from 'k6/crypto';
import { DOMParser } from 'xmldom'
import { RefinedResponseBody, ResponseType } from 'k6/http';
import { DOMParser } from 'xmldom';

import * as defaults from './defaults';
import * as types from './types';
import {RefinedResponseBody, ResponseType} from "k6/http";

export const randomNumber = ({ min, max }: { min: number; max: number }): number => {
return Math.random() * (max - min) + min;
Expand Down Expand Up @@ -84,5 +85,5 @@ export const queryStringToObject = (qs: string): { [key: string]: string } => {
};

export const parseXML = (body: RefinedResponseBody<ResponseType>): Document => {
return new DOMParser().parseFromString(body as string, 'text/xml')
return new DOMParser().parseFromString(body as string, 'text/xml');
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,44 @@ import {
} from '../../ocis/1018/upload_download_delete/shared.lib';

// upload, download and delete files with following distribution:
// 83,68% under 1mb
// -- 92 100kb
// -- 92 200kb
// -- 92 300kb
// -- 92 400kb
// -- 92 500kb
// -- 92 600kb
// -- 92 700kb
// -- 92 800kb
// -- 92 900kb
// 12,57% between 1mb and 10mb
// -- 13 1mb
// -- 13 2mb
// -- 13 3mb
// -- 13 4mb
// -- 13 5mb
// -- 13 6mb
// -- 13 7mb
// -- 13 8mb
// -- 13 9mb
// 2,96% between 1mb and 100mb
// -- 3 10mb
// -- 3 20mb
// -- 3 30mb
// -- 3 40mb
// -- 3 50mb
// -- 3 60mb
// -- 3 70mb
// -- 3 80mb
// -- 3 90mb
// -- 3 100mb
// 0,78% larger then 100mb
// -- 1 120mb
// -- 1 140mb
// -- 1 160mb
// -- 1 180mb
// -- 1 200mb
// -- 1 220mb
// -- 1 240mb
// -- 1 260mb
// -- 1 280mb
// -- 1 300mb
// -- 92 files - 100kb
// -- 92 files - 200kb
// -- 92 files - 300kb
// -- 92 files - 400kb
// -- 92 files - 500kb
// -- 92 files - 600kb
// -- 92 files - 700kb
// -- 92 files - 800kb
// -- 92 files - 900kb
// -- 13 files - 1mb
// -- 13 files - 2mb
// -- 13 files - 3mb
// -- 13 files - 4mb
// -- 13 files - 5mb
// -- 13 files - 6mb
// -- 13 files - 7mb
// -- 13 files - 8mb
// -- 13 files - 9mb
// -- 3 files - 10mb
// -- 3 files - 20mb
// -- 3 files - 30mb
// -- 3 files - 40mb
// -- 3 files - 50mb
// -- 3 files - 60mb
// -- 3 files - 70mb
// -- 3 files - 80mb
// -- 3 files - 90mb
// -- 3 files - 100mb
// -- 1 files - 120mb
// -- 1 files - 140mb
// -- 1 files - 160mb
// -- 1 files - 180mb
// -- 1 files - 200mb
// -- 1 files - 220mb
// -- 1 files - 240mb
// -- 1 files - 260mb
// -- 1 files - 280mb
// -- 1 files - 300mb

const createFiles = (count: number, size: number, unit: types.AssetUnit): { size: number; unit: types.AssetUnit }[] => {
return times(count, () => ({ size, unit }));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { Options } from 'k6/options';
import { times } from 'lodash';

import { auth, defaults, k6, playbook, types, utils } from '../../../../../../lib';
import { default as propfind, options as propfindOptions } from './deep.lib';
import { auth, defaults, k6, types, utils } from '../../../../../../lib';
import { default as propfind, options as propfindOptions } from './shared.lib';

// put 1000 files into nested dirs and run a 'PROPFIND' through API
const files: {
size: number;
unit: types.AssetUnit;
}[] = times(1000, () => ({ size: 1, unit: 'KB' }));
const authFactory = new auth(utils.buildAccount({ login: defaults.ACCOUNTS.EINSTEIN }));
const plays = {
davUpload: new playbook.dav.Upload(),
davCreate: new playbook.dav.Create(),
davPropfind: new playbook.dav.Propfind(),
davDelete: new playbook.dav.Delete(),
};
export const options: Options = k6.options({
tags: {
test_id: 'propfind-deep',
issue_url: 'github.com/owncloud/ocis/issues/1018',
},
...propfindOptions({ plays, files }),
...propfindOptions({ files }),
});

export default (): void => propfind({ files, plays, credential: authFactory.credential, account: authFactory.account });
export default (): void => propfind({ files, credential: authFactory.credential, account: authFactory.account });
Loading

0 comments on commit 6b6669f

Please sign in to comment.