mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-16 09:36:18 +02:00
k6 script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@ docker-base
|
||||
docs/sitemap.txt
|
||||
.env
|
||||
.devcontainer/*
|
||||
k6/urls.json
|
||||
|
41
k6/index.js
Normal file
41
k6/index.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import { randomSeed } from 'k6';
|
||||
import http from 'k6/http';
|
||||
import { SharedArray } from 'k6/data';
|
||||
import exec from 'k6/execution';
|
||||
|
||||
const URL_PREFIX = "http://localhost:8082/unsafe"
|
||||
|
||||
export let options = {
|
||||
discardResponseBodies: true,
|
||||
noConnectionReuse: false,
|
||||
|
||||
vus: 20,
|
||||
iterations: 10000,
|
||||
};
|
||||
|
||||
randomSeed(42)
|
||||
|
||||
const urls = new SharedArray('urls', function () {
|
||||
const data = JSON.parse(open('./urls.json'));
|
||||
|
||||
let unshuffled = [];
|
||||
data.forEach((e) => {
|
||||
let url = URL_PREFIX + e.url
|
||||
let weight = e.weight || 1
|
||||
|
||||
for (var i = 0; i < weight; i++) {
|
||||
unshuffled.push(url)
|
||||
}
|
||||
})
|
||||
|
||||
let shuffled = unshuffled
|
||||
.map(value => ({ value, sort: Math.random() }))
|
||||
.sort((a, b) => a.sort - b.sort)
|
||||
.map(({ value }) => value)
|
||||
|
||||
return shuffled;
|
||||
});
|
||||
|
||||
export default function() {
|
||||
http.get(urls[exec.scenario.iterationInTest % urls.length])
|
||||
}
|
13
k6/urls.json.example
Normal file
13
k6/urls.json.example
Normal file
@@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"url": "/rs:fit:500:500/crop:1000:1000/sh:2/rot:90/wm:1/pd:10/plain/local:///test.jpg",
|
||||
"weight": 5
|
||||
},
|
||||
{
|
||||
"url": "/rs:fit:500:0/plain/local:///test.png",
|
||||
"weight": 2
|
||||
},
|
||||
{
|
||||
"url": "/rs:fill:300:0/wm:0.5:re:::0.2/plain/local:///test.gif"
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user