Skip to content
Merged
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
14 changes: 13 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ Deletes the build folder that cmake creates to ensure a fresh rebuild.

__release__

Use _Release_ as cmake build type. _Debug_ will be used as default.
Uses _Release_ as cmake build type. _Debug_ will be used as default. In _Debug_ mode code coverage flags will be set when GNU or Clang compiler is detected.

__without_tests__

Builds the project without tests

__skip_tests__

Skips the execution of project tests

__without_examples__

Builds the project without examples

__with_ssl__

Expand Down
24 changes: 14 additions & 10 deletions test/k6/load-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// k6 script to perform some load tests. Also cf. https://k6.io
// command line:
// k6 run test/k6/load-test.js

import http from 'k6/http';
import exec from 'k6/execution';
import { check, sleep } from 'k6';
Expand All @@ -7,35 +11,35 @@ export const options = {
duration: '30s',
};

export default function() {
export default function () {

const baseUrl = __ENV.url || 'http://localhost:8888';

const td = http.get(baseUrl);
check(td, {'get thing description status was 200': (r) => r.status == 200 });
check(td, { 'get thing description status was 200': (r) => r.status == 200 });

const ps = http.get(baseUrl + '/properties');
check(ps, {'get properties status was 200': (r) => r.status == 200 });
check(ps, { 'get properties status was 200': (r) => r.status == 200 });

const as = http.get(baseUrl + '/actions');
check(as, {'get actions status was 200': (r) => r.status == 200 });
check(as, { 'get actions status was 200': (r) => r.status == 200 });

const es = http.get(baseUrl + '/events');
check(es, {'get events status was 200': (r) => r.status == 200 });
check(es, { 'get events status was 200': (r) => r.status == 200 });

const headers = {
headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json',
},
};

const on = exec.scenario.iterationInTest % 2 == 0;
const onProp = http.put(baseUrl + '/properties/on', JSON.stringify({"on":on}), headers);
check(onProp, {'put on property status was 200': (r) => r.status == 200 });
const onProp = http.put(baseUrl + '/properties/on', JSON.stringify({ "on": on }), headers);
check(onProp, { 'put on property status was 200': (r) => r.status == 200 });

const brightness = 10 * (exec.scenario.iterationInTest % 10);
const duration = 1 + 200 * (exec.scenario.iterationInTest % 5);
const fadePayload = {"fade":{"input":{"brightness":brightness, "duration":duration}}};
const fadePayload = { "fade": { "input": { "brightness": brightness, "duration": duration } } };
const fade = http.post(baseUrl + '/actions', JSON.stringify(fadePayload), headers);
check(fade, {'post fade actions status was 201': (r) => r.status == 201 });
check(fade, { 'post fade actions status was 201': (r) => r.status == 201 });
}