1 /**************************************************************************//**
3 * Unit tests for JSON encoding and throttling.
5 * This software is intended to show the essential elements of the library's
11 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *****************************************************************************/
32 #include "evel_internal.h"
33 #include "evel_throttle.h"
45 /*****************************************************************************/
46 /* Local prototypes. */
47 /*****************************************************************************/
48 static void test_encode_heartbeat();
49 static void test_encode_header_overrides();
50 static void test_encode_fault();
51 static void test_encode_fault_with_escaping();
52 static void test_encode_measurement();
53 static void test_encode_mobile_mand();
54 static void test_encode_mobile_opts();
55 static void test_encode_other();
56 static void test_encode_report();
57 static void test_encode_service();
58 static void test_encode_service_subset(const SERVICE_TEST service_test);
59 static void test_encode_signaling();
60 static void test_encode_state_change();
61 static void test_encode_syslog();
62 static void test_json_response_junk();
63 static void test_json_provide_throttle_state();
64 static void test_json_measurement_interval();
65 static void test_json_throttle_spec_field();
66 static void test_json_throttle_spec_nv_pair();
67 static void test_json_throttle_spec_two_domains();
68 static void test_json_throttle_spec_bad_command_type();
69 static void test_encode_fault_throttled();
70 static void test_encode_measurement_throttled();
71 static void test_encode_mobile_throttled();
72 static void test_encode_other_throttled();
73 static void test_encode_report_throttled();
74 static void test_encode_service_throttled();
75 static void test_encode_signaling_throttled();
76 static void test_encode_state_change_throttled();
77 static void test_encode_syslog_throttled();
78 static void compare_strings(char * expected,
83 /**************************************************************************//**
86 * Runs all unit test cases, and fails hard on the first failure.
88 * @param[in] argc Argument count.
89 * @param[in] argv Argument vector - for usage see usage_text.
90 *****************************************************************************/
91 int main(int argc, char ** argv)
96 /***************************************************************************/
97 /* Fix our timezone to UTC. */
98 /***************************************************************************/
101 /***************************************************************************/
102 /* Initialize metadata. */
103 /***************************************************************************/
104 openstack_metadata_initialize();
106 /***************************************************************************/
107 /* Minimal initialisation to exercise the encoders. */
108 /***************************************************************************/
109 functional_role = "UNIT TEST";
110 log_initialize(EVEL_LOG_DEBUG, "EVEL");
112 /***************************************************************************/
113 /* Test each encoder. */
114 /***************************************************************************/
115 test_encode_heartbeat();
116 test_encode_header_overrides();
118 test_encode_measurement();
119 test_encode_mobile_mand();
120 test_encode_mobile_opts();
122 test_encode_report();
123 test_encode_service();
124 test_encode_signaling();
125 test_encode_state_change();
126 test_encode_syslog();
128 /***************************************************************************/
129 /* Test JSON Throttle. */
130 /***************************************************************************/
131 test_json_response_junk();
132 test_json_provide_throttle_state();
133 test_json_measurement_interval();
134 test_json_throttle_spec_field();
135 test_json_throttle_spec_nv_pair();
136 test_json_throttle_spec_two_domains();
137 test_json_throttle_spec_bad_command_type();
139 /***************************************************************************/
140 /* Test each encoder with throttling applied. */
141 /***************************************************************************/
142 test_encode_fault_throttled();
143 test_encode_measurement_throttled();
144 test_encode_mobile_throttled();
145 test_encode_other_throttled();
146 test_encode_report_throttled();
147 test_encode_service_throttled();
148 test_encode_signaling_throttled();
149 test_encode_state_change_throttled();
150 test_encode_syslog_throttled();
152 /***************************************************************************/
153 /* Test character escaping. */
154 /***************************************************************************/
155 test_encode_fault_with_escaping();
157 printf ("\nAll Tests Passed\n");
162 /*****************************************************************************/
163 /* We link with this gettimeofday so that we get a fixed result */
164 /*****************************************************************************/
165 int gettimeofday(struct timeval *tv,
166 struct timezone *tz __attribute__((unused)))
173 void test_encode_heartbeat()
177 "\"commonEventHeader\": {"
178 "\"domain\": \"heartbeat\", "
179 "\"eventId\": \"121\", "
180 "\"functionalRole\": \"UNIT TEST\", "
181 "\"lastEpochMicrosec\": 1000002, "
182 "\"priority\": \"Normal\", "
183 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
184 "\"sequence\": 121, "
185 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
186 "\"startEpochMicrosec\": 1000002, "
188 "\"eventType\": \"Autonomous heartbeat\", "
189 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
190 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
193 size_t json_size = 0;
194 char json_body[EVEL_MAX_JSON_BODY];
196 /***************************************************************************/
197 /* Test the VM name/uuid once. */
198 /***************************************************************************/
199 evel_set_next_event_sequence(121);
201 EVENT_HEADER * heartbeat = evel_new_heartbeat();
202 assert(heartbeat != NULL);
204 json_size = evel_json_encode_event(
205 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat);
206 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat");
207 assert((json_size == strlen(json_body)) && "Bad size returned");
209 evel_free_event(heartbeat);
212 void test_encode_header_overrides()
216 "\"commonEventHeader\": {"
217 "\"domain\": \"heartbeat\", "
218 "\"eventId\": \"121\", "
219 "\"functionalRole\": \"UNIT TEST\", "
220 "\"lastEpochMicrosec\": 1000, "
221 "\"priority\": \"Normal\", "
222 "\"reportingEntityName\": \"entity_name_override\", "
223 "\"sequence\": 121, "
224 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
225 "\"startEpochMicrosec\": 1001, "
227 "\"eventType\": \"Autonomous heartbeat\", "
228 "\"reportingEntityId\": \"entity_id_override\", "
229 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
232 size_t json_size = 0;
233 char json_body[EVEL_MAX_JSON_BODY];
235 /***************************************************************************/
236 /* Test the VM name/uuid once. */
237 /***************************************************************************/
238 evel_set_next_event_sequence(121);
240 EVENT_HEADER * heartbeat = evel_new_heartbeat();
241 assert(heartbeat != NULL);
243 evel_start_epoch_set(heartbeat, 1001);
244 evel_last_epoch_set(heartbeat, 1000);
245 evel_reporting_entity_name_set(heartbeat, "entity_name_override");
246 evel_reporting_entity_id_set(heartbeat, "entity_id_override");
248 json_size = evel_json_encode_event(
249 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat);
250 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat");
251 assert((json_size == strlen(json_body)) && "Bad size returned");
253 evel_free_event(heartbeat);
256 void test_encode_fault()
260 "\"commonEventHeader\": {"
261 "\"domain\": \"fault\", "
262 "\"eventId\": \"122\", "
263 "\"functionalRole\": \"UNIT TEST\", "
264 "\"lastEpochMicrosec\": 1000002, "
265 "\"priority\": \"Normal\", "
266 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
267 "\"sequence\": 122, "
268 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
269 "\"startEpochMicrosec\": 1000002, "
271 "\"eventType\": \"Bad things happen...\", "
272 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
273 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
276 "\"alarmCondition\": \"My alarm condition\", "
277 "\"eventSeverity\": \"MAJOR\", "
278 "\"eventSourceType\": \"other\", "
279 "\"specificProblem\": \"It broke very badly\", "
280 "\"vfStatus\": \"Active\", "
281 "\"faultFieldsVersion\": 1.1, "
282 "\"alarmAdditionalInformation\": ["
283 "{\"name\": \"name1\", "
284 "\"value\": \"value1\"}, "
285 "{\"name\": \"name2\", "
286 "\"value\": \"value2\"}], "
287 "\"alarmInterfaceA\": \"My Interface Card\""
290 size_t json_size = 0;
291 char json_body[EVEL_MAX_JSON_BODY];
292 evel_set_next_event_sequence(122);
293 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
294 "It broke very badly",
295 EVEL_PRIORITY_NORMAL,
296 EVEL_SEVERITY_MAJOR);
297 assert(fault != NULL);
298 evel_fault_type_set(fault, "Bad things happen...");
299 evel_fault_interface_set(fault, "My Interface Card");
300 evel_fault_addl_info_add(fault, "name1", "value1");
301 evel_fault_addl_info_add(fault, "name2", "value2");
303 json_size = evel_json_encode_event(
304 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
305 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
306 assert((json_size == strlen(json_body)) && "Bad size returned");
308 evel_free_event(fault);
311 void test_encode_measurement()
315 "{\"commonEventHeader\": {"
316 "\"domain\": \"measurementsForVfScaling\", "
317 "\"eventId\": \"123\", "
318 "\"functionalRole\": \"UNIT TEST\", "
319 "\"lastEpochMicrosec\": 3000, "
320 "\"priority\": \"Normal\", "
321 "\"reportingEntityName\": \"entity_name\", "
322 "\"sequence\": 123, "
323 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
324 "\"startEpochMicrosec\": 2000, "
326 "\"eventType\": \"Perf management...\", "
327 "\"reportingEntityId\": \"entity_id\", "
328 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
330 "\"measurementsForVfScalingFields\": "
332 "\"measurementInterval\": 5.500000, "
333 "\"concurrentSessions\": 1, "
334 "\"configuredEntities\": 2, "
335 "\"cpuUsageArray\": ["
336 "{\"cpuIdentifier\": \"cpu1\", "
337 "\"percentUsage\": 11.110000}, "
338 "{\"cpuIdentifier\": \"cpu2\", "
339 "\"percentUsage\": 22.220000}], "
340 "\"filesystemUsageArray\": ["
341 "{\"blockConfigured\": 100.110000, "
342 "\"blockIops\": 33, "
343 "\"blockUsed\": 100.220000, "
344 "\"ephemeralConfigured\": 100.110000, "
345 "\"ephemeralIops\": 44, "
346 "\"ephemeralUsed\": 200.220000, "
347 "\"filesystemName\": \"00-11-22\"}, "
348 "{\"blockConfigured\": 300.110000, "
349 "\"blockIops\": 55, "
350 "\"blockUsed\": 300.220000, "
351 "\"ephemeralConfigured\": 300.110000, "
352 "\"ephemeralIops\": 66, "
353 "\"ephemeralUsed\": 400.220000, "
354 "\"filesystemName\": \"33-44-55\"}], "
355 "\"latencyDistribution\": ["
356 "{\"countsInTheBucket\": 20}, "
357 "{\"lowEndOfLatencyBucket\": 10.000000, "
358 "\"highEndOfLatencyBucket\": 20.000000, "
359 "\"countsInTheBucket\": 30}], "
360 "\"meanRequestLatency\": 4.400000, "
361 "\"memoryConfigured\": 6.600000, "
362 "\"memoryUsed\": 3.300000, "
363 "\"requestRate\": 7, "
364 "\"vNicUsageArray\": ["
368 "\"packetsIn\": 100, "
369 "\"packetsOut\": 200, "
370 "\"vNicIdentifier\": \"eth0\""
375 "\"packetsIn\": 110, "
376 "\"packetsOut\": 240, "
377 "\"vNicIdentifier\": \"eth1\", "
378 "\"broadcastPacketsIn\": 11, "
379 "\"broadcastPacketsOut\": 12, "
380 "\"multicastPacketsIn\": 15, "
381 "\"multicastPacketsOut\": 16, "
382 "\"unicastPacketsIn\": 17, "
383 "\"unicastPacketsOut\": 18"
386 "\"aggregateCpuUsage\": 8.800000, "
387 "\"numberOfMediaPortsInUse\": 1234, "
388 "\"vnfcScalingMetric\": 1234.567800, "
390 "\"receiveDiscards\": 1, "
391 "\"receiveErrors\": 0, "
392 "\"transmitDiscards\": 2, "
393 "\"transmitErrors\": 1}, "
394 "\"featureUsageArray\": ["
395 "{\"featureIdentifier\": \"FeatureA\", "
396 "\"featureUtilization\": 123}, "
397 "{\"featureIdentifier\": \"FeatureB\", "
398 "\"featureUtilization\": 567}], "
399 "\"codecUsageArray\": ["
400 "{\"codecIdentifier\": \"G711a\", "
401 "\"numberInUse\": 91}, "
402 "{\"codecIdentifier\": \"G729ab\", "
403 "\"numberInUse\": 92}], "
404 "\"additionalMeasurements\": ["
405 "{\"name\": \"Group1\", "
406 "\"measurements\": ["
407 "{\"name\": \"Name1\", "
408 "\"value\": \"Value1\"}]}, "
409 "{\"name\": \"Group2\", "
410 "\"measurements\": ["
411 "{\"name\": \"Name1\", "
412 "\"value\": \"Value1\"}, "
413 "{\"name\": \"Name2\", "
414 "\"value\": \"Value2\"}]}], "
415 "\"measurementsForVfScalingVersion\": 1.1}}}";
417 size_t json_size = 0;
418 char json_body[EVEL_MAX_JSON_BODY];
419 EVENT_MEASUREMENT * measurement = NULL;
420 MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
421 MEASUREMENT_VNIC_USE * vnic_use = NULL;
423 /***************************************************************************/
425 /***************************************************************************/
426 evel_set_next_event_sequence(123);
427 measurement = evel_new_measurement(5.5);
428 assert(measurement != NULL);
429 evel_measurement_type_set(measurement, "Perf management...");
430 evel_measurement_conc_sess_set(measurement, 1);
431 evel_measurement_cfg_ents_set(measurement, 2);
432 evel_measurement_mean_req_lat_set(measurement, 4.4);
433 evel_measurement_mem_cfg_set(measurement, 6.6);
434 evel_measurement_mem_used_set(measurement, 3.3);
435 evel_measurement_request_rate_set(measurement, 7);
436 evel_measurement_agg_cpu_use_set(measurement, 8.8);
437 evel_measurement_cpu_use_add(measurement, "cpu1", 11.11);
438 evel_measurement_cpu_use_add(measurement, "cpu2", 22.22);
439 evel_measurement_fsys_use_add(measurement,"00-11-22",100.11, 100.22, 33,
441 evel_measurement_fsys_use_add(measurement,"33-44-55",300.11, 300.22, 55,
443 evel_start_epoch_set(&measurement->header, 2000);
444 evel_last_epoch_set(&measurement->header, 3000);
445 evel_reporting_entity_name_set(&measurement->header, "entity_name");
446 evel_reporting_entity_id_set(&measurement->header, "entity_id");
448 /***************************************************************************/
449 /* Latency Bucket with no optional parameters. */
450 /***************************************************************************/
451 bucket = evel_new_meas_latency_bucket(20);
452 evel_meas_latency_bucket_add(measurement, bucket);
454 /***************************************************************************/
455 /* Latency Bucket with all optional parameters. */
456 /***************************************************************************/
457 bucket = evel_new_meas_latency_bucket(30);
458 evel_meas_latency_bucket_low_end_set(bucket, 10.0);
459 evel_meas_latency_bucket_high_end_set(bucket, 20.0);
460 evel_meas_latency_bucket_add(measurement, bucket);
462 /***************************************************************************/
463 /* vNIC Use with no optional parameters. */
464 /***************************************************************************/
465 vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4);
466 evel_meas_vnic_use_add(measurement, vnic_use);
468 /***************************************************************************/
469 /* vNIC Use with all optional parameters. */
470 /***************************************************************************/
471 vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14);
472 evel_vnic_use_bcast_pkt_in_set(vnic_use, 11);
473 evel_vnic_use_bcast_pkt_out_set(vnic_use, 12);
474 evel_vnic_use_mcast_pkt_in_set(vnic_use, 15);
475 evel_vnic_use_mcast_pkt_out_set(vnic_use, 16);
476 evel_vnic_use_ucast_pkt_in_set(vnic_use, 17);
477 evel_vnic_use_ucast_pkt_out_set(vnic_use, 18);
478 evel_meas_vnic_use_add(measurement, vnic_use);
480 evel_measurement_errors_set(measurement, 1, 0, 2, 1);
482 evel_measurement_feature_use_add(measurement, "FeatureA", 123);
483 evel_measurement_feature_use_add(measurement, "FeatureB", 567);
485 evel_measurement_codec_use_add(measurement, "G711a", 91);
486 evel_measurement_codec_use_add(measurement, "G729ab", 92);
488 evel_measurement_media_port_use_set(measurement, 1234);
490 evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678);
492 evel_measurement_custom_measurement_add(measurement,
493 "Group1", "Name1", "Value1");
494 evel_measurement_custom_measurement_add(measurement,
495 "Group2", "Name1", "Value1");
496 evel_measurement_custom_measurement_add(measurement,
497 "Group2", "Name2", "Value2");
499 json_size = evel_json_encode_event(
500 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) measurement);
501 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Measurement");
502 assert((json_size == strlen(json_body)) && "Bad size returned");
504 evel_free_event(measurement);
507 void test_encode_mobile_mand()
511 "{\"commonEventHeader\": {"
512 "\"domain\": \"mobileFlow\", "
513 "\"eventId\": \"1241\", "
514 "\"functionalRole\": \"UNIT TEST\", "
515 "\"lastEpochMicrosec\": 1000002, "
516 "\"priority\": \"Normal\", "
517 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
518 "\"sequence\": 1241, "
519 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
520 "\"startEpochMicrosec\": 1000002, "
522 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
523 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
525 "\"mobileFlowFields\": {"
526 "\"flowDirection\": \"Outbound\", "
527 "\"gtpPerFlowMetrics\": {"
528 "\"avgBitErrorRate\": 12.300000, "
529 "\"avgPacketDelayVariation\": 3.120000, "
530 "\"avgPacketLatency\": 100, "
531 "\"avgReceiveThroughput\": 2100, "
532 "\"avgTransmitThroughput\": 500, "
533 "\"flowActivationEpoch\": 1470409421, "
534 "\"flowActivationMicrosec\": 987, "
535 "\"flowDeactivationEpoch\": 1470409431, "
536 "\"flowDeactivationMicrosec\": 11, "
537 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:51 +0000\", "
538 "\"flowStatus\": \"Working\", "
539 "\"maxPacketDelayVariation\": 87, "
540 "\"numActivationFailures\": 3, "
541 "\"numBitErrors\": 17, "
542 "\"numBytesReceived\": 123654, "
543 "\"numBytesTransmitted\": 4561, "
544 "\"numDroppedPackets\": 0, "
545 "\"numL7BytesReceived\": 12, "
546 "\"numL7BytesTransmitted\": 10, "
547 "\"numLostPackets\": 1, "
548 "\"numOutOfOrderPackets\": 3, "
549 "\"numPacketErrors\": 7, "
550 "\"numPacketsReceivedExclRetrans\": 899, "
551 "\"numPacketsReceivedInclRetrans\": 901, "
552 "\"numPacketsTransmittedInclRetrans\": 302, "
553 "\"numRetries\": 6, "
554 "\"numTimeouts\": 2, "
555 "\"numTunneledL7BytesReceived\": 0, "
556 "\"roundTripTime\": 110, "
557 "\"timeToFirstByte\": 225"
559 "\"ipProtocolType\": \"TCP\", "
560 "\"ipVersion\": \"IPv4\", "
561 "\"otherEndpointIpAddress\": \"2.3.4.1\", "
562 "\"otherEndpointPort\": 2341, "
563 "\"reportingEndpointIpAddr\": \"4.2.3.1\", "
564 "\"reportingEndpointPort\": 4321"
567 size_t json_size = 0;
568 char json_body[EVEL_MAX_JSON_BODY];
569 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
570 EVENT_MOBILE_FLOW * mobile_flow = NULL;
572 /***************************************************************************/
574 /***************************************************************************/
575 evel_set_next_event_sequence(1241);
577 metrics = evel_new_mobile_gtp_flow_metrics(12.3,
607 assert(metrics != NULL);
608 mobile_flow = evel_new_mobile_flow("Outbound",
616 assert(mobile_flow != NULL);
618 json_size = evel_json_encode_event(
619 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
620 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
621 assert((json_size == strlen(json_body)) && "Bad size returned");
623 evel_free_event(mobile_flow);
626 void test_encode_mobile_opts()
630 "{\"commonEventHeader\": {"
631 "\"domain\": \"mobileFlow\", "
632 "\"eventId\": \"1242\", "
633 "\"functionalRole\": \"UNIT TEST\", "
634 "\"lastEpochMicrosec\": 1000002, "
635 "\"priority\": \"Normal\", "
636 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
637 "\"sequence\": 1242, "
638 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
639 "\"startEpochMicrosec\": 1000002, "
641 "\"eventType\": \"Mobile flow...\", "
642 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
643 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
645 "\"mobileFlowFields\": {"
646 "\"flowDirection\": \"Inbound\", "
647 "\"gtpPerFlowMetrics\": {"
648 "\"avgBitErrorRate\": 132.000100, "
649 "\"avgPacketDelayVariation\": 31.200000, "
650 "\"avgPacketLatency\": 101, "
651 "\"avgReceiveThroughput\": 2101, "
652 "\"avgTransmitThroughput\": 501, "
653 "\"flowActivationEpoch\": 1470409422, "
654 "\"flowActivationMicrosec\": 988, "
655 "\"flowDeactivationEpoch\": 1470409432, "
656 "\"flowDeactivationMicrosec\": 12, "
657 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
658 "\"flowStatus\": \"Inactive\", "
659 "\"maxPacketDelayVariation\": 88, "
660 "\"numActivationFailures\": 4, "
661 "\"numBitErrors\": 18, "
662 "\"numBytesReceived\": 123655, "
663 "\"numBytesTransmitted\": 4562, "
664 "\"numDroppedPackets\": 1, "
665 "\"numL7BytesReceived\": 13, "
666 "\"numL7BytesTransmitted\": 11, "
667 "\"numLostPackets\": 2, "
668 "\"numOutOfOrderPackets\": 4, "
669 "\"numPacketErrors\": 8, "
670 "\"numPacketsReceivedExclRetrans\": 900, "
671 "\"numPacketsReceivedInclRetrans\": 902, "
672 "\"numPacketsTransmittedInclRetrans\": 303, "
673 "\"numRetries\": 7, "
674 "\"numTimeouts\": 3, "
675 "\"numTunneledL7BytesReceived\": 1, "
676 "\"roundTripTime\": 111, "
677 "\"timeToFirstByte\": 226, "
678 "\"ipTosCountList\": ["
682 "\"ipTosList\": [\"1\", \"4\", \"17\"], "
683 "\"tcpFlagList\": [\"CWR\", \"URG\"], "
684 "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
685 "\"mobileQciCosList\": [\"conversational\", \"65\"], "
686 "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
687 "\"durConnectionFailedStatus\": 12, "
688 "\"durTunnelFailedStatus\": 13, "
689 "\"flowActivatedBy\": \"Remote\", "
690 "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
691 "\"flowDeactivatedBy\": \"Remote\", "
692 "\"gtpConnectionStatus\": \"Connected\", "
693 "\"gtpTunnelStatus\": \"Not tunneling\", "
694 "\"largePacketRtt\": 80, "
695 "\"largePacketThreshold\": 600.000000, "
696 "\"maxReceiveBitRate\": 1357924680, "
697 "\"maxTransmitBitRate\": 235711, "
698 "\"numGtpEchoFailures\": 1, "
699 "\"numGtpTunnelErrors\": 4, "
700 "\"numHttpErrors\": 2"
702 "\"ipProtocolType\": \"UDP\", "
703 "\"ipVersion\": \"IPv6\", "
704 "\"otherEndpointIpAddress\": \"2.3.4.2\", "
705 "\"otherEndpointPort\": 2342, "
706 "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
707 "\"reportingEndpointPort\": 4322, "
708 "\"applicationType\": \"Demo application\", "
709 "\"appProtocolType\": \"GSM\", "
710 "\"appProtocolVersion\": \"1\", "
711 "\"cid\": \"65535\", "
712 "\"connectionType\": \"S1-U\", "
713 "\"ecgi\": \"e65535\", "
714 "\"gtpProtocolType\": \"GTP-U\", "
715 "\"gtpVersion\": \"1\", "
716 "\"httpHeader\": \"http://www.something.com\", "
717 "\"imei\": \"209917614823\", "
718 "\"imsi\": \"355251/05/850925/8\", "
722 "\"msisdn\": \"6017123456789\", "
723 "\"otherFunctionalRole\": \"MME\", "
725 "\"radioAccessTechnology\": \"LTE\", "
727 "\"samplingAlgorithm\": 1, "
728 "\"tac\": \"2099\", "
729 "\"tunnelId\": \"Tunnel 1\", "
733 size_t json_size = 0;
734 char json_body[EVEL_MAX_JSON_BODY];
735 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
736 EVENT_MOBILE_FLOW * mobile_flow = NULL;
738 /***************************************************************************/
740 /***************************************************************************/
741 evel_set_next_event_sequence(1242);
743 metrics = evel_new_mobile_gtp_flow_metrics(132.0001,
773 assert(metrics != NULL);
775 evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12);
776 evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13);
777 evel_mobile_gtp_metrics_act_by_set(metrics, "Remote");
778 evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423);
779 evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote");
780 evel_mobile_gtp_metrics_con_status_set(metrics, "Connected");
781 evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling");
782 evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13);
783 evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1);
784 evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99);
785 evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80);
786 evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0);
787 evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680);
788 evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711);
789 evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1);
790 evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4);
791 evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2);
792 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10);
793 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121);
794 evel_mobile_gtp_metrics_qci_cos_count_add(
795 metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11);
796 evel_mobile_gtp_metrics_qci_cos_count_add(
797 metrics, EVEL_QCI_COS_LTE_65, 122);
799 mobile_flow = evel_new_mobile_flow("Inbound",
807 assert(mobile_flow != NULL);
809 evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
810 evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
811 evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
812 evel_mobile_flow_app_prot_ver_set(mobile_flow, "1");
813 evel_mobile_flow_cid_set(mobile_flow, "65535");
814 evel_mobile_flow_con_type_set(mobile_flow, "S1-U");
815 evel_mobile_flow_ecgi_set(mobile_flow, "e65535");
816 evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U");
817 evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1");
818 evel_mobile_flow_http_header_set(mobile_flow,
819 "http://www.something.com");
820 evel_mobile_flow_imei_set(mobile_flow, "209917614823");
821 evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8");
822 evel_mobile_flow_lac_set(mobile_flow, "1");
823 evel_mobile_flow_mcc_set(mobile_flow, "410");
824 evel_mobile_flow_mnc_set(mobile_flow, "04");
825 evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789");
826 evel_mobile_flow_other_func_role_set(mobile_flow, "MME");
827 evel_mobile_flow_rac_set(mobile_flow, "514");
828 evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE");
829 evel_mobile_flow_sac_set(mobile_flow, "1");
830 evel_mobile_flow_samp_alg_set(mobile_flow, 1);
831 evel_mobile_flow_tac_set(mobile_flow, "2099");
832 evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1");
833 evel_mobile_flow_vlan_id_set(mobile_flow, "15");
835 json_size = evel_json_encode_event(
836 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
837 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
838 assert((json_size == strlen(json_body)) && "Bad size returned");
840 evel_free_event(mobile_flow);
843 void test_encode_report()
847 "{\"commonEventHeader\": {"
848 "\"domain\": \"measurementsForVfReporting\", "
849 "\"eventId\": \"125\", "
850 "\"functionalRole\": \"UNIT TEST\", "
851 "\"lastEpochMicrosec\": 1000002, "
852 "\"priority\": \"Normal\", "
853 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
854 "\"sequence\": 125, "
855 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
856 "\"startEpochMicrosec\": 1000002, "
858 "\"eventType\": \"Perf reporting...\", "
859 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
860 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
862 "\"measurementsForVfReportingFields\": "
863 "{\"measurementInterval\": 1.100000, "
864 "\"featureUsageArray\": ["
865 "{\"featureIdentifier\": \"FeatureA\", "
866 "\"featureUtilization\": 123}, "
867 "{\"featureIdentifier\": \"FeatureB\", "
868 "\"featureUtilization\": 567}], "
869 "\"additionalMeasurements\": ["
870 "{\"name\": \"Group1\", "
871 "\"measurements\": ["
872 "{\"name\": \"Name1\", "
873 "\"value\": \"Value1\"}]}, "
874 "{\"name\": \"Group2\", "
875 "\"measurements\": ["
876 "{\"name\": \"Name1\", "
877 "\"value\": \"Value1\"}, "
878 "{\"name\": \"Name2\", "
879 "\"value\": \"Value2\"}]}], "
880 "\"measurementFieldsVersion\": 1.1}}}";
882 size_t json_size = 0;
883 char json_body[EVEL_MAX_JSON_BODY];
884 EVENT_REPORT * report = NULL;
886 /***************************************************************************/
888 /***************************************************************************/
889 evel_set_next_event_sequence(125);
890 report = evel_new_report(1.1);
891 assert(report != NULL);
892 evel_report_type_set(report, "Perf reporting...");
893 evel_report_feature_use_add(report, "FeatureA", 123);
894 evel_report_feature_use_add(report, "FeatureB", 567);
895 evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
896 evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
897 evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
899 json_size = evel_json_encode_event(
900 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
901 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
902 assert((json_size == strlen(json_body)) && "Bad size returned");
904 evel_free_event(report);
907 void test_encode_service()
909 test_encode_service_subset(SERVICE_NONE);
910 test_encode_service_subset(SERVICE_CODEC);
911 test_encode_service_subset(SERVICE_TRANSCODING);
912 test_encode_service_subset(SERVICE_RTCP);
913 test_encode_service_subset(SERVICE_EOC_VQM);
914 test_encode_service_subset(SERVICE_MARKER);
917 void test_encode_service_subset(const SERVICE_TEST service_test)
919 char * expected_start =
921 "{\"commonEventHeader\": {"
922 "\"domain\": \"serviceEvents\", "
923 "\"eventId\": \"2000\", "
924 "\"functionalRole\": \"UNIT TEST\", "
925 "\"lastEpochMicrosec\": 1000002, "
926 "\"priority\": \"Normal\", "
927 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
928 "\"sequence\": 2000, "
929 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
930 "\"startEpochMicrosec\": 1000002, "
932 "\"eventType\": \"Service Event\", "
933 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
934 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
936 "\"serviceEventsFields\": {"
937 "\"eventInstanceIdentifier\": "
939 "\"vendorId\": \"vendor_x_id\", "
940 "\"eventId\": \"vendor_x_event_id\", "
941 "\"productId\": \"vendor_x_product_id\", "
942 "\"subsystemId\": \"vendor_x_subsystem_id\", "
943 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
945 "\"serviceEventsFieldsVersion\": 1.1, "
946 "\"correlator\": \"vendor_x_correlator\", "
947 "\"additionalFields\": ["
948 "{\"name\": \"Name1\", \"value\": \"Value1\"}, "
949 "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
950 "{\"name\": \"Name3\", \"value\": \"Value3\"}, "
951 "{\"name\": \"Name4\", \"value\": \"Value4\"}]";
952 char * expected_codec =
954 "\"codecSelected\": {"
955 "\"codec\": \"PCMA\""
957 char * expected_transcoding =
959 "\"codecSelectedTranscoding\": {"
960 "\"calleeSideCodec\": \"PCMA\", "
961 "\"callerSideCodec\": \"G729A\""
963 char * expected_rtcp =
966 "\"rtcpData\": \"some_rtcp_data\""
968 char * expected_eoc_vqm =
970 "\"endOfCallVqmSummaries\": {"
971 "\"adjacencyName\": \"vendor_x_adjacency\", "
972 "\"endpointDescription\": \"Caller\", "
973 "\"endpointJitter\": 66, "
974 "\"endpointRtpOctetsDiscarded\": 100, "
975 "\"endpointRtpOctetsReceived\": 200, "
976 "\"endpointRtpOctetsSent\": 300, "
977 "\"endpointRtpPacketsDiscarded\": 400, "
978 "\"endpointRtpPacketsReceived\": 500, "
979 "\"endpointRtpPacketsSent\": 600, "
980 "\"localJitter\": 99, "
981 "\"localRtpOctetsDiscarded\": 150, "
982 "\"localRtpOctetsReceived\": 250, "
983 "\"localRtpOctetsSent\": 350, "
984 "\"localRtpPacketsDiscarded\": 450, "
985 "\"localRtpPacketsReceived\": 550, "
986 "\"localRtpPacketsSent\": 650, "
987 "\"mosCqe\": 12.255000, "
988 "\"packetsLost\": 157, "
989 "\"packetLossPercent\": 0.232000, "
991 "\"roundTripDelay\": 15"
993 char * expected_marker =
996 "\"phoneNumber\": \"0888888888\""
998 char * expected_end =
1001 char * expected_middle = NULL;
1002 switch (service_test)
1005 expected_middle = "";
1008 expected_middle = expected_codec;
1010 case SERVICE_TRANSCODING:
1011 expected_middle = expected_transcoding;
1014 expected_middle = expected_rtcp;
1016 case SERVICE_EOC_VQM:
1017 expected_middle = expected_eoc_vqm;
1019 case SERVICE_MARKER:
1020 expected_middle = expected_marker;
1023 assert(expected_middle != NULL);
1026 char expected[EVEL_MAX_JSON_BODY];
1027 offset = snprintf(expected + offset,
1028 EVEL_MAX_JSON_BODY - offset,
1034 size_t json_size = 0;
1035 char json_body[EVEL_MAX_JSON_BODY];
1036 EVENT_SERVICE * event = NULL;
1037 evel_set_next_event_sequence(2000);
1038 event = evel_new_service("vendor_x_id", "vendor_x_event_id");
1039 assert(event != NULL);
1040 evel_service_type_set(event, "Service Event");
1041 evel_service_product_id_set(event, "vendor_x_product_id");
1042 evel_service_subsystem_id_set(event, "vendor_x_subsystem_id");
1043 evel_service_friendly_name_set(event, "vendor_x_frieldly_name");
1044 evel_service_correlator_set(event, "vendor_x_correlator");
1046 switch (service_test)
1051 evel_service_codec_set(event, "PCMA");
1053 case SERVICE_TRANSCODING:
1054 evel_service_callee_codec_set(event, "PCMA");
1055 evel_service_caller_codec_set(event, "G729A");
1058 evel_service_rtcp_data_set(event, "some_rtcp_data");
1060 case SERVICE_EOC_VQM:
1061 evel_service_adjacency_name_set(event, "vendor_x_adjacency");
1062 evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER);
1063 evel_service_endpoint_jitter_set(event, 66);
1064 evel_service_endpoint_rtp_oct_disc_set(event, 100);
1065 evel_service_endpoint_rtp_oct_recv_set(event, 200);
1066 evel_service_endpoint_rtp_oct_sent_set(event, 300);
1067 evel_service_endpoint_rtp_pkt_disc_set(event, 400);
1068 evel_service_endpoint_rtp_pkt_recv_set(event, 500);
1069 evel_service_endpoint_rtp_pkt_sent_set(event, 600);
1070 evel_service_local_jitter_set(event, 99);
1071 evel_service_local_rtp_oct_disc_set(event, 150);
1072 evel_service_local_rtp_oct_recv_set(event, 250);
1073 evel_service_local_rtp_oct_sent_set(event, 350);
1074 evel_service_local_rtp_pkt_disc_set(event, 450);
1075 evel_service_local_rtp_pkt_recv_set(event, 550);
1076 evel_service_local_rtp_pkt_sent_set(event, 650);
1077 evel_service_mos_cqe_set(event, 12.255);
1078 evel_service_packets_lost_set(event, 157);
1079 evel_service_packet_loss_percent_set(event, 0.232);
1080 evel_service_r_factor_set(event, 11);
1081 evel_service_round_trip_delay_set(event, 15);
1083 case SERVICE_MARKER:
1084 evel_service_phone_number_set(event, "0888888888");
1088 evel_service_addl_field_add(event, "Name1", "Value1");
1089 evel_service_addl_field_add(event, "Name2", "Value2");
1090 evel_service_addl_field_add(event, "Name3", "Value3");
1091 evel_service_addl_field_add(event, "Name4", "Value4");
1092 json_size = evel_json_encode_event(
1093 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
1094 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
1095 assert((json_size == strlen(json_body)) && "Bad size returned");
1097 evel_free_event(event);
1100 void test_encode_signaling()
1104 "{\"commonEventHeader\": {"
1105 "\"domain\": \"signaling\", "
1106 "\"eventId\": \"2001\", "
1107 "\"functionalRole\": \"UNIT TEST\", "
1108 "\"lastEpochMicrosec\": 1000002, "
1109 "\"priority\": \"Normal\", "
1110 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1111 "\"sequence\": 2001, "
1112 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1113 "\"startEpochMicrosec\": 1000002, "
1114 "\"version\": 1.2, "
1115 "\"eventType\": \"Signaling\", "
1116 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1117 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1119 "\"signalingFields\": {"
1120 "\"eventInstanceIdentifier\": "
1122 "\"vendorId\": \"vendor_x_id\", "
1123 "\"eventId\": \"vendor_x_event_id\", "
1124 "\"productId\": \"vendor_x_product_id\", "
1125 "\"subsystemId\": \"vendor_x_subsystem_id\", "
1126 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
1128 "\"signalingFieldsVersion\": 1.1, "
1129 "\"correlator\": \"vendor_x_correlator\", "
1130 "\"localIpAddress\": \"1.0.3.1\", "
1131 "\"localPort\": \"1031\", "
1132 "\"remoteIpAddress\": \"5.3.3.0\", "
1133 "\"remotePort\": \"5330\", "
1134 "\"compressedSip\": \"compressed_sip\", "
1135 "\"summarySip\": \"summary_sip\""
1138 size_t json_size = 0;
1139 char json_body[EVEL_MAX_JSON_BODY];
1140 EVENT_SIGNALING * event = NULL;
1141 evel_set_next_event_sequence(2001);
1142 event = evel_new_signaling("vendor_x_id", "vendor_x_event_id");
1143 assert(event != NULL);
1144 evel_signaling_type_set(event, "Signaling");
1145 evel_signaling_product_id_set(event, "vendor_x_product_id");
1146 evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id");
1147 evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name");
1148 evel_signaling_correlator_set(event, "vendor_x_correlator");
1149 evel_signaling_local_ip_address_set(event, "1.0.3.1");
1150 evel_signaling_local_port_set(event, "1031");
1151 evel_signaling_remote_ip_address_set(event, "5.3.3.0");
1152 evel_signaling_remote_port_set(event, "5330");
1153 evel_signaling_compressed_sip_set(event, "compressed_sip");
1154 evel_signaling_summary_sip_set(event, "summary_sip");
1155 json_size = evel_json_encode_event(
1156 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
1157 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Signaling");
1158 assert((json_size == strlen(json_body)) && "Bad size returned");
1160 evel_free_event(event);
1163 void test_encode_state_change()
1167 "{\"commonEventHeader\": {"
1168 "\"domain\": \"stateChange\", "
1169 "\"eventId\": \"128\", "
1170 "\"functionalRole\": \"UNIT TEST\", "
1171 "\"lastEpochMicrosec\": 1000002, "
1172 "\"priority\": \"Normal\", "
1173 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1174 "\"sequence\": 128, "
1175 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1176 "\"startEpochMicrosec\": 1000002, "
1177 "\"version\": 1.2, "
1178 "\"eventType\": \"SC Type\", "
1179 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1180 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1182 "\"stateChangeFields\": {"
1183 "\"newState\": \"inService\", "
1184 "\"oldState\": \"outOfService\", "
1185 "\"stateInterface\": \"An Interface\", "
1186 "\"additionalFields\": ["
1187 "{\"name\": \"Name1\", "
1188 "\"value\": \"Value1\"}, "
1189 "{\"name\": \"Name2\", "
1190 "\"value\": \"Value2\"}"
1192 "\"stateChangeFieldsVersion\": 1.1"
1195 size_t json_size = 0;
1196 char json_body[EVEL_MAX_JSON_BODY];
1197 EVENT_STATE_CHANGE * state_change = NULL;
1198 evel_set_next_event_sequence(128);
1199 state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE,
1200 EVEL_ENTITY_STATE_OUT_OF_SERVICE,
1202 assert(state_change != NULL);
1203 evel_state_change_type_set(state_change, "SC Type");
1204 evel_state_change_addl_field_add(state_change, "Name1", "Value1");
1205 evel_state_change_addl_field_add(state_change, "Name2", "Value2");
1207 json_size = evel_json_encode_event(
1208 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) state_change);
1209 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "StateChange");
1210 assert((json_size == strlen(json_body)) && "Bad size returned");
1212 evel_free_event(state_change);
1215 void test_encode_syslog()
1219 "{\"commonEventHeader\": {"
1220 "\"domain\": \"syslog\", "
1221 "\"eventId\": \"126\", "
1222 "\"functionalRole\": \"UNIT TEST\", "
1223 "\"lastEpochMicrosec\": 1000002, "
1224 "\"priority\": \"Normal\", "
1225 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1226 "\"sequence\": 126, "
1227 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1228 "\"startEpochMicrosec\": 1000002, "
1229 "\"version\": 1.2, "
1230 "\"eventType\": \"SL Type\", "
1231 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1232 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1234 "\"syslogFields\": {"
1235 "\"eventSourceType\": \"virtualNetworkFunction\", "
1236 "\"syslogMsg\": \"SL Message\", "
1237 "\"syslogTag\": \"SL Tag\", "
1238 "\"syslogFieldsVersion\": 1.1, "
1239 "\"eventSourceHost\": \"SL Host\", "
1240 "\"syslogFacility\": 6, "
1241 "\"syslogProc\": \"SL Proc\", "
1242 "\"syslogProcId\": 2, "
1243 "\"syslogSData\": \"SL SDATA\", "
1246 size_t json_size = 0;
1247 char json_body[EVEL_MAX_JSON_BODY];
1248 EVENT_SYSLOG * syslog = NULL;
1249 evel_set_next_event_sequence(126);
1250 syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION,
1253 assert(syslog != NULL);
1254 evel_syslog_type_set(syslog, "SL Type");
1255 evel_syslog_event_source_host_set(syslog, "SL Host");
1256 evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
1257 evel_syslog_proc_set(syslog, "SL Proc");
1258 evel_syslog_proc_id_set(syslog, 2);
1259 evel_syslog_version_set(syslog, 1);
1260 evel_syslog_s_data_set(syslog, "SL SDATA");
1262 json_size = evel_json_encode_event(
1263 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog);
1264 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog");
1265 assert((json_size == strlen(json_body)) && "Bad size returned");
1267 evel_free_event(syslog);
1270 void test_encode_other()
1274 "{\"commonEventHeader\": {"
1275 "\"domain\": \"other\", "
1276 "\"eventId\": \"129\", "
1277 "\"functionalRole\": \"UNIT TEST\", "
1278 "\"lastEpochMicrosec\": 1000002, "
1279 "\"priority\": \"Normal\", "
1280 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1281 "\"sequence\": 129, "
1282 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1283 "\"startEpochMicrosec\": 1000002, "
1284 "\"version\": 1.2, "
1285 "\"eventType\": \"Other Type\", "
1286 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1287 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1289 "\"otherFields\": ["
1290 "{\"name\": \"Other field 1\", "
1291 "\"value\": \"Other value 1\"}, "
1292 "{\"name\": \"Other field 2\", "
1293 "\"value\": \"Other value 2\"}"
1297 size_t json_size = 0;
1298 char json_body[EVEL_MAX_JSON_BODY];
1299 EVENT_OTHER * other = NULL;
1300 evel_set_next_event_sequence(129);
1301 other = evel_new_other();
1302 assert(other != NULL);
1303 evel_other_type_set(other, "Other Type");
1304 evel_other_field_add(other,
1307 evel_other_field_add(other,
1311 json_size = evel_json_encode_event(
1312 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) other);
1313 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Other");
1314 assert((json_size == strlen(json_body)) && "Bad size returned");
1316 evel_free_event(other);
1319 void compare_strings(char * expected,
1324 if (strncmp(expected, actual, max_size) != 0)
1327 while (diff < max_size)
1329 if (expected[diff] != actual[diff])
1336 printf("Comparison Failure at Offset %d\n\n", diff);
1337 printf("Expected:\n%s\n", expected);
1338 printf("Actual:\n%s\n", actual);
1339 printf("Description: %s\n", description);
1344 /**************************************************************************//**
1345 * Copy a json string to a ::MEMORY_CHUNK for testing.
1347 * @param chunk The memory chunk.
1348 * @param string The json string.
1349 *****************************************************************************/
1350 void copy_string_to_chunk(MEMORY_CHUNK * chunk, char * string)
1354 /***************************************************************************/
1355 /* Check preconditions. */
1356 /***************************************************************************/
1357 assert(chunk != NULL);
1358 assert(string != NULL);
1360 mem_size = strlen(string) + 1;
1361 chunk->memory = malloc(mem_size);
1362 memcpy(chunk->memory, string, mem_size);
1363 chunk->size = mem_size;
1366 /**************************************************************************//**
1367 * Copy a json string to a ::MEMORY_CHUNK for testing.
1369 * @param json The JSON string.
1370 * @param post Memory chunk to post a response.
1371 *****************************************************************************/
1372 void handle_json_response(char * json, MEMORY_CHUNK * post)
1375 post->memory = NULL;
1377 copy_string_to_chunk(&chunk, json);
1378 evel_handle_event_response(&chunk, post);
1382 /**************************************************************************//**
1383 * Test that a non-"commandList" JSON buffer leaves the throttle state off.
1384 *****************************************************************************/
1385 void test_json_response_junk()
1392 "\"1\", \"2\", \"3\"], "
1394 "\"1\", \"2\", \"3\"]"
1397 evel_throttle_initialize();
1398 handle_json_response(json_junk, &post);
1400 /***************************************************************************/
1401 /* Check that all domains are not throttled. */
1402 /***************************************************************************/
1403 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1405 assert(evel_get_throttle_spec(domain) == NULL);
1408 /***************************************************************************/
1409 /* Check that we generated no post. */
1410 /***************************************************************************/
1411 assert(post.memory == NULL);
1413 evel_throttle_terminate();
1416 char * json_command_list_provide =
1418 "\"commandList\": ["
1421 "\"commandType\": \"provideThrottlingState\""
1427 char * json_command_list_fault_clear =
1429 "\"commandList\": ["
1432 "\"commandType\": \"throttlingSpecification\", "
1433 "\"eventDomainThrottleSpecification\": {"
1434 "\"eventDomain\": \"fault\""
1441 char * json_command_list_syslog_clear =
1443 "\"commandList\": ["
1446 "\"commandType\": \"throttlingSpecification\", "
1447 "\"eventDomainThrottleSpecification\": {"
1448 "\"eventDomain\": \"syslog\""
1455 char * expected_throttle_state_normal =
1457 "\"eventThrottlingState\": {"
1458 "\"eventThrottlingMode\": \"normal\"}"
1461 /**************************************************************************//**
1462 * Test that we can return the default throttling state.
1463 *****************************************************************************/
1464 void test_json_provide_throttle_state()
1469 char * expected_post = expected_throttle_state_normal;
1471 evel_throttle_initialize();
1472 handle_json_response(json_command_list_provide, &post);
1474 /***************************************************************************/
1475 /* Check that all domains are not throttled. */
1476 /***************************************************************************/
1477 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1479 assert(evel_get_throttle_spec(domain) == NULL);
1482 /***************************************************************************/
1483 /* Check that we generated a throttling specification post. */
1484 /***************************************************************************/
1485 assert(post.memory != NULL);
1486 compare_strings(expected_post, post.memory, strlen(expected_post),
1487 "Throttle State Normal");
1490 evel_throttle_terminate();
1493 /**************************************************************************//**
1494 * Test the measurement interval handling and API.
1495 *****************************************************************************/
1496 void test_json_measurement_interval()
1499 char * json_command_list_interval_only =
1501 "\"commandList\": ["
1504 "\"measurementInterval\": 60"
1510 char * json_command_list_interval_first =
1512 "\"commandList\": ["
1515 "\"measurementInterval\": 30, "
1516 "\"commandType\": \"measurementIntervalChange\""
1522 char * json_command_list_command_first =
1524 "\"commandList\": ["
1527 "\"commandType\": \"measurementIntervalChange\", "
1528 "\"measurementInterval\": 60"
1534 evel_throttle_initialize();
1535 assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
1537 /***************************************************************************/
1538 /* Check that we're not handling stuff when we shouldn't. */
1539 /***************************************************************************/
1540 handle_json_response(json_command_list_interval_only, &post);
1541 assert(post.memory == NULL);
1542 assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
1544 /***************************************************************************/
1545 /* Check that we're OK with the interval coming first. */
1546 /***************************************************************************/
1547 handle_json_response(json_command_list_interval_first, &post);
1548 assert(post.memory == NULL);
1549 assert(evel_get_measurement_interval() == 30);
1551 /***************************************************************************/
1552 /* Check that we're OK with the command type coming first. */
1553 /***************************************************************************/
1554 handle_json_response(json_command_list_command_first, &post);
1555 assert(post.memory == NULL);
1556 assert(evel_get_measurement_interval() == 60);
1558 evel_throttle_terminate();
1561 /**************************************************************************//**
1562 * Test a single domain, single field suppression.
1563 *****************************************************************************/
1564 void test_json_throttle_spec_field()
1569 char * json_command_list_fault_single =
1571 "\"commandList\": ["
1574 "\"commandType\": \"throttlingSpecification\", "
1575 "\"eventDomainThrottleSpecification\": {"
1576 "\"eventDomain\": \"fault\", "
1577 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
1584 char * json_command_list_fault_double =
1586 "\"commandList\": ["
1589 "\"commandType\": \"throttlingSpecification\", "
1590 "\"eventDomainThrottleSpecification\": {"
1591 "\"eventDomain\": \"fault\", "
1592 "\"suppressedFieldNames\": ["
1593 "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
1600 char * expected_post_fault_single =
1602 "\"eventThrottlingState\": {"
1603 "\"eventThrottlingMode\": \"throttled\", "
1604 "\"eventDomainThrottleSpecificationList\": ["
1606 "\"eventDomain\": \"fault\", "
1607 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
1613 char * expected_post_fault_double =
1615 "\"eventThrottlingState\": {"
1616 "\"eventThrottlingMode\": \"throttled\", "
1617 "\"eventDomainThrottleSpecificationList\": ["
1619 "\"eventDomain\": \"fault\", "
1620 "\"suppressedFieldNames\": ["
1621 "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
1627 /***************************************************************************/
1628 /* Initialize and provide a specification with a single fault suppressed. */
1629 /***************************************************************************/
1630 evel_throttle_initialize();
1631 handle_json_response(json_command_list_fault_single, &post);
1633 /***************************************************************************/
1634 /* Check that the FAULT domain is throttled. */
1635 /***************************************************************************/
1636 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1637 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1639 if (domain != EVEL_DOMAIN_FAULT)
1641 assert(evel_get_throttle_spec(domain) == NULL);
1644 assert(post.memory == NULL);
1646 /***************************************************************************/
1647 /* Request and verify the throttling state. */
1648 /***************************************************************************/
1649 handle_json_response(json_command_list_provide, &post);
1650 assert(post.memory != NULL);
1651 compare_strings(expected_post_fault_single,
1653 strlen(expected_post_fault_single),
1654 "Fault - Single Field");
1658 /***************************************************************************/
1659 /* Update a specification with two faults suppressed. */
1660 /***************************************************************************/
1661 handle_json_response(json_command_list_fault_double, &post);
1663 /***************************************************************************/
1664 /* Check that the FAULT domain is throttled. */
1665 /***************************************************************************/
1666 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1667 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1669 if (domain != EVEL_DOMAIN_FAULT)
1671 assert(evel_get_throttle_spec(domain) == NULL);
1674 assert(post.memory == NULL);
1676 /***************************************************************************/
1677 /* Request and verify the throttling state. */
1678 /***************************************************************************/
1679 handle_json_response(json_command_list_provide, &post);
1680 assert(post.memory != NULL);
1681 compare_strings(expected_post_fault_double,
1683 strlen(expected_post_fault_double),
1684 "Fault - Double Field");
1688 /***************************************************************************/
1689 /* Now clear the FAULT domain. */
1690 /***************************************************************************/
1691 handle_json_response(json_command_list_fault_clear, &post);
1692 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1694 assert(evel_get_throttle_spec(domain) == NULL);
1697 evel_throttle_terminate();
1700 /**************************************************************************//**
1701 * Test a single domain, nv_pair suppression.
1702 *****************************************************************************/
1703 void test_json_throttle_spec_nv_pair()
1708 char * json_command_list_fault_pair_single =
1710 "\"commandList\": ["
1713 "\"commandType\": \"throttlingSpecification\", "
1714 "\"eventDomainThrottleSpecification\": {"
1715 "\"eventDomain\": \"fault\", "
1716 "\"suppressedNvPairsList\": ["
1718 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1719 "\"suppressedNvPairNames\": [\"name1\"]"
1728 char * json_command_list_fault_pair_double =
1730 "\"commandList\": ["
1733 "\"commandType\": \"throttlingSpecification\", "
1734 "\"eventDomainThrottleSpecification\": {"
1735 "\"eventDomain\": \"fault\", "
1736 "\"suppressedNvPairsList\": ["
1738 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1739 "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
1748 char * expected_post_fault_pair_single =
1750 "\"eventThrottlingState\": {"
1751 "\"eventThrottlingMode\": \"throttled\", "
1752 "\"eventDomainThrottleSpecificationList\": ["
1754 "\"eventDomain\": \"fault\", "
1755 "\"suppressedNvPairsList\": ["
1757 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1758 "\"suppressedNvPairNames\": [\"name1\"]"
1766 char * expected_post_fault_pair_double =
1768 "\"eventThrottlingState\": {"
1769 "\"eventThrottlingMode\": \"throttled\", "
1770 "\"eventDomainThrottleSpecificationList\": ["
1772 "\"eventDomain\": \"fault\", "
1773 "\"suppressedNvPairsList\": ["
1775 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1776 "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
1784 /***************************************************************************/
1785 /* Initialize and provide a specification with a single nvpair with a */
1786 /* single sub-field suppressed. */
1787 /***************************************************************************/
1788 evel_throttle_initialize();
1789 handle_json_response(json_command_list_fault_pair_single, &post);
1791 /***************************************************************************/
1792 /* Check that the FAULT domain is throttled. */
1793 /***************************************************************************/
1794 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1795 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1797 if (domain != EVEL_DOMAIN_FAULT)
1799 assert(evel_get_throttle_spec(domain) == NULL);
1802 assert(post.memory == NULL);
1804 /***************************************************************************/
1805 /* Request and verify the throttling state. */
1806 /***************************************************************************/
1807 handle_json_response(json_command_list_provide, &post);
1808 assert(post.memory != NULL);
1809 compare_strings(expected_post_fault_pair_single,
1811 strlen(expected_post_fault_pair_single),
1812 "Fault - Single Pair, Single Field");
1816 /***************************************************************************/
1817 /* Update a specification with a single nvpair with two sub-fields */
1819 /***************************************************************************/
1820 handle_json_response(json_command_list_fault_pair_double, &post);
1822 /***************************************************************************/
1823 /* Check that the FAULT domain is throttled. */
1824 /***************************************************************************/
1825 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1826 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1828 if (domain != EVEL_DOMAIN_FAULT)
1830 assert(evel_get_throttle_spec(domain) == NULL);
1833 assert(post.memory == NULL);
1835 /***************************************************************************/
1836 /* Request and verify the throttling state. */
1837 /***************************************************************************/
1838 handle_json_response(json_command_list_provide, &post);
1839 assert(post.memory != NULL);
1840 compare_strings(expected_post_fault_pair_double,
1842 strlen(expected_post_fault_pair_double),
1843 "Fault - Double Field");
1847 /***************************************************************************/
1848 /* Now clear the FAULT domain. */
1849 /***************************************************************************/
1850 handle_json_response(json_command_list_fault_clear, &post);
1851 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1853 assert(evel_get_throttle_spec(domain) == NULL);
1856 evel_throttle_terminate();
1859 /**************************************************************************//**
1860 * Test two domains, nv_pair suppression.
1861 *****************************************************************************/
1862 void test_json_throttle_spec_two_domains()
1867 char * json_command_list_two_domains =
1869 "\"commandList\": ["
1872 "\"commandType\": \"throttlingSpecification\", "
1873 "\"eventDomainThrottleSpecification\": {"
1874 "\"eventDomain\": \"fault\", "
1875 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
1876 "\"suppressedNvPairsList\": ["
1878 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1879 "\"suppressedNvPairNames\": [\"name1\"]"
1883 "\"commandType\": \"throttlingSpecification\", "
1884 "\"eventDomainThrottleSpecification\": {"
1885 "\"eventDomain\": \"syslog\", "
1886 "\"suppressedFieldNames\": [\"syslogProcId\"], "
1887 "\"suppressedNvPairsList\": ["
1889 "\"nvPairFieldName\": \"additionalFields\", "
1890 "\"suppressedNvPairNames\": [\"name1\"]"
1895 char * expected_post_two_domains =
1897 "\"eventThrottlingState\": {"
1898 "\"eventThrottlingMode\": \"throttled\", "
1899 "\"eventDomainThrottleSpecificationList\": ["
1901 "\"eventDomain\": \"fault\", "
1902 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
1903 "\"suppressedNvPairsList\": ["
1905 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1906 "\"suppressedNvPairNames\": [\"name1\"]"
1909 "\"eventDomain\": \"syslog\", "
1910 "\"suppressedFieldNames\": [\"syslogProcId\"], "
1911 "\"suppressedNvPairsList\": ["
1913 "\"nvPairFieldName\": \"additionalFields\", "
1914 "\"suppressedNvPairNames\": [\"name1\"]"
1920 /***************************************************************************/
1921 /* Initialize and provide a specification with a single nvpair with a */
1922 /* single sub-field suppressed. */
1923 /***************************************************************************/
1924 evel_throttle_initialize();
1925 handle_json_response(json_command_list_two_domains, &post);
1927 /***************************************************************************/
1928 /* Check that the FAULT and SYSLOG domains are throttled. */
1929 /***************************************************************************/
1930 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1931 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
1932 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1934 if ((domain != EVEL_DOMAIN_FAULT) && (domain != EVEL_DOMAIN_SYSLOG))
1936 assert(evel_get_throttle_spec(domain) == NULL);
1939 assert(post.memory == NULL);
1941 /***************************************************************************/
1942 /* Request and verify the throttling state. */
1943 /***************************************************************************/
1944 handle_json_response(json_command_list_provide, &post);
1945 assert(post.memory != NULL);
1946 compare_strings(expected_post_two_domains,
1948 strlen(expected_post_two_domains),
1949 "Fault - Two Domains");
1953 /***************************************************************************/
1954 /* Now clear the FAULT and SYSLOG domains. */
1955 /***************************************************************************/
1956 handle_json_response(json_command_list_fault_clear, &post);
1957 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL);
1958 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
1959 handle_json_response(json_command_list_syslog_clear, &post);
1960 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1962 assert(evel_get_throttle_spec(domain) == NULL);
1965 evel_throttle_terminate();
1968 /**************************************************************************//**
1969 * Test bad command type.
1970 *****************************************************************************/
1971 void test_json_throttle_spec_bad_command_type()
1976 /***************************************************************************/
1977 /* Search for "dodgy" in the JSON, and you will see the dodgy bits we're */
1978 /* handling in these tests. */
1979 /***************************************************************************/
1980 #define NUM_BAD_COMMANDS 8
1981 char * json_command_list_dodgy_command =
1983 "\"commandList\": ["
1986 "\"commandType\": \"dodgyCommand\", "
1987 "\"eventDomainThrottleSpecification\": {"
1988 "\"eventDomain\": \"fault\", "
1989 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
1990 "\"suppressedNvPairsList\": ["
1992 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1993 "\"suppressedNvPairNames\": [\"name1\"]"
1998 char * json_command_list_dodgy_spec =
2000 "\"commandList\": ["
2003 "\"commandType\": \"throttlingSpecification\", "
2004 "\"dodgyEventDomainThrottleSpecification\": {"
2005 "\"eventDomain\": \"fault\", "
2006 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2007 "\"suppressedNvPairsList\": ["
2009 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2010 "\"suppressedNvPairNames\": [\"name1\"]"
2015 char * json_command_list_dodgy_event_domain_key =
2017 "\"commandList\": ["
2020 "\"commandType\": \"throttlingSpecification\", "
2021 "\"eventDomainThrottleSpecification\": {"
2022 "\"dodgyEventDomainKey\": \"fault\", "
2023 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2024 "\"suppressedNvPairsList\": ["
2026 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2027 "\"suppressedNvPairNames\": [\"name1\"]"
2032 char * json_command_list_dodgy_event_domain =
2034 "\"commandList\": ["
2037 "\"commandType\": \"throttlingSpecification\", "
2038 "\"eventDomainThrottleSpecification\": {"
2039 "\"eventDomain\": \"dodgyEventDomain\", "
2040 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2041 "\"suppressedNvPairsList\": ["
2043 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2044 "\"suppressedNvPairNames\": [\"name1\"]"
2049 char * json_command_list_dodgy_field_names_key =
2051 "\"commandList\": ["
2054 "\"commandType\": \"throttlingSpecification\", "
2055 "\"eventDomainThrottleSpecification\": {"
2056 "\"eventDomain\": \"fault\", "
2057 "\"suppressedNvPairsList\": ["
2059 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2060 "\"suppressedNvPairNames\": [\"name1\"]"
2065 char * json_command_list_dodgy_pair_names_list_key =
2067 "\"commandList\": ["
2070 "\"commandType\": \"throttlingSpecification\", "
2071 "\"eventDomainThrottleSpecification\": {"
2072 "\"eventDomain\": \"fault\", "
2073 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2074 "\"dodgySuppressedNvPairsListKey\": ["
2076 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2077 "\"suppressedNvPairNames\": [\"name1\"]"
2082 char * json_command_list_dodgy_pair_field_name_key =
2084 "\"commandList\": ["
2087 "\"commandType\": \"throttlingSpecification\", "
2088 "\"eventDomainThrottleSpecification\": {"
2089 "\"eventDomain\": \"fault\", "
2090 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2091 "\"suppressedNvPairsList\": ["
2093 "\"dodgyNvPairFieldNameKey\": \"alarmAdditionalInformation\", "
2094 "\"suppressedNvPairNames\": [\"name1\"]"
2099 char * json_command_list_dodgy_pair_names_key =
2101 "\"commandList\": ["
2104 "\"commandType\": \"throttlingSpecification\", "
2105 "\"eventDomainThrottleSpecification\": {"
2106 "\"eventDomain\": \"fault\", "
2107 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2108 "\"suppressedNvPairsList\": ["
2110 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2111 "\"dodgySuppressedNvPairNamesKey\": [\"name1\"]"
2116 char * json_command_list_dodgy_depth =
2118 "\"commandList\": ["
2121 "\"commandType\": \"throttlingSpecification\", "
2122 "\"eventDomainThrottleSpecification\": {"
2123 "\"eventDomain\": \"fault\", "
2124 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2125 "\"suppressedNvPairsList\": ["
2127 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2128 "\"dodgySuppressedNvPairNamesKey\": "
2129 "[\"name1\", [[[[[[[[]]]]]]]]]"
2134 char * expected_throttle_state_dodgy_field_names_key =
2136 "\"eventThrottlingState\": {"
2137 "\"eventThrottlingMode\": \"throttled\", "
2138 "\"eventDomainThrottleSpecificationList\": ["
2140 "\"eventDomain\": \"fault\", "
2141 "\"suppressedNvPairsList\": ["
2143 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2144 "\"suppressedNvPairNames\": [\"name1\"]"
2150 char * expected_throttle_state_dodgy_pair_names_list_key =
2152 "\"eventThrottlingState\": {"
2153 "\"eventThrottlingMode\": \"throttled\", "
2154 "\"eventDomainThrottleSpecificationList\": ["
2156 "\"eventDomain\": \"fault\", "
2157 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2163 char * expected_throttle_state_dodgy_pair_field_name_key =
2165 "\"eventThrottlingState\": {"
2166 "\"eventThrottlingMode\": \"throttled\", "
2167 "\"eventDomainThrottleSpecificationList\": ["
2169 "\"eventDomain\": \"fault\", "
2170 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2176 char * expected_throttle_state_dodgy_pair_names_key =
2178 "\"eventThrottlingState\": {"
2179 "\"eventThrottlingMode\": \"throttled\", "
2180 "\"eventDomainThrottleSpecificationList\": ["
2182 "\"eventDomain\": \"fault\", "
2183 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2189 char * json_command_lists[] = {
2190 json_command_list_dodgy_command,
2191 json_command_list_dodgy_spec,
2192 json_command_list_dodgy_event_domain_key,
2193 json_command_list_dodgy_event_domain,
2194 json_command_list_dodgy_depth,
2195 json_command_list_dodgy_field_names_key,
2196 json_command_list_dodgy_pair_names_list_key,
2197 json_command_list_dodgy_pair_field_name_key,
2198 json_command_list_dodgy_pair_names_key
2201 char * expected_posts[] = {
2202 expected_throttle_state_normal,
2203 expected_throttle_state_normal,
2204 expected_throttle_state_normal,
2205 expected_throttle_state_normal,
2206 expected_throttle_state_normal,
2207 expected_throttle_state_dodgy_field_names_key,
2208 expected_throttle_state_dodgy_pair_names_list_key,
2209 expected_throttle_state_dodgy_pair_field_name_key,
2210 expected_throttle_state_dodgy_pair_names_key
2213 const int num_commands =
2214 sizeof(json_command_lists) / sizeof(json_command_lists[0]);
2215 const int num_posts =
2216 sizeof(expected_posts) / sizeof(expected_posts[0]);
2217 assert(num_commands == num_posts);
2219 /***************************************************************************/
2220 /* Initialize and provide a specification with a single nvpair with a */
2221 /* single sub-field suppressed. */
2222 /***************************************************************************/
2223 evel_throttle_initialize();
2226 for (ii = 0; ii < num_commands; ii++)
2228 EVEL_DEBUG("Testing commandList[%d] = %s\n", ii, json_command_lists[ii]);
2229 handle_json_response(json_command_lists[ii], &post);
2231 /*************************************************************************/
2232 /* Check that throttling is in a normal state - because we ignored the */
2233 /* command / ..... */
2234 /*************************************************************************/
2235 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
2237 assert(evel_get_throttle_spec(domain) == NULL);
2239 if (expected_posts[ii] == expected_throttle_state_normal)
2241 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL);
2245 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
2247 assert(post.memory == NULL);
2249 /*************************************************************************/
2250 /* Request and verify the throttling state. */
2251 /*************************************************************************/
2252 handle_json_response(json_command_list_provide, &post);
2253 assert(post.memory != NULL);
2254 compare_strings(expected_posts[ii],
2256 strlen(expected_posts[ii]),
2257 "Throttle State Normal");
2262 evel_throttle_terminate();
2265 void test_encode_fault_throttled()
2269 /***************************************************************************/
2270 /* We also test suppression of the event header parameters here. */
2271 /***************************************************************************/
2272 char * json_command_list =
2274 "\"commandList\": ["
2277 "\"commandType\": \"throttlingSpecification\", "
2278 "\"eventDomainThrottleSpecification\": {"
2279 "\"eventDomain\": \"fault\", "
2280 "\"suppressedFieldNames\": ["
2281 "\"alarmInterfaceA\", "
2283 "\"reportingEntityId\", "
2285 "\"suppressedNvPairsList\": ["
2287 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2288 "\"suppressedNvPairNames\": [\"name3\", \"name4\"]"
2295 "\"commonEventHeader\": {"
2296 "\"domain\": \"fault\", "
2297 "\"eventId\": \"122\", "
2298 "\"functionalRole\": \"UNIT TEST\", "
2299 "\"lastEpochMicrosec\": 1000002, "
2300 "\"priority\": \"Normal\", "
2301 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2302 "\"sequence\": 122, "
2303 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2304 "\"startEpochMicrosec\": 1000002, "
2307 "\"faultFields\": {"
2308 "\"alarmCondition\": \"My alarm condition\", "
2309 "\"eventSeverity\": \"MAJOR\", "
2310 "\"eventSourceType\": \"other\", "
2311 "\"specificProblem\": \"It broke very badly\", "
2312 "\"vfStatus\": \"Active\", "
2313 "\"faultFieldsVersion\": 1.1, "
2314 "\"alarmAdditionalInformation\": ["
2315 "{\"name\": \"name1\", "
2316 "\"value\": \"value1\"}, "
2317 "{\"name\": \"name2\", "
2318 "\"value\": \"value2\"}]"
2321 /***************************************************************************/
2322 /* Initialize and provide a specification with a single fault suppressed. */
2323 /***************************************************************************/
2324 evel_throttle_initialize();
2325 handle_json_response(json_command_list, &post);
2327 /***************************************************************************/
2328 /* Check that the domain is throttled. */
2329 /***************************************************************************/
2330 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
2331 assert(post.memory == NULL);
2333 size_t json_size = 0;
2334 char json_body[EVEL_MAX_JSON_BODY];
2335 evel_set_next_event_sequence(122);
2336 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
2337 "It broke very badly",
2338 EVEL_PRIORITY_NORMAL,
2339 EVEL_SEVERITY_MAJOR);
2340 assert(fault != NULL);
2341 evel_fault_type_set(fault, "Bad things happen...");
2342 evel_fault_addl_info_add(fault, "name1", "value1");
2343 evel_fault_addl_info_add(fault, "name2", "value2");
2345 /***************************************************************************/
2346 /* Suppressed fields. */
2347 /***************************************************************************/
2348 evel_fault_interface_set(fault, "My Interface Card");
2349 evel_fault_addl_info_add(fault, "name3", "value3");
2350 evel_fault_addl_info_add(fault, "name4", "value4");
2352 json_size = evel_json_encode_event(
2353 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
2354 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
2355 assert((json_size == strlen(json_body)) && "Bad size returned");
2357 evel_free_event(fault);
2358 evel_throttle_terminate();
2361 void test_encode_measurement_throttled()
2365 /***************************************************************************/
2366 /* We also test suppression of the event header parameters here. */
2367 /***************************************************************************/
2368 char * json_command_list =
2370 "\"commandList\": ["
2373 "\"commandType\": \"throttlingSpecification\", "
2374 "\"eventDomainThrottleSpecification\": {"
2375 "\"eventDomain\": \"measurementsForVfScaling\", "
2376 "\"suppressedFieldNames\": ["
2378 "\"vnfcScalingMetric\", "
2379 "\"numberOfMediaPortsInUse\", "
2380 "\"aggregateCpuUsage\", "
2383 "\"memoryConfigured\", "
2384 "\"meanRequestLatency\", "
2385 "\"latencyDistribution\", "
2386 "\"concurrentSessions\", "
2387 "\"configuredEntities\", "
2389 "\"reportingEntityId\", "
2391 "\"suppressedNvPairsList\": ["
2393 "\"nvPairFieldName\": \"cpuUsageArray\", "
2394 "\"suppressedNvPairNames\": [\"cpu3\", \"cpu4\"]"
2397 "\"nvPairFieldName\": \"filesystemUsageArray\", "
2398 "\"suppressedNvPairNames\": [\"00-11-22\", \"33-44-55\"]"
2401 "\"nvPairFieldName\": \"vNicUsageArray\", "
2402 "\"suppressedNvPairNames\": [\"eth1\", \"eth0\"]"
2405 "\"nvPairFieldName\": \"featureUsageArray\", "
2406 "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
2409 "\"nvPairFieldName\": \"codecUsageArray\", "
2410 "\"suppressedNvPairNames\": [\"G729ab\"]"
2413 "\"nvPairFieldName\": \"additionalMeasurements\", "
2414 "\"suppressedNvPairNames\": [\"Group2\"]"
2422 "{\"commonEventHeader\": {"
2423 "\"domain\": \"measurementsForVfScaling\", "
2424 "\"eventId\": \"123\", "
2425 "\"functionalRole\": \"UNIT TEST\", "
2426 "\"lastEpochMicrosec\": 1000002, "
2427 "\"priority\": \"Normal\", "
2428 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2429 "\"sequence\": 123, "
2430 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2431 "\"startEpochMicrosec\": 1000002, "
2434 "\"measurementsForVfScalingFields\": "
2436 "\"measurementInterval\": 5.500000, "
2437 "\"cpuUsageArray\": ["
2438 "{\"cpuIdentifier\": \"cpu1\", "
2439 "\"percentUsage\": 11.110000}, "
2440 "{\"cpuIdentifier\": \"cpu2\", "
2441 "\"percentUsage\": 22.220000}], "
2442 "\"filesystemUsageArray\": ["
2443 "{\"blockConfigured\": 500.110000, "
2444 "\"blockIops\": 77, "
2445 "\"blockUsed\": 500.220000, "
2446 "\"ephemeralConfigured\": 500.110000, "
2447 "\"ephemeralIops\": 88, "
2448 "\"ephemeralUsed\": 600.220000, "
2449 "\"filesystemName\": \"66-77-88\"}], "
2450 "\"featureUsageArray\": ["
2451 "{\"featureIdentifier\": \"FeatureA\", "
2452 "\"featureUtilization\": 123}], "
2453 "\"codecUsageArray\": ["
2454 "{\"codecIdentifier\": \"G711a\", "
2455 "\"numberInUse\": 91}], "
2456 "\"additionalMeasurements\": ["
2457 "{\"name\": \"Group1\", "
2458 "\"measurements\": ["
2459 "{\"name\": \"Name1\", "
2460 "\"value\": \"Value1\"}]}], "
2461 "\"measurementsForVfScalingVersion\": 1.1}}}";
2463 /***************************************************************************/
2464 /* Initialize and provide a specification with a single fault suppressed. */
2465 /***************************************************************************/
2466 evel_throttle_initialize();
2467 handle_json_response(json_command_list, &post);
2469 /***************************************************************************/
2470 /* Check that the domain is throttled. */
2471 /***************************************************************************/
2472 assert(evel_get_throttle_spec(EVEL_DOMAIN_MEASUREMENT) != NULL);
2473 assert(post.memory == NULL);
2475 size_t json_size = 0;
2476 char json_body[EVEL_MAX_JSON_BODY];
2477 evel_set_next_event_sequence(123);
2478 EVENT_MEASUREMENT * measurement = evel_new_measurement(5.5);
2479 MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
2480 MEASUREMENT_VNIC_USE * vnic_use = NULL;
2481 assert(measurement != NULL);
2483 evel_measurement_type_set(measurement, "Perf management...");
2484 evel_measurement_conc_sess_set(measurement, 1);
2485 evel_measurement_cfg_ents_set(measurement, 2);
2486 evel_measurement_mean_req_lat_set(measurement, 4.4);
2487 evel_measurement_mem_cfg_set(measurement, 6.6);
2488 evel_measurement_mem_used_set(measurement, 3.3);
2489 evel_measurement_request_rate_set(measurement, 7);
2490 evel_measurement_agg_cpu_use_set(measurement, 8.8);
2491 evel_measurement_cpu_use_add(measurement, "cpu1", 11.11);
2492 evel_measurement_cpu_use_add(measurement, "cpu2", 22.22);
2493 evel_measurement_cpu_use_add(measurement, "cpu3", 33.33);
2494 evel_measurement_cpu_use_add(measurement, "cpu4", 44.44);
2495 evel_measurement_fsys_use_add(measurement, "00-11-22",
2497 200.11, 200.22, 44);
2498 evel_measurement_fsys_use_add(measurement, "33-44-55",
2500 400.11, 400.22, 66);
2501 evel_measurement_fsys_use_add(measurement, "66-77-88",
2503 600.11, 600.22, 88);
2505 bucket = evel_new_meas_latency_bucket(20);
2506 evel_meas_latency_bucket_add(measurement, bucket);
2508 bucket = evel_new_meas_latency_bucket(30);
2509 evel_meas_latency_bucket_low_end_set(bucket, 10.0);
2510 evel_meas_latency_bucket_high_end_set(bucket, 20.0);
2511 evel_meas_latency_bucket_add(measurement, bucket);
2513 vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4);
2514 evel_vnic_use_bcast_pkt_in_set(vnic_use, 1);
2515 evel_vnic_use_bcast_pkt_out_set(vnic_use, 2);
2516 evel_vnic_use_mcast_pkt_in_set(vnic_use, 5);
2517 evel_vnic_use_mcast_pkt_out_set(vnic_use, 6);
2518 evel_vnic_use_ucast_pkt_in_set(vnic_use, 7);
2519 evel_vnic_use_ucast_pkt_out_set(vnic_use, 8);
2520 evel_meas_vnic_use_add(measurement, vnic_use);
2522 vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14);
2523 evel_vnic_use_bcast_pkt_in_set(vnic_use, 11);
2524 evel_vnic_use_bcast_pkt_out_set(vnic_use, 12);
2525 evel_vnic_use_mcast_pkt_in_set(vnic_use, 15);
2526 evel_vnic_use_mcast_pkt_out_set(vnic_use, 16);
2527 evel_vnic_use_ucast_pkt_in_set(vnic_use, 17);
2528 evel_vnic_use_ucast_pkt_out_set(vnic_use, 18);
2529 evel_meas_vnic_use_add(measurement, vnic_use);
2531 evel_measurement_errors_set(measurement, 1, 0, 2, 1);
2532 evel_measurement_feature_use_add(measurement, "FeatureA", 123);
2533 evel_measurement_feature_use_add(measurement, "FeatureB", 567);
2534 evel_measurement_codec_use_add(measurement, "G711a", 91);
2535 evel_measurement_codec_use_add(measurement, "G729ab", 92);
2536 evel_measurement_media_port_use_set(measurement, 1234);
2537 evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678);
2538 evel_measurement_custom_measurement_add(measurement,
2539 "Group1", "Name1", "Value1");
2540 evel_measurement_custom_measurement_add(measurement,
2541 "Group2", "Name1", "Value1");
2542 evel_measurement_custom_measurement_add(measurement,
2543 "Group2", "Name2", "Value2");
2545 json_size = evel_json_encode_event(
2546 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) measurement);
2547 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Measurement");
2548 assert((json_size == strlen(json_body)) && "Bad size returned");
2550 evel_free_event(measurement);
2551 evel_throttle_terminate();
2554 void test_encode_mobile_throttled()
2558 /***************************************************************************/
2559 /* We also test suppression of the event header parameters here. */
2560 /***************************************************************************/
2561 char * json_command_list =
2563 "\"commandList\": ["
2566 "\"commandType\": \"throttlingSpecification\", "
2567 "\"eventDomainThrottleSpecification\": {"
2568 "\"eventDomain\": \"mobileFlow\", "
2569 "\"suppressedFieldNames\": ["
2570 "\"applicationType\", "
2571 "\"appProtocolType\", "
2572 "\"appProtocolVersion\", "
2574 "\"connectionType\", "
2576 "\"gtpProtocolType\", "
2585 "\"otherFunctionalRole\", "
2587 "\"radioAccessTechnology\", "
2589 "\"samplingAlgorithm\", "
2594 "\"reportingEntityId\", "
2596 "\"suppressedNvPairsList\": ["
2603 "{\"commonEventHeader\": {"
2604 "\"domain\": \"mobileFlow\", "
2605 "\"eventId\": \"1242\", "
2606 "\"functionalRole\": \"UNIT TEST\", "
2607 "\"lastEpochMicrosec\": 1000002, "
2608 "\"priority\": \"Normal\", "
2609 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2610 "\"sequence\": 1242, "
2611 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2612 "\"startEpochMicrosec\": 1000002, "
2615 "\"mobileFlowFields\": {"
2616 "\"flowDirection\": \"Inbound\", "
2617 "\"gtpPerFlowMetrics\": {"
2618 "\"avgBitErrorRate\": 132.000100, "
2619 "\"avgPacketDelayVariation\": 31.200000, "
2620 "\"avgPacketLatency\": 101, "
2621 "\"avgReceiveThroughput\": 2101, "
2622 "\"avgTransmitThroughput\": 501, "
2623 "\"flowActivationEpoch\": 1470409422, "
2624 "\"flowActivationMicrosec\": 988, "
2625 "\"flowDeactivationEpoch\": 1470409432, "
2626 "\"flowDeactivationMicrosec\": 12, "
2627 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
2628 "\"flowStatus\": \"Inactive\", "
2629 "\"maxPacketDelayVariation\": 88, "
2630 "\"numActivationFailures\": 4, "
2631 "\"numBitErrors\": 18, "
2632 "\"numBytesReceived\": 123655, "
2633 "\"numBytesTransmitted\": 4562, "
2634 "\"numDroppedPackets\": 1, "
2635 "\"numL7BytesReceived\": 13, "
2636 "\"numL7BytesTransmitted\": 11, "
2637 "\"numLostPackets\": 2, "
2638 "\"numOutOfOrderPackets\": 4, "
2639 "\"numPacketErrors\": 8, "
2640 "\"numPacketsReceivedExclRetrans\": 900, "
2641 "\"numPacketsReceivedInclRetrans\": 902, "
2642 "\"numPacketsTransmittedInclRetrans\": 303, "
2643 "\"numRetries\": 7, "
2644 "\"numTimeouts\": 3, "
2645 "\"numTunneledL7BytesReceived\": 1, "
2646 "\"roundTripTime\": 111, "
2647 "\"timeToFirstByte\": 226, "
2648 "\"ipTosCountList\": ["
2652 "\"ipTosList\": [\"1\", \"4\", \"17\"], "
2653 "\"tcpFlagList\": [\"CWR\", \"URG\"], "
2654 "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
2655 "\"mobileQciCosList\": [\"conversational\", \"65\"], "
2656 "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
2657 "\"durConnectionFailedStatus\": 12, "
2658 "\"durTunnelFailedStatus\": 13, "
2659 "\"flowActivatedBy\": \"Remote\", "
2660 "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
2661 "\"flowDeactivatedBy\": \"Remote\", "
2662 "\"gtpConnectionStatus\": \"Connected\", "
2663 "\"gtpTunnelStatus\": \"Not tunneling\", "
2664 "\"largePacketRtt\": 80, "
2665 "\"largePacketThreshold\": 600.000000, "
2666 "\"maxReceiveBitRate\": 1357924680, "
2667 "\"maxTransmitBitRate\": 235711, "
2668 "\"numGtpEchoFailures\": 1, "
2669 "\"numGtpTunnelErrors\": 4, "
2670 "\"numHttpErrors\": 2"
2672 "\"ipProtocolType\": \"UDP\", "
2673 "\"ipVersion\": \"IPv6\", "
2674 "\"otherEndpointIpAddress\": \"2.3.4.2\", "
2675 "\"otherEndpointPort\": 2342, "
2676 "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
2677 "\"reportingEndpointPort\": 4322"
2680 /***************************************************************************/
2681 /* Initialize and provide a specification with a single fault suppressed. */
2682 /***************************************************************************/
2683 evel_throttle_initialize();
2684 handle_json_response(json_command_list, &post);
2686 /***************************************************************************/
2687 /* Check that the domain is throttled. */
2688 /***************************************************************************/
2689 assert(evel_get_throttle_spec(EVEL_DOMAIN_MOBILE_FLOW) != NULL);
2690 assert(post.memory == NULL);
2692 size_t json_size = 0;
2693 char json_body[EVEL_MAX_JSON_BODY];
2694 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
2695 EVENT_MOBILE_FLOW * mobile_flow = NULL;
2697 /***************************************************************************/
2699 /***************************************************************************/
2700 evel_set_next_event_sequence(1242);
2702 metrics = evel_new_mobile_gtp_flow_metrics(132.0001,
2732 assert(metrics != NULL);
2734 evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12);
2735 evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13);
2736 evel_mobile_gtp_metrics_act_by_set(metrics, "Remote");
2737 evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423);
2738 evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote");
2739 evel_mobile_gtp_metrics_con_status_set(metrics, "Connected");
2740 evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling");
2741 evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13);
2742 evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1);
2743 evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99);
2744 evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80);
2745 evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0);
2746 evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680);
2747 evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711);
2748 evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1);
2749 evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4);
2750 evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2);
2751 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10);
2752 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121);
2753 evel_mobile_gtp_metrics_qci_cos_count_add(
2754 metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11);
2755 evel_mobile_gtp_metrics_qci_cos_count_add(
2756 metrics, EVEL_QCI_COS_LTE_65, 122);
2758 mobile_flow = evel_new_mobile_flow("Inbound",
2766 assert(mobile_flow != NULL);
2768 evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
2769 evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
2770 evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
2771 evel_mobile_flow_app_prot_ver_set(mobile_flow, "1");
2772 evel_mobile_flow_cid_set(mobile_flow, "65535");
2773 evel_mobile_flow_con_type_set(mobile_flow, "S1-U");
2774 evel_mobile_flow_ecgi_set(mobile_flow, "e65535");
2775 evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U");
2776 evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1");
2777 evel_mobile_flow_http_header_set(mobile_flow,
2778 "http://www.something.com");
2779 evel_mobile_flow_imei_set(mobile_flow, "209917614823");
2780 evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8");
2781 evel_mobile_flow_lac_set(mobile_flow, "1");
2782 evel_mobile_flow_mcc_set(mobile_flow, "410");
2783 evel_mobile_flow_mnc_set(mobile_flow, "04");
2784 evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789");
2785 evel_mobile_flow_other_func_role_set(mobile_flow, "MME");
2786 evel_mobile_flow_rac_set(mobile_flow, "514");
2787 evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE");
2788 evel_mobile_flow_sac_set(mobile_flow, "1");
2789 evel_mobile_flow_samp_alg_set(mobile_flow, 1);
2790 evel_mobile_flow_tac_set(mobile_flow, "2099");
2791 evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1");
2792 evel_mobile_flow_vlan_id_set(mobile_flow, "15");
2794 json_size = evel_json_encode_event(
2795 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
2796 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
2797 assert((json_size == strlen(json_body)) && "Bad size returned");
2799 evel_free_event(mobile_flow);
2800 evel_throttle_terminate();
2803 void test_encode_other_throttled()
2807 /***************************************************************************/
2808 /* We also test suppression of the event header parameters here. */
2809 /***************************************************************************/
2810 char * json_command_list =
2812 "\"commandList\": ["
2815 "\"commandType\": \"throttlingSpecification\", "
2816 "\"eventDomainThrottleSpecification\": {"
2817 "\"eventDomain\": \"other\", "
2818 "\"suppressedFieldNames\": ["
2820 "\"reportingEntityId\", "
2822 "\"suppressedNvPairsList\": ["
2829 "{\"commonEventHeader\": {"
2830 "\"domain\": \"other\", "
2831 "\"eventId\": \"129\", "
2832 "\"functionalRole\": \"UNIT TEST\", "
2833 "\"lastEpochMicrosec\": 1000002, "
2834 "\"priority\": \"Normal\", "
2835 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2836 "\"sequence\": 129, "
2837 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2838 "\"startEpochMicrosec\": 1000002, "
2841 "\"otherFields\": ["
2842 "{\"name\": \"Other field 1\", "
2843 "\"value\": \"Other value 1\"}, "
2844 "{\"name\": \"Other field 2\", "
2845 "\"value\": \"Other value 2\"}"
2849 /***************************************************************************/
2850 /* Initialize and provide a specification with a single fault suppressed. */
2851 /***************************************************************************/
2852 evel_throttle_initialize();
2853 handle_json_response(json_command_list, &post);
2855 /***************************************************************************/
2856 /* Check that the domain is throttled. */
2857 /***************************************************************************/
2858 assert(evel_get_throttle_spec(EVEL_DOMAIN_OTHER) != NULL);
2859 assert(post.memory == NULL);
2861 size_t json_size = 0;
2862 char json_body[EVEL_MAX_JSON_BODY];
2863 EVENT_OTHER * other = NULL;
2864 evel_set_next_event_sequence(129);
2865 other = evel_new_other();
2866 assert(other != NULL);
2867 evel_other_type_set(other, "Other Type");
2868 evel_other_field_add(other,
2871 evel_other_field_add(other,
2875 json_size = evel_json_encode_event(
2876 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) other);
2877 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Other");
2878 assert((json_size == strlen(json_body)) && "Bad size returned");
2880 evel_free_event(other);
2881 evel_throttle_terminate();
2884 void test_encode_report_throttled()
2888 /***************************************************************************/
2889 /* We also test suppression of the event header parameters here. */
2890 /***************************************************************************/
2891 char * json_command_list =
2893 "\"commandList\": ["
2896 "\"commandType\": \"throttlingSpecification\", "
2897 "\"eventDomainThrottleSpecification\": {"
2898 "\"eventDomain\": \"report\", "
2899 "\"suppressedFieldNames\": ["
2901 "\"reportingEntityId\", "
2903 "\"suppressedNvPairsList\": ["
2905 "\"nvPairFieldName\": \"featureUsageArray\", "
2906 "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
2909 "\"nvPairFieldName\": \"additionalMeasurements\", "
2910 "\"suppressedNvPairNames\": [\"Group2\"]"
2918 "{\"commonEventHeader\": {"
2919 "\"domain\": \"measurementsForVfReporting\", "
2920 "\"eventId\": \"125\", "
2921 "\"functionalRole\": \"UNIT TEST\", "
2922 "\"lastEpochMicrosec\": 1000002, "
2923 "\"priority\": \"Normal\", "
2924 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2925 "\"sequence\": 125, "
2926 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2927 "\"startEpochMicrosec\": 1000002, "
2930 "\"measurementsForVfReportingFields\": "
2931 "{\"measurementInterval\": 1.100000, "
2932 "\"featureUsageArray\": ["
2933 "{\"featureIdentifier\": \"FeatureA\", "
2934 "\"featureUtilization\": 123}], "
2935 "\"additionalMeasurements\": ["
2936 "{\"name\": \"Group1\", "
2937 "\"measurements\": ["
2938 "{\"name\": \"Name1\", "
2939 "\"value\": \"Value1\"}]}], "
2940 "\"measurementFieldsVersion\": 1.1}}}";
2942 /***************************************************************************/
2943 /* Initialize and provide a specification with a single fault suppressed. */
2944 /***************************************************************************/
2945 evel_throttle_initialize();
2946 handle_json_response(json_command_list, &post);
2948 /***************************************************************************/
2949 /* Check that the domain is throttled. */
2950 /***************************************************************************/
2951 assert(evel_get_throttle_spec(EVEL_DOMAIN_REPORT) != NULL);
2952 assert(post.memory == NULL);
2954 size_t json_size = 0;
2955 char json_body[EVEL_MAX_JSON_BODY];
2956 EVENT_REPORT * report = NULL;
2958 /***************************************************************************/
2960 /***************************************************************************/
2961 evel_set_next_event_sequence(125);
2962 report = evel_new_report(1.1);
2963 assert(report != NULL);
2964 evel_report_type_set(report, "Perf reporting...");
2965 evel_report_feature_use_add(report, "FeatureA", 123);
2966 evel_report_feature_use_add(report, "FeatureB", 567);
2967 evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
2968 evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
2969 evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
2971 json_size = evel_json_encode_event(
2972 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
2973 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
2974 assert((json_size == strlen(json_body)) && "Bad size returned");
2976 evel_free_event(report);
2977 evel_throttle_terminate();
2980 void test_encode_service_throttled()
2984 /***************************************************************************/
2985 /* We also test suppression of the event header parameters here. */
2986 /***************************************************************************/
2987 char * json_command_list =
2989 "\"commandList\": ["
2992 "\"commandType\": \"throttlingSpecification\", "
2993 "\"eventDomainThrottleSpecification\": {"
2994 "\"eventDomain\": \"serviceEvents\", "
2995 "\"suppressedFieldNames\": ["
2998 "\"codecSelected\", "
2999 "\"codecSelectedTranscoding\", "
3000 "\"endOfCallVqmSummaries\", "
3003 "\"reportingEntityId\", "
3005 "\"suppressedNvPairsList\": ["
3007 "\"nvPairFieldName\": \"additionalFields\", "
3008 "\"suppressedNvPairNames\": [\"Name1\", \"Name3\"]"
3016 "{\"commonEventHeader\": {"
3017 "\"domain\": \"serviceEvents\", "
3018 "\"eventId\": \"2000\", "
3019 "\"functionalRole\": \"UNIT TEST\", "
3020 "\"lastEpochMicrosec\": 1000002, "
3021 "\"priority\": \"Normal\", "
3022 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3023 "\"sequence\": 2000, "
3024 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3025 "\"startEpochMicrosec\": 1000002, "
3028 "\"serviceEventsFields\": {"
3029 "\"eventInstanceIdentifier\": "
3031 "\"vendorId\": \"vendor_x_id\", "
3032 "\"eventId\": \"vendor_x_event_id\", "
3033 "\"productId\": \"vendor_x_product_id\", "
3034 "\"subsystemId\": \"vendor_x_subsystem_id\", "
3035 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
3037 "\"serviceEventsFieldsVersion\": 1.1, "
3038 "\"additionalFields\": ["
3039 "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
3040 "{\"name\": \"Name4\", \"value\": \"Value4\"}]"
3043 /***************************************************************************/
3044 /* Initialize and provide a specification with a single fault suppressed. */
3045 /***************************************************************************/
3046 evel_throttle_initialize();
3047 handle_json_response(json_command_list, &post);
3049 /***************************************************************************/
3050 /* Check that the domain is throttled. */
3051 /***************************************************************************/
3052 assert(evel_get_throttle_spec(EVEL_DOMAIN_SERVICE) != NULL);
3053 assert(post.memory == NULL);
3055 size_t json_size = 0;
3056 char json_body[EVEL_MAX_JSON_BODY];
3057 EVENT_SERVICE * event = NULL;
3058 evel_set_next_event_sequence(2000);
3059 event = evel_new_service("vendor_x_id", "vendor_x_event_id");
3060 assert(event != NULL);
3061 evel_service_type_set(event, "Service Event");
3062 evel_service_product_id_set(event, "vendor_x_product_id");
3063 evel_service_subsystem_id_set(event, "vendor_x_subsystem_id");
3064 evel_service_friendly_name_set(event, "vendor_x_frieldly_name");
3065 evel_service_correlator_set(event, "vendor_x_correlator");
3066 evel_service_codec_set(event, "PCMA");
3067 evel_service_codec_set(event, "PCMA");
3068 evel_service_callee_codec_set(event, "PCMA");
3069 evel_service_caller_codec_set(event, "G729A");
3070 evel_service_rtcp_data_set(event, "some_rtcp_data");
3071 evel_service_adjacency_name_set(event, "vendor_x_adjacency");
3072 evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER);
3073 evel_service_endpoint_jitter_set(event, 66);
3074 evel_service_endpoint_rtp_oct_disc_set(event, 100);
3075 evel_service_endpoint_rtp_oct_recv_set(event, 200);
3076 evel_service_endpoint_rtp_oct_sent_set(event, 300);
3077 evel_service_endpoint_rtp_pkt_disc_set(event, 400);
3078 evel_service_endpoint_rtp_pkt_recv_set(event, 500);
3079 evel_service_endpoint_rtp_pkt_sent_set(event, 600);
3080 evel_service_local_jitter_set(event, 99);
3081 evel_service_local_rtp_oct_disc_set(event, 150);
3082 evel_service_local_rtp_oct_recv_set(event, 250);
3083 evel_service_local_rtp_oct_sent_set(event, 350);
3084 evel_service_local_rtp_pkt_disc_set(event, 450);
3085 evel_service_local_rtp_pkt_recv_set(event, 550);
3086 evel_service_local_rtp_pkt_sent_set(event, 650);
3087 evel_service_mos_cqe_set(event, 12.255);
3088 evel_service_packets_lost_set(event, 157);
3089 evel_service_packet_loss_percent_set(event, 0.232);
3090 evel_service_r_factor_set(event, 11);
3091 evel_service_round_trip_delay_set(event, 15);
3092 evel_service_phone_number_set(event, "0888888888");
3093 evel_service_addl_field_add(event, "Name1", "Value1");
3094 evel_service_addl_field_add(event, "Name2", "Value2");
3095 evel_service_addl_field_add(event, "Name3", "Value3");
3096 evel_service_addl_field_add(event, "Name4", "Value4");
3097 json_size = evel_json_encode_event(
3098 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
3099 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
3100 assert((json_size == strlen(json_body)) && "Bad size returned");
3102 evel_free_event(event);
3103 evel_throttle_terminate();
3106 void test_encode_signaling_throttled()
3110 /***************************************************************************/
3111 /* We also test suppression of the event header parameters here. */
3112 /***************************************************************************/
3113 char * json_command_list =
3115 "\"commandList\": ["
3118 "\"commandType\": \"throttlingSpecification\", "
3119 "\"eventDomainThrottleSpecification\": {"
3120 "\"eventDomain\": \"signaling\", "
3121 "\"suppressedFieldNames\": ["
3124 "\"reportingEntityId\", "
3126 "\"localIpAddress\", "
3128 "\"remoteIpAddress\", "
3130 "\"compressedSip\", "
3132 "\"suppressedNvPairsList\": ["
3139 "{\"commonEventHeader\": {"
3140 "\"domain\": \"signaling\", "
3141 "\"eventId\": \"2001\", "
3142 "\"functionalRole\": \"UNIT TEST\", "
3143 "\"lastEpochMicrosec\": 1000002, "
3144 "\"priority\": \"Normal\", "
3145 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3146 "\"sequence\": 2001, "
3147 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3148 "\"startEpochMicrosec\": 1000002, "
3151 "\"signalingFields\": {"
3152 "\"eventInstanceIdentifier\": "
3154 "\"vendorId\": \"vendor_x_id\", "
3155 "\"eventId\": \"vendor_x_event_id\", "
3156 "\"productId\": \"vendor_x_product_id\", "
3157 "\"subsystemId\": \"vendor_x_subsystem_id\", "
3158 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
3160 "\"signalingFieldsVersion\": 1.1"
3163 /***************************************************************************/
3164 /* Initialize and provide a specification with a single fault suppressed. */
3165 /***************************************************************************/
3166 evel_throttle_initialize();
3167 handle_json_response(json_command_list, &post);
3169 /***************************************************************************/
3170 /* Check that the domain is throttled. */
3171 /***************************************************************************/
3172 assert(evel_get_throttle_spec(EVEL_DOMAIN_SIGNALING) != NULL);
3173 assert(post.memory == NULL);
3175 size_t json_size = 0;
3176 char json_body[EVEL_MAX_JSON_BODY];
3177 EVENT_SIGNALING * event = NULL;
3178 evel_set_next_event_sequence(2001);
3179 event = evel_new_signaling("vendor_x_id", "vendor_x_event_id");
3180 assert(event != NULL);
3181 evel_signaling_type_set(event, "Signaling");
3182 evel_signaling_product_id_set(event, "vendor_x_product_id");
3183 evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id");
3184 evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name");
3185 evel_signaling_correlator_set(event, "vendor_x_correlator");
3186 evel_signaling_local_ip_address_set(event, "1.0.3.1");
3187 evel_signaling_local_port_set(event, "1031");
3188 evel_signaling_remote_ip_address_set(event, "5.3.3.0");
3189 evel_signaling_remote_port_set(event, "5330");
3190 evel_signaling_compressed_sip_set(event, "compressed_sip");
3191 evel_signaling_summary_sip_set(event, "summary_sip");
3192 json_size = evel_json_encode_event(
3193 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
3194 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Signaling");
3195 assert((json_size == strlen(json_body)) && "Bad size returned");
3197 evel_free_event(event);
3198 evel_throttle_terminate();
3201 void test_encode_state_change_throttled()
3205 /***************************************************************************/
3206 /* We also test suppression of the event header parameters here. */
3207 /***************************************************************************/
3208 char * json_command_list =
3210 "\"commandList\": ["
3213 "\"commandType\": \"throttlingSpecification\", "
3214 "\"eventDomainThrottleSpecification\": {"
3215 "\"eventDomain\": \"stateChange\", "
3216 "\"suppressedFieldNames\": ["
3218 "\"reportingEntityId\", "
3220 "\"suppressedNvPairsList\": ["
3222 "\"nvPairFieldName\": \"additionalFields\", "
3223 "\"suppressedNvPairNames\": [\"Name1\"]"
3231 "{\"commonEventHeader\": {"
3232 "\"domain\": \"stateChange\", "
3233 "\"eventId\": \"128\", "
3234 "\"functionalRole\": \"UNIT TEST\", "
3235 "\"lastEpochMicrosec\": 1000002, "
3236 "\"priority\": \"Normal\", "
3237 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3238 "\"sequence\": 128, "
3239 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3240 "\"startEpochMicrosec\": 1000002, "
3243 "\"stateChangeFields\": {"
3244 "\"newState\": \"inService\", "
3245 "\"oldState\": \"outOfService\", "
3246 "\"stateInterface\": \"An Interface\", "
3247 "\"additionalFields\": ["
3248 "{\"name\": \"Name2\", "
3249 "\"value\": \"Value2\"}"
3251 "\"stateChangeFieldsVersion\": 1.1"
3254 /***************************************************************************/
3255 /* Initialize and provide a specification with a single fault suppressed. */
3256 /***************************************************************************/
3257 evel_throttle_initialize();
3258 handle_json_response(json_command_list, &post);
3260 /***************************************************************************/
3261 /* Check that the domain is throttled. */
3262 /***************************************************************************/
3263 assert(evel_get_throttle_spec(EVEL_DOMAIN_STATE_CHANGE) != NULL);
3264 assert(post.memory == NULL);
3266 size_t json_size = 0;
3267 char json_body[EVEL_MAX_JSON_BODY];
3268 EVENT_STATE_CHANGE * state_change = NULL;
3269 evel_set_next_event_sequence(128);
3270 state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE,
3271 EVEL_ENTITY_STATE_OUT_OF_SERVICE,
3273 assert(state_change != NULL);
3274 evel_state_change_type_set(state_change, "SC Type");
3275 evel_state_change_addl_field_add(state_change, "Name1", "Value1");
3276 evel_state_change_addl_field_add(state_change, "Name2", "Value2");
3278 json_size = evel_json_encode_event(
3279 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) state_change);
3280 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "StateChange");
3281 assert((json_size == strlen(json_body)) && "Bad size returned");
3283 evel_free_event(state_change);
3284 evel_throttle_terminate();
3287 void test_encode_syslog_throttled()
3291 /***************************************************************************/
3292 /* We also test suppression of the event header parameters here. */
3293 /***************************************************************************/
3294 char * json_command_list =
3296 "\"commandList\": ["
3299 "\"commandType\": \"throttlingSpecification\", "
3300 "\"eventDomainThrottleSpecification\": {"
3301 "\"eventDomain\": \"syslog\", "
3302 "\"suppressedFieldNames\": ["
3303 "\"eventSourceHost\", "
3304 "\"syslogFacility\", "
3306 "\"syslogProcId\", "
3310 "\"reportingEntityId\", "
3312 "\"suppressedNvPairsList\": ["
3314 "\"nvPairFieldName\": \"additionalFields\", "
3315 "\"suppressedNvPairNames\": [\"Name2\"]"
3323 "{\"commonEventHeader\": {"
3324 "\"domain\": \"syslog\", "
3325 "\"eventId\": \"126\", "
3326 "\"functionalRole\": \"UNIT TEST\", "
3327 "\"lastEpochMicrosec\": 1000002, "
3328 "\"priority\": \"Normal\", "
3329 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3330 "\"sequence\": 126, "
3331 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3332 "\"startEpochMicrosec\": 1000002, "
3335 "\"syslogFields\": {"
3336 "\"eventSourceType\": \"virtualNetworkFunction\", "
3337 "\"syslogMsg\": \"SL Message\", "
3338 "\"syslogTag\": \"SL Tag\", "
3339 "\"syslogFieldsVersion\": 1.1, "
3340 "\"additionalFields\": ["
3341 "{\"name\": \"Name1\", "
3342 "\"value\": \"Value1\"}"
3346 /***************************************************************************/
3347 /* Initialize and provide a specification with a single fault suppressed. */
3348 /***************************************************************************/
3349 evel_throttle_initialize();
3350 handle_json_response(json_command_list, &post);
3352 /***************************************************************************/
3353 /* Check that the domain is throttled. */
3354 /***************************************************************************/
3355 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
3356 assert(post.memory == NULL);
3358 size_t json_size = 0;
3359 char json_body[EVEL_MAX_JSON_BODY];
3360 EVENT_SYSLOG * syslog = NULL;
3361 evel_set_next_event_sequence(126);
3362 syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION,
3365 assert(syslog != NULL);
3366 evel_syslog_type_set(syslog, "SL Type");
3367 evel_syslog_event_source_host_set(syslog, "SL Host");
3368 evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
3369 evel_syslog_proc_set(syslog, "SL Proc");
3370 evel_syslog_proc_id_set(syslog, 2);
3371 evel_syslog_version_set(syslog, 1);
3372 evel_syslog_s_data_set(syslog, "SL SDATA");
3373 evel_syslog_addl_field_add(syslog, "Name1", "Value1");
3374 evel_syslog_addl_field_add(syslog, "Name2", "Value2");
3376 json_size = evel_json_encode_event(
3377 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog);
3378 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog");
3379 assert((json_size == strlen(json_body)) && "Bad size returned");
3381 evel_free_event(syslog);
3382 evel_throttle_terminate();
3385 void test_encode_fault_with_escaping()
3389 "\"commonEventHeader\": {"
3390 "\"domain\": \"fault\", "
3391 "\"eventId\": \"122\", "
3392 "\"functionalRole\": \"UNIT TEST\", "
3393 "\"lastEpochMicrosec\": 1000002, "
3394 "\"priority\": \"Normal\", "
3395 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3396 "\"sequence\": 122, "
3397 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3398 "\"startEpochMicrosec\": 1000002, "
3399 "\"version\": 1.2, "
3400 "\"eventType\": \"Bad things happen...\\\\\", "
3401 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
3402 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
3404 "\"faultFields\": {"
3405 "\"alarmCondition\": \"My alarm condition\", "
3406 "\"eventSeverity\": \"MAJOR\", "
3407 "\"eventSourceType\": \"other\", "
3408 "\"specificProblem\": \"It broke \\\"very\\\" badly\", "
3409 "\"vfStatus\": \"Active\", "
3410 "\"faultFieldsVersion\": 1.1, "
3411 "\"alarmAdditionalInformation\": ["
3412 "{\"name\": \"name1\", "
3413 "\"value\": \"value1\"}, "
3414 "{\"name\": \"name2\", "
3415 "\"value\": \"value2\"}], "
3416 "\"alarmInterfaceA\": \"My Interface Card\""
3419 size_t json_size = 0;
3420 char json_body[EVEL_MAX_JSON_BODY];
3421 evel_set_next_event_sequence(122);
3422 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
3423 "It broke \"very\" badly",
3424 EVEL_PRIORITY_NORMAL,
3425 EVEL_SEVERITY_MAJOR);
3426 assert(fault != NULL);
3427 evel_fault_type_set(fault, "Bad things happen...\\");
3428 evel_fault_interface_set(fault, "My Interface Card");
3429 evel_fault_addl_info_add(fault, "name1", "value1");
3430 evel_fault_addl_info_add(fault, "name2", "value2");
3432 json_size = evel_json_encode_event(
3433 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
3434 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
3435 assert((json_size == strlen(json_body)) && "Bad size returned");
3437 evel_free_event(fault);