1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Unless otherwise specified, all software contained herein is
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
18 ****************************************************************************/
19 /**************************************************************************//**
21 * Unit tests for JSON encoding and throttling.
23 * This software is intended to show the essential elements of the library's
26 ****************************************************************************/
35 #include "evel_internal.h"
36 #include "evel_throttle.h"
48 /*****************************************************************************/
49 /* Local prototypes. */
50 /*****************************************************************************/
51 static void test_encode_heartbeat();
52 static void test_encode_header_overrides();
53 static void test_encode_fault();
54 static void test_encode_fault_with_escaping();
55 static void test_encode_measurement();
56 static void test_encode_mobile_mand();
57 static void test_encode_mobile_opts();
58 static void test_encode_other();
59 static void test_encode_report();
60 static void test_encode_service();
61 static void test_encode_service_subset(const SERVICE_TEST service_test);
62 static void test_encode_signaling();
63 static void test_encode_state_change();
64 static void test_encode_syslog();
65 static void test_json_response_junk();
66 static void test_json_provide_throttle_state();
67 static void test_json_measurement_interval();
68 static void test_json_throttle_spec_field();
69 static void test_json_throttle_spec_nv_pair();
70 static void test_json_throttle_spec_two_domains();
71 static void test_json_throttle_spec_bad_command_type();
72 static void test_encode_fault_throttled();
73 static void test_encode_measurement_throttled();
74 static void test_encode_mobile_throttled();
75 static void test_encode_other_throttled();
76 static void test_encode_report_throttled();
77 static void test_encode_service_throttled();
78 static void test_encode_signaling_throttled();
79 static void test_encode_state_change_throttled();
80 static void test_encode_syslog_throttled();
81 static void compare_strings(char * expected,
86 /**************************************************************************//**
89 * Runs all unit test cases, and fails hard on the first failure.
91 * @param[in] argc Argument count.
92 * @param[in] argv Argument vector - for usage see usage_text.
93 *****************************************************************************/
94 int main(int argc, char ** argv)
99 /***************************************************************************/
100 /* Fix our timezone to UTC. */
101 /***************************************************************************/
104 /***************************************************************************/
105 /* Initialize metadata. */
106 /***************************************************************************/
107 openstack_metadata_initialize();
109 /***************************************************************************/
110 /* Minimal initialisation to exercise the encoders. */
111 /***************************************************************************/
112 functional_role = "UNIT TEST";
113 log_initialize(EVEL_LOG_DEBUG, "EVEL");
115 /***************************************************************************/
116 /* Test each encoder. */
117 /***************************************************************************/
118 test_encode_heartbeat();
119 test_encode_header_overrides();
121 test_encode_measurement();
122 test_encode_mobile_mand();
123 test_encode_mobile_opts();
125 test_encode_report();
126 test_encode_service();
127 test_encode_signaling();
128 test_encode_state_change();
129 test_encode_syslog();
131 /***************************************************************************/
132 /* Test JSON Throttle. */
133 /***************************************************************************/
134 test_json_response_junk();
135 test_json_provide_throttle_state();
136 test_json_measurement_interval();
137 test_json_throttle_spec_field();
138 test_json_throttle_spec_nv_pair();
139 test_json_throttle_spec_two_domains();
140 test_json_throttle_spec_bad_command_type();
142 /***************************************************************************/
143 /* Test each encoder with throttling applied. */
144 /***************************************************************************/
145 test_encode_fault_throttled();
146 test_encode_measurement_throttled();
147 test_encode_mobile_throttled();
148 test_encode_other_throttled();
149 test_encode_report_throttled();
150 test_encode_service_throttled();
151 test_encode_signaling_throttled();
152 test_encode_state_change_throttled();
153 test_encode_syslog_throttled();
155 /***************************************************************************/
156 /* Test character escaping. */
157 /***************************************************************************/
158 test_encode_fault_with_escaping();
160 printf ("\nAll Tests Passed\n");
165 /*****************************************************************************/
166 /* We link with this gettimeofday so that we get a fixed result */
167 /*****************************************************************************/
168 int gettimeofday(struct timeval *tv,
169 struct timezone *tz __attribute__((unused)))
176 void test_encode_heartbeat()
180 "\"commonEventHeader\": {"
181 "\"domain\": \"heartbeat\", "
182 "\"eventId\": \"121\", "
183 "\"functionalRole\": \"UNIT TEST\", "
184 "\"lastEpochMicrosec\": 1000002, "
185 "\"priority\": \"Normal\", "
186 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
187 "\"sequence\": 121, "
188 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
189 "\"startEpochMicrosec\": 1000002, "
191 "\"eventType\": \"Autonomous heartbeat\", "
192 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
193 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
196 size_t json_size = 0;
197 char json_body[EVEL_MAX_JSON_BODY];
199 /***************************************************************************/
200 /* Test the VM name/uuid once. */
201 /***************************************************************************/
202 evel_set_next_event_sequence(121);
204 EVENT_HEADER * heartbeat = evel_new_heartbeat();
205 assert(heartbeat != NULL);
207 json_size = evel_json_encode_event(
208 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat);
209 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat");
210 assert((json_size == strlen(json_body)) && "Bad size returned");
212 evel_free_event(heartbeat);
215 void test_encode_header_overrides()
219 "\"commonEventHeader\": {"
220 "\"domain\": \"heartbeat\", "
221 "\"eventId\": \"121\", "
222 "\"functionalRole\": \"UNIT TEST\", "
223 "\"lastEpochMicrosec\": 1000, "
224 "\"priority\": \"Normal\", "
225 "\"reportingEntityName\": \"entity_name_override\", "
226 "\"sequence\": 121, "
227 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
228 "\"startEpochMicrosec\": 1001, "
230 "\"eventType\": \"Autonomous heartbeat\", "
231 "\"reportingEntityId\": \"entity_id_override\", "
232 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
235 size_t json_size = 0;
236 char json_body[EVEL_MAX_JSON_BODY];
238 /***************************************************************************/
239 /* Test the VM name/uuid once. */
240 /***************************************************************************/
241 evel_set_next_event_sequence(121);
243 EVENT_HEADER * heartbeat = evel_new_heartbeat();
244 assert(heartbeat != NULL);
246 evel_start_epoch_set(heartbeat, 1001);
247 evel_last_epoch_set(heartbeat, 1000);
248 evel_reporting_entity_name_set(heartbeat, "entity_name_override");
249 evel_reporting_entity_id_set(heartbeat, "entity_id_override");
251 json_size = evel_json_encode_event(
252 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) heartbeat);
253 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Heartbeat");
254 assert((json_size == strlen(json_body)) && "Bad size returned");
256 evel_free_event(heartbeat);
259 void test_encode_fault()
263 "\"commonEventHeader\": {"
264 "\"domain\": \"fault\", "
265 "\"eventId\": \"122\", "
266 "\"functionalRole\": \"UNIT TEST\", "
267 "\"lastEpochMicrosec\": 1000002, "
268 "\"priority\": \"Normal\", "
269 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
270 "\"sequence\": 122, "
271 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
272 "\"startEpochMicrosec\": 1000002, "
274 "\"eventType\": \"Bad things happen...\", "
275 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
276 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
279 "\"alarmCondition\": \"My alarm condition\", "
280 "\"eventSeverity\": \"MAJOR\", "
281 "\"eventSourceType\": \"other\", "
282 "\"specificProblem\": \"It broke very badly\", "
283 "\"eventCategory\": \"link\", "
284 "\"vfStatus\": \"Active\", "
285 "\"faultFieldsVersion\": 1.1, "
286 "\"alarmAdditionalInformation\": ["
287 "{\"name\": \"name1\", "
288 "\"value\": \"value1\"}, "
289 "{\"name\": \"name2\", "
290 "\"value\": \"value2\"}], "
291 "\"alarmInterfaceA\": \"My Interface Card\""
294 size_t json_size = 0;
295 char json_body[EVEL_MAX_JSON_BODY];
296 evel_set_next_event_sequence(122);
297 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
298 "It broke very badly",
299 EVEL_PRIORITY_NORMAL,
302 EVEL_VF_STATUS_PREP_TERMINATE);
303 assert(fault != NULL);
304 evel_fault_type_set(fault, "Bad things happen...");
305 evel_fault_interface_set(fault, "My Interface Card");
306 evel_fault_addl_info_add(fault, "name1", "value1");
307 evel_fault_addl_info_add(fault, "name2", "value2");
309 json_size = evel_json_encode_event(
310 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
311 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
312 assert((json_size == strlen(json_body)) && "Bad size returned");
314 evel_free_event(fault);
317 void test_encode_measurement()
321 "{\"commonEventHeader\": {"
322 "\"domain\": \"measurementsForVfScaling\", "
323 "\"eventId\": \"123\", "
324 "\"functionalRole\": \"UNIT TEST\", "
325 "\"lastEpochMicrosec\": 3000, "
326 "\"priority\": \"Normal\", "
327 "\"reportingEntityName\": \"entity_name\", "
328 "\"sequence\": 123, "
329 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
330 "\"startEpochMicrosec\": 2000, "
332 "\"eventType\": \"Perf management...\", "
333 "\"reportingEntityId\": \"entity_id\", "
334 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
336 "\"measurementsForVfScalingFields\": "
338 "\"measurementInterval\": 5.500000, "
339 "\"concurrentSessions\": 1, "
340 "\"configuredEntities\": 2, "
341 "\"cpuUsageArray\": ["
342 "{\"cpuIdentifier\": \"cpu1\", "
343 "\"percentUsage\": 11.110000}, "
344 "{\"cpuIdentifier\": \"cpu2\", "
345 "\"percentUsage\": 22.220000}], "
346 "\"filesystemUsageArray\": ["
347 "{\"blockConfigured\": 100.110000, "
348 "\"blockIops\": 33, "
349 "\"blockUsed\": 100.220000, "
350 "\"ephemeralConfigured\": 100.110000, "
351 "\"ephemeralIops\": 44, "
352 "\"ephemeralUsed\": 200.220000, "
353 "\"filesystemName\": \"00-11-22\"}, "
354 "{\"blockConfigured\": 300.110000, "
355 "\"blockIops\": 55, "
356 "\"blockUsed\": 300.220000, "
357 "\"ephemeralConfigured\": 300.110000, "
358 "\"ephemeralIops\": 66, "
359 "\"ephemeralUsed\": 400.220000, "
360 "\"filesystemName\": \"33-44-55\"}], "
361 "\"latencyDistribution\": ["
362 "{\"countsInTheBucket\": 20}, "
363 "{\"lowEndOfLatencyBucket\": 10.000000, "
364 "\"highEndOfLatencyBucket\": 20.000000, "
365 "\"countsInTheBucket\": 30}], "
366 "\"meanRequestLatency\": 4.400000, "
367 "\"memoryConfigured\": 6.600000, "
368 "\"memoryUsed\": 3.300000, "
369 "\"requestRate\": 7, "
370 "\"vNicUsageArray\": ["
374 "\"packetsIn\": 100, "
375 "\"packetsOut\": 200, "
376 "\"vNicIdentifier\": \"eth0\""
381 "\"packetsIn\": 110, "
382 "\"packetsOut\": 240, "
383 "\"vNicIdentifier\": \"eth1\", "
384 "\"broadcastPacketsIn\": 11, "
385 "\"broadcastPacketsOut\": 12, "
386 "\"multicastPacketsIn\": 15, "
387 "\"multicastPacketsOut\": 16, "
388 "\"unicastPacketsIn\": 17, "
389 "\"unicastPacketsOut\": 18"
392 "\"aggregateCpuUsage\": 8.800000, "
393 "\"numberOfMediaPortsInUse\": 1234, "
394 "\"vnfcScalingMetric\": 1234.567800, "
396 "\"receiveDiscards\": 1, "
397 "\"receiveErrors\": 0, "
398 "\"transmitDiscards\": 2, "
399 "\"transmitErrors\": 1}, "
400 "\"featureUsageArray\": ["
401 "{\"featureIdentifier\": \"FeatureA\", "
402 "\"featureUtilization\": 123}, "
403 "{\"featureIdentifier\": \"FeatureB\", "
404 "\"featureUtilization\": 567}], "
405 "\"codecUsageArray\": ["
406 "{\"codecIdentifier\": \"G711a\", "
407 "\"numberInUse\": 91}, "
408 "{\"codecIdentifier\": \"G729ab\", "
409 "\"numberInUse\": 92}], "
410 "\"additionalMeasurements\": ["
411 "{\"name\": \"Group1\", "
412 "\"measurements\": ["
413 "{\"name\": \"Name1\", "
414 "\"value\": \"Value1\"}]}, "
415 "{\"name\": \"Group2\", "
416 "\"measurements\": ["
417 "{\"name\": \"Name1\", "
418 "\"value\": \"Value1\"}, "
419 "{\"name\": \"Name2\", "
420 "\"value\": \"Value2\"}]}], "
421 "\"measurementsForVfScalingVersion\": 1.1}}}";
423 size_t json_size = 0;
424 char json_body[EVEL_MAX_JSON_BODY];
425 EVENT_MEASUREMENT * measurement = NULL;
426 MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
427 MEASUREMENT_VNIC_PERFORMANCE * vnic_use = NULL;
428 MEASUREMENT_CPU_USE *cpu_use;
430 /***************************************************************************/
432 /***************************************************************************/
433 evel_set_next_event_sequence(123);
434 measurement = evel_new_measurement(5.5);
435 assert(measurement != NULL);
436 evel_measurement_type_set(measurement, "Perf management...");
437 evel_measurement_conc_sess_set(measurement, 1);
438 evel_measurement_cfg_ents_set(measurement, 2);
439 evel_measurement_mean_req_lat_set(measurement, 4.4);
440 evel_measurement_request_rate_set(measurement, 7);
442 cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", 11.11);
443 evel_measurement_cpu_use_idle_set(cpu_use,22.22);
444 evel_measurement_cpu_use_interrupt_set(cpu_use,33.33);
445 evel_measurement_cpu_use_nice_set(cpu_use,44.44);
446 evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
447 evel_measurement_cpu_use_steal_set(cpu_use,66.66);
448 evel_measurement_cpu_use_system_set(cpu_use,77.77);
449 evel_measurement_cpu_use_usageuser_set(cpu_use,88.88);
450 evel_measurement_cpu_use_wait_set(cpu_use,99.99);
452 cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu2", 22.22);
453 evel_measurement_cpu_use_idle_set(cpu_use,12.22);
454 evel_measurement_cpu_use_interrupt_set(cpu_use,33.33);
455 evel_measurement_cpu_use_nice_set(cpu_use,44.44);
456 evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
457 evel_measurement_cpu_use_steal_set(cpu_use,66.66);
458 evel_measurement_cpu_use_system_set(cpu_use,77.77);
459 evel_measurement_cpu_use_usageuser_set(cpu_use,88.88);
460 evel_measurement_cpu_use_wait_set(cpu_use,19.99);
463 evel_measurement_fsys_use_add(measurement,"00-11-22",100.11, 100.22, 33,
465 evel_measurement_fsys_use_add(measurement,"33-44-55",300.11, 300.22, 55,
467 evel_start_epoch_set(&measurement->header, 2000);
468 evel_last_epoch_set(&measurement->header, 3000);
469 evel_reporting_entity_name_set(&measurement->header, "entity_name");
470 evel_reporting_entity_id_set(&measurement->header, "entity_id");
472 /***************************************************************************/
473 /* Latency Bucket with no optional parameters. */
474 /***************************************************************************/
475 bucket = evel_new_meas_latency_bucket(20);
476 evel_meas_latency_bucket_add(measurement, bucket);
478 /***************************************************************************/
479 /* Latency Bucket with all optional parameters. */
480 /***************************************************************************/
481 bucket = evel_new_meas_latency_bucket(30);
482 evel_meas_latency_bucket_low_end_set(bucket, 10.0);
483 evel_meas_latency_bucket_high_end_set(bucket, 20.0);
484 evel_meas_latency_bucket_add(measurement, bucket);
486 /***************************************************************************/
487 /* vNIC Use with no optional parameters. */
488 /***************************************************************************/
489 vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4);
490 evel_meas_vnic_use_add(measurement, vnic_use);
492 /***************************************************************************/
493 /* vNIC Use with all optional parameters. */
494 /***************************************************************************/
495 vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14);
496 evel_vnic_use_bcast_pkt_in_set(vnic_use, 11);
497 evel_vnic_use_bcast_pkt_out_set(vnic_use, 12);
498 evel_vnic_use_mcast_pkt_in_set(vnic_use, 15);
499 evel_vnic_use_mcast_pkt_out_set(vnic_use, 16);
500 evel_vnic_use_ucast_pkt_in_set(vnic_use, 17);
501 evel_vnic_use_ucast_pkt_out_set(vnic_use, 18);
502 evel_meas_vnic_use_add(measurement, vnic_use);
504 evel_measurement_errors_set(measurement, 1, 0, 2, 1);
506 evel_measurement_feature_use_add(measurement, "FeatureA", 123);
507 evel_measurement_feature_use_add(measurement, "FeatureB", 567);
509 evel_measurement_codec_use_add(measurement, "G711a", 91);
510 evel_measurement_codec_use_add(measurement, "G729ab", 92);
512 evel_measurement_media_port_use_set(measurement, 1234);
514 evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678);
516 evel_measurement_custom_measurement_add(measurement,
517 "Group1", "Name1", "Value1");
518 evel_measurement_custom_measurement_add(measurement,
519 "Group2", "Name1", "Value1");
520 evel_measurement_custom_measurement_add(measurement,
521 "Group2", "Name2", "Value2");
523 json_size = evel_json_encode_event(
524 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) measurement);
525 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Measurement");
526 assert((json_size == strlen(json_body)) && "Bad size returned");
528 evel_free_event(measurement);
531 void test_encode_mobile_mand()
535 "{\"commonEventHeader\": {"
536 "\"domain\": \"mobileFlow\", "
537 "\"eventId\": \"1241\", "
538 "\"functionalRole\": \"UNIT TEST\", "
539 "\"lastEpochMicrosec\": 1000002, "
540 "\"priority\": \"Normal\", "
541 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
542 "\"sequence\": 1241, "
543 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
544 "\"startEpochMicrosec\": 1000002, "
546 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
547 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
549 "\"mobileFlowFields\": {"
550 "\"flowDirection\": \"Outbound\", "
551 "\"gtpPerFlowMetrics\": {"
552 "\"avgBitErrorRate\": 12.300000, "
553 "\"avgPacketDelayVariation\": 3.120000, "
554 "\"avgPacketLatency\": 100, "
555 "\"avgReceiveThroughput\": 2100, "
556 "\"avgTransmitThroughput\": 500, "
557 "\"flowActivationEpoch\": 1470409421, "
558 "\"flowActivationMicrosec\": 987, "
559 "\"flowDeactivationEpoch\": 1470409431, "
560 "\"flowDeactivationMicrosec\": 11, "
561 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:51 +0000\", "
562 "\"flowStatus\": \"Working\", "
563 "\"maxPacketDelayVariation\": 87, "
564 "\"numActivationFailures\": 3, "
565 "\"numBitErrors\": 17, "
566 "\"numBytesReceived\": 123654, "
567 "\"numBytesTransmitted\": 4561, "
568 "\"numDroppedPackets\": 0, "
569 "\"numL7BytesReceived\": 12, "
570 "\"numL7BytesTransmitted\": 10, "
571 "\"numLostPackets\": 1, "
572 "\"numOutOfOrderPackets\": 3, "
573 "\"numPacketErrors\": 7, "
574 "\"numPacketsReceivedExclRetrans\": 899, "
575 "\"numPacketsReceivedInclRetrans\": 901, "
576 "\"numPacketsTransmittedInclRetrans\": 302, "
577 "\"numRetries\": 6, "
578 "\"numTimeouts\": 2, "
579 "\"numTunneledL7BytesReceived\": 0, "
580 "\"roundTripTime\": 110, "
581 "\"timeToFirstByte\": 225"
583 "\"ipProtocolType\": \"TCP\", "
584 "\"ipVersion\": \"IPv4\", "
585 "\"otherEndpointIpAddress\": \"2.3.4.1\", "
586 "\"otherEndpointPort\": 2341, "
587 "\"reportingEndpointIpAddr\": \"4.2.3.1\", "
588 "\"reportingEndpointPort\": 4321"
591 size_t json_size = 0;
592 char json_body[EVEL_MAX_JSON_BODY];
593 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
594 EVENT_MOBILE_FLOW * mobile_flow = NULL;
596 /***************************************************************************/
598 /***************************************************************************/
599 evel_set_next_event_sequence(1241);
601 metrics = evel_new_mobile_gtp_flow_metrics(12.3,
631 assert(metrics != NULL);
632 mobile_flow = evel_new_mobile_flow("Outbound",
640 assert(mobile_flow != NULL);
642 json_size = evel_json_encode_event(
643 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
644 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
645 assert((json_size == strlen(json_body)) && "Bad size returned");
647 evel_free_event(mobile_flow);
650 void test_encode_mobile_opts()
654 "{\"commonEventHeader\": {"
655 "\"domain\": \"mobileFlow\", "
656 "\"eventId\": \"1242\", "
657 "\"functionalRole\": \"UNIT TEST\", "
658 "\"lastEpochMicrosec\": 1000002, "
659 "\"priority\": \"Normal\", "
660 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
661 "\"sequence\": 1242, "
662 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
663 "\"startEpochMicrosec\": 1000002, "
665 "\"eventType\": \"Mobile flow...\", "
666 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
667 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
669 "\"mobileFlowFields\": {"
670 "\"flowDirection\": \"Inbound\", "
671 "\"gtpPerFlowMetrics\": {"
672 "\"avgBitErrorRate\": 132.000100, "
673 "\"avgPacketDelayVariation\": 31.200000, "
674 "\"avgPacketLatency\": 101, "
675 "\"avgReceiveThroughput\": 2101, "
676 "\"avgTransmitThroughput\": 501, "
677 "\"flowActivationEpoch\": 1470409422, "
678 "\"flowActivationMicrosec\": 988, "
679 "\"flowDeactivationEpoch\": 1470409432, "
680 "\"flowDeactivationMicrosec\": 12, "
681 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
682 "\"flowStatus\": \"Inactive\", "
683 "\"maxPacketDelayVariation\": 88, "
684 "\"numActivationFailures\": 4, "
685 "\"numBitErrors\": 18, "
686 "\"numBytesReceived\": 123655, "
687 "\"numBytesTransmitted\": 4562, "
688 "\"numDroppedPackets\": 1, "
689 "\"numL7BytesReceived\": 13, "
690 "\"numL7BytesTransmitted\": 11, "
691 "\"numLostPackets\": 2, "
692 "\"numOutOfOrderPackets\": 4, "
693 "\"numPacketErrors\": 8, "
694 "\"numPacketsReceivedExclRetrans\": 900, "
695 "\"numPacketsReceivedInclRetrans\": 902, "
696 "\"numPacketsTransmittedInclRetrans\": 303, "
697 "\"numRetries\": 7, "
698 "\"numTimeouts\": 3, "
699 "\"numTunneledL7BytesReceived\": 1, "
700 "\"roundTripTime\": 111, "
701 "\"timeToFirstByte\": 226, "
702 "\"ipTosCountList\": ["
706 "\"ipTosList\": [\"1\", \"4\", \"17\"], "
707 "\"tcpFlagList\": [\"CWR\", \"URG\"], "
708 "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
709 "\"mobileQciCosList\": [\"conversational\", \"65\"], "
710 "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
711 "\"durConnectionFailedStatus\": 12, "
712 "\"durTunnelFailedStatus\": 13, "
713 "\"flowActivatedBy\": \"Remote\", "
714 "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
715 "\"flowDeactivatedBy\": \"Remote\", "
716 "\"gtpConnectionStatus\": \"Connected\", "
717 "\"gtpTunnelStatus\": \"Not tunneling\", "
718 "\"largePacketRtt\": 80, "
719 "\"largePacketThreshold\": 600.000000, "
720 "\"maxReceiveBitRate\": 1357924680, "
721 "\"maxTransmitBitRate\": 235711, "
722 "\"numGtpEchoFailures\": 1, "
723 "\"numGtpTunnelErrors\": 4, "
724 "\"numHttpErrors\": 2"
726 "\"ipProtocolType\": \"UDP\", "
727 "\"ipVersion\": \"IPv6\", "
728 "\"otherEndpointIpAddress\": \"2.3.4.2\", "
729 "\"otherEndpointPort\": 2342, "
730 "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
731 "\"reportingEndpointPort\": 4322, "
732 "\"applicationType\": \"Demo application\", "
733 "\"appProtocolType\": \"GSM\", "
734 "\"appProtocolVersion\": \"1\", "
735 "\"cid\": \"65535\", "
736 "\"connectionType\": \"S1-U\", "
737 "\"ecgi\": \"e65535\", "
738 "\"gtpProtocolType\": \"GTP-U\", "
739 "\"gtpVersion\": \"1\", "
740 "\"httpHeader\": \"http://www.something.com\", "
741 "\"imei\": \"209917614823\", "
742 "\"imsi\": \"355251/05/850925/8\", "
746 "\"msisdn\": \"6017123456789\", "
747 "\"otherFunctionalRole\": \"MME\", "
749 "\"radioAccessTechnology\": \"LTE\", "
751 "\"samplingAlgorithm\": 1, "
752 "\"tac\": \"2099\", "
753 "\"tunnelId\": \"Tunnel 1\", "
757 size_t json_size = 0;
758 char json_body[EVEL_MAX_JSON_BODY];
759 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
760 EVENT_MOBILE_FLOW * mobile_flow = NULL;
762 /***************************************************************************/
764 /***************************************************************************/
765 evel_set_next_event_sequence(1242);
767 metrics = evel_new_mobile_gtp_flow_metrics(132.0001,
797 assert(metrics != NULL);
799 evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12);
800 evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13);
801 evel_mobile_gtp_metrics_act_by_set(metrics, "Remote");
802 evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423);
803 evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote");
804 evel_mobile_gtp_metrics_con_status_set(metrics, "Connected");
805 evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling");
806 evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13);
807 evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1);
808 evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99);
809 evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80);
810 evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0);
811 evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680);
812 evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711);
813 evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1);
814 evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4);
815 evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2);
816 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10);
817 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121);
818 evel_mobile_gtp_metrics_qci_cos_count_add(
819 metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11);
820 evel_mobile_gtp_metrics_qci_cos_count_add(
821 metrics, EVEL_QCI_COS_LTE_65, 122);
823 mobile_flow = evel_new_mobile_flow("Inbound",
831 assert(mobile_flow != NULL);
833 evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
834 evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
835 evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
836 evel_mobile_flow_app_prot_ver_set(mobile_flow, "1");
837 evel_mobile_flow_cid_set(mobile_flow, "65535");
838 evel_mobile_flow_con_type_set(mobile_flow, "S1-U");
839 evel_mobile_flow_ecgi_set(mobile_flow, "e65535");
840 evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U");
841 evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1");
842 evel_mobile_flow_http_header_set(mobile_flow,
843 "http://www.something.com");
844 evel_mobile_flow_imei_set(mobile_flow, "209917614823");
845 evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8");
846 evel_mobile_flow_lac_set(mobile_flow, "1");
847 evel_mobile_flow_mcc_set(mobile_flow, "410");
848 evel_mobile_flow_mnc_set(mobile_flow, "04");
849 evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789");
850 evel_mobile_flow_other_func_role_set(mobile_flow, "MME");
851 evel_mobile_flow_rac_set(mobile_flow, "514");
852 evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE");
853 evel_mobile_flow_sac_set(mobile_flow, "1");
854 evel_mobile_flow_samp_alg_set(mobile_flow, 1);
855 evel_mobile_flow_tac_set(mobile_flow, "2099");
856 evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1");
857 evel_mobile_flow_vlan_id_set(mobile_flow, "15");
859 json_size = evel_json_encode_event(
860 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
861 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
862 assert((json_size == strlen(json_body)) && "Bad size returned");
864 evel_free_event(mobile_flow);
867 void test_encode_report()
871 "{\"commonEventHeader\": {"
872 "\"domain\": \"measurementsForVfReporting\", "
873 "\"eventId\": \"125\", "
874 "\"functionalRole\": \"UNIT TEST\", "
875 "\"lastEpochMicrosec\": 1000002, "
876 "\"priority\": \"Normal\", "
877 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
878 "\"sequence\": 125, "
879 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
880 "\"startEpochMicrosec\": 1000002, "
882 "\"eventType\": \"Perf reporting...\", "
883 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
884 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
886 "\"measurementsForVfReportingFields\": "
887 "{\"measurementInterval\": 1.100000, "
888 "\"featureUsageArray\": ["
889 "{\"featureIdentifier\": \"FeatureA\", "
890 "\"featureUtilization\": 123}, "
891 "{\"featureIdentifier\": \"FeatureB\", "
892 "\"featureUtilization\": 567}], "
893 "\"additionalMeasurements\": ["
894 "{\"name\": \"Group1\", "
895 "\"measurements\": ["
896 "{\"name\": \"Name1\", "
897 "\"value\": \"Value1\"}]}, "
898 "{\"name\": \"Group2\", "
899 "\"measurements\": ["
900 "{\"name\": \"Name1\", "
901 "\"value\": \"Value1\"}, "
902 "{\"name\": \"Name2\", "
903 "\"value\": \"Value2\"}]}], "
904 "\"measurementFieldsVersion\": 1.1}}}";
906 size_t json_size = 0;
907 char json_body[EVEL_MAX_JSON_BODY];
908 EVENT_REPORT * report = NULL;
910 /***************************************************************************/
912 /***************************************************************************/
913 evel_set_next_event_sequence(125);
914 report = evel_new_report(1.1);
915 assert(report != NULL);
916 evel_report_type_set(report, "Perf reporting...");
917 evel_report_feature_use_add(report, "FeatureA", 123);
918 evel_report_feature_use_add(report, "FeatureB", 567);
919 evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
920 evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
921 evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
923 json_size = evel_json_encode_event(
924 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
925 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
926 assert((json_size == strlen(json_body)) && "Bad size returned");
928 evel_free_event(report);
931 void test_encode_service()
933 test_encode_service_subset(SERVICE_NONE);
934 test_encode_service_subset(SERVICE_CODEC);
935 test_encode_service_subset(SERVICE_TRANSCODING);
936 test_encode_service_subset(SERVICE_RTCP);
937 test_encode_service_subset(SERVICE_EOC_VQM);
938 test_encode_service_subset(SERVICE_MARKER);
941 void test_encode_service_subset(const SERVICE_TEST service_test)
943 char * expected_start =
945 "{\"commonEventHeader\": {"
946 "\"domain\": \"serviceEvents\", "
947 "\"eventId\": \"2000\", "
948 "\"functionalRole\": \"UNIT TEST\", "
949 "\"lastEpochMicrosec\": 1000002, "
950 "\"priority\": \"Normal\", "
951 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
952 "\"sequence\": 2000, "
953 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
954 "\"startEpochMicrosec\": 1000002, "
956 "\"eventType\": \"Service Event\", "
957 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
958 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
960 "\"serviceEventsFields\": {"
961 "\"eventInstanceIdentifier\": "
963 "\"vendorId\": \"vendor_x_id\", "
964 "\"eventId\": \"vendor_x_event_id\", "
965 "\"productId\": \"vendor_x_product_id\", "
966 "\"subsystemId\": \"vendor_x_subsystem_id\", "
967 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
969 "\"serviceEventsFieldsVersion\": 1.1, "
970 "\"correlator\": \"vendor_x_correlator\", "
971 "\"additionalFields\": ["
972 "{\"name\": \"Name1\", \"value\": \"Value1\"}, "
973 "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
974 "{\"name\": \"Name3\", \"value\": \"Value3\"}, "
975 "{\"name\": \"Name4\", \"value\": \"Value4\"}]";
976 char * expected_codec =
978 "\"codecSelected\": {"
979 "\"codec\": \"PCMA\""
981 char * expected_transcoding =
983 "\"codecSelectedTranscoding\": {"
984 "\"calleeSideCodec\": \"PCMA\", "
985 "\"callerSideCodec\": \"G729A\""
987 char * expected_rtcp =
990 "\"rtcpData\": \"some_rtcp_data\""
992 char * expected_eoc_vqm =
994 "\"endOfCallVqmSummaries\": {"
995 "\"adjacencyName\": \"vendor_x_adjacency\", "
996 "\"endpointDescription\": \"Caller\", "
997 "\"endpointJitter\": 66, "
998 "\"endpointRtpOctetsDiscarded\": 100, "
999 "\"endpointRtpOctetsReceived\": 200, "
1000 "\"endpointRtpOctetsSent\": 300, "
1001 "\"endpointRtpPacketsDiscarded\": 400, "
1002 "\"endpointRtpPacketsReceived\": 500, "
1003 "\"endpointRtpPacketsSent\": 600, "
1004 "\"localJitter\": 99, "
1005 "\"localRtpOctetsDiscarded\": 150, "
1006 "\"localRtpOctetsReceived\": 250, "
1007 "\"localRtpOctetsSent\": 350, "
1008 "\"localRtpPacketsDiscarded\": 450, "
1009 "\"localRtpPacketsReceived\": 550, "
1010 "\"localRtpPacketsSent\": 650, "
1011 "\"mosCqe\": 12.255000, "
1012 "\"packetsLost\": 157, "
1013 "\"packetLossPercent\": 0.232000, "
1015 "\"roundTripDelay\": 15"
1017 char * expected_marker =
1020 "\"phoneNumber\": \"0888888888\""
1022 char * expected_end =
1025 char * expected_middle = NULL;
1026 switch (service_test)
1029 expected_middle = "";
1032 expected_middle = expected_codec;
1034 case SERVICE_TRANSCODING:
1035 expected_middle = expected_transcoding;
1038 expected_middle = expected_rtcp;
1040 case SERVICE_EOC_VQM:
1041 expected_middle = expected_eoc_vqm;
1043 case SERVICE_MARKER:
1044 expected_middle = expected_marker;
1047 assert(expected_middle != NULL);
1050 char expected[EVEL_MAX_JSON_BODY];
1051 offset = snprintf(expected + offset,
1052 EVEL_MAX_JSON_BODY - offset,
1058 size_t json_size = 0;
1059 char json_body[EVEL_MAX_JSON_BODY];
1060 EVENT_SGNALING * event = NULL;
1061 evel_set_next_event_sequence(2000);
1062 event = evel_new_signaling("vendor_x_id",
1063 "correlator", "1.0.3.1", "1234", "192.168.1.3","3456");
1064 assert(event != NULL);
1065 evel_signaling_type_set(event, "Signaling");
1066 evel_signaling_correlator_set(event, "vendor_x_correlator");
1067 evel_signaling_vnfmodule_name_set(event, "vendor_x_module");
1068 evel_signaling_vnfname_set(event, "vendor_x_vnf");
1070 switch (service_test)
1075 evel_signaling_addl_info_add(event, "codec", "PCMA");
1077 case SERVICE_TRANSCODING:
1078 evel_signaling_addl_info_add(event, "calleecodec", "PCMA");
1079 evel_signaling_addl_info_add(event, "callercodec", "G729A");
1082 evel_signaling_addl_info_add(event, "rtcpdata", "abcdefgh");
1084 case SERVICE_EOC_VQM:
1085 evel_signaling_addl_info_add(event, "adjacency", "vendor_x");
1086 /*evel_service_adjacency_name_set(event, "vendor_x_adjacency");
1087 evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER);
1088 evel_service_endpoint_jitter_set(event, 66);
1089 evel_service_endpoint_rtp_oct_disc_set(event, 100);
1090 evel_service_endpoint_rtp_oct_recv_set(event, 200);
1091 evel_service_endpoint_rtp_oct_sent_set(event, 300);
1092 evel_service_endpoint_rtp_pkt_disc_set(event, 400);
1093 evel_service_endpoint_rtp_pkt_recv_set(event, 500);
1094 evel_service_endpoint_rtp_pkt_sent_set(event, 600);
1095 evel_service_local_jitter_set(event, 99);
1096 evel_service_local_rtp_oct_disc_set(event, 150);
1097 evel_service_local_rtp_oct_recv_set(event, 250);
1098 evel_service_local_rtp_oct_sent_set(event, 350);
1099 evel_service_local_rtp_pkt_disc_set(event, 450);
1100 evel_service_local_rtp_pkt_recv_set(event, 550);
1101 evel_service_local_rtp_pkt_sent_set(event, 650);
1102 evel_service_mos_cqe_set(event, 12.255);
1103 evel_service_packets_lost_set(event, 157);
1104 evel_service_packet_loss_percent_set(event, 0.232);
1105 evel_service_r_factor_set(event, 11);
1106 evel_service_round_trip_delay_set(event, 15);*/
1108 case SERVICE_MARKER:
1109 evel_signaling_addl_info_add(event, "service_phone", "0888888888");
1113 json_size = evel_json_encode_event(
1114 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
1115 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
1116 assert((json_size == strlen(json_body)) && "Bad size returned");
1118 evel_free_event(event);
1121 void test_encode_signaling()
1125 "{\"commonEventHeader\": {"
1126 "\"domain\": \"signaling\", "
1127 "\"eventId\": \"2001\", "
1128 "\"functionalRole\": \"UNIT TEST\", "
1129 "\"lastEpochMicrosec\": 1000002, "
1130 "\"priority\": \"Normal\", "
1131 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1132 "\"sequence\": 2001, "
1133 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1134 "\"startEpochMicrosec\": 1000002, "
1135 "\"version\": 1.2, "
1136 "\"eventType\": \"Signaling\", "
1137 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1138 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1140 "\"signalingFields\": {"
1141 "\"eventInstanceIdentifier\": "
1143 "\"vendorId\": \"vendor_x_id\", "
1144 "\"eventId\": \"vendor_x_event_id\", "
1145 "\"productId\": \"vendor_x_product_id\", "
1146 "\"subsystemId\": \"vendor_x_subsystem_id\", "
1147 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
1149 "\"signalingFieldsVersion\": 1.1, "
1150 "\"correlator\": \"vendor_x_correlator\", "
1151 "\"localIpAddress\": \"1.0.3.1\", "
1152 "\"localPort\": \"1031\", "
1153 "\"remoteIpAddress\": \"5.3.3.0\", "
1154 "\"remotePort\": \"5330\", "
1155 "\"compressedSip\": \"compressed_sip\", "
1156 "\"summarySip\": \"summary_sip\""
1159 size_t json_size = 0;
1160 char json_body[EVEL_MAX_JSON_BODY];
1161 EVENT_SIGNALING * event = NULL;
1162 evel_set_next_event_sequence(2001);
1163 event = evel_new_signaling("vendor_x_id",
1164 "correlator", "1.0.3.1", "1234", "192.168.1.3","3456");
1165 assert(event != NULL);
1166 evel_signaling_vnfmodule_name_set(event, "vendor_x_module");
1167 evel_signaling_vnfname_set(event, "vendor_x_vnf");
1168 evel_signaling_type_set(event, "Signaling");
1169 evel_signaling_product_id_set(event, "vendor_x_product_id");
1170 evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id");
1171 evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name");
1172 evel_signaling_correlator_set(event, "vendor_x_correlator");
1173 evel_signaling_local_ip_address_set(event, "1.0.3.1");
1174 evel_signaling_local_port_set(event, "1031");
1175 evel_signaling_remote_ip_address_set(event, "5.3.3.0");
1176 evel_signaling_remote_port_set(event, "5330");
1177 evel_signaling_compressed_sip_set(event, "compressed_sip");
1178 evel_signaling_summary_sip_set(event, "summary_sip");
1179 json_size = evel_json_encode_event(
1180 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
1181 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Signaling");
1182 assert((json_size == strlen(json_body)) && "Bad size returned");
1184 evel_free_event(event);
1187 void test_encode_state_change()
1191 "{\"commonEventHeader\": {"
1192 "\"domain\": \"stateChange\", "
1193 "\"eventId\": \"128\", "
1194 "\"functionalRole\": \"UNIT TEST\", "
1195 "\"lastEpochMicrosec\": 1000002, "
1196 "\"priority\": \"Normal\", "
1197 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1198 "\"sequence\": 128, "
1199 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1200 "\"startEpochMicrosec\": 1000002, "
1201 "\"version\": 1.2, "
1202 "\"eventType\": \"SC Type\", "
1203 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1204 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1206 "\"stateChangeFields\": {"
1207 "\"newState\": \"inService\", "
1208 "\"oldState\": \"outOfService\", "
1209 "\"stateInterface\": \"An Interface\", "
1210 "\"additionalFields\": ["
1211 "{\"name\": \"Name1\", "
1212 "\"value\": \"Value1\"}, "
1213 "{\"name\": \"Name2\", "
1214 "\"value\": \"Value2\"}"
1216 "\"stateChangeFieldsVersion\": 1.1"
1219 size_t json_size = 0;
1220 char json_body[EVEL_MAX_JSON_BODY];
1221 EVENT_STATE_CHANGE * state_change = NULL;
1222 evel_set_next_event_sequence(128);
1223 state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE,
1224 EVEL_ENTITY_STATE_OUT_OF_SERVICE,
1226 assert(state_change != NULL);
1227 evel_state_change_type_set(state_change, "SC Type");
1228 evel_state_change_addl_field_add(state_change, "Name1", "Value1");
1229 evel_state_change_addl_field_add(state_change, "Name2", "Value2");
1231 json_size = evel_json_encode_event(
1232 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) state_change);
1233 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "StateChange");
1234 assert((json_size == strlen(json_body)) && "Bad size returned");
1236 evel_free_event(state_change);
1239 void test_encode_syslog()
1243 "{\"commonEventHeader\": {"
1244 "\"domain\": \"syslog\", "
1245 "\"eventId\": \"126\", "
1246 "\"functionalRole\": \"UNIT TEST\", "
1247 "\"lastEpochMicrosec\": 1000002, "
1248 "\"priority\": \"Normal\", "
1249 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1250 "\"sequence\": 126, "
1251 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1252 "\"startEpochMicrosec\": 1000002, "
1253 "\"version\": 1.2, "
1254 "\"eventType\": \"SL Type\", "
1255 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1256 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1258 "\"syslogFields\": {"
1259 "\"eventSourceType\": \"virtualNetworkFunction\", "
1260 "\"syslogMsg\": \"SL Message\", "
1261 "\"syslogTag\": \"SL Tag\", "
1262 "\"syslogFieldsVersion\": 1.1, "
1263 "\"eventSourceHost\": \"SL Host\", "
1264 "\"syslogFacility\": 6, "
1265 "\"syslogProc\": \"SL Proc\", "
1266 "\"syslogProcId\": 2, "
1267 "\"syslogSData\": \"SL SDATA\", "
1270 size_t json_size = 0;
1271 char json_body[EVEL_MAX_JSON_BODY];
1272 EVENT_SYSLOG * syslog = NULL;
1273 evel_set_next_event_sequence(126);
1274 syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION,
1277 assert(syslog != NULL);
1278 evel_syslog_type_set(syslog, "SL Type");
1279 evel_syslog_event_source_host_set(syslog, "SL Host");
1280 evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
1281 evel_syslog_proc_set(syslog, "SL Proc");
1282 evel_syslog_proc_id_set(syslog, 2);
1283 evel_syslog_version_set(syslog, 1);
1284 evel_syslog_s_data_set(syslog, "SL SDATA");
1286 json_size = evel_json_encode_event(
1287 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog);
1288 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog");
1289 assert((json_size == strlen(json_body)) && "Bad size returned");
1291 evel_free_event(syslog);
1294 void test_encode_other()
1298 "{\"commonEventHeader\": {"
1299 "\"domain\": \"other\", "
1300 "\"eventId\": \"129\", "
1301 "\"functionalRole\": \"UNIT TEST\", "
1302 "\"lastEpochMicrosec\": 1000002, "
1303 "\"priority\": \"Normal\", "
1304 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
1305 "\"sequence\": 129, "
1306 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
1307 "\"startEpochMicrosec\": 1000002, "
1308 "\"version\": 1.2, "
1309 "\"eventType\": \"Other Type\", "
1310 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
1311 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
1313 "\"otherFields\": ["
1314 "{\"name\": \"Other field 1\", "
1315 "\"value\": \"Other value 1\"}, "
1316 "{\"name\": \"Other field 2\", "
1317 "\"value\": \"Other value 2\"}"
1321 size_t json_size = 0;
1322 char json_body[EVEL_MAX_JSON_BODY];
1323 EVENT_OTHER * other = NULL;
1324 evel_set_next_event_sequence(129);
1325 other = evel_new_other();
1326 assert(other != NULL);
1327 evel_other_type_set(other, "Other Type");
1328 evel_other_field_add(other,
1331 evel_other_field_add(other,
1335 json_size = evel_json_encode_event(
1336 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) other);
1337 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Other");
1338 assert((json_size == strlen(json_body)) && "Bad size returned");
1340 evel_free_event(other);
1343 void compare_strings(char * expected,
1348 if (strncmp(expected, actual, max_size) != 0)
1351 while (diff < max_size)
1353 if (expected[diff] != actual[diff])
1360 printf("Comparison Failure at Offset %d\n\n", diff);
1361 printf("Expected:\n%s\n", expected);
1362 printf("Actual:\n%s\n", actual);
1363 printf("Description: %s\n", description);
1368 /**************************************************************************//**
1369 * Copy a json string to a ::MEMORY_CHUNK for testing.
1371 * @param chunk The memory chunk.
1372 * @param string The json string.
1373 *****************************************************************************/
1374 void copy_string_to_chunk(MEMORY_CHUNK * chunk, char * string)
1378 /***************************************************************************/
1379 /* Check preconditions. */
1380 /***************************************************************************/
1381 assert(chunk != NULL);
1382 assert(string != NULL);
1384 mem_size = strlen(string) + 1;
1385 chunk->memory = malloc(mem_size);
1386 memcpy(chunk->memory, string, mem_size);
1387 chunk->size = mem_size;
1390 /**************************************************************************//**
1391 * Copy a json string to a ::MEMORY_CHUNK for testing.
1393 * @param json The JSON string.
1394 * @param post Memory chunk to post a response.
1395 *****************************************************************************/
1396 void handle_json_response(char * json, MEMORY_CHUNK * post)
1399 post->memory = NULL;
1401 copy_string_to_chunk(&chunk, json);
1402 evel_handle_event_response(&chunk, post);
1406 /**************************************************************************//**
1407 * Test that a non-"commandList" JSON buffer leaves the throttle state off.
1408 *****************************************************************************/
1409 void test_json_response_junk()
1416 "\"1\", \"2\", \"3\"], "
1418 "\"1\", \"2\", \"3\"]"
1421 evel_throttle_initialize();
1422 handle_json_response(json_junk, &post);
1424 /***************************************************************************/
1425 /* Check that all domains are not throttled. */
1426 /***************************************************************************/
1427 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1429 assert(evel_get_throttle_spec(domain) == NULL);
1432 /***************************************************************************/
1433 /* Check that we generated no post. */
1434 /***************************************************************************/
1435 assert(post.memory == NULL);
1437 evel_throttle_terminate();
1440 char * json_command_list_provide =
1442 "\"commandList\": ["
1445 "\"commandType\": \"provideThrottlingState\""
1451 char * json_command_list_fault_clear =
1453 "\"commandList\": ["
1456 "\"commandType\": \"throttlingSpecification\", "
1457 "\"eventDomainThrottleSpecification\": {"
1458 "\"eventDomain\": \"fault\""
1465 char * json_command_list_syslog_clear =
1467 "\"commandList\": ["
1470 "\"commandType\": \"throttlingSpecification\", "
1471 "\"eventDomainThrottleSpecification\": {"
1472 "\"eventDomain\": \"syslog\""
1479 char * expected_throttle_state_normal =
1481 "\"eventThrottlingState\": {"
1482 "\"eventThrottlingMode\": \"normal\"}"
1485 /**************************************************************************//**
1486 * Test that we can return the default throttling state.
1487 *****************************************************************************/
1488 void test_json_provide_throttle_state()
1493 char * expected_post = expected_throttle_state_normal;
1495 evel_throttle_initialize();
1496 handle_json_response(json_command_list_provide, &post);
1498 /***************************************************************************/
1499 /* Check that all domains are not throttled. */
1500 /***************************************************************************/
1501 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1503 assert(evel_get_throttle_spec(domain) == NULL);
1506 /***************************************************************************/
1507 /* Check that we generated a throttling specification post. */
1508 /***************************************************************************/
1509 assert(post.memory != NULL);
1510 compare_strings(expected_post, post.memory, strlen(expected_post),
1511 "Throttle State Normal");
1514 evel_throttle_terminate();
1517 /**************************************************************************//**
1518 * Test the measurement interval handling and API.
1519 *****************************************************************************/
1520 void test_json_measurement_interval()
1523 char * json_command_list_interval_only =
1525 "\"commandList\": ["
1528 "\"measurementInterval\": 60"
1534 char * json_command_list_interval_first =
1536 "\"commandList\": ["
1539 "\"measurementInterval\": 30, "
1540 "\"commandType\": \"measurementIntervalChange\""
1546 char * json_command_list_command_first =
1548 "\"commandList\": ["
1551 "\"commandType\": \"measurementIntervalChange\", "
1552 "\"measurementInterval\": 60"
1558 evel_throttle_initialize();
1559 assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
1561 /***************************************************************************/
1562 /* Check that we're not handling stuff when we shouldn't. */
1563 /***************************************************************************/
1564 handle_json_response(json_command_list_interval_only, &post);
1565 assert(post.memory == NULL);
1566 assert(evel_get_measurement_interval() == EVEL_MEASUREMENT_INTERVAL_UKNOWN);
1568 /***************************************************************************/
1569 /* Check that we're OK with the interval coming first. */
1570 /***************************************************************************/
1571 handle_json_response(json_command_list_interval_first, &post);
1572 assert(post.memory == NULL);
1573 assert(evel_get_measurement_interval() == 30);
1575 /***************************************************************************/
1576 /* Check that we're OK with the command type coming first. */
1577 /***************************************************************************/
1578 handle_json_response(json_command_list_command_first, &post);
1579 assert(post.memory == NULL);
1580 assert(evel_get_measurement_interval() == 60);
1582 evel_throttle_terminate();
1585 /**************************************************************************//**
1586 * Test a single domain, single field suppression.
1587 *****************************************************************************/
1588 void test_json_throttle_spec_field()
1593 char * json_command_list_fault_single =
1595 "\"commandList\": ["
1598 "\"commandType\": \"throttlingSpecification\", "
1599 "\"eventDomainThrottleSpecification\": {"
1600 "\"eventDomain\": \"fault\", "
1601 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
1608 char * json_command_list_fault_double =
1610 "\"commandList\": ["
1613 "\"commandType\": \"throttlingSpecification\", "
1614 "\"eventDomainThrottleSpecification\": {"
1615 "\"eventDomain\": \"fault\", "
1616 "\"suppressedFieldNames\": ["
1617 "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
1624 char * expected_post_fault_single =
1626 "\"eventThrottlingState\": {"
1627 "\"eventThrottlingMode\": \"throttled\", "
1628 "\"eventDomainThrottleSpecificationList\": ["
1630 "\"eventDomain\": \"fault\", "
1631 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
1637 char * expected_post_fault_double =
1639 "\"eventThrottlingState\": {"
1640 "\"eventThrottlingMode\": \"throttled\", "
1641 "\"eventDomainThrottleSpecificationList\": ["
1643 "\"eventDomain\": \"fault\", "
1644 "\"suppressedFieldNames\": ["
1645 "\"alarmInterfaceA\", \"alarmAdditionalInformation\"]"
1651 /***************************************************************************/
1652 /* Initialize and provide a specification with a single fault suppressed. */
1653 /***************************************************************************/
1654 evel_throttle_initialize();
1655 handle_json_response(json_command_list_fault_single, &post);
1657 /***************************************************************************/
1658 /* Check that the FAULT domain is throttled. */
1659 /***************************************************************************/
1660 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1661 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1663 if (domain != EVEL_DOMAIN_FAULT)
1665 assert(evel_get_throttle_spec(domain) == NULL);
1668 assert(post.memory == NULL);
1670 /***************************************************************************/
1671 /* Request and verify the throttling state. */
1672 /***************************************************************************/
1673 handle_json_response(json_command_list_provide, &post);
1674 assert(post.memory != NULL);
1675 compare_strings(expected_post_fault_single,
1677 strlen(expected_post_fault_single),
1678 "Fault - Single Field");
1682 /***************************************************************************/
1683 /* Update a specification with two faults suppressed. */
1684 /***************************************************************************/
1685 handle_json_response(json_command_list_fault_double, &post);
1687 /***************************************************************************/
1688 /* Check that the FAULT domain is throttled. */
1689 /***************************************************************************/
1690 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1691 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1693 if (domain != EVEL_DOMAIN_FAULT)
1695 assert(evel_get_throttle_spec(domain) == NULL);
1698 assert(post.memory == NULL);
1700 /***************************************************************************/
1701 /* Request and verify the throttling state. */
1702 /***************************************************************************/
1703 handle_json_response(json_command_list_provide, &post);
1704 assert(post.memory != NULL);
1705 compare_strings(expected_post_fault_double,
1707 strlen(expected_post_fault_double),
1708 "Fault - Double Field");
1712 /***************************************************************************/
1713 /* Now clear the FAULT domain. */
1714 /***************************************************************************/
1715 handle_json_response(json_command_list_fault_clear, &post);
1716 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1718 assert(evel_get_throttle_spec(domain) == NULL);
1721 evel_throttle_terminate();
1724 /**************************************************************************//**
1725 * Test a single domain, nv_pair suppression.
1726 *****************************************************************************/
1727 void test_json_throttle_spec_nv_pair()
1732 char * json_command_list_fault_pair_single =
1734 "\"commandList\": ["
1737 "\"commandType\": \"throttlingSpecification\", "
1738 "\"eventDomainThrottleSpecification\": {"
1739 "\"eventDomain\": \"fault\", "
1740 "\"suppressedNvPairsList\": ["
1742 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1743 "\"suppressedNvPairNames\": [\"name1\"]"
1752 char * json_command_list_fault_pair_double =
1754 "\"commandList\": ["
1757 "\"commandType\": \"throttlingSpecification\", "
1758 "\"eventDomainThrottleSpecification\": {"
1759 "\"eventDomain\": \"fault\", "
1760 "\"suppressedNvPairsList\": ["
1762 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1763 "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
1772 char * expected_post_fault_pair_single =
1774 "\"eventThrottlingState\": {"
1775 "\"eventThrottlingMode\": \"throttled\", "
1776 "\"eventDomainThrottleSpecificationList\": ["
1778 "\"eventDomain\": \"fault\", "
1779 "\"suppressedNvPairsList\": ["
1781 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1782 "\"suppressedNvPairNames\": [\"name1\"]"
1790 char * expected_post_fault_pair_double =
1792 "\"eventThrottlingState\": {"
1793 "\"eventThrottlingMode\": \"throttled\", "
1794 "\"eventDomainThrottleSpecificationList\": ["
1796 "\"eventDomain\": \"fault\", "
1797 "\"suppressedNvPairsList\": ["
1799 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1800 "\"suppressedNvPairNames\": [\"name1\", \"name2\"]"
1808 /***************************************************************************/
1809 /* Initialize and provide a specification with a single nvpair with a */
1810 /* single sub-field suppressed. */
1811 /***************************************************************************/
1812 evel_throttle_initialize();
1813 handle_json_response(json_command_list_fault_pair_single, &post);
1815 /***************************************************************************/
1816 /* Check that the FAULT domain is throttled. */
1817 /***************************************************************************/
1818 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1819 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1821 if (domain != EVEL_DOMAIN_FAULT)
1823 assert(evel_get_throttle_spec(domain) == NULL);
1826 assert(post.memory == NULL);
1828 /***************************************************************************/
1829 /* Request and verify the throttling state. */
1830 /***************************************************************************/
1831 handle_json_response(json_command_list_provide, &post);
1832 assert(post.memory != NULL);
1833 compare_strings(expected_post_fault_pair_single,
1835 strlen(expected_post_fault_pair_single),
1836 "Fault - Single Pair, Single Field");
1840 /***************************************************************************/
1841 /* Update a specification with a single nvpair with two sub-fields */
1843 /***************************************************************************/
1844 handle_json_response(json_command_list_fault_pair_double, &post);
1846 /***************************************************************************/
1847 /* Check that the FAULT domain is throttled. */
1848 /***************************************************************************/
1849 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1850 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1852 if (domain != EVEL_DOMAIN_FAULT)
1854 assert(evel_get_throttle_spec(domain) == NULL);
1857 assert(post.memory == NULL);
1859 /***************************************************************************/
1860 /* Request and verify the throttling state. */
1861 /***************************************************************************/
1862 handle_json_response(json_command_list_provide, &post);
1863 assert(post.memory != NULL);
1864 compare_strings(expected_post_fault_pair_double,
1866 strlen(expected_post_fault_pair_double),
1867 "Fault - Double Field");
1871 /***************************************************************************/
1872 /* Now clear the FAULT domain. */
1873 /***************************************************************************/
1874 handle_json_response(json_command_list_fault_clear, &post);
1875 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1877 assert(evel_get_throttle_spec(domain) == NULL);
1880 evel_throttle_terminate();
1883 /**************************************************************************//**
1884 * Test two domains, nv_pair suppression.
1885 *****************************************************************************/
1886 void test_json_throttle_spec_two_domains()
1891 char * json_command_list_two_domains =
1893 "\"commandList\": ["
1896 "\"commandType\": \"throttlingSpecification\", "
1897 "\"eventDomainThrottleSpecification\": {"
1898 "\"eventDomain\": \"fault\", "
1899 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
1900 "\"suppressedNvPairsList\": ["
1902 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1903 "\"suppressedNvPairNames\": [\"name1\"]"
1907 "\"commandType\": \"throttlingSpecification\", "
1908 "\"eventDomainThrottleSpecification\": {"
1909 "\"eventDomain\": \"syslog\", "
1910 "\"suppressedFieldNames\": [\"syslogProcId\"], "
1911 "\"suppressedNvPairsList\": ["
1913 "\"nvPairFieldName\": \"additionalFields\", "
1914 "\"suppressedNvPairNames\": [\"name1\"]"
1919 char * expected_post_two_domains =
1921 "\"eventThrottlingState\": {"
1922 "\"eventThrottlingMode\": \"throttled\", "
1923 "\"eventDomainThrottleSpecificationList\": ["
1925 "\"eventDomain\": \"fault\", "
1926 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
1927 "\"suppressedNvPairsList\": ["
1929 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
1930 "\"suppressedNvPairNames\": [\"name1\"]"
1933 "\"eventDomain\": \"syslog\", "
1934 "\"suppressedFieldNames\": [\"syslogProcId\"], "
1935 "\"suppressedNvPairsList\": ["
1937 "\"nvPairFieldName\": \"additionalFields\", "
1938 "\"suppressedNvPairNames\": [\"name1\"]"
1944 /***************************************************************************/
1945 /* Initialize and provide a specification with a single nvpair with a */
1946 /* single sub-field suppressed. */
1947 /***************************************************************************/
1948 evel_throttle_initialize();
1949 handle_json_response(json_command_list_two_domains, &post);
1951 /***************************************************************************/
1952 /* Check that the FAULT and SYSLOG domains are throttled. */
1953 /***************************************************************************/
1954 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
1955 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
1956 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
1958 if ((domain != EVEL_DOMAIN_FAULT) && (domain != EVEL_DOMAIN_SYSLOG))
1960 assert(evel_get_throttle_spec(domain) == NULL);
1963 assert(post.memory == NULL);
1965 /***************************************************************************/
1966 /* Request and verify the throttling state. */
1967 /***************************************************************************/
1968 handle_json_response(json_command_list_provide, &post);
1969 assert(post.memory != NULL);
1970 compare_strings(expected_post_two_domains,
1972 strlen(expected_post_two_domains),
1973 "Fault - Two Domains");
1977 /***************************************************************************/
1978 /* Now clear the FAULT and SYSLOG domains. */
1979 /***************************************************************************/
1980 handle_json_response(json_command_list_fault_clear, &post);
1981 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL);
1982 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
1983 handle_json_response(json_command_list_syslog_clear, &post);
1984 for (domain = EVEL_DOMAIN_FAULT; domain < EVEL_MAX_DOMAINS; domain++)
1986 assert(evel_get_throttle_spec(domain) == NULL);
1989 evel_throttle_terminate();
1992 /**************************************************************************//**
1993 * Test bad command type.
1994 *****************************************************************************/
1995 void test_json_throttle_spec_bad_command_type()
2000 /***************************************************************************/
2001 /* Search for "dodgy" in the JSON, and you will see the dodgy bits we're */
2002 /* handling in these tests. */
2003 /***************************************************************************/
2004 #define NUM_BAD_COMMANDS 8
2005 char * json_command_list_dodgy_command =
2007 "\"commandList\": ["
2010 "\"commandType\": \"dodgyCommand\", "
2011 "\"eventDomainThrottleSpecification\": {"
2012 "\"eventDomain\": \"fault\", "
2013 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2014 "\"suppressedNvPairsList\": ["
2016 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2017 "\"suppressedNvPairNames\": [\"name1\"]"
2022 char * json_command_list_dodgy_spec =
2024 "\"commandList\": ["
2027 "\"commandType\": \"throttlingSpecification\", "
2028 "\"dodgyEventDomainThrottleSpecification\": {"
2029 "\"eventDomain\": \"fault\", "
2030 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2031 "\"suppressedNvPairsList\": ["
2033 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2034 "\"suppressedNvPairNames\": [\"name1\"]"
2039 char * json_command_list_dodgy_event_domain_key =
2041 "\"commandList\": ["
2044 "\"commandType\": \"throttlingSpecification\", "
2045 "\"eventDomainThrottleSpecification\": {"
2046 "\"dodgyEventDomainKey\": \"fault\", "
2047 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2048 "\"suppressedNvPairsList\": ["
2050 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2051 "\"suppressedNvPairNames\": [\"name1\"]"
2056 char * json_command_list_dodgy_event_domain =
2058 "\"commandList\": ["
2061 "\"commandType\": \"throttlingSpecification\", "
2062 "\"eventDomainThrottleSpecification\": {"
2063 "\"eventDomain\": \"dodgyEventDomain\", "
2064 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2065 "\"suppressedNvPairsList\": ["
2067 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2068 "\"suppressedNvPairNames\": [\"name1\"]"
2073 char * json_command_list_dodgy_field_names_key =
2075 "\"commandList\": ["
2078 "\"commandType\": \"throttlingSpecification\", "
2079 "\"eventDomainThrottleSpecification\": {"
2080 "\"eventDomain\": \"fault\", "
2081 "\"suppressedNvPairsList\": ["
2083 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2084 "\"suppressedNvPairNames\": [\"name1\"]"
2089 char * json_command_list_dodgy_pair_names_list_key =
2091 "\"commandList\": ["
2094 "\"commandType\": \"throttlingSpecification\", "
2095 "\"eventDomainThrottleSpecification\": {"
2096 "\"eventDomain\": \"fault\", "
2097 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2098 "\"dodgySuppressedNvPairsListKey\": ["
2100 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2101 "\"suppressedNvPairNames\": [\"name1\"]"
2106 char * json_command_list_dodgy_pair_field_name_key =
2108 "\"commandList\": ["
2111 "\"commandType\": \"throttlingSpecification\", "
2112 "\"eventDomainThrottleSpecification\": {"
2113 "\"eventDomain\": \"fault\", "
2114 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2115 "\"suppressedNvPairsList\": ["
2117 "\"dodgyNvPairFieldNameKey\": \"alarmAdditionalInformation\", "
2118 "\"suppressedNvPairNames\": [\"name1\"]"
2123 char * json_command_list_dodgy_pair_names_key =
2125 "\"commandList\": ["
2128 "\"commandType\": \"throttlingSpecification\", "
2129 "\"eventDomainThrottleSpecification\": {"
2130 "\"eventDomain\": \"fault\", "
2131 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2132 "\"suppressedNvPairsList\": ["
2134 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2135 "\"dodgySuppressedNvPairNamesKey\": [\"name1\"]"
2140 char * json_command_list_dodgy_depth =
2142 "\"commandList\": ["
2145 "\"commandType\": \"throttlingSpecification\", "
2146 "\"eventDomainThrottleSpecification\": {"
2147 "\"eventDomain\": \"fault\", "
2148 "\"suppressedFieldNames\": [\"alarmInterfaceA\"], "
2149 "\"suppressedNvPairsList\": ["
2151 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2152 "\"dodgySuppressedNvPairNamesKey\": "
2153 "[\"name1\", [[[[[[[[]]]]]]]]]"
2158 char * expected_throttle_state_dodgy_field_names_key =
2160 "\"eventThrottlingState\": {"
2161 "\"eventThrottlingMode\": \"throttled\", "
2162 "\"eventDomainThrottleSpecificationList\": ["
2164 "\"eventDomain\": \"fault\", "
2165 "\"suppressedNvPairsList\": ["
2167 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2168 "\"suppressedNvPairNames\": [\"name1\"]"
2174 char * expected_throttle_state_dodgy_pair_names_list_key =
2176 "\"eventThrottlingState\": {"
2177 "\"eventThrottlingMode\": \"throttled\", "
2178 "\"eventDomainThrottleSpecificationList\": ["
2180 "\"eventDomain\": \"fault\", "
2181 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2187 char * expected_throttle_state_dodgy_pair_field_name_key =
2189 "\"eventThrottlingState\": {"
2190 "\"eventThrottlingMode\": \"throttled\", "
2191 "\"eventDomainThrottleSpecificationList\": ["
2193 "\"eventDomain\": \"fault\", "
2194 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2200 char * expected_throttle_state_dodgy_pair_names_key =
2202 "\"eventThrottlingState\": {"
2203 "\"eventThrottlingMode\": \"throttled\", "
2204 "\"eventDomainThrottleSpecificationList\": ["
2206 "\"eventDomain\": \"fault\", "
2207 "\"suppressedFieldNames\": [\"alarmInterfaceA\"]"
2213 char * json_command_lists[] = {
2214 json_command_list_dodgy_command,
2215 json_command_list_dodgy_spec,
2216 json_command_list_dodgy_event_domain_key,
2217 json_command_list_dodgy_event_domain,
2218 json_command_list_dodgy_depth,
2219 json_command_list_dodgy_field_names_key,
2220 json_command_list_dodgy_pair_names_list_key,
2221 json_command_list_dodgy_pair_field_name_key,
2222 json_command_list_dodgy_pair_names_key
2225 char * expected_posts[] = {
2226 expected_throttle_state_normal,
2227 expected_throttle_state_normal,
2228 expected_throttle_state_normal,
2229 expected_throttle_state_normal,
2230 expected_throttle_state_normal,
2231 expected_throttle_state_dodgy_field_names_key,
2232 expected_throttle_state_dodgy_pair_names_list_key,
2233 expected_throttle_state_dodgy_pair_field_name_key,
2234 expected_throttle_state_dodgy_pair_names_key
2237 const int num_commands =
2238 sizeof(json_command_lists) / sizeof(json_command_lists[0]);
2239 const int num_posts =
2240 sizeof(expected_posts) / sizeof(expected_posts[0]);
2241 assert(num_commands == num_posts);
2243 /***************************************************************************/
2244 /* Initialize and provide a specification with a single nvpair with a */
2245 /* single sub-field suppressed. */
2246 /***************************************************************************/
2247 evel_throttle_initialize();
2250 for (ii = 0; ii < num_commands; ii++)
2252 EVEL_DEBUG("Testing commandList[%d] = %s\n", ii, json_command_lists[ii]);
2253 handle_json_response(json_command_lists[ii], &post);
2255 /*************************************************************************/
2256 /* Check that throttling is in a normal state - because we ignored the */
2257 /* command / ..... */
2258 /*************************************************************************/
2259 for (domain = EVEL_DOMAIN_MEASUREMENT; domain < EVEL_MAX_DOMAINS; domain++)
2261 assert(evel_get_throttle_spec(domain) == NULL);
2263 if (expected_posts[ii] == expected_throttle_state_normal)
2265 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) == NULL);
2269 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
2271 assert(post.memory == NULL);
2273 /*************************************************************************/
2274 /* Request and verify the throttling state. */
2275 /*************************************************************************/
2276 handle_json_response(json_command_list_provide, &post);
2277 assert(post.memory != NULL);
2278 compare_strings(expected_posts[ii],
2280 strlen(expected_posts[ii]),
2281 "Throttle State Normal");
2286 evel_throttle_terminate();
2289 void test_encode_fault_throttled()
2293 /***************************************************************************/
2294 /* We also test suppression of the event header parameters here. */
2295 /***************************************************************************/
2296 char * json_command_list =
2298 "\"commandList\": ["
2301 "\"commandType\": \"throttlingSpecification\", "
2302 "\"eventDomainThrottleSpecification\": {"
2303 "\"eventDomain\": \"fault\", "
2304 "\"suppressedFieldNames\": ["
2305 "\"alarmInterfaceA\", "
2307 "\"reportingEntityId\", "
2309 "\"suppressedNvPairsList\": ["
2311 "\"nvPairFieldName\": \"alarmAdditionalInformation\", "
2312 "\"suppressedNvPairNames\": [\"name3\", \"name4\"]"
2319 "\"commonEventHeader\": {"
2320 "\"domain\": \"fault\", "
2321 "\"eventId\": \"122\", "
2322 "\"functionalRole\": \"UNIT TEST\", "
2323 "\"lastEpochMicrosec\": 1000002, "
2324 "\"priority\": \"Normal\", "
2325 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2326 "\"sequence\": 122, "
2327 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2328 "\"startEpochMicrosec\": 1000002, "
2331 "\"faultFields\": {"
2332 "\"alarmCondition\": \"My alarm condition\", "
2333 "\"eventSeverity\": \"MAJOR\", "
2334 "\"eventSourceType\": \"other\", "
2335 "\"specificProblem\": \"It broke very badly\", "
2336 "\"vfStatus\": \"Active\", "
2337 "\"faultFieldsVersion\": 1.1, "
2338 "\"alarmAdditionalInformation\": ["
2339 "{\"name\": \"name1\", "
2340 "\"value\": \"value1\"}, "
2341 "{\"name\": \"name2\", "
2342 "\"value\": \"value2\"}]"
2345 /***************************************************************************/
2346 /* Initialize and provide a specification with a single fault suppressed. */
2347 /***************************************************************************/
2348 evel_throttle_initialize();
2349 handle_json_response(json_command_list, &post);
2351 /***************************************************************************/
2352 /* Check that the domain is throttled. */
2353 /***************************************************************************/
2354 assert(evel_get_throttle_spec(EVEL_DOMAIN_FAULT) != NULL);
2355 assert(post.memory == NULL);
2357 size_t json_size = 0;
2358 char json_body[EVEL_MAX_JSON_BODY];
2359 evel_set_next_event_sequence(122);
2360 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
2361 "It broke very badly",
2362 EVEL_PRIORITY_NORMAL,
2363 EVEL_SEVERITY_MAJOR,
2365 EVEL_VF_STATUS_PREP_TERMINATE);
2366 assert(fault != NULL);
2367 evel_fault_type_set(fault, "Bad things happen...");
2368 evel_fault_addl_info_add(fault, "name1", "value1");
2369 evel_fault_addl_info_add(fault, "name2", "value2");
2371 /***************************************************************************/
2372 /* Suppressed fields. */
2373 /***************************************************************************/
2374 evel_fault_interface_set(fault, "My Interface Card");
2375 evel_fault_addl_info_add(fault, "name3", "value3");
2376 evel_fault_addl_info_add(fault, "name4", "value4");
2378 json_size = evel_json_encode_event(
2379 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
2380 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
2381 assert((json_size == strlen(json_body)) && "Bad size returned");
2383 evel_free_event(fault);
2384 evel_throttle_terminate();
2387 void test_encode_measurement_throttled()
2391 /***************************************************************************/
2392 /* We also test suppression of the event header parameters here. */
2393 /***************************************************************************/
2394 char * json_command_list =
2396 "\"commandList\": ["
2399 "\"commandType\": \"throttlingSpecification\", "
2400 "\"eventDomainThrottleSpecification\": {"
2401 "\"eventDomain\": \"measurementsForVfScaling\", "
2402 "\"suppressedFieldNames\": ["
2404 "\"vnfcScalingMetric\", "
2405 "\"numberOfMediaPortsInUse\", "
2406 "\"aggregateCpuUsage\", "
2409 "\"memoryConfigured\", "
2410 "\"meanRequestLatency\", "
2411 "\"latencyDistribution\", "
2412 "\"concurrentSessions\", "
2413 "\"configuredEntities\", "
2415 "\"reportingEntityId\", "
2417 "\"suppressedNvPairsList\": ["
2419 "\"nvPairFieldName\": \"cpuUsageArray\", "
2420 "\"suppressedNvPairNames\": [\"cpu3\", \"cpu4\"]"
2423 "\"nvPairFieldName\": \"filesystemUsageArray\", "
2424 "\"suppressedNvPairNames\": [\"00-11-22\", \"33-44-55\"]"
2427 "\"nvPairFieldName\": \"vNicUsageArray\", "
2428 "\"suppressedNvPairNames\": [\"eth1\", \"eth0\"]"
2431 "\"nvPairFieldName\": \"featureUsageArray\", "
2432 "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
2435 "\"nvPairFieldName\": \"codecUsageArray\", "
2436 "\"suppressedNvPairNames\": [\"G729ab\"]"
2439 "\"nvPairFieldName\": \"additionalMeasurements\", "
2440 "\"suppressedNvPairNames\": [\"Group2\"]"
2448 "{\"commonEventHeader\": {"
2449 "\"domain\": \"measurementsForVfScaling\", "
2450 "\"eventId\": \"123\", "
2451 "\"functionalRole\": \"UNIT TEST\", "
2452 "\"lastEpochMicrosec\": 1000002, "
2453 "\"priority\": \"Normal\", "
2454 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2455 "\"sequence\": 123, "
2456 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2457 "\"startEpochMicrosec\": 1000002, "
2460 "\"measurementsForVfScalingFields\": "
2462 "\"measurementInterval\": 5.500000, "
2463 "\"cpuUsageArray\": ["
2464 "{\"cpuIdentifier\": \"cpu1\", "
2465 "\"percentUsage\": 11.110000}, "
2466 "{\"cpuIdentifier\": \"cpu2\", "
2467 "\"percentUsage\": 22.220000}], "
2468 "\"filesystemUsageArray\": ["
2469 "{\"blockConfigured\": 500.110000, "
2470 "\"blockIops\": 77, "
2471 "\"blockUsed\": 500.220000, "
2472 "\"ephemeralConfigured\": 500.110000, "
2473 "\"ephemeralIops\": 88, "
2474 "\"ephemeralUsed\": 600.220000, "
2475 "\"filesystemName\": \"66-77-88\"}], "
2476 "\"featureUsageArray\": ["
2477 "{\"featureIdentifier\": \"FeatureA\", "
2478 "\"featureUtilization\": 123}], "
2479 "\"codecUsageArray\": ["
2480 "{\"codecIdentifier\": \"G711a\", "
2481 "\"numberInUse\": 91}], "
2482 "\"additionalMeasurements\": ["
2483 "{\"name\": \"Group1\", "
2484 "\"measurements\": ["
2485 "{\"name\": \"Name1\", "
2486 "\"value\": \"Value1\"}]}], "
2487 "\"measurementsForVfScalingVersion\": 1.1}}}";
2488 MEASUREMENT_CPU_USE *cpu_use;
2490 /***************************************************************************/
2491 /* Initialize and provide a specification with a single fault suppressed. */
2492 /***************************************************************************/
2493 evel_throttle_initialize();
2494 handle_json_response(json_command_list, &post);
2496 /***************************************************************************/
2497 /* Check that the domain is throttled. */
2498 /***************************************************************************/
2499 assert(evel_get_throttle_spec(EVEL_DOMAIN_MEASUREMENT) != NULL);
2500 assert(post.memory == NULL);
2502 size_t json_size = 0;
2503 char json_body[EVEL_MAX_JSON_BODY];
2504 evel_set_next_event_sequence(123);
2505 EVENT_MEASUREMENT * measurement = evel_new_measurement(5.5);
2506 MEASUREMENT_LATENCY_BUCKET * bucket = NULL;
2507 MEASUREMENT_VNIC_PERFORMANCE * vnic_use = NULL;
2508 assert(measurement != NULL);
2510 evel_measurement_type_set(measurement, "Perf management...");
2511 evel_measurement_conc_sess_set(measurement, 1);
2512 evel_measurement_cfg_ents_set(measurement, 2);
2513 evel_measurement_mean_req_lat_set(measurement, 4.4);
2514 evel_measurement_mem_cfg_set(measurement, 6.6);
2515 evel_measurement_mem_used_set(measurement, 3.3);
2516 evel_measurement_request_rate_set(measurement, 7);
2518 cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu1", 11.11);
2519 evel_measurement_cpu_use_idle_set(cpu_use,22.22);
2520 evel_measurement_cpu_use_interrupt_set(cpu_use,33.33);
2521 evel_measurement_cpu_use_nice_set(cpu_use,44.44);
2522 evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
2523 evel_measurement_cpu_use_steal_set(cpu_use,66.66);
2524 evel_measurement_cpu_use_system_set(cpu_use,77.77);
2525 evel_measurement_cpu_use_usageuser_set(cpu_use,88.88);
2526 evel_measurement_cpu_use_wait_set(cpu_use,99.99);
2528 cpu_use = evel_measurement_new_cpu_use_add(measurement, "cpu2", 22.22);
2529 evel_measurement_cpu_use_idle_set(cpu_use,12.22);
2530 evel_measurement_cpu_use_interrupt_set(cpu_use,33.33);
2531 evel_measurement_cpu_use_nice_set(cpu_use,44.44);
2532 evel_measurement_cpu_use_softirq_set(cpu_use,55.55);
2533 evel_measurement_cpu_use_steal_set(cpu_use,66.66);
2534 evel_measurement_cpu_use_system_set(cpu_use,77.77);
2535 evel_measurement_cpu_use_usageuser_set(cpu_use,88.88);
2536 evel_measurement_cpu_use_wait_set(cpu_use,19.99);
2538 evel_measurement_fsys_use_add(measurement, "00-11-22",
2540 200.11, 200.22, 44);
2541 evel_measurement_fsys_use_add(measurement, "33-44-55",
2543 400.11, 400.22, 66);
2544 evel_measurement_fsys_use_add(measurement, "66-77-88",
2546 600.11, 600.22, 88);
2548 bucket = evel_new_meas_latency_bucket(20);
2549 evel_meas_latency_bucket_add(measurement, bucket);
2551 bucket = evel_new_meas_latency_bucket(30);
2552 evel_meas_latency_bucket_low_end_set(bucket, 10.0);
2553 evel_meas_latency_bucket_high_end_set(bucket, 20.0);
2554 evel_meas_latency_bucket_add(measurement, bucket);
2556 vnic_use = evel_new_measurement_vnic_use("eth0", 100, 200, 3, 4);
2557 evel_vnic_use_bcast_pkt_in_set(vnic_use, 1);
2558 evel_vnic_use_bcast_pkt_out_set(vnic_use, 2);
2559 evel_vnic_use_mcast_pkt_in_set(vnic_use, 5);
2560 evel_vnic_use_mcast_pkt_out_set(vnic_use, 6);
2561 evel_vnic_use_ucast_pkt_in_set(vnic_use, 7);
2562 evel_vnic_use_ucast_pkt_out_set(vnic_use, 8);
2563 evel_meas_vnic_use_add(measurement, vnic_use);
2565 vnic_use = evel_new_measurement_vnic_use("eth1", 110, 240, 13, 14);
2566 evel_vnic_use_bcast_pkt_in_set(vnic_use, 11);
2567 evel_vnic_use_bcast_pkt_out_set(vnic_use, 12);
2568 evel_vnic_use_mcast_pkt_in_set(vnic_use, 15);
2569 evel_vnic_use_mcast_pkt_out_set(vnic_use, 16);
2570 evel_vnic_use_ucast_pkt_in_set(vnic_use, 17);
2571 evel_vnic_use_ucast_pkt_out_set(vnic_use, 18);
2572 evel_meas_vnic_use_add(measurement, vnic_use);
2574 evel_measurement_errors_set(measurement, 1, 0, 2, 1);
2575 evel_measurement_feature_use_add(measurement, "FeatureA", 123);
2576 evel_measurement_feature_use_add(measurement, "FeatureB", 567);
2577 evel_measurement_codec_use_add(measurement, "G711a", 91);
2578 evel_measurement_codec_use_add(measurement, "G729ab", 92);
2579 evel_measurement_media_port_use_set(measurement, 1234);
2580 evel_measurement_vnfc_scaling_metric_set(measurement, 1234.5678);
2581 evel_measurement_custom_measurement_add(measurement,
2582 "Group1", "Name1", "Value1");
2583 evel_measurement_custom_measurement_add(measurement,
2584 "Group2", "Name1", "Value1");
2585 evel_measurement_custom_measurement_add(measurement,
2586 "Group2", "Name2", "Value2");
2588 json_size = evel_json_encode_event(
2589 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) measurement);
2590 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Measurement");
2591 assert((json_size == strlen(json_body)) && "Bad size returned");
2593 evel_free_event(measurement);
2594 evel_throttle_terminate();
2597 void test_encode_mobile_throttled()
2601 /***************************************************************************/
2602 /* We also test suppression of the event header parameters here. */
2603 /***************************************************************************/
2604 char * json_command_list =
2606 "\"commandList\": ["
2609 "\"commandType\": \"throttlingSpecification\", "
2610 "\"eventDomainThrottleSpecification\": {"
2611 "\"eventDomain\": \"mobileFlow\", "
2612 "\"suppressedFieldNames\": ["
2613 "\"applicationType\", "
2614 "\"appProtocolType\", "
2615 "\"appProtocolVersion\", "
2617 "\"connectionType\", "
2619 "\"gtpProtocolType\", "
2628 "\"otherFunctionalRole\", "
2630 "\"radioAccessTechnology\", "
2632 "\"samplingAlgorithm\", "
2637 "\"reportingEntityId\", "
2639 "\"suppressedNvPairsList\": ["
2646 "{\"commonEventHeader\": {"
2647 "\"domain\": \"mobileFlow\", "
2648 "\"eventId\": \"1242\", "
2649 "\"functionalRole\": \"UNIT TEST\", "
2650 "\"lastEpochMicrosec\": 1000002, "
2651 "\"priority\": \"Normal\", "
2652 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2653 "\"sequence\": 1242, "
2654 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2655 "\"startEpochMicrosec\": 1000002, "
2658 "\"mobileFlowFields\": {"
2659 "\"flowDirection\": \"Inbound\", "
2660 "\"gtpPerFlowMetrics\": {"
2661 "\"avgBitErrorRate\": 132.000100, "
2662 "\"avgPacketDelayVariation\": 31.200000, "
2663 "\"avgPacketLatency\": 101, "
2664 "\"avgReceiveThroughput\": 2101, "
2665 "\"avgTransmitThroughput\": 501, "
2666 "\"flowActivationEpoch\": 1470409422, "
2667 "\"flowActivationMicrosec\": 988, "
2668 "\"flowDeactivationEpoch\": 1470409432, "
2669 "\"flowDeactivationMicrosec\": 12, "
2670 "\"flowDeactivationTime\": \"Fri, 05 Aug 2016 15:03:52 +0000\", "
2671 "\"flowStatus\": \"Inactive\", "
2672 "\"maxPacketDelayVariation\": 88, "
2673 "\"numActivationFailures\": 4, "
2674 "\"numBitErrors\": 18, "
2675 "\"numBytesReceived\": 123655, "
2676 "\"numBytesTransmitted\": 4562, "
2677 "\"numDroppedPackets\": 1, "
2678 "\"numL7BytesReceived\": 13, "
2679 "\"numL7BytesTransmitted\": 11, "
2680 "\"numLostPackets\": 2, "
2681 "\"numOutOfOrderPackets\": 4, "
2682 "\"numPacketErrors\": 8, "
2683 "\"numPacketsReceivedExclRetrans\": 900, "
2684 "\"numPacketsReceivedInclRetrans\": 902, "
2685 "\"numPacketsTransmittedInclRetrans\": 303, "
2686 "\"numRetries\": 7, "
2687 "\"numTimeouts\": 3, "
2688 "\"numTunneledL7BytesReceived\": 1, "
2689 "\"roundTripTime\": 111, "
2690 "\"timeToFirstByte\": 226, "
2691 "\"ipTosCountList\": ["
2695 "\"ipTosList\": [\"1\", \"4\", \"17\"], "
2696 "\"tcpFlagList\": [\"CWR\", \"URG\"], "
2697 "\"tcpFlagCountList\": [[\"CWR\", 10], [\"URG\", 121]], "
2698 "\"mobileQciCosList\": [\"conversational\", \"65\"], "
2699 "\"mobileQciCosCountList\": [[\"conversational\", 11], [\"65\", 122]], "
2700 "\"durConnectionFailedStatus\": 12, "
2701 "\"durTunnelFailedStatus\": 13, "
2702 "\"flowActivatedBy\": \"Remote\", "
2703 "\"flowActivationTime\": \"Fri, 05 Aug 2016 15:03:43 +0000\", "
2704 "\"flowDeactivatedBy\": \"Remote\", "
2705 "\"gtpConnectionStatus\": \"Connected\", "
2706 "\"gtpTunnelStatus\": \"Not tunneling\", "
2707 "\"largePacketRtt\": 80, "
2708 "\"largePacketThreshold\": 600.000000, "
2709 "\"maxReceiveBitRate\": 1357924680, "
2710 "\"maxTransmitBitRate\": 235711, "
2711 "\"numGtpEchoFailures\": 1, "
2712 "\"numGtpTunnelErrors\": 4, "
2713 "\"numHttpErrors\": 2"
2715 "\"ipProtocolType\": \"UDP\", "
2716 "\"ipVersion\": \"IPv6\", "
2717 "\"otherEndpointIpAddress\": \"2.3.4.2\", "
2718 "\"otherEndpointPort\": 2342, "
2719 "\"reportingEndpointIpAddr\": \"4.2.3.2\", "
2720 "\"reportingEndpointPort\": 4322"
2723 /***************************************************************************/
2724 /* Initialize and provide a specification with a single fault suppressed. */
2725 /***************************************************************************/
2726 evel_throttle_initialize();
2727 handle_json_response(json_command_list, &post);
2729 /***************************************************************************/
2730 /* Check that the domain is throttled. */
2731 /***************************************************************************/
2732 assert(evel_get_throttle_spec(EVEL_DOMAIN_MOBILE_FLOW) != NULL);
2733 assert(post.memory == NULL);
2735 size_t json_size = 0;
2736 char json_body[EVEL_MAX_JSON_BODY];
2737 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
2738 EVENT_MOBILE_FLOW * mobile_flow = NULL;
2740 /***************************************************************************/
2742 /***************************************************************************/
2743 evel_set_next_event_sequence(1242);
2745 metrics = evel_new_mobile_gtp_flow_metrics(132.0001,
2775 assert(metrics != NULL);
2777 evel_mobile_gtp_metrics_dur_con_fail_set(metrics, 12);
2778 evel_mobile_gtp_metrics_dur_tun_fail_set(metrics, 13);
2779 evel_mobile_gtp_metrics_act_by_set(metrics, "Remote");
2780 evel_mobile_gtp_metrics_act_time_set(metrics, (time_t)1470409423);
2781 evel_mobile_gtp_metrics_deact_by_set(metrics, "Remote");
2782 evel_mobile_gtp_metrics_con_status_set(metrics, "Connected");
2783 evel_mobile_gtp_metrics_tun_status_set(metrics, "Not tunneling");
2784 evel_mobile_gtp_metrics_iptos_set(metrics, 1, 13);
2785 evel_mobile_gtp_metrics_iptos_set(metrics, 17, 1);
2786 evel_mobile_gtp_metrics_iptos_set(metrics, 4, 99);
2787 evel_mobile_gtp_metrics_large_pkt_rtt_set(metrics, 80);
2788 evel_mobile_gtp_metrics_large_pkt_thresh_set(metrics, 600.0);
2789 evel_mobile_gtp_metrics_max_rcv_bit_rate_set(metrics, 1357924680);
2790 evel_mobile_gtp_metrics_max_trx_bit_rate_set(metrics, 235711);
2791 evel_mobile_gtp_metrics_num_echo_fail_set(metrics, 1);
2792 evel_mobile_gtp_metrics_num_tun_fail_set(metrics, 4);
2793 evel_mobile_gtp_metrics_num_http_errors_set(metrics, 2);
2794 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_CWR, 10);
2795 evel_mobile_gtp_metrics_tcp_flag_count_add(metrics, EVEL_TCP_URG, 121);
2796 evel_mobile_gtp_metrics_qci_cos_count_add(
2797 metrics, EVEL_QCI_COS_UMTS_CONVERSATIONAL, 11);
2798 evel_mobile_gtp_metrics_qci_cos_count_add(
2799 metrics, EVEL_QCI_COS_LTE_65, 122);
2801 mobile_flow = evel_new_mobile_flow("Inbound",
2809 assert(mobile_flow != NULL);
2811 evel_mobile_flow_type_set(mobile_flow, "Mobile flow...");
2812 evel_mobile_flow_app_type_set(mobile_flow, "Demo application");
2813 evel_mobile_flow_app_prot_type_set(mobile_flow, "GSM");
2814 evel_mobile_flow_app_prot_ver_set(mobile_flow, "1");
2815 evel_mobile_flow_cid_set(mobile_flow, "65535");
2816 evel_mobile_flow_con_type_set(mobile_flow, "S1-U");
2817 evel_mobile_flow_ecgi_set(mobile_flow, "e65535");
2818 evel_mobile_flow_gtp_prot_type_set(mobile_flow, "GTP-U");
2819 evel_mobile_flow_gtp_prot_ver_set(mobile_flow, "1");
2820 evel_mobile_flow_http_header_set(mobile_flow,
2821 "http://www.something.com");
2822 evel_mobile_flow_imei_set(mobile_flow, "209917614823");
2823 evel_mobile_flow_imsi_set(mobile_flow, "355251/05/850925/8");
2824 evel_mobile_flow_lac_set(mobile_flow, "1");
2825 evel_mobile_flow_mcc_set(mobile_flow, "410");
2826 evel_mobile_flow_mnc_set(mobile_flow, "04");
2827 evel_mobile_flow_msisdn_set(mobile_flow, "6017123456789");
2828 evel_mobile_flow_other_func_role_set(mobile_flow, "MME");
2829 evel_mobile_flow_rac_set(mobile_flow, "514");
2830 evel_mobile_flow_radio_acc_tech_set(mobile_flow, "LTE");
2831 evel_mobile_flow_sac_set(mobile_flow, "1");
2832 evel_mobile_flow_samp_alg_set(mobile_flow, 1);
2833 evel_mobile_flow_tac_set(mobile_flow, "2099");
2834 evel_mobile_flow_tunnel_id_set(mobile_flow, "Tunnel 1");
2835 evel_mobile_flow_vlan_id_set(mobile_flow, "15");
2837 json_size = evel_json_encode_event(
2838 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) mobile_flow);
2839 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Mobile");
2840 assert((json_size == strlen(json_body)) && "Bad size returned");
2842 evel_free_event(mobile_flow);
2843 evel_throttle_terminate();
2846 void test_encode_other_throttled()
2850 /***************************************************************************/
2851 /* We also test suppression of the event header parameters here. */
2852 /***************************************************************************/
2853 char * json_command_list =
2855 "\"commandList\": ["
2858 "\"commandType\": \"throttlingSpecification\", "
2859 "\"eventDomainThrottleSpecification\": {"
2860 "\"eventDomain\": \"other\", "
2861 "\"suppressedFieldNames\": ["
2863 "\"reportingEntityId\", "
2865 "\"suppressedNvPairsList\": ["
2872 "{\"commonEventHeader\": {"
2873 "\"domain\": \"other\", "
2874 "\"eventId\": \"129\", "
2875 "\"functionalRole\": \"UNIT TEST\", "
2876 "\"lastEpochMicrosec\": 1000002, "
2877 "\"priority\": \"Normal\", "
2878 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2879 "\"sequence\": 129, "
2880 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2881 "\"startEpochMicrosec\": 1000002, "
2884 "\"otherFields\": ["
2885 "{\"name\": \"Other field 1\", "
2886 "\"value\": \"Other value 1\"}, "
2887 "{\"name\": \"Other field 2\", "
2888 "\"value\": \"Other value 2\"}"
2892 /***************************************************************************/
2893 /* Initialize and provide a specification with a single fault suppressed. */
2894 /***************************************************************************/
2895 evel_throttle_initialize();
2896 handle_json_response(json_command_list, &post);
2898 /***************************************************************************/
2899 /* Check that the domain is throttled. */
2900 /***************************************************************************/
2901 assert(evel_get_throttle_spec(EVEL_DOMAIN_OTHER) != NULL);
2902 assert(post.memory == NULL);
2904 size_t json_size = 0;
2905 char json_body[EVEL_MAX_JSON_BODY];
2906 EVENT_OTHER * other = NULL;
2907 evel_set_next_event_sequence(129);
2908 other = evel_new_other();
2909 assert(other != NULL);
2910 evel_other_type_set(other, "Other Type");
2911 evel_other_field_add(other,
2914 evel_other_field_add(other,
2918 json_size = evel_json_encode_event(
2919 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) other);
2920 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Other");
2921 assert((json_size == strlen(json_body)) && "Bad size returned");
2923 evel_free_event(other);
2924 evel_throttle_terminate();
2927 void test_encode_report_throttled()
2931 /***************************************************************************/
2932 /* We also test suppression of the event header parameters here. */
2933 /***************************************************************************/
2934 char * json_command_list =
2936 "\"commandList\": ["
2939 "\"commandType\": \"throttlingSpecification\", "
2940 "\"eventDomainThrottleSpecification\": {"
2941 "\"eventDomain\": \"report\", "
2942 "\"suppressedFieldNames\": ["
2944 "\"reportingEntityId\", "
2946 "\"suppressedNvPairsList\": ["
2948 "\"nvPairFieldName\": \"featureUsageArray\", "
2949 "\"suppressedNvPairNames\": [\"FeatureB\", \"FeatureC\"]"
2952 "\"nvPairFieldName\": \"additionalMeasurements\", "
2953 "\"suppressedNvPairNames\": [\"Group2\"]"
2961 "{\"commonEventHeader\": {"
2962 "\"domain\": \"measurementsForVfReporting\", "
2963 "\"eventId\": \"125\", "
2964 "\"functionalRole\": \"UNIT TEST\", "
2965 "\"lastEpochMicrosec\": 1000002, "
2966 "\"priority\": \"Normal\", "
2967 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
2968 "\"sequence\": 125, "
2969 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
2970 "\"startEpochMicrosec\": 1000002, "
2973 "\"measurementsForVfReportingFields\": "
2974 "{\"measurementInterval\": 1.100000, "
2975 "\"featureUsageArray\": ["
2976 "{\"featureIdentifier\": \"FeatureA\", "
2977 "\"featureUtilization\": 123}], "
2978 "\"additionalMeasurements\": ["
2979 "{\"name\": \"Group1\", "
2980 "\"measurements\": ["
2981 "{\"name\": \"Name1\", "
2982 "\"value\": \"Value1\"}]}], "
2983 "\"measurementFieldsVersion\": 1.1}}}";
2985 /***************************************************************************/
2986 /* Initialize and provide a specification with a single fault suppressed. */
2987 /***************************************************************************/
2988 evel_throttle_initialize();
2989 handle_json_response(json_command_list, &post);
2991 /***************************************************************************/
2992 /* Check that the domain is throttled. */
2993 /***************************************************************************/
2994 assert(evel_get_throttle_spec(EVEL_DOMAIN_REPORT) != NULL);
2995 assert(post.memory == NULL);
2997 size_t json_size = 0;
2998 char json_body[EVEL_MAX_JSON_BODY];
2999 EVENT_REPORT * report = NULL;
3001 /***************************************************************************/
3003 /***************************************************************************/
3004 evel_set_next_event_sequence(125);
3005 report = evel_new_report(1.1);
3006 assert(report != NULL);
3007 evel_report_type_set(report, "Perf reporting...");
3008 evel_report_feature_use_add(report, "FeatureA", 123);
3009 evel_report_feature_use_add(report, "FeatureB", 567);
3010 evel_report_custom_measurement_add(report, "Group1", "Name1", "Value1");
3011 evel_report_custom_measurement_add(report, "Group2", "Name1", "Value1");
3012 evel_report_custom_measurement_add(report, "Group2", "Name2", "Value2");
3014 json_size = evel_json_encode_event(
3015 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) report);
3016 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Report");
3017 assert((json_size == strlen(json_body)) && "Bad size returned");
3019 evel_free_event(report);
3020 evel_throttle_terminate();
3023 void test_encode_service_throttled()
3027 /***************************************************************************/
3028 /* We also test suppression of the event header parameters here. */
3029 /***************************************************************************/
3030 char * json_command_list =
3032 "\"commandList\": ["
3035 "\"commandType\": \"throttlingSpecification\", "
3036 "\"eventDomainThrottleSpecification\": {"
3037 "\"eventDomain\": \"serviceEvents\", "
3038 "\"suppressedFieldNames\": ["
3041 "\"codecSelected\", "
3042 "\"codecSelectedTranscoding\", "
3043 "\"endOfCallVqmSummaries\", "
3046 "\"reportingEntityId\", "
3048 "\"suppressedNvPairsList\": ["
3050 "\"nvPairFieldName\": \"additionalFields\", "
3051 "\"suppressedNvPairNames\": [\"Name1\", \"Name3\"]"
3059 "{\"commonEventHeader\": {"
3060 "\"domain\": \"serviceEvents\", "
3061 "\"eventId\": \"2000\", "
3062 "\"functionalRole\": \"UNIT TEST\", "
3063 "\"lastEpochMicrosec\": 1000002, "
3064 "\"priority\": \"Normal\", "
3065 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3066 "\"sequence\": 2000, "
3067 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3068 "\"startEpochMicrosec\": 1000002, "
3071 "\"serviceEventsFields\": {"
3072 "\"eventInstanceIdentifier\": "
3074 "\"vendorId\": \"vendor_x_id\", "
3075 "\"eventId\": \"vendor_x_event_id\", "
3076 "\"productId\": \"vendor_x_product_id\", "
3077 "\"subsystemId\": \"vendor_x_subsystem_id\", "
3078 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
3080 "\"serviceEventsFieldsVersion\": 1.1, "
3081 "\"additionalFields\": ["
3082 "{\"name\": \"Name2\", \"value\": \"Value2\"}, "
3083 "{\"name\": \"Name4\", \"value\": \"Value4\"}]"
3086 /***************************************************************************/
3087 /* Initialize and provide a specification with a single fault suppressed. */
3088 /***************************************************************************/
3089 evel_throttle_initialize();
3090 handle_json_response(json_command_list, &post);
3092 /***************************************************************************/
3093 /* Check that the domain is throttled. */
3094 /***************************************************************************/
3095 assert(evel_get_throttle_spec(EVEL_DOMAIN_SERVICE) != NULL);
3096 assert(post.memory == NULL);
3098 size_t json_size = 0;
3099 char json_body[EVEL_MAX_JSON_BODY];
3100 EVENT_SERVICE * event = NULL;
3101 evel_set_next_event_sequence(2000);
3102 event = evel_new_service("vendor_x_id", "vendor_x_event_id");
3103 assert(event != NULL);
3104 evel_service_type_set(event, "Service Event");
3105 evel_service_product_id_set(event, "vendor_x_product_id");
3106 evel_service_subsystem_id_set(event, "vendor_x_subsystem_id");
3107 evel_service_friendly_name_set(event, "vendor_x_frieldly_name");
3108 evel_service_correlator_set(event, "vendor_x_correlator");
3109 evel_service_codec_set(event, "PCMA");
3110 evel_service_codec_set(event, "PCMA");
3111 evel_service_callee_codec_set(event, "PCMA");
3112 evel_service_caller_codec_set(event, "G729A");
3113 evel_service_rtcp_data_set(event, "some_rtcp_data");
3114 evel_service_adjacency_name_set(event, "vendor_x_adjacency");
3115 evel_service_endpoint_desc_set(event, EVEL_SERVICE_ENDPOINT_CALLER);
3116 evel_service_endpoint_jitter_set(event, 66);
3117 evel_service_endpoint_rtp_oct_disc_set(event, 100);
3118 evel_service_endpoint_rtp_oct_recv_set(event, 200);
3119 evel_service_endpoint_rtp_oct_sent_set(event, 300);
3120 evel_service_endpoint_rtp_pkt_disc_set(event, 400);
3121 evel_service_endpoint_rtp_pkt_recv_set(event, 500);
3122 evel_service_endpoint_rtp_pkt_sent_set(event, 600);
3123 evel_service_local_jitter_set(event, 99);
3124 evel_service_local_rtp_oct_disc_set(event, 150);
3125 evel_service_local_rtp_oct_recv_set(event, 250);
3126 evel_service_local_rtp_oct_sent_set(event, 350);
3127 evel_service_local_rtp_pkt_disc_set(event, 450);
3128 evel_service_local_rtp_pkt_recv_set(event, 550);
3129 evel_service_local_rtp_pkt_sent_set(event, 650);
3130 evel_service_mos_cqe_set(event, 12.255);
3131 evel_service_packets_lost_set(event, 157);
3132 evel_service_packet_loss_percent_set(event, 0.232);
3133 evel_service_r_factor_set(event, 11);
3134 evel_service_round_trip_delay_set(event, 15);
3135 evel_service_phone_number_set(event, "0888888888");
3136 evel_service_addl_field_add(event, "Name1", "Value1");
3137 evel_service_addl_field_add(event, "Name2", "Value2");
3138 evel_service_addl_field_add(event, "Name3", "Value3");
3139 evel_service_addl_field_add(event, "Name4", "Value4");
3140 json_size = evel_json_encode_event(
3141 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
3142 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Service");
3143 assert((json_size == strlen(json_body)) && "Bad size returned");
3145 evel_free_event(event);
3146 evel_throttle_terminate();
3149 void test_encode_signaling_throttled()
3153 /***************************************************************************/
3154 /* We also test suppression of the event header parameters here. */
3155 /***************************************************************************/
3156 char * json_command_list =
3158 "\"commandList\": ["
3161 "\"commandType\": \"throttlingSpecification\", "
3162 "\"eventDomainThrottleSpecification\": {"
3163 "\"eventDomain\": \"signaling\", "
3164 "\"suppressedFieldNames\": ["
3167 "\"reportingEntityId\", "
3169 "\"localIpAddress\", "
3171 "\"remoteIpAddress\", "
3173 "\"compressedSip\", "
3175 "\"suppressedNvPairsList\": ["
3182 "{\"commonEventHeader\": {"
3183 "\"domain\": \"signaling\", "
3184 "\"eventId\": \"2001\", "
3185 "\"functionalRole\": \"UNIT TEST\", "
3186 "\"lastEpochMicrosec\": 1000002, "
3187 "\"priority\": \"Normal\", "
3188 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3189 "\"sequence\": 2001, "
3190 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3191 "\"startEpochMicrosec\": 1000002, "
3194 "\"signalingFields\": {"
3195 "\"eventInstanceIdentifier\": "
3197 "\"vendorId\": \"vendor_x_id\", "
3198 "\"eventId\": \"vendor_x_event_id\", "
3199 "\"productId\": \"vendor_x_product_id\", "
3200 "\"subsystemId\": \"vendor_x_subsystem_id\", "
3201 "\"eventFriendlyName\": \"vendor_x_frieldly_name\""
3203 "\"signalingFieldsVersion\": 1.1"
3206 /***************************************************************************/
3207 /* Initialize and provide a specification with a single fault suppressed. */
3208 /***************************************************************************/
3209 evel_throttle_initialize();
3210 handle_json_response(json_command_list, &post);
3212 /***************************************************************************/
3213 /* Check that the domain is throttled. */
3214 /***************************************************************************/
3215 assert(evel_get_throttle_spec(EVEL_DOMAIN_SIGNALING) != NULL);
3216 assert(post.memory == NULL);
3218 size_t json_size = 0;
3219 char json_body[EVEL_MAX_JSON_BODY];
3220 EVENT_SIGNALING * event = NULL;
3221 evel_set_next_event_sequence(2001);
3222 event = evel_new_signaling("vendor_x_id",
3223 "correlator", "1.0.3.1", "1234", "192.168.1.3","3456");
3224 assert(event != NULL);
3225 evel_signaling_vnfmodule_name_set(event, "vendor_x_module");
3226 evel_signaling_vnfname_set(event, "vendor_x_vnf");
3227 evel_signaling_type_set(event, "Signaling");
3228 evel_signaling_product_id_set(event, "vendor_x_product_id");
3229 evel_signaling_subsystem_id_set(event, "vendor_x_subsystem_id");
3230 evel_signaling_friendly_name_set(event, "vendor_x_frieldly_name");
3231 evel_signaling_correlator_set(event, "vendor_x_correlator");
3232 evel_signaling_local_ip_address_set(event, "1.0.3.1");
3233 evel_signaling_local_port_set(event, "1031");
3234 evel_signaling_remote_ip_address_set(event, "5.3.3.0");
3235 evel_signaling_remote_port_set(event, "5330");
3236 evel_signaling_compressed_sip_set(event, "compressed_sip");
3237 evel_signaling_summary_sip_set(event, "summary_sip");
3238 json_size = evel_json_encode_event(
3239 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) event);
3240 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Signaling");
3241 assert((json_size == strlen(json_body)) && "Bad size returned");
3243 evel_free_event(event);
3244 evel_throttle_terminate();
3247 void test_encode_state_change_throttled()
3251 /***************************************************************************/
3252 /* We also test suppression of the event header parameters here. */
3253 /***************************************************************************/
3254 char * json_command_list =
3256 "\"commandList\": ["
3259 "\"commandType\": \"throttlingSpecification\", "
3260 "\"eventDomainThrottleSpecification\": {"
3261 "\"eventDomain\": \"stateChange\", "
3262 "\"suppressedFieldNames\": ["
3264 "\"reportingEntityId\", "
3266 "\"suppressedNvPairsList\": ["
3268 "\"nvPairFieldName\": \"additionalFields\", "
3269 "\"suppressedNvPairNames\": [\"Name1\"]"
3277 "{\"commonEventHeader\": {"
3278 "\"domain\": \"stateChange\", "
3279 "\"eventId\": \"128\", "
3280 "\"functionalRole\": \"UNIT TEST\", "
3281 "\"lastEpochMicrosec\": 1000002, "
3282 "\"priority\": \"Normal\", "
3283 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3284 "\"sequence\": 128, "
3285 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3286 "\"startEpochMicrosec\": 1000002, "
3289 "\"stateChangeFields\": {"
3290 "\"newState\": \"inService\", "
3291 "\"oldState\": \"outOfService\", "
3292 "\"stateInterface\": \"An Interface\", "
3293 "\"additionalFields\": ["
3294 "{\"name\": \"Name2\", "
3295 "\"value\": \"Value2\"}"
3297 "\"stateChangeFieldsVersion\": 1.1"
3300 /***************************************************************************/
3301 /* Initialize and provide a specification with a single fault suppressed. */
3302 /***************************************************************************/
3303 evel_throttle_initialize();
3304 handle_json_response(json_command_list, &post);
3306 /***************************************************************************/
3307 /* Check that the domain is throttled. */
3308 /***************************************************************************/
3309 assert(evel_get_throttle_spec(EVEL_DOMAIN_STATE_CHANGE) != NULL);
3310 assert(post.memory == NULL);
3312 size_t json_size = 0;
3313 char json_body[EVEL_MAX_JSON_BODY];
3314 EVENT_STATE_CHANGE * state_change = NULL;
3315 evel_set_next_event_sequence(128);
3316 state_change = evel_new_state_change(EVEL_ENTITY_STATE_IN_SERVICE,
3317 EVEL_ENTITY_STATE_OUT_OF_SERVICE,
3319 assert(state_change != NULL);
3320 evel_state_change_type_set(state_change, "SC Type");
3321 evel_state_change_addl_field_add(state_change, "Name1", "Value1");
3322 evel_state_change_addl_field_add(state_change, "Name2", "Value2");
3324 json_size = evel_json_encode_event(
3325 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) state_change);
3326 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "StateChange");
3327 assert((json_size == strlen(json_body)) && "Bad size returned");
3329 evel_free_event(state_change);
3330 evel_throttle_terminate();
3333 void test_encode_syslog_throttled()
3337 /***************************************************************************/
3338 /* We also test suppression of the event header parameters here. */
3339 /***************************************************************************/
3340 char * json_command_list =
3342 "\"commandList\": ["
3345 "\"commandType\": \"throttlingSpecification\", "
3346 "\"eventDomainThrottleSpecification\": {"
3347 "\"eventDomain\": \"syslog\", "
3348 "\"suppressedFieldNames\": ["
3349 "\"eventSourceHost\", "
3350 "\"syslogFacility\", "
3352 "\"syslogProcId\", "
3356 "\"reportingEntityId\", "
3358 "\"suppressedNvPairsList\": ["
3360 "\"nvPairFieldName\": \"additionalFields\", "
3361 "\"suppressedNvPairNames\": [\"Name2\"]"
3369 "{\"commonEventHeader\": {"
3370 "\"domain\": \"syslog\", "
3371 "\"eventId\": \"126\", "
3372 "\"functionalRole\": \"UNIT TEST\", "
3373 "\"lastEpochMicrosec\": 1000002, "
3374 "\"priority\": \"Normal\", "
3375 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3376 "\"sequence\": 126, "
3377 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3378 "\"startEpochMicrosec\": 1000002, "
3381 "\"syslogFields\": {"
3382 "\"eventSourceType\": \"virtualNetworkFunction\", "
3383 "\"syslogMsg\": \"SL Message\", "
3384 "\"syslogTag\": \"SL Tag\", "
3385 "\"syslogFieldsVersion\": 1.1, "
3386 "\"additionalFields\": ["
3387 "{\"name\": \"Name1\", "
3388 "\"value\": \"Value1\"}"
3392 /***************************************************************************/
3393 /* Initialize and provide a specification with a single fault suppressed. */
3394 /***************************************************************************/
3395 evel_throttle_initialize();
3396 handle_json_response(json_command_list, &post);
3398 /***************************************************************************/
3399 /* Check that the domain is throttled. */
3400 /***************************************************************************/
3401 assert(evel_get_throttle_spec(EVEL_DOMAIN_SYSLOG) != NULL);
3402 assert(post.memory == NULL);
3404 size_t json_size = 0;
3405 char json_body[EVEL_MAX_JSON_BODY];
3406 EVENT_SYSLOG * syslog = NULL;
3407 evel_set_next_event_sequence(126);
3408 syslog = evel_new_syslog(EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION,
3411 assert(syslog != NULL);
3412 evel_syslog_type_set(syslog, "SL Type");
3413 evel_syslog_event_source_host_set(syslog, "SL Host");
3414 evel_syslog_facility_set(syslog, EVEL_SYSLOG_FACILITY_LINE_PRINTER);
3415 evel_syslog_proc_set(syslog, "SL Proc");
3416 evel_syslog_proc_id_set(syslog, 2);
3417 evel_syslog_version_set(syslog, 1);
3418 evel_syslog_s_data_set(syslog, "SL SDATA");
3419 evel_syslog_addl_field_add(syslog, "Name1", "Value1");
3420 evel_syslog_addl_field_add(syslog, "Name2", "Value2");
3422 json_size = evel_json_encode_event(
3423 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) syslog);
3424 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Syslog");
3425 assert((json_size == strlen(json_body)) && "Bad size returned");
3427 evel_free_event(syslog);
3428 evel_throttle_terminate();
3431 void test_encode_fault_with_escaping()
3435 "\"commonEventHeader\": {"
3436 "\"domain\": \"fault\", "
3437 "\"eventId\": \"122\", "
3438 "\"functionalRole\": \"UNIT TEST\", "
3439 "\"lastEpochMicrosec\": 1000002, "
3440 "\"priority\": \"Normal\", "
3441 "\"reportingEntityName\": \"Dummy VM name - No Metadata available\", "
3442 "\"sequence\": 122, "
3443 "\"sourceName\": \"Dummy VM name - No Metadata available\", "
3444 "\"startEpochMicrosec\": 1000002, "
3445 "\"version\": 1.2, "
3446 "\"eventType\": \"Bad things happen...\\\\\", "
3447 "\"reportingEntityId\": \"Dummy VM UUID - No Metadata available\", "
3448 "\"sourceId\": \"Dummy VM UUID - No Metadata available\""
3450 "\"faultFields\": {"
3451 "\"alarmCondition\": \"My alarm condition\", "
3452 "\"eventSeverity\": \"MAJOR\", "
3453 "\"eventSourceType\": \"other\", "
3454 "\"specificProblem\": \"It broke \\\"very\\\" badly\", "
3455 "\"vfStatus\": \"Active\", "
3456 "\"faultFieldsVersion\": 1.1, "
3457 "\"alarmAdditionalInformation\": ["
3458 "{\"name\": \"name1\", "
3459 "\"value\": \"value1\"}, "
3460 "{\"name\": \"name2\", "
3461 "\"value\": \"value2\"}], "
3462 "\"alarmInterfaceA\": \"My Interface Card\""
3465 size_t json_size = 0;
3466 char json_body[EVEL_MAX_JSON_BODY];
3467 evel_set_next_event_sequence(122);
3468 EVENT_FAULT * fault = evel_new_fault("My alarm condition",
3469 "It broke \"very\" badly",
3470 EVEL_PRIORITY_NORMAL,
3471 EVEL_SEVERITY_MAJOR,
3473 EVEL_VF_STATUS_PREP_TERMINATE);
3474 assert(fault != NULL);
3475 evel_fault_type_set(fault, "Bad things happen...\\");
3476 evel_fault_interface_set(fault, "My Interface Card");
3477 evel_fault_addl_info_add(fault, "name1", "value1");
3478 evel_fault_addl_info_add(fault, "name2", "value2");
3480 json_size = evel_json_encode_event(
3481 json_body, EVEL_MAX_JSON_BODY, (EVENT_HEADER *) fault);
3482 compare_strings(expected, json_body, EVEL_MAX_JSON_BODY, "Fault");
3483 assert((json_size == strlen(json_body)) && "Bad size returned");
3485 evel_free_event(fault);