Skip to content

Commit

Permalink
getting started with k6 tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanvancea committed Mar 1, 2024
1 parent 570e354 commit 8cdf5ec
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
36 changes: 36 additions & 0 deletions k6-getting-started/create_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import http from 'k6/http';
import {sleep, check} from 'k6';

import { randomString } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';

export const options = {
vus: 3,
duration: '5s'
}

const baseUrl = "https://test-api.k6.io";

export default function(){
const randomUsername = randomString(16);

const requestBody = JSON.stringify({
"username": randomUsername,
"first_name": "John",
"last_name": "Doe",
"email": randomUsername+"@gmail.com",
"password": "123123123"
});

const params = {
headers: {
"Content-Type": "application/json"
}
}
const resp = http.post(`${baseUrl}/user/register/`,requestBody,params);

check(resp, {
'status code 201': r => r.status === 201
})

console.log(resp);
};
17 changes: 17 additions & 0 deletions k6-getting-started/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import http from 'k6/http';
import {sleep, check} from 'k6';

// export const options = {
// vus: 3,
// duration: '5s'
// }

const baseUrl = "https://test-api.k6.io";

export default function(){

const resp = http.get(`${baseUrl}/public/crocodiles/`);
check(resp, {
'status code 200': r => r.status === 200
})
};

0 comments on commit 8cdf5ec

Please sign in to comment.