Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanding test cases #203

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions e2e/tests/abort-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import http from 'k6/http';
import { check } from 'k6';
import exec from 'k6/execution';

export let options = {
stages: [
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});

// abort at some random point in the 2nd half of the test
if (exec.scenario.progress > 0.5) {
const rnd = Math.floor(Math.random() * 100);
if (rnd > 50) {
exec.test.abort();
}
}
}
26 changes: 26 additions & 0 deletions e2e/tests/abort-one-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import http from 'k6/http';
import { check } from 'k6';
import exec from 'k6/execution';

export let options = {
stages: [
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});

// abort the 1st instance at some random point in the 2nd half of the test
const instanceId = exec.test.options.tags["instance_id"];
if (instanceId == 1 && exec.scenario.progress > 0.5) {
const rnd = Math.floor(Math.random() * 100);
if (rnd > 50) {
exec.test.abort();
}
}
}
31 changes: 31 additions & 0 deletions e2e/tests/cloudoutput_fail-and-abort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import http from 'k6/http';
import { check } from 'k6';

export let options = {
stages: [
{ target: 100, duration: '1m30s' },
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
thresholds: {
http_req_duration: [
{
threshold: 'p(99) < 200',
abortOnFail: true,
delayAbortEval: '10s',
},
],
},
ext: {
loadimpact: {
name: 'Configured k6-operator test',
}
}
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});
}
29 changes: 29 additions & 0 deletions e2e/tests/cloudoutput_fail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import http from 'k6/http';
import { check } from 'k6';

export let options = {
stages: [
{ target: 100, duration: '1m30s' },
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
thresholds: {
http_req_duration: [
{
threshold: 'p(99) < 200',
},
],
},
ext: {
loadimpact: {
name: 'Configured k6-operator test',
}
}
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});
}
31 changes: 31 additions & 0 deletions e2e/tests/cloudoutput_pass-long-fmt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import http from 'k6/http';
import { check } from 'k6';

export let options = {
stages: [
{ target: 100, duration: '1m30s' },
{ target: 200, duration: '5m30s' },
{ target: 0, duration: '30s' },
],
thresholds: {
http_req_duration: [
{
threshold: 'p(95)<20000',
abortOnFail: true,
delayAbortEval: '10s',
},
],
},
ext: {
loadimpact: {
name: 'Configured k6-operator test',
}
}
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});
}
25 changes: 25 additions & 0 deletions e2e/tests/cloudoutput_pass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import http from 'k6/http';
import { check } from 'k6';

export let options = {
stages: [
{ target: 100, duration: '1m30s' },
{ target: 200, duration: '5m30s' },
{ target: 0, duration: '30s' },
],
thresholds: {
http_req_duration: ['p(95)<20000'],
},
ext: {
loadimpact: {
name: 'Configured k6-operator test',
}
}
};

export default function () {
const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});
}
28 changes: 28 additions & 0 deletions e2e/tests/one-runner-delayed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import http from 'k6/http';
import { check, sleep } from 'k6';
import exec from 'k6/execution';

export let options = {
scenarios: {
default: {
executor: 'per-vu-iterations',
vus: 10,
iterations: 10,
maxDuration: '1m30s'
}
}
};

export default function () {
// delay the 1st instance from executing to simulate a delay
const instanceId = exec.test.options.tags["instance_id"];
if (instanceId == 1 && exec.scenario.iterationInInstance == 0) {
sleep(60);
}


const result = http.get('https://test-api.k6.io/public/crocodiles/');
check(result, {
'http response status code is 200': result.status === 200,
});
}