Skip to content

Commit

Permalink
Update threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
kevariable committed Dec 29, 2024
1 parent 2bfde01 commit cd25415
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions k6/src/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { uuidv4 } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
import { vu } from 'k6/execution'

export const options = {
thresholds: {
create_contact_counter_success: ['count>190'],
create_contact_counter_err: ['count<10']
},

scenarios: {
createContacts: {
exec: 'createContacts',
Expand Down
17 changes: 15 additions & 2 deletions k6/src/supports/contact.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import http from "k6/http";
import {check} from "k6";
import {Counter} from "k6/metrics";

const createContactCounter = new Counter('create_contact_counter_success')
const createContactCounterError = new Counter('create_contact_counter_err')

export const createContact = (createContactRequest, token) => {
const createContact = http.post('http://app:3000/api/contacts', createContactRequest, {
Expand All @@ -12,9 +16,18 @@ export const createContact = (createContactRequest, token) => {

const createContactResponse = createContact.json()


check(createContact, {
'response must be 200': createContact.status === 200,
'response must be 200': () => {
const passed = createContact.status === 200

if (passed) {
createContactCounter.add(1)
} else {
createContactCounterError.add(1)
}

return passed
},
'response contains id': createContactResponse.data?.id !== undefined,
})
}

0 comments on commit cd25415

Please sign in to comment.