Hi,
I am using k6 to run my functional and load api tests. I am using docker containers to run my tests.
I have tried bunch of approaches but I can’t make a test fail inside the docker container. It’s always returning with code 0. So to give you an example
docker-compose up
Recreating platform-api-tests_test_1 ... done
Attaching to platform-api-tests_test_1
test_1 |
test_1 | /\ |‾‾| /‾‾/ /‾/
test_1 | /\ / \ | |_/ / / /
test_1 | / \/ \ | | / ‾‾\
test_1 | / \ | |‾\ \ | (_) |
test_1 | / __________ \ |__| \__\ \___/ .io
test_1 |
execution: local--------------------------------------------------] servertorunner
test_1 | output: -
test_1 | script: start.js
test_1 |
test_1 | duration: -, iterations: 1
test_1 | vus: 1, max: 1
test_1 |
time="2020-09-24T00:40:48Z" level=error msg="GoError: GoError: test\n\tat native\n\tat file:///test/api/threshold.js:26:16(25)\n\tat file:///test/api/threshold.js:23:20(14)\n\tat file:///test/start.js:15:27(4)\n"
test_1 | time="2020-09-24T00:40:48Z" level=info msg="Test finished" i=1 t=1.1576ms
test_1 |
test_1 | data_received........: 0 B 0 B/s
test_1 | data_sent............: 0 B 0 B/s
test_1 | iteration_duration...: avg=849.3µs min=849.3µs med=849.3µs max=849.3µs p(90)=849.3µs p(95)=849.3µs
test_1 | iterations...........: 1 863.856254/s
test_1 | rt_errors............: 100.00% ✓ 1 ✗ 0
test_1 | vus..................: 1 min=1 max=1
test_1 | vus_max..............: 1 min=1 max=1
test_1 |
platform-api-tests_test_1 exited with code 0
Even a simple example like
import { fail } from "k6";
export default function() {
fail("failing")
};
If I run this inside a container it will pass result in pass
docker-compose up
Recreating platform-api-tests_test_1 ... done
Attaching to platform-api-tests_test_1
test_1 |
test_1 | /\ |‾‾| /‾‾/ /‾/
test_1 | /\ / \ | |_/ / / /
test_1 | / \/ \ | | / ‾‾\
test_1 | / \ | |‾\ \ | (_) |
test_1 | / __________ \ |__| \__\ \___/ .io
test_1 |
execution: local--------------------------------------------------] servertorunner
test_1 | output: -
test_1 | script: start.js
test_1 |
test_1 | duration: -, iterations: 1
test_1 | vus: 1, max: 1
test_1 |
time="2020-09-24T00:54:19Z" level=error msg="GoError: failing\n\tat native\n\tat file:///test/api/threshold.js:5:15(4)\n\tat file:///test/start.js:15:27(4)\n"
test_1 | time="2020-09-24T00:54:19Z" level=info msg="Test finished" i=1 t=0s
test_1 |
test_1 | data_received........: 0 B 0 B/s
test_1 | data_sent............: 0 B 0 B/s
test_1 | iteration_duration...: avg=79.3µs min=79.3µs med=79.3µs max=79.3µs p(90)=79.3µs p(95)=79.3µs
test_1 | iterations...........: 1 0/s
test_1 | vus..................: 1 min=1 max=1
test_1 | vus_max..............: 1 min=1 max=1
test_1 |
As you can see there is an error code but still the container exited with code 0. I have tired thresholds, fail and other ways to tackle this issue but still the code is returning 0. Can you advise please ? How to make the docker container exit with an error code.