Thanks, I followed your advice and came across something weird. I’ve changed the code (this is actually the one that I need to execute). There are just 2 requests, first one creates a service and second one cancels the service created. Cannot create a service that already exists and either can cancel a service that doesn’t exit.Therefore I execute the requests in sequence to avoid (code status 500), but when executing the second request ‘cancel’ I get an error ‘code status 415’ (check logs). Curiously when executing any of the requests independently everything is fine, I just get the problem when running both at the same time as a Group.
SCRIPT
import http from 'k6/http';
import { check, sleep ,group} from 'k6';
let options = {
vus: 1,
duration: '7s',
};
const SLEEP_DURATION = 3;
export default function () {
const url = 'http://localhost:8083/service-now/writeInSnow';
let headers = { 'Content-Type': 'application/json' };
let data_create = { "user_sys_id": "904301771b0fd090243b20ad3b4bcb06",
"tech_sys_id": "1e9f2829e5e33100ea07c36ce50dc80a",
"incident_sys_id": "e1bc611e1b396410dd077669cd4bcb43",
"scheduledStart": "2021-02-22 16:00:00",
"scheduledEnd": "2021-02-22 16:45:00",
"u_state": 17,
"u_operation": "submit",
"comment": "RDV pris / Appointment taken"};
let data_cancel = { "user_sys_id": "904301771b0fd090243b20ad3b4bcb06",
"tech_sys_id": "1e9f2829e5e33100ea07c36ce50dc80a",
"incident_sys_id": "e1bc611e1b396410dd077669cd4bcb43",
"scheduledStart": "2021-02-22 16:00:00",
"scheduledEnd": "2021-02-22 16:45:00",
"u_state": 4,
"u_operation": "close",
"comment": "RDV pris / Appointment taken"};
group('secuence',function () {
// Launching create
let res_create = http.request('POST', url, JSON.stringify(data_create), {
headers: headers,
});
console.log(JSON.stringify(res_create, null, " "));
check(res_create, {
'is status 200 create': (r) => r.status === 200,"status is 500 create": r => r.status === 500,});
sleep(SLEEP_DURATION);
headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
res_create = http.request('POST', url, data_create, { headers: headers });
// Launching cancel
let res_cancel = http.request('POST', url, JSON.stringify(data_cancel), {
headers: headers,
});
console.log(JSON.stringify(res_cancel, null, " "));
check(res_cancel, {
'is status 200 cancel': (r) => r.status === 200,"status is 500 cancel": r => r.status === 500,});
sleep(SLEEP_DURATION);
headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
res_cancel = http.request('POST', url, data_cancel, { headers: headers });
});
}
LOGS
INFO[0004] {
"remote_ip": "127.0.0.1",,
"remote_port": 8083,-
"url": "http://localhost:8083/service-now/writeInSnow",
"status": 200,
"status_text": "200 ",
"proto": "HTTP/1.1",
"headers": {
"Content-Type": "application/json",
"Date": "Tue, 09 Feb 2021 15:33:45 GMT",
"Vary": "Origin, Access-Control-Request-Method, Access-Control-Request-Headers"
},
"cookies": {},
"body": "{\"results\":[{\"u_estimated_travel_duration\":\"900\",\"w_work_order_task\":null,\"sys_import_state_comment\":\"<response><message/><status>200</status><invalid/><required/><number>WOT0877529</number><sys_id>5e63e0a41b5ee410dd077669cd4bcbcf</sys_id></response>\",\"template_import_log\":\"\",\"sys_updated_on\":\"2021-02-09 15:33:44\",\"u_estimated_work_duration\":\"3600\",\"sys_class_name\":\"u_workordertask_endpoint\",\"sys_target_sys_id\":{\"link\":\"https://totalintegration.service-now.com/api/now/table/wm_task/5e63e0a41b5ee410dd077669cd4bcbcf\",\"value\":\"5e63e0a41b5ee410dd077669cd4bcbcf\"},\"sys_id\":\"5663e0a41b5ee410dd077669cd4bcbca\",\"sys_updated_by\":\"rdv.fuji\",\"u_short_description\":\"\",\"sys_created_on\":\"2021-02-09 15:33:43\",\"u_scheduled_start\":\"2021-02-22 16:00:00\",\"sys_created_by\":\"rdv.fuji\",\"sys_import_row\":\"344\",\"u_assigned_to\":\"1e9f2829e5e33100ea07c36ce50dc80a\",\"u_number\":\"\",\"u_work_order_number\":\"WO0410116\",\"u_work_notes\":\"RDV pris / Appointment taken\",\"sys_target_table\":\"wm_task\",\"u_state\":\"\",\"sys_mod_count\":\"2\",\"u_assignment_group\":\"540cacdd01670200ea079bc64b4a3172\",\"sys_tags\":\"\",\"sys_import_state\":\"inserted\",\"u_category\":\"computer_installation\",\"u_description\":\"\",\"u_service\":\"WOTask\",\"u_business_partner_id\":\"7f62ffe91b955c94a40632649b4bcb3b\",\"u_close_code\":\"\",\"u_operation\":\"submit\"}]}",
"timings": {
"duration": 2050.4961,
"blocked": 3.0007,
"looking_up": 0,
"connecting": 1.0019,
"tls_handshaking": 0,
"sending": 0.4984,
"waiting": 2048.4985,
"receiving": 1.4992
},
"tls_version": "",
"tls_cipher_suite": "",
"ocsp": {
"produced_at": 0,
"this_update": 0,
"next_update": 0,
"revoked_at": 0,
"revocation_reason": "",
"status": ""
},
"error": "",
"error_code": 0,
"request": {
"method": "POST",
"url": "http://localhost:8083/service-now/writeInSnow",
"headers": {
"User-Agent": [
"k6/0.29.0 (https://k6.io/)"
],
"Content-Type": [
"application/json"
]
},
"body": "{\"user_sys_id\":\"904301771b0fd090243b20ad3b4bcb06\",\"tech_sys_id\":\"1e9f2829e5e33100ea07c36ce50dc80a\",\"incident_sys_id\":\"e1bc611e1b396410dd077669cd4bcb43\",\"scheduledStart\":\"2021-02-22 16:00:00\",\"scheduledEnd\":\"2021-02-22 16:45:00\",\"u_state\":17,\"u_operation\":\"submit\",\"comment\":\"RDV pris / Appointment taken\"}",
"cookies": {}
}
} source=console
INFO[0007] {
"remote_ip": "127.0.0.1",,
"remote_port": 8083,-
"url": "http://localhost:8083/service-now/writeInSnow",
"status": 415,
"status_text": "415 ",
"proto": "HTTP/1.1",
"headers": {
"Vary": "Origin, Access-Control-Request-Method, Access-Control-Request-Headers",
"Accept": "application/json, application/hal+json, application/octet-stream, application/xml, application/x-www-form-urlencoded, application/*+json, text/plain, text/xml, application/*+xml, multipart/form-data, multipart/mixed, */*",
"Content-Length": "0",
"Date": "Tue, 09 Feb 2021 15:33:48 GMT"
},
"cookies": {},
"body": "",
"timings": {
"duration": 9.4968,
"blocked": 0,
"looking_up": 0,
"connecting": 0,
"tls_handshaking": 0,
"sending": 0,
"waiting": 8.998,
"receiving": 0.4988
},
"tls_version": "",
"tls_cipher_suite": "",
"ocsp": {
"produced_at": 0,
"this_update": 0,
"next_update": 0,
"revoked_at": 0,
"revocation_reason": "",
"status": ""
},
"error": "",
"error_code": 1415,
"request": {
"method": "POST",
"url": "http://localhost:8083/service-now/writeInSnow",
"headers": {
"User-Agent": [
"k6/0.29.0 (https://k6.io/)"
],
"Content-Type": [
"application/x-www-form-urlencoded"
]
},
"body": "{\"user_sys_id\":\"904301771b0fd090243b20ad3b4bcb06\",\"tech_sys_id\":\"1e9f2829e5e33100ea07c36ce50dc80a\",\"incident_sys_id\":\"e1bc611e1b396410dd077669cd4bcb43\",\"scheduledStart\":\"2021-02-22 16:00:00\",\"scheduledEnd\":\"2021-02-22 16:45:00\",\"u_state\":4,\"u_operation\":\"close\",\"comment\":\"RDV pris / Appointment taken\"}",
"cookies": {}
}
} source=console
Any idea what’s the reason for this??