-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
358 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import { check, sleep } from 'k6'; | ||
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; | ||
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js'; | ||
|
||
const http = new Httpx({ | ||
baseURL: 'http://localhost:4000', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
|
||
const pauseMin = 2; | ||
const pauseMax = 6; | ||
|
||
export const options = { | ||
discardResponseBodies: true, | ||
ext: { | ||
loadimpact: { | ||
projectID: 3651337, | ||
name: 'Zero to GraphQL Using Elixir', | ||
distribution: { | ||
'amazon:us:ashburn': { loadZone: 'amazon:us:ashburn', percent: 100 } | ||
}, | ||
apm: [], | ||
}, | ||
}, | ||
thresholds: { | ||
// load_generator_memory_used_percent: [{ threshold: 'value<=80', abortOnFail: true }], | ||
// load_generator_cpu_percent: [{ threshold: 'value<=80', abortOnFail: true }], | ||
http_req_failed: [{ threshold: 'rate<0.01', abortOnFail: true }], // http errors should be less than 1%, otherwise abort the test | ||
http_req_duration: ['p(95) <= 100'], // 95% of the requests must complete in 100ms. | ||
http_req_duration: ['p(99) <= 100'], // 99% of the requests must complete in 100ms. | ||
}, | ||
scenarios: { | ||
getPersonByID: { | ||
executor: 'ramping-vus', | ||
// gracefulStop: '30s', | ||
startVUs: 0, | ||
stages: [ | ||
{ duration: '1m', target: 20 }, // ramp up | ||
{ duration: '1m30s', target: 20 }, // stable | ||
{ duration: '1m', target: 0 }, // ramp down to 0 users | ||
], | ||
// gracefulRampDown: '30s', | ||
gracefulRampDown: '0s', | ||
exec: 'getPersonByID', | ||
}, | ||
getPeople: { | ||
executor: 'ramping-vus', | ||
// gracefulStop: '30s', | ||
startVUs: 0, | ||
stages: [ | ||
{ duration: '1m', target: 20 }, // ramp up | ||
{ duration: '1m30s', target: 20 }, // stable | ||
{ duration: '1m', target: 0 }, // ramp down to 0 users | ||
], | ||
// gracefulRampDown: '30s', | ||
gracefulRampDown: '0s', | ||
exec: 'getPeople', | ||
}, | ||
}, | ||
} | ||
|
||
// Scenario: getPersonByID (executor: ramping-vus) | ||
|
||
export function getPersonByID() { | ||
// Get Person By ID | ||
_getPersonByID(randomIntBetween(1, 4)) | ||
|
||
// Add random delay | ||
sleep(randomIntBetween(pauseMin, pauseMax)) | ||
} | ||
|
||
export async function _getPersonByID(id) { | ||
const query = ` | ||
query GetPersonByID($id: ID!) { | ||
person(id: $id) { | ||
firstName | ||
lastName | ||
username | ||
friends { | ||
firstName | ||
lastName | ||
username | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await http.asyncPost( | ||
'/graphql', | ||
JSON.stringify({ | ||
query: query, | ||
variables: { | ||
id: id | ||
} | ||
}, | ||
{ | ||
tags: { | ||
name: 'getPersonByID' | ||
} | ||
}) | ||
) | ||
|
||
// check that response is 200 | ||
check(response, { | ||
"status was 200": (r) => r.status === 200 | ||
}) | ||
} | ||
|
||
// Scenario: getPeople (executor: ramping-vus) | ||
|
||
export function getPeople() { | ||
// Get People | ||
_getPeople() | ||
|
||
// Add random delay | ||
sleep(randomIntBetween(pauseMin, pauseMax)) | ||
} | ||
|
||
export async function _getPeople() { | ||
const query = ` | ||
query GetPeople { | ||
people { | ||
id | ||
firstName | ||
lastName | ||
username | ||
friends { | ||
id | ||
firstName | ||
lastName | ||
username | ||
} | ||
} | ||
} | ||
`; | ||
|
||
const response = await http.asyncPost( | ||
'/graphql', | ||
JSON.stringify({ | ||
query: query | ||
}, | ||
{ | ||
tags: { | ||
name: 'getPeople' | ||
} | ||
}) | ||
) | ||
|
||
// check that response is 200 | ||
check(response, { | ||
"status was 200": (r) => r.status === 200 | ||
}) | ||
} | ||
|
||
export async function getRandomInt(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import { check, sleep } from 'k6'; | ||
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.4.0/index.js'; | ||
import { Httpx } from 'https://jslib.k6.io/httpx/0.1.0/index.js'; | ||
import { SharedArray } from 'k6/data'; | ||
|
||
var hostname = __ENV.hostname; | ||
if (hostname == null) hostname = 'localhost:4000'; | ||
|
||
export const options = { | ||
discardResponseBodies: true, | ||
ext: { | ||
loadimpact: { | ||
projectID: 3651337, | ||
name: 'Zero to GraphQL Using Elixir', | ||
distribution: { | ||
'amazon:us:ashburn': { loadZone: 'amazon:us:ashburn', percent: 100 } | ||
}, | ||
apm: [], | ||
}, | ||
}, | ||
thresholds: { | ||
// load_generator_memory_used_percent: [{ threshold: 'value<=80', abortOnFail: true }], | ||
// load_generator_cpu_percent: [{ threshold: 'value<=80', abortOnFail: true }], | ||
http_req_duration: ['p(95)<=100'], // 95% of the requests must complete | ||
http_req_duration: ['p(99)<=100'], // 99% of the requests must complete | ||
}, | ||
scenarios: { | ||
getPersonByID: { | ||
executor: 'shared-iterations', | ||
gracefulStop: '30s', | ||
stages: [ | ||
{ duration: '1m', target: 200 }, // ramp up | ||
{ duration: '5m', target: 200 }, // stable | ||
{ duration: '1m', target: 800 }, // ramp up | ||
{ duration: '5m', target: 800 }, // stable | ||
{ duration: '1m', target: 1000 }, // ramp up | ||
{ duration: '5m', target: 1000 }, // stable | ||
{ duration: '5m', target: 0 }, // ramp down to 0 users | ||
], | ||
gracefulRampDown: '30s', | ||
exec: 'getPersonByID', | ||
}, | ||
getPeople: { | ||
executor: 'shared-iterations', | ||
gracefulStop: '30s', | ||
stages: [ | ||
{ duration: '1m', target: 200 }, // ramp up | ||
{ duration: '5m', target: 200 }, // stable | ||
{ duration: '1m', target: 800 }, // ramp up | ||
{ duration: '5m', target: 800 }, // stable | ||
{ duration: '1m', target: 1000 }, // ramp up | ||
{ duration: '5m', target: 1000 }, // stable | ||
{ duration: '5m', target: 0 }, // ramp down to 0 users | ||
], | ||
gracefulRampDown: '30s', | ||
exec: 'getPeople', | ||
}, | ||
}, | ||
} | ||
|
||
|
||
// Scenario: getPersonByID (executor: ramping-vus) | ||
|
||
export function getPersonByID() { | ||
// Get Person By ID | ||
getPersonByID(randomIntBetween(1, 4)) | ||
|
||
// Add random delay | ||
sleep(randomIntBetween(pauseMin, pauseMax)) | ||
} | ||
|
||
export async function getPersonByID(id) { | ||
const query = gql` | ||
query GetPersonByID($id: ID!) { | ||
person(id: $id) { | ||
firstName | ||
lastName | ||
username | ||
friends { | ||
firstName | ||
lastName | ||
username | ||
} | ||
} | ||
} | ||
`; | ||
|
||
http.addHeader('Content-Type', 'application/json') | ||
|
||
const response = await http.asyncPost( | ||
'http://localhost:4000/graphql', | ||
JSON.stringify({ | ||
query: query, | ||
variables: { | ||
id: id | ||
} | ||
}, | ||
{ | ||
tags: { | ||
name: 'getPersonByID' | ||
} | ||
}) | ||
) | ||
|
||
check(response, { | ||
"status was 200": (r) => r.status === 200 | ||
}) | ||
} | ||
|
||
// Scenario: getPeople (executor: ramping-vus) | ||
|
||
export function getPeople() { | ||
// Get People | ||
getPeople() | ||
|
||
// Add random delay | ||
sleep(randomIntBetween(pauseMin, pauseMax)) | ||
} | ||
|
||
export async function getPeople() { | ||
const query = gql` | ||
query GetPeople { | ||
people { | ||
id | ||
firstName | ||
lastName | ||
username | ||
friends { | ||
id | ||
firstName | ||
lastName | ||
username | ||
} | ||
} | ||
} | ||
`; | ||
|
||
http.addHeader('Content-Type', 'application/json') | ||
|
||
const response = await http.asyncPost( | ||
'http://localhost:4000/graphql', | ||
JSON.stringify({ | ||
query: query | ||
}, | ||
{ | ||
tags: { | ||
name: 'getPeople' | ||
} | ||
}) | ||
) | ||
|
||
check(response, { | ||
"status was 200": (r) => r.status === 200 | ||
}) | ||
} | ||
|
||
export async function getRandomInt(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { sleep, check } from 'k6'; | ||
import { SharedArray } from 'k6/data'; | ||
|
||
var hostname = __ENV.hostname; | ||
if (hostname == null) hostname = 'localhost:5157'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '30s', target: 2000 }, // ramp up | ||
{ duration: '2m', target: 2000 }, // stable | ||
{ duration: '30s', target: 0 }, // ramp-down to 0 users | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { sleep, check } from 'k6'; | ||
import { SharedArray } from 'k6/data'; | ||
|
||
var hostname = __ENV.hostname; | ||
if (hostname == null) hostname = 'localhost:5157'; | ||
|
||
export const options = { | ||
stages: [ | ||
{ duration: '5m', target: 200 }, // ramp up | ||
{ duration: '8h', target: 200 }, // stable | ||
{ duration: '5m', target: 0 }, // ramp-down to 0 users | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.