Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function() {
const http = new Http({
exporter: "jaeger",
propagator: "w3c",
endpoint: "http://localhost:14268/api/traces"
});
const r = http.get('https://test-api.k6.io');
console.log(`trace-id=${r.trace_id}`);
sleep(1);
}
function searchProducts() {
for (let i = 0; i < 4; i++) {
searchQuery.post();
sleep(Math.random() * 3 + 0.5);
}
}
check(work, {
'status 202': (r) => r.status === 202
})
sleep(1 + parseInt(DELAY_GET_WORK))
const id = JSON.parse(work.request.body).id
const urlGetWork = `${NODE_HOST}/works/${id}`
const res = http.get(urlGetWork)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default () => {
const email = `user${Date.now()}+${__VU}@po.et`;
const payload = JSON.stringify({ email, password: 'aB%12345678910' })
const url = `${FROST_HOST}/accounts`
const params = { headers: { 'Content-Type': 'application/json' } }
const res = http.post(url, payload, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default (token) => {
const url = `${FROST_HOST}/accounts/profile`
const params = { headers: { 'Content-Type': 'application/json', token } }
const res = http.get(url, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default ({ token, work }) => {
const url = `${FROST_HOST}/works`
const params = { headers: { 'Content-Type': 'application/json', token } }
const res = http.post(url, work, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default function () {
let res = http.post(configuration.url, configuration.payload, configuration.params);
check(res, {
"status was 200": (r) => r.status == 200,
"transaction time OK": (r) => r.timings.duration < 200
});
sleep(1);
};
export default () => {
const requestClaim = http.get(`${CLAIM_HOST}`)
const url = `${NODE_HOST}/works`
const payload = requestClaim.body
const params = { headers: { 'Content-Type': 'application/json' } }
const work = http.post(url, payload, params)
check(work, {
'status 202': (r) => r.status === 202
})
sleep(1 + parseInt(DELAY_GET_WORK))
const id = JSON.parse(work.request.body).id
const urlGetWork = `${NODE_HOST}/works/${id}`
const res = http.get(urlGetWork)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default (token) => {
const url = `${FROST_HOST}/tokens`
const params = { headers: { 'Content-Type': 'application/json', token } }
const res = http.post(url, {}, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
function think() {
sleep(Math.random() * 0.5)
}