Commit 4266bd4b authored by Ubuntu's avatar Ubuntu

add task test

parent 217b1ab4
import http from 'k6/http';
import { check, fail } from 'k6';
export const options = {
vus: 2,
duration: '3600s',
};
export default function() {
const url = 'http://43.198.252.255:8000/api/v1//txt2img/base/llm';
const payload = JSON.stringify({
"test": 1
})
const param = {
headers:{
'apikey': 'L6eXzteHYa2Uq0ar4kdMaBOiOIjmRI08',
'Content-Type': 'application/json'
},
};
var res = http.post(url, payload, param);
const statusCheck = check(res, {
'status is 200': (r) => r.status === 200,
});
const taskCheck = check(res, {
'task is success': (r) => r.json('task.is_success') === true,
});
if (!statusCheck) {
// console.log('task status failed', res.status);
fail('task ' + res.headers['Task-Id'] + ' failed with status error: ' + res.status);
} else if (!taskCheck) {
// check res.boy is empty
if (res.body == null ) {
fail('task ' + res.headers['Task-Id'] + ' failed with empty response');
} else {
if (res.json('task.api_error.message') !== undefined) {
fail('task ' + res.headers['Task-Id'] + ' failed with api error: ' + res.json('task.api_error.message'));
}
if (res.json('task.error') !== undefined) {
fail('task ' + res.headers['Task-Id'] + ' failed with execute error: ' + res.json('task.error'));
}
}
}
// console.log("res is ", res);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment