Skip to content

Commit

Permalink
Use k6.io test domains instead of loadimpact
Browse files Browse the repository at this point in the history
fixes #1400
  • Loading branch information
mstoykov committed Oct 23, 2020
1 parent 0e39d45 commit 86e8752
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ export let options = {
// Main function
export default function () {
let response = http.get("https://test.loadimpact.com/");
let response = http.get("https://test.k6.io/");
// check() returns false if any of the specified conditions fail
let checkRes = check(response, {
"http2 is used": (r) => r.proto === "HTTP/2.0",
"status is 200": (r) => r.status === 200,
"content is present": (r) => r.body.indexOf("Welcome to the LoadImpact.com demo site!") !== -1,
"content is present": (r) => r.body.indexOf("Collection of simple web-pages suitable for load testing.") !== -1,
});
// We reverse the check() result since we want to count the failures
Expand All @@ -317,8 +317,9 @@ export default function () {
group("Static Assets", function () {
// Execute multiple requests in parallel like a browser, to fetch some static resources
let resps = http.batch([
["GET", "https://test.loadimpact.com/style.css", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.loadimpact.com/images/logo.png", null, { tags: { staticAsset: "yes" } }]
["GET", "https://test.k6.io/static/css/site.css", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.k6.io/static/favicon.ico", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.k6.io/static/js/prisms.js", null, { tags: { staticAsset: "yes" } }],
]);
// Combine check() call with failure tracking
failureRate.add(!check(resps, {
Expand Down
10 changes: 5 additions & 5 deletions samples/es6sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ export default function() {
});

group("json", function() {
let res = http.get("https://httpbin.org/get", null, {
let res = http.get("https://httpbin.org/get", {
headers: { "X-Test": "abc123" },
});

check(res, {
"status is 200": (res) => res.status === 200,
"X-Test header is correct": (res) => res.json().headers['X-Test'] === "abc123",
});
// console.log(res.body);
});

group("html", function() {
check(http.get("http://test.loadimpact.com/"), {
check(http.get("http://test.k6.io/"), {
"status is 200": (res) => res.status === 200,
"content type is html": (res) => res.headers['Content-Type'] === "text/html",
"welcome message is correct": (res) => res.html("h2").text() === "Welcome to the LoadImpact.com demo site!",
"content type is html": (res) => res.headers['Content-Type'].startsWith("text/html"),
"welcome message is correct": (res) => res.html("p.description").text() === "Collection of simple web-pages suitable for load testing.",
});
});

Expand Down
4 changes: 2 additions & 2 deletions samples/http_batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import http from 'k6/http';

export default function() {
const responses = http.batch([
"http://test.loadimpact.com",
"http://test.loadimpact.com/pi.php"
"http://test.k6.io",
"http://test.k6.io/pi.php"
]);

check(responses[0], {
Expand Down
11 changes: 6 additions & 5 deletions samples/thresholds_readme_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ export let options = {

// Main function
export default function () {
let response = http.get("https://test.loadimpact.com/");
let response = http.get("https://test.k6.io/");

// check() returns false if any of the specified conditions fail
let checkRes = check(response, {
"http2 is used": (r) => r.proto === "HTTP/2.0",
"status is 200": (r) => r.status === 200,
"content is present": (r) => r.body.indexOf("Welcome to the LoadImpact.com demo site!") !== -1,
"content is present": (r) => r.body.indexOf("Collection of simple web-pages suitable for load testing.") !== -1,
});

// We reverse the check() result since we want to count the failures
Expand All @@ -49,8 +49,9 @@ export default function () {
group("Static Assets", function () {
// Execute multiple requests in parallel like a browser, to fetch some static resources
let resps = http.batch([
["GET", "https://test.loadimpact.com/style.css", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.loadimpact.com/images/logo.png", null, { tags: { staticAsset: "yes" } }]
["GET", "https://test.k6.io/static/css/site.css", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.k6.io/static/favicon.ico", null, { tags: { staticAsset: "yes" } }],
["GET", "https://test.k6.io/static/js/prisms.js", null, { tags: { staticAsset: "yes" } }],
]);
// Combine check() call with failure tracking
failureRate.add(!check(resps, {
Expand All @@ -60,4 +61,4 @@ export default function () {
});

sleep(Math.random() * 3 + 2); // Random sleep between 2s and 5s
}
}

0 comments on commit 86e8752

Please sign in to comment.