Skip to content

Commit 0a73313

Browse files
committed
Add unit tests for bitrate unit conversion
- Test conversion of mbps, kbps, gbps, tbps to bps - Verify both IPv4 and IPv6 parsers handle all bitrate units - Ensure normalized output maintains bps format
1 parent c325817 commit 0a73313

4 files changed

Lines changed: 204 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
expected_output = {
2+
'vrf': {
3+
'default': {
4+
'address_family': {
5+
'ipv4': {
6+
'count_multicast_starg': 2,
7+
'count_multicast_sg': 4,
8+
'count_multicast_starg_prefix': 0,
9+
'count_multicast_total': 6,
10+
'group_count': 2,
11+
'avg_source_per_group': 2.0,
12+
'groups': {
13+
'225.0.0.1/32': {
14+
'source_count': 2,
15+
'source': {
16+
'(*,G)': {
17+
'packets': 0,
18+
'bytes': 0,
19+
'aps': 0,
20+
'pps': 0,
21+
'bitrate': 0.0,
22+
'bitrate_unit': 'bps',
23+
'oifs': 2
24+
},
25+
'100.100.100.5': {
26+
'packets': 1704,
27+
'bytes': 86904,
28+
'aps': 51,
29+
'pps': 0,
30+
'bitrate': 1500000.0,
31+
'bitrate_unit': 'bps',
32+
'oifs': 2
33+
},
34+
'100.100.100.6': {
35+
'packets': 1700,
36+
'bytes': 86700,
37+
'aps': 51,
38+
'pps': 0,
39+
'bitrate': 500000.0,
40+
'bitrate_unit': 'bps',
41+
'oifs': 1
42+
}
43+
}
44+
},
45+
'225.0.0.2/32': {
46+
'source_count': 2,
47+
'source': {
48+
'(*,G)': {
49+
'packets': 0,
50+
'bytes': 0,
51+
'aps': 0,
52+
'pps': 0,
53+
'bitrate': 0.0,
54+
'bitrate_unit': 'bps',
55+
'oifs': 2
56+
},
57+
'100.100.100.7': {
58+
'packets': 1743,
59+
'bytes': 88893,
60+
'aps': 51,
61+
'pps': 0,
62+
'bitrate': 2000000000.0,
63+
'bitrate_unit': 'bps',
64+
'oifs': 1
65+
},
66+
'100.100.100.8': {
67+
'packets': 1891,
68+
'bytes': 100806,
69+
'aps': 53,
70+
'pps': 0,
71+
'bitrate': 1000000000000.0,
72+
'bitrate_unit': 'bps',
73+
'oifs': 2
74+
}
75+
}
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
IP Multicast Routing Table for VRF "default"
2+
Route Statistics unavailable - only liveness detected
3+
4+
Total number of routes: 6
5+
Total number of (*,G) routes: 2
6+
Total number of (S,G) routes: 4
7+
Total number of (*,G-prefix) routes: 0
8+
Group count: 2, rough average sources per group: 2.0
9+
10+
Group: 225.0.0.1/32, Source count: 2
11+
Source packets bytes aps pps bit-rate oifs
12+
(*,G) 0 0 0 0 0.000 bps 2
13+
100.100.100.5 1704 86904 51 0 1.500 mbps 2
14+
100.100.100.6 1700 86700 51 0 500.000 kbps 1
15+
16+
Group: 225.0.0.2/32, Source count: 2
17+
Source packets bytes aps pps bit-rate oifs
18+
(*,G) 0 0 0 0 0.000 bps 2
19+
100.100.100.7 1743 88893 51 0 2.000 gbps 1
20+
100.100.100.8 1891 100806 53 0 1.000 tbps 2
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
expected_output = {
2+
'vrf': {
3+
'default': {
4+
'address_family': {
5+
'ipv6': {
6+
'count_multicast_starg': 2,
7+
'count_multicast_sg': 4,
8+
'count_multicast_starg_prefix': 0,
9+
'count_multicast_total': 6,
10+
'group_count': 2,
11+
'avg_source_per_group': 2.0,
12+
'groups': {
13+
'ff32::/32': {
14+
'source_count': 2,
15+
'source': {
16+
'(*,G)': {
17+
'packets': 0,
18+
'bytes': 0,
19+
'aps': 0,
20+
'pps': 0,
21+
'bitrate': 0.0,
22+
'bitrate_unit': 'bps',
23+
'oifs': 2
24+
},
25+
'2001:180:1:57::1181': {
26+
'packets': 968,
27+
'bytes': 49478,
28+
'aps': 51,
29+
'pps': 0,
30+
'bitrate': 1500000.0,
31+
'bitrate_unit': 'bps',
32+
'oifs': 1
33+
},
34+
'2001:180:1:57::1182': {
35+
'packets': 970,
36+
'bytes': 49580,
37+
'aps': 51,
38+
'pps': 0,
39+
'bitrate': 750000.0,
40+
'bitrate_unit': 'bps',
41+
'oifs': 1
42+
}
43+
}
44+
},
45+
'ff33:0:0:1197::1/128': {
46+
'source_count': 2,
47+
'source': {
48+
'(*,G)': {
49+
'packets': 0,
50+
'bytes': 0,
51+
'aps': 0,
52+
'pps': 0,
53+
'bitrate': 0.0,
54+
'bitrate_unit': 'bps',
55+
'oifs': 2
56+
},
57+
'2001:180:1:57::1183': {
58+
'packets': 1000,
59+
'bytes': 51000,
60+
'aps': 52,
61+
'pps': 0,
62+
'bitrate': 3000000000.0,
63+
'bitrate_unit': 'bps',
64+
'oifs': 1
65+
},
66+
'2001:180:1:57::1184': {
67+
'packets': 1100,
68+
'bytes': 56100,
69+
'aps': 53,
70+
'pps': 0,
71+
'bitrate': 2000000000000.0,
72+
'bitrate_unit': 'bps',
73+
'oifs': 2
74+
}
75+
}
76+
}
77+
}
78+
}
79+
}
80+
}
81+
}
82+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
IPv6 Multicast Routing Table for VRF "default"
2+
Route Statistics unavailable - only liveness detected
3+
4+
Total number of routes: 6
5+
Total number of (*,G) routes: 2
6+
Total number of (S,G) routes: 4
7+
Total number of (*,G-prefix) routes: 0
8+
Group count: 2, rough average sources per group: 2.0
9+
10+
Group: ff32::/32, Source count: 2
11+
Source packets bytes aps pps bit-rate oifs
12+
(*,G) 0 0 0 0 0.000 bps 2
13+
2001:180:1:57::1181 968 49478 51 0 1.500 mbps 1
14+
2001:180:1:57::1182 970 49580 51 0 750.000 kbps 1
15+
16+
Group: ff33:0:0:1197::1/128, Source count: 2
17+
Source packets bytes aps pps bit-rate oifs
18+
(*,G) 0 0 0 0 0.000 bps 2
19+
2001:180:1:57::1183 1000 51000 52 0 3.000 gbps 1
20+
2001:180:1:57::1184 1100 56100 53 0 2.000 tbps 2

0 commit comments

Comments
 (0)