xk6-frostfs/examples/native.js
Alexander Chuprov 978e1b891e
[#164] *.js: Fix formatting
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-11-15 19:07:24 +03:00

43 lines
1 KiB
JavaScript

import {fail} from "k6";
import native from 'k6/x/frostfs/native';
import {uuidv4} from '../scenarios/libs/k6-utils-1.4.0.js';
const payload = open('../go.sum', 'b');
const frostfs_cli = native.connect(
"s01.frostfs.devenv:8080",
"1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb", 0, 0,
false, 0)
export const options = {
stages : [
{duration : '30s', target : 10},
],
};
export function setup() {
const params = {
acl : 'public-read-write',
placement_policy : 'REP 3',
name : 'container-name',
name_global_scope : 'false'
}
const res = frostfs_cli.putContainer(params)
if (!res.success) {
fail(res.error)
}
console.info("created container", res.container_id)
return { container_id: res.container_id }
}
export default function(data) {
let headers = {'unique_header' : uuidv4()} let resp =
frostfs_cli.put(data.container_id, headers, payload)
if (resp.success) {
frostfs_cli.get(data.container_id, resp.object_id)
}
else {
console.log(resp.error)
}
}