Skip to content

Commit

Permalink
Add ramping arrival rate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MushtabaA committed Mar 6, 2024
1 parent 51610dc commit 21d4050
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
File renamed without changes.
46 changes: 46 additions & 0 deletions scripts/iterationRate/rampingArrivalRate/fastRampingArrivalRate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import http from 'k6/http';
import { group, sleep } from 'k6';

const BASE_URL = `http://${__ENV.HOST || 'localhost'}:8080/tools.descartes.teastore.webui`;

const groupResponseTimes = {};

export const options = {
discardResponseBodies: true,
scenarios: {
fastRampingArrivalRate: {
executor: 'ramping-arrival-rate',

// Start `startRate` iterations per second
timeUnit: '1s',

// Pre-allocate necessary VUs.
preAllocatedVUs: 100,

stages: [

{ target: 20, duration: '10s' },

{ target: 50, duration: '10s' },

{ target: 100, duration: '30s' },

{ target: 200, duration: '60s' },

{ target: 50, duration: '30s' },
],
},
},
};

export default function () {
group('Black Tea Category Browse', () => {
const start = new Date();
http.get(`${BASE_URL}/category?category=2&page=1`);
const end = new Date();
const duration = end - start;
groupResponseTimes['Black Tea Category Browse'] = (groupResponseTimes['Black Tea Category Browse'] || 0) + duration;
// Sleep time is 1000ms. Total iteration time is sleep + time to finish request.
sleep(1);
});
}
38 changes: 38 additions & 0 deletions scripts/iterationRate/rampingArrivalRate/rampingExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import http from 'k6/http';

export const options = {
discardResponseBodies: true,

scenarios: {
contacts: {
executor: 'ramping-arrival-rate',

// Start iterations per `timeUnit`
startRate: 300,

// Start `startRate` iterations per minute
timeUnit: '1m',

// Pre-allocate necessary VUs.
preAllocatedVUs: 50,

stages: [
// Start 300 iterations per `timeUnit` for the first minute.
{ target: 300, duration: '1m' },

// Linearly ramp-up to starting 600 iterations per `timeUnit` over the following two minutes.
{ target: 600, duration: '2m' },

// Continue starting 600 iterations per `timeUnit` for the following four minutes.
{ target: 600, duration: '4m' },

// Linearly ramp-down to starting 60 iterations per `timeUnit` over the last two minutes.
{ target: 60, duration: '2m' },
],
},
},
};

export default function () {
http.get('https://test.k6.io/contacts.php');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import http from 'k6/http';
import { group, sleep } from 'k6';

const BASE_URL = `http://${__ENV.HOST || 'localhost'}:8080/tools.descartes.teastore.webui`;

const groupResponseTimes = {};

export const options = {
discardResponseBodies: true,
scenarios: {
fastRampingArrivalRate: {
executor: 'ramping-arrival-rate',

// Start `startRate` iterations per second
timeUnit: '1m',

// Pre-allocate necessary VUs.
preAllocatedVUs: 100,

stages: [

{ target: 20, duration: '1min' },

{ target: 50, duration: '1min' },

{ target: 100, duration: '1min' },

{ target: 200, duration: '2min' },

{ target: 50, duration: '2min' },

{ target: 50, duration: '30s' },
],
},
},
};

export default function () {
group('Black Tea Category Browse', () => {
const start = new Date();
http.get(`${BASE_URL}/category?category=2&page=1`);
const end = new Date();
const duration = end - start;
groupResponseTimes['Black Tea Category Browse'] = (groupResponseTimes['Black Tea Category Browse'] || 0) + duration;
// Sleep time is 1000ms. Total iteration time is sleep + time to finish request.
sleep(1);
});
}

0 comments on commit 21d4050

Please sign in to comment.