Skip to content

Commit b69ccb1

Browse files
Merge pull request #76 from owncloud/OCISDEV-228-new-load-performance-test-for-upload-2
[OCISDEV-228] New load performance test for upload & download a file
2 parents 354ad0b + b2bb5bf commit b69ccb1

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Options } from 'k6/options'
2+
3+
import { create_upload_download_delete_file_120, options as inherited_options } from './simple.k6'
4+
5+
export const options: Options = {
6+
...inherited_options,
7+
iterations: 10,
8+
duration: '7d',
9+
teardownTimeout: '1h'
10+
}
11+
12+
export default create_upload_download_delete_file_120
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { ENV } from '@ownclouders/k6-tdk/lib/utils'
2+
import { Options } from 'k6/options'
3+
import { omit } from 'lodash'
4+
import { envValues } from '@/values'
5+
6+
import { options as inherited_options } from './baseline.k6'
7+
8+
export { create_upload_download_delete_file_120 } from './simple.k6'
9+
10+
const settings = {
11+
...envValues()
12+
}
13+
14+
export const options: Options = {
15+
...omit(inherited_options, 'iterations', 'duration'),
16+
scenarios: {
17+
create_upload_rename_delete_folder_and_file_040: {
18+
executor: 'ramping-vus',
19+
startVUs: 0,
20+
exec: 'create_upload_download_delete_file_120',
21+
env: {
22+
SLEEP_AFTER_ITERATION: ENV('TEST_KOKO_PLATFORM_120_RAMPING_SLEEP_AFTER_ITERATION', '60s')
23+
},
24+
stages: [
25+
{
26+
target: parseInt(ENV('TEST_KOKO_PLATFORM_120_RAMPING_STAGES_VUS', '500'), 10),
27+
duration: ENV('TEST_KOKO_PLATFORM_120_RAMPING_STAGES_UP_DURATION', '20m')
28+
},
29+
{
30+
target: parseInt(ENV('TEST_KOKO_PLATFORM_120_RAMPING_STAGES_VUS', '500'), 10),
31+
duration: ENV('TEST_KOKO_PLATFORM_120_RAMPING_STAGES_PEAK_DURATION', '30m')
32+
},
33+
{
34+
target: 0,
35+
duration: ENV('TEST_KOKO_PLATFORM_120_RAMPING_STAGES_DOWN_DURATION', '10m')
36+
}
37+
]
38+
}
39+
},
40+
...(settings.thresholds.enabled && {
41+
thresholds: {
42+
http_req_failed: [settings.thresholds.rate],
43+
http_req_duration: [ENV('TEST_KOKO_PLATFORM_120_RAMPING_THRESHOLDS_DURATION', 'p(95)<750')],
44+
}
45+
})
46+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { queryJson, randomString, store } from '@ownclouders/k6-tdk/lib/utils'
2+
import { sleep } from 'k6'
3+
import { randomBytes } from 'k6/crypto'
4+
import exec from 'k6/execution'
5+
import { Options } from 'k6/options'
6+
7+
import { userPool } from '@/pools'
8+
import { clientFor } from '@/shortcuts'
9+
import { getPoolItem } from '@/utils'
10+
import { envValues } from '@/values'
11+
12+
export const options: Options = {
13+
vus: 1,
14+
iterations: 1,
15+
insecureSkipTLSVerify: true
16+
}
17+
18+
const settings = {
19+
...envValues()
20+
}
21+
22+
export const create_upload_download_delete_file_120 = async (): Promise<void> => {
23+
const user = getPoolItem({ pool: userPool, n: exec.vu.idInTest })
24+
const userStore = store(user.userLogin)
25+
26+
const client = await userStore.setOrGet('client', async () => {
27+
return clientFor(user)
28+
})
29+
30+
const root = await userStore.setOrGet('root', async () => {
31+
const getMyDrivesResponse = await client.me.getMyDrives({ params: { $filter: "driveType eq 'personal'" } })
32+
const [actorRoot = user.userLogin] = queryJson("$.value[?(@.driveType === 'personal')].id", getMyDrivesResponse?.body)
33+
sleep(settings.sleep.after_request)
34+
35+
return actorRoot
36+
})
37+
38+
const folderName = [user.userLogin.replace(/[^A-Za-z0-9]/g, ''), randomString(), 'iteration', exec.vu.iterationInInstance + 1].join('-')
39+
await client.resource.createResource({ root, resourcePath: folderName })
40+
sleep(settings.sleep.after_request)
41+
42+
let resource: { name: string, size: number }
43+
resource = { ...settings.seed.resource.large }
44+
45+
await client.resource.uploadResource({
46+
root: [root, folderName].join('/'),
47+
resourcePath: resource.name,
48+
resourceBytes: randomBytes(resource.size)
49+
})
50+
sleep(settings.sleep.after_request)
51+
52+
await client.resource.downloadResource({ root, resourcePath: [folderName, resource.name].join('/') })
53+
sleep(settings.sleep.after_request)
54+
55+
await client.resource.deleteResource({ root, resourcePath: folderName })
56+
57+
sleep(settings.sleep.after_iteration)
58+
}
59+
60+
export default create_upload_download_delete_file_120
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Description
2+
3+
The `120 create upload download delete file` test creates a folder in the user's personal space, the user then uploads a large file to it, download the file and deletes them.
4+
5+
## Procedure
6+
7+
* each `user` logs into the system individually.
8+
* each `user iteration` creates a folder.
9+
* each `user iteration` uploads a resource into that folder.
10+
* each `user iteration` download the resource.
11+
* each `user iteration` deletes the folder.
12+
13+
the test runs `N` times for each user, for example if you define `--vus 2` and `--iterations 5`
14+
the testing steps as a whole will run 10 times (5 times per user).
15+
16+
17+
## Available options
18+
19+
* [Shared options](/k6-tests/src/values/env)
20+
21+
22+
## How to run the test
23+
24+
please read [here](/k6-tests/docs/run) how the test can be executed, only the script is different

0 commit comments

Comments
 (0)