summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Provoost <luc.provoost@intel.com>2020-04-27 12:32:43 -0400
committerLuc Provoost <luc.provoost@intel.com>2020-05-15 11:55:09 +0200
commit4d932aced6931d756e07dbce6ab7cf04799ba5f4 (patch)
treee8ac2d1af449671f451450fb8ae106496a73798f
parent44327c1d12591af41658a4c492fdee597fe4ab74 (diff)
Code rewrite and Python3 support
The code has been rewritten in multiple classes and files for better readability and maintainability. You should now also use Python3 to run the scripts. Some of the variables in the config files have moved to other sections. The pushgateway parameter moved to the [varia] section of the rapid environment file. Change-Id: Ic61a1bc3baa39447d42b21dfcc0f16c28fcdfa6e Signed-off-by: Luc Provoost <luc.provoost@intel.com>
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/TST009_Throughput.test30
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/bare.test17
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/basicrapid.test40
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/corestats.test4
-rwxr-xr-xVNFs/DPPD-PROX/helper-scripts/rapid/devbind.sh9
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/gen.cfg6
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/gen_gw.cfg6
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/impair.cfg2
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/impair.test16
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/irq.test10
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/l2framerate.test12
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/l2gen.cfg6
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/l2gen_bare.cfg4
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/l2zeroloss.test16
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/l3framerate.test7
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/portstats.test4
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py203
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_cli.py92
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py91
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_defaults.py34
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_flowsizetest.py259
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_generator_machine.py112
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_impairtest.py79
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_irqtest.py71
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_log.py122
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py122
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py136
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_portstatstest.py85
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_test.py290
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/rapid_warmuptest.py51
-rwxr-xr-xVNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py1317
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/secgw.test16
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/secgw1.cfg2
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/secgw2.cfg2
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/swap.cfg2
35 files changed, 1860 insertions, 1415 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/TST009_Throughput.test b/VNFs/DPPD-PROX/helper-scripts/rapid/TST009_Throughput.test
index d0d8db57..db7c9139 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/TST009_Throughput.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/TST009_Throughput.test
@@ -14,13 +14,11 @@
## limitations under the License.
##
-[DEFAULT]
-name = BasicSwapTesting
+[TestParameters]
+name = TST009Testing
number_of_tests = 2
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
-#PushGateway=http://192.168.36.1:9091
+lat_percentile = 99
[TestM1]
name = Generator
@@ -35,14 +33,6 @@ name = Swap
config_file = swap.cfg
cores = [1]
-[TST009SearchParams]
-drop_rate_threshold = 0
-MAXr = 3
-MAXz = 5000
-MAXFramesPerSecondAllIngress = 12000000
-StepSize = 10000
-
-
[test1]
test=warmuptest
flowsize=512
@@ -52,7 +42,17 @@ warmuptime=2
[test2]
test=TST009test
-packetsizes=[64]
+# Following parameter defines the success criterium for the test.
+# When this test uses multiple combinations of packet size and flows,
+# all combinations must be meeting the same threshold
+# The threshold is expressed in Mpps
+pass_threshold=0.1
+packetsizes=[64,128]
# the number of flows in the list need to be powers of 2, max 2^20
# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
-flows=[1024]
+flows=[8,1024]
+drop_rate_threshold = 0
+MAXr = 3
+MAXz = 5000
+MAXFramesPerSecondAllIngress = 12000000
+StepSize = 10000
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/bare.test b/VNFs/DPPD-PROX/helper-scripts/rapid/bare.test
index 7991f3b1..e3775be9 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/bare.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/bare.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = BareTesting
number_of_tests = 2
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Generator
@@ -33,13 +31,6 @@ name = Swap
config_file = l2swap.cfg
cores = [1]
-[BinarySearchParams]
-drop_rate_threshold = 0
-lat_avg_threshold = 500
-lat_max_threshold = 1000
-accuracy = 0.1
-startspeed = 10
-
[test1]
test=warmuptest
flowsize=512
@@ -53,3 +44,9 @@ packetsizes=[64,128]
# the number of flows in the list need to be powers of 2, max 2^20
# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
flows=[512,1]
+drop_rate_threshold = 0
+lat_avg_threshold = 500
+lat_max_threshold = 1000
+accuracy = 0.1
+startspeed = 10
+
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/basicrapid.test b/VNFs/DPPD-PROX/helper-scripts/rapid/basicrapid.test
index d3213d21..361b0dd7 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/basicrapid.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/basicrapid.test
@@ -14,13 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = BasicSwapTesting
number_of_tests = 2
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
-#PushGateway=http://192.168.36.1:9091
lat_percentile = 99
[TestM1]
@@ -29,19 +26,14 @@ config_file = gen.cfg
dest_vm = 2
gencores = [1]
latcores = [3]
+#bucket_size_exp = 12
[TestM2]
name = Swap
config_file = swap.cfg
-cores = [1]
-
-[BinarySearchParams]
-drop_rate_threshold = 0.1
-lat_avg_threshold = 50
-lat_perc_threshold = 80
-lat_max_threshold = inf
-accuracy = 0.1
-startspeed = 5
+cores = [1,2]
+#prox_socket = true
+#prox_launch_exit = true
[test1]
test=warmuptest
@@ -52,7 +44,21 @@ warmuptime=2
[test2]
test=flowsizetest
-packetsizes=[64]
-# the number of flows in the list need to be powers of 2, max 2^20
-# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
-flows=[64]
+# Following parameter defines the success criterium for the test.
+# When this test uses multiple combinations of packet size and flows,
+# all combinations must be meeting the same threshold
+# The threshold is expressed in Mpps
+pass_threshold=0.1
+packetsizes=[64,128]
+# the number of flows in the list need to be powers of 2, max 2^30
+# If not a power of 2, we will use the lowest power of 2 that is larger than
+# the requested number of flows. e.g. 9 will result in 16 flows
+flows=[64,500000]
+# Setting one of the following thresholds to infinity (inf)
+# results in the criterion not being evaluated to rate the test as scussesful
+drop_rate_threshold = 0.1
+lat_avg_threshold = 50
+lat_perc_threshold = 80
+lat_max_threshold = inf
+accuracy = 1
+startspeed = 50
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/corestats.test b/VNFs/DPPD-PROX/helper-scripts/rapid/corestats.test
index 026a2036..f29e8587 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/corestats.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/corestats.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = CoreStatistics
number_of_tests = 1
total_number_of_test_machines = 1
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Swap
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/devbind.sh b/VNFs/DPPD-PROX/helper-scripts/rapid/devbind.sh
new file mode 100755
index 00000000..ac6ccaa1
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/devbind.sh
@@ -0,0 +1,9 @@
+link="$(sudo ip -o link | grep MACADDRESS |cut -d":" -f 2)"
+if [ -n "$link" ];
+then
+ echo Need to bind
+ sudo ~/dpdk/usertools/dpdk-devbind.py --force --bind igb_uio $(sudo ~/dpdk/usertools/dpdk-devbind.py --status |grep $link | cut -d" " -f 1)
+else
+ echo Assuming port is already bound to DPDK
+fi
+exit 0
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/gen.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/gen.cfg
index 4944f017..852eed3e 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/gen.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/gen.cfg
@@ -48,10 +48,10 @@ mode=gen
sub mode=l3
tx port=p0
bps=1250000000
-pkt inline=00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip} ${dest_hex_ip} 0b b8 0b b9 00 1a 55 7b
+pkt inline=00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip1} ${dest_hex_ip1} 0b b8 0b b9 00 1a 55 7b
pkt size=60
-;gateway ipv4=${gw_ip}
-local ipv4=${local_ip}
+;gateway ipv4=${gw_ip1}
+local ipv4=${local_ip1}
min bulk size=$mbs
max bulk size=16
drop=yes
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/gen_gw.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/gen_gw.cfg
index b4843acf..3b958757 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/gen_gw.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/gen_gw.cfg
@@ -48,10 +48,10 @@ mode=gen
sub mode=l3
tx port=p0
bps=1250000000
-pkt inline=00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip} ${dest_hex_ip} 0b b8 0b b9 00 1a 55 7b
+pkt inline=00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip1} ${dest_hex_ip1} 0b b8 0b b9 00 1a 55 7b
pkt size=60
-gateway ipv4=${gw_ip}
-local ipv4=${local_ip}
+gateway ipv4=${gw_ip1}
+local ipv4=${local_ip1}
min bulk size=$mbs
max bulk size=16
drop=yes
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/impair.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/impair.cfg
index 183fe77b..26c4b4e7 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/impair.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/impair.cfg
@@ -48,4 +48,4 @@ rx port=if0
tx port=if0
delay us=1000
probability=100
-local ipv4=${local_ip}
+local ipv4=${local_ip1}
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/impair.test b/VNFs/DPPD-PROX/helper-scripts/rapid/impair.test
index ee926ae4..b8e34568 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/impair.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/impair.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = impairTesting
number_of_tests = 2
total_number_of_test_machines = 3
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Generator
@@ -39,13 +37,6 @@ name = Swap
config_file = swap.cfg
cores = [1]
-[BinarySearchParams]
-drop_rate_threshold = 0.1
-lat_avg_threshold = 500
-lat_max_threshold = 1000
-accuracy = 0.1
-startspeed = 10
-
[test1]
test=warmuptest
flowsize=1024
@@ -57,3 +48,8 @@ warmuptime=2
test=impairtest
packetsize=64
flowsize=64
+drop_rate_threshold = 0.1
+lat_avg_threshold = 500
+lat_max_threshold = 1000
+accuracy = 0.1
+startspeed = 10
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/irq.test b/VNFs/DPPD-PROX/helper-scripts/rapid/irq.test
index 5ba0df87..2cf72f9b 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/irq.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/irq.test
@@ -14,20 +14,18 @@
## limitations under the License.
##
-[DEFAULT]
-name = BasicSwapTesting
+[TestParameters]
+name = IRQTesting
number_of_tests = 1
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
[TestM1]
-name = InterruptTesting
+name = InterruptTestMachine1
config_file = irq.cfg
cores = [1,2,3]
[TestM2]
-name = InterruptTesting
+name = InterruptTestMachine2
config_file = irq.cfg
cores = [1,2,3]
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/l2framerate.test b/VNFs/DPPD-PROX/helper-scripts/rapid/l2framerate.test
index 4fb0baef..3efbc1a8 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/l2framerate.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/l2framerate.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = L2BasicSwapTesting
number_of_tests = 1
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Generator
@@ -27,7 +25,6 @@ config_file = l2gen.cfg
dest_vm = 2
gencores = [1]
latcores = [3]
-startspeed = 10
[TestM2]
name = Swap
@@ -36,6 +33,11 @@ cores = [1]
[test1]
test=fixed_rate
+# Following parameter defines the success criterium for the test.
+# When this test uses multiple combinations of packet size and flows,
+# all combinations must be meeting the same threshold
+# The threshold is expressed in Mpps
+pass_threshold=0.1
+startspeed = 10
packetsizes=[256]
flows=[64]
-speed=10
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen.cfg
index b1f624c1..e4c1c37e 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen.cfg
@@ -46,10 +46,10 @@ task=0
mode=gen
tx port=p0
bps=1250000000
-pkt inline=${dest_hex_mac} 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip} ${dest_hex_ip} 0b b8 0b b9 00 1a 55 7b
+pkt inline=${dest_hex_mac1} 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip1} ${dest_hex_ip1} 0b b8 0b b9 00 1a 55 7b
pkt size=60
-;gateway ipv4=${gw_ip}
-local ipv4=${local_ip}
+;gateway ipv4=${gw_ip1}
+local ipv4=${local_ip1}
min bulk size=$mbs
max bulk size=16
drop=yes
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen_bare.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen_bare.cfg
index 57a7094d..ff9ef8b8 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen_bare.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/l2gen_bare.cfg
@@ -46,9 +46,9 @@ task=0
mode=gen
tx port=p0
bps=1250000000
-pkt inline=${dest_hex_mac} 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip} ${dest_hex_ip} 0b b8 0b b9 00 1a 55 7b
+pkt inline=${dest_hex_mac1} 00 00 00 00 00 00 08 00 45 00 00 2e 00 01 00 00 40 11 f7 7d ${local_hex_ip1} ${dest_hex_ip1} 0b b8 0b b9 00 1a 55 7b
pkt size=60
-local ipv4=${local_ip}
+local ipv4=${local_ip1}
min bulk size=$mbs
max bulk size=64
drop=yes
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/l2zeroloss.test b/VNFs/DPPD-PROX/helper-scripts/rapid/l2zeroloss.test
index 106b4c6d..bc417c1b 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/l2zeroloss.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/l2zeroloss.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = L2BasicSwapTesting
number_of_tests = 2
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Generator
@@ -33,13 +31,6 @@ name = Swap
config_file = l2swap.cfg
cores = [1]
-[BinarySearchParams]
-drop_rate_threshold = 0
-lat_avg_threshold = 500
-lat_max_threshold = 1000
-accuracy = 0.1
-startspeed = 10
-
[test1]
test=warmuptest
flowsize=512
@@ -53,3 +44,8 @@ packetsizes=[64]
# the number of flows in the list need to be powers of 2, max 2^20
# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
flows=[512,1]
+drop_rate_threshold = 0
+lat_avg_threshold = 500
+lat_max_threshold = 1000
+accuracy = 0.1
+startspeed = 10
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/l3framerate.test b/VNFs/DPPD-PROX/helper-scripts/rapid/l3framerate.test
index 94ddff86..de67d64a 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/l3framerate.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/l3framerate.test
@@ -14,13 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = L3FrameRateTesting
number_of_tests = 2
total_number_of_test_machines = 2
-prox_socket = true
-prox_launch_exit = true
-#PushGateway=http://192.168.36.1:9091
[TestM1]
name = Generator
@@ -47,4 +44,4 @@ packetsizes=[64,128]
# the number of flows in the list need to be powers of 2, max 2^20
# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
flows=[1,64]
-speed=10
+startspeed=5
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/portstats.test b/VNFs/DPPD-PROX/helper-scripts/rapid/portstats.test
index c5a18849..7bf99676 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/portstats.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/portstats.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = PortStats
number_of_tests = 1
total_number_of_test_machines = 1
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Swap
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py
index ba21913c..82faa789 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py
@@ -1,5 +1,5 @@
##
-## Copyright (c) 2010-2019 Intel Corporation
+## Copyright (c) 2010-2020 Intel Corporation
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -15,10 +15,17 @@
##
from __future__ import print_function
+from __future__ import division
+from builtins import map
+from builtins import range
+from past.utils import old_div
+from builtins import object
import os
+import time
import subprocess
import socket
+from rapid_log import RapidLog
class prox_ctrl(object):
def __init__(self, ip, key=None, user=None):
@@ -28,20 +35,55 @@ class prox_ctrl(object):
self._children = []
self._proxsock = []
+ def __del__(self):
+ self.close()
+
def ip(self):
return self._ip
- def connect(self):
+ def test_connect(self):
"""Simply try to run 'true' over ssh on remote system.
On failure, raise RuntimeWarning exception when possibly worth
retrying, and raise RuntimeError exception otherwise.
"""
return self.run_cmd('true', True)
+ def connect(self):
+ attempts = 1
+ RapidLog.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (self._ip, attempts))
+ while True:
+ try:
+ self.test_connect()
+ break
+ except RuntimeWarning as ex:
+ attempts += 1
+ if attempts > 20:
+ RapidLog.exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex))
+ raise Exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex))
+ time.sleep(2)
+ RapidLog.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (self._ip, attempts))
+ RapidLog.debug("Connected to VM on %s" % self._ip)
+
+ def connect_socket(self):
+ attempts = 1
+ RapidLog.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (self._ip, attempts))
+ sock = None
+ while True:
+ sock = self.prox_sock()
+ if sock is not None:
+ break
+ attempts += 1
+ if attempts > 20:
+ RapidLog.exception("Failed to connect to PROX on %s after %d attempts" % (self._ip, attempts))
+ raise Exception("Failed to connect to PROX on %s after %d attempts" % (self._ip, attempts))
+ time.sleep(2)
+ RapidLog.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (self._ip, attempts))
+ RapidLog.info("Connected to PROX on %s" % self._ip)
+ return sock
def close(self):
"""Must be called before program termination."""
-# for prox in self._proxsock:
-# prox.quit()
+ for sock in self._proxsock:
+ sock.quit()
children = len(self._children)
if children == 0:
return
@@ -160,6 +202,9 @@ class prox_sock(object):
self._sock = sock
self._rcvd = b''
+ def __del__(self):
+ self.quit()
+
def quit(self):
if self._sock is not None:
self._send('quit')
@@ -174,81 +219,50 @@ class prox_sock(object):
def speed(self, speed, cores, tasks=[0]):
for core in cores:
- for task in tasks:
- self._send('speed %s %s %s' % (core, task, speed))
+ for task in tasks:
+ self._send('speed %s %s %s' % (core, task, speed))
def reset_stats(self):
self._send('reset stats')
def lat_stats(self, cores, tasks=[0]):
min_lat = 999999999
- max_lat = avg_lat = 0
- number_tasks_returning_stats = 0
- buckets = [0] * 128
+ max_lat = avg_lat = 0
+ number_tasks_returning_stats = 0
+ buckets = [0] * 128
self._send('lat all stats %s %s' % (','.join(map(str, cores)), ','.join(map(str, tasks))))
for core in cores:
- for task in tasks:
- stats = self._recv().split(',')
- if 'is not measuring' in stats[0]:
- continue
- if stats[0].startswith('error'):
- log.critical("lat stats error: unexpected reply from PROX (potential incompatibility between scripts and PROX)")
- raise Exception("lat stats error")
- number_tasks_returning_stats += 1
- min_lat = min(int(stats[0]),min_lat)
- max_lat = max(int(stats[1]),max_lat)
- avg_lat += int(stats[2])
- #min_since begin = int(stats[3])
- #max_since_begin = int(stats[4])
- tsc = int(stats[5]) # Taking the last tsc as the timestamp since PROX will return the same tsc for each core/task combination
- hz = int(stats[6])
- #coreid = int(stats[7])
- #taskid = int(stats[8])
- stats = self._recv().split(':')
- if stats[0].startswith('error'):
- log.critical("lat stats error: unexpected lat bucket reply (potential incompatibility between scripts and PROX)")
- raise Exception("lat bucket reply error")
- buckets[0] = int(stats[1])
- for i in range(1, 128):
- stats = self._recv().split(':')
- buckets[i] = int(stats[1])
- avg_lat = avg_lat/number_tasks_returning_stats
+ for task in tasks:
+ stats = self._recv().split(',')
+ if 'is not measuring' in stats[0]:
+ continue
+ if stats[0].startswith('error'):
+ RapidLog.critical("lat stats error: unexpected reply from PROX (potential incompatibility between scripts and PROX)")
+ raise Exception("lat stats error")
+ number_tasks_returning_stats += 1
+ min_lat = min(int(stats[0]),min_lat)
+ max_lat = max(int(stats[1]),max_lat)
+ avg_lat += int(stats[2])
+ #min_since begin = int(stats[3])
+ #max_since_begin = int(stats[4])
+ tsc = int(stats[5]) # Taking the last tsc as the timestamp since PROX will return the same tsc for each core/task combination
+ hz = int(stats[6])
+ #coreid = int(stats[7])
+ #taskid = int(stats[8])
+ stats = self._recv().split(':')
+ if stats[0].startswith('error'):
+ RapidLog.critical("lat stats error: unexpected lat bucket reply (potential incompatibility between scripts and PROX)")
+ raise Exception("lat bucket reply error")
+ buckets[0] = int(stats[1])
+ for i in range(1, 128):
+ stats = self._recv().split(':')
+ buckets[i] = int(stats[1])
+ avg_lat = old_div(avg_lat,number_tasks_returning_stats)
self._send('stats latency(0).used')
used = float(self._recv())
self._send('stats latency(0).total')
total = float(self._recv())
- return min_lat, max_lat, avg_lat, (used/total), tsc, hz, buckets
-
- def old_lat_stats(self, cores, tasks=[0]):
- min_lat = 999999999
- max_lat = avg_lat = 0
- number_tasks_returning_stats = 0
- buckets = [0] * 128
- self._send('lat stats %s %s' % (','.join(map(str, cores)), ','.join(map(str, tasks))))
- for core in cores:
- for task in tasks:
- stats = self._recv().split(',')
- if stats[0].startswith('error'):
- if stats[0].startswith('error: invalid syntax'):
- log.critical("lat stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)")
- raise Exception("lat stats error")
- continue
- number_tasks_returning_stats += 1
- min_lat = min(int(stats[0]),min_lat)
- max_lat = max(int(stats[1]),max_lat)
- avg_lat += int(stats[2])
- #min_since begin = int(stats[3])
- #max_since_begin = int(stats[4])
- tsc = int(stats[5])
- hz = int(stats[6])
- #coreid = int(stats[7])
- #taskid = int(stats[8])
- avg_lat = avg_lat/number_tasks_returning_stats
- self._send('stats latency(0).used')
- used = float(self._recv())
- self._send('stats latency(0).total')
- total = float(self._recv())
- return min_lat, max_lat, avg_lat, (used/total), tsc, hz, buckets
+ return min_lat, max_lat, avg_lat, (old_div(used,total)), tsc, hz, buckets
def irq_stats(self, core, bucket, task=0):
self._send('stats task.core(%s).task(%s).irq(%s)' % (core, task, bucket))
@@ -259,45 +273,45 @@ class prox_sock(object):
rx = tx = drop = tsc = hz = 0
self._send('show irq buckets %s %s' % (core,task))
buckets = self._recv().split(';')
- buckets = buckets[:-1]
+ buckets = buckets[:-1]
return buckets
def core_stats(self, cores, tasks=[0]):
rx = tx = drop = tsc = hz = rx_non_dp = tx_non_dp = tx_fail = 0
self._send('dp core stats %s %s' % (','.join(map(str, cores)), ','.join(map(str, tasks))))
for core in cores:
- for task in tasks:
- stats = self._recv().split(',')
- if stats[0].startswith('error'):
- if stats[0].startswith('error: invalid syntax'):
- log.critical("dp core stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)")
- raise Exception("dp core stats error")
- continue
- rx += int(stats[0])
- tx += int(stats[1])
- rx_non_dp += int(stats[2])
- tx_non_dp += int(stats[3])
- drop += int(stats[4])
- tx_fail += int(stats[5])
- tsc = int(stats[6])
- hz = int(stats[7])
+ for task in tasks:
+ stats = self._recv().split(',')
+ if stats[0].startswith('error'):
+ if stats[0].startswith('error: invalid syntax'):
+ RapidLog.critical("dp core stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)")
+ raise Exception("dp core stats error")
+ continue
+ rx += int(stats[0])
+ tx += int(stats[1])
+ rx_non_dp += int(stats[2])
+ tx_non_dp += int(stats[3])
+ drop += int(stats[4])
+ tx_fail += int(stats[5])
+ tsc = int(stats[6])
+ hz = int(stats[7])
return rx, rx_non_dp, tx, tx_non_dp, drop, tx_fail, tsc, hz
def multi_port_stats(self, ports=[0]):
rx = tx = port_id = tsc = no_mbufs = errors = 0
self._send('multi port stats %s' % (','.join(map(str, ports))))
- result = self._recv().split(';')
- if result[0].startswith('error'):
- log.critical("multi port stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)")
- raise Exception("multi port stats error")
+ result = self._recv().split(';')
+ if result[0].startswith('error'):
+ RapidLog.critical("multi port stats error: unexpected invalid syntax (potential incompatibility between scripts and PROX)")
+ raise Exception("multi port stats error")
for statistics in result:
- stats = statistics.split(',')
- port_id = int(stats[0])
- rx += int(stats[1])
- tx += int(stats[2])
- no_mbufs += int(stats[3])
- errors += int(stats[4])
- tsc = int(stats[5])
+ stats = statistics.split(',')
+ port_id = int(stats[0])
+ rx += int(stats[1])
+ tx += int(stats[2])
+ no_mbufs += int(stats[3])
+ errors += int(stats[4])
+ tsc = int(stats[5])
return rx, tx, no_mbufs, errors, tsc
def set_random(self, cores, task, offset, mask, length):
@@ -326,4 +340,3 @@ class prox_sock(object):
rsp = self._rcvd[:pos]
self._rcvd = self._rcvd[pos+1:]
return rsp.decode()
-
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_cli.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_cli.py
new file mode 100644
index 00000000..3860e875
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_cli.py
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import getopt
+import sys
+
+class RapidCli(object):
+ """
+ Class to deal with runrapid cli
+ """
+ @staticmethod
+ def usage(test_params):
+ print("usage: runrapid [--version] [-v]")
+ print(" [--env ENVIRONMENT_NAME]")
+ print(" [--test TEST_NAME]")
+ print(" [--map MACHINE_MAP_FILE]")
+ print(" [--runtime TIME_FOR_TEST]")
+ print(" [--configonly False|True]")
+ print(" [--log DEBUG|INFO|WARNING|ERROR|CRITICAL]")
+ print(" [-h] [--help]")
+ print("")
+ print("Command-line interface to runrapid")
+ print("")
+ print("optional arguments:")
+ print(" -v, --version Show program's version number and exit")
+ print(" --env ENVIRONMENT_NAME Parameters will be read from ENVIRONMENT_NAME. Default is %s."%test_params['environment_file'])
+ print(" --test TEST_NAME Test cases will be read from TEST_NAME. Default is %s."%test_params['test_file'])
+ print(" --map MACHINE_MAP_FILE Machine mapping will be read from MACHINE_MAP_FILE. Default is %s."%test_params['machine_map_file'])
+ print(" --runtime Specify time in seconds for 1 test run")
+ print(" --configonly If this option is specified, only upload all config files to the VMs, do not run the tests")
+ print(" --log Specify logging level for log file output, default is DEBUG")
+ print(" --screenlog Specify logging level for screen output, default is INFO")
+ print(" -h, --help Show help message and exit.")
+ print("")
+
+ @staticmethod
+ def process_cli(test_params):
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "vh", ["version","help", "env=", "test=", "map=", "runtime=","configonly","log=","screenlog="])
+ except getopt.GetoptError as err:
+ print("===========================================")
+ print(str(err))
+ print("===========================================")
+ RapidCli.usage(test_params)
+ sys.exit(2)
+ if args:
+ RapidCli.usage(test_params)
+ sys.exit(2)
+ for opt, arg in opts:
+ if opt in ["-h", "--help"]:
+ RapidCli.usage(test_params)
+ sys.exit()
+ if opt in ["-v", "--version"]:
+ print("Rapid Automated Performance Indication for Dataplane "+test_params['version'])
+ sys.exit()
+ if opt in ["--env"]:
+ test_params['environment_file'] = arg
+ if opt in ["--test"]:
+ test_params['test_file'] = arg
+ if opt in ["--map"]:
+ test_params['machine_map_file'] = arg
+ if opt in ["--runtime"]:
+ test_params['runtime'] = int(arg)
+ if opt in ["--configonly"]:
+ test_params['configonly'] = True
+ print('No actual runs, only uploading configuration files')
+ if opt in ["--log"]:
+ test_params['loglevel'] = arg
+ print ("Log level: "+ test_params['loglevel'])
+ if opt in ["--screenlog"]:
+ test_params['screenloglevel'] = arg
+ print ("Screen Log level: "+ test_params['screenloglevel'])
+ print ("Using '"+test_params['environment_file']+"' as name for the environment")
+ print ("Using '"+test_params['test_file']+"' for test case definition")
+ print ("Using '"+test_params['machine_map_file']+"' for machine mapping")
+ print ("Runtime: "+ str(test_params['runtime']))
+ return(test_params)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py
new file mode 100644
index 00000000..c55c67f1
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_corestatstest.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import sys
+import time
+from rapid_log import RapidLog
+from rapid_test import RapidTest
+
+class CoreStatsTest(RapidTest):
+ """
+ Class to manage the corestatstesting
+ """
+ def __init__(self, runtime, pushgateway, environment_file, machines):
+ self.runtime = runtime
+ self.pushgateway = pushgateway
+ self.environment_file = environment_file
+ self.machines = machines
+
+ def run(self):
+ # fieldnames = ['PROXID','Time','Received','Sent','NonDPReceived','NonDPSent','Delta','NonDPDelta','Dropped']
+ # writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
+ # writer.writeheader()
+ RapidLog.info("+------------------------------------------------------------------------------------------------------------------+")
+ RapidLog.info("| Measuring core statistics on 1 or more PROX instances |")
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
+ RapidLog.info("| PROX ID | Time | RX | TX | non DP RX | non DP TX | TX - RX | nonDP TX-RX| DROP TOT |")
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
+ duration = self.runtime
+ tot_drop = []
+ old_rx = []; old_non_dp_rx = []; old_tx = []; old_non_dp_tx = []; old_drop = []; old_tx_fail = []; old_tsc = []
+ new_rx = []; new_non_dp_rx = []; new_tx = []; new_non_dp_tx = []; new_drop = []; new_tx_fail = []; new_tsc = []
+ machines_to_go = len (self.machines)
+ for machine in self.machines:
+ machine.reset_stats()
+ tot_drop.append(0)
+ old_rx.append(0); old_non_dp_rx.append(0); old_tx.append(0); old_non_dp_tx.append(0); old_drop.append(0); old_tx_fail.append(0); old_tsc.append(0)
+ old_rx[-1], old_non_dp_rx[-1], old_tx[-1], old_non_dp_tx[-1], old_drop[-1], old_tx_fail[-1], old_tsc[-1], tsc_hz = machine.core_stats()
+ new_rx.append(0); new_non_dp_rx.append(0); new_tx.append(0); new_non_dp_tx.append(0); new_drop.append(0); new_tx_fail.append(0); new_tsc.append(0)
+ while (duration > 0):
+ time.sleep(0.5)
+ # Get statistics after some execution time
+ for i, machine in enumerate(self.machines, start=0):
+ new_rx[i], new_non_dp_rx[i], new_tx[i], new_non_dp_tx[i], new_drop[i], new_tx_fail[i], new_tsc[i], tsc_hz = machine.core_stats()
+ drop = new_drop[i]-old_drop[i]
+ rx = new_rx[i] - old_rx[i]
+ tx = new_tx[i] - old_tx[i]
+ non_dp_rx = new_non_dp_rx[i] - old_non_dp_rx[i]
+ non_dp_tx = new_non_dp_tx[i] - old_non_dp_tx[i]
+ tsc = new_tsc[i] - old_tsc[i]
+ if tsc == 0 :
+ continue
+ machines_to_go -= 1
+ old_drop[i] = new_drop[i]
+ old_rx[i] = new_rx[i]
+ old_tx[i] = new_tx[i]
+ old_non_dp_rx[i] = new_non_dp_rx[i]
+ old_non_dp_tx[i] = new_non_dp_tx[i]
+ old_tsc[i] = new_tsc[i]
+ tot_drop[i] = tot_drop[i] + tx - rx
+ RapidLog.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(non_dp_rx)+' | '+'{:>10.0f}'.format(non_dp_tx)+' | ' + '{:>10.0f}'.format(tx-rx) + ' | '+ '{:>10.0f}'.format(non_dp_tx-non_dp_rx) + ' | '+'{:>10.0f}'.format(tot_drop[i]) +' |')
+ # writer.writerow({'PROXID':i,'Time':duration,'Received':rx,'Sent':tx,'NonDPReceived':non_dp_rx,'NonDPSent':non_dp_tx,'Delta':tx-rx,'NonDPDelta':non_dp_tx-non_dp_rx,'Dropped':tot_drop[i]})
+ if self.pushgateway:
+ URL = self.pushgateway+ '/metrics/job/' + TestName + '/instance/' + self.environment_file + str(i)
+ DATA = 'PROXID {}\nTime {}\n Received {}\nSent {}\nNonDPReceived {}\nNonDPSent {}\nDelta {}\nNonDPDelta {}\nDropped {}\n'.format(i,duration,rx,tx,non_dp_rx,non_dp_tx,tx-rx,non_dp_tx-non_dp_rx,tot_drop[i])
+ HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
+ response = requests.post(url=URL, data=DATA,headers=HEADERS)
+ if (response.status_code != 202) and (response.status_code != 200):
+ RapidLog.info('Cannot send metrics to {}'.format(URL))
+ RapidLog.info(DATA)
+ if machines_to_go == 0:
+ duration = duration - 1
+ machines_to_go = len (self.machines)
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
+ return (True)
+
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_defaults.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_defaults.py
new file mode 100644
index 00000000..3ff2d5ba
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_defaults.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+class RapidDefaults(object):
+ """
+ Class to define the test defaults
+ """
+ test_params = {
+ 'version' : '2020.04.15', # Please do NOT change, used for debugging
+ 'environment_file' : 'rapid.env', #Default string for environment
+ 'test_file' : 'basicrapid.test', #Default string for test
+ 'machine_map_file' : 'machine.map', #Default string for machine map file
+ 'loglevel' : 'DEBUG', # sets log level for writing to file
+ 'screenloglevel' : 'INFO', # sets log level for writing to screen
+ 'runtime' : 10, # time in seconds for 1 test run
+ 'configonly' : False, # If True, the system will upload all the necessary config fiels to the VMs, but not start PROX and the actual testing
+ 'rundir' : '~', # Directory where to find the tools in the machines running PROX
+ 'lat_percentile' : 0.99
+ }
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_flowsizetest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_flowsizetest.py
new file mode 100644
index 00000000..b8071b4d
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_flowsizetest.py
@@ -0,0 +1,259 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import sys
+import time
+from math import ceil
+from past.utils import old_div
+from rapid_log import RapidLog
+from rapid_log import bcolors
+from rapid_test import RapidTest
+inf = float("inf")
+
+class FlowSizeTest(RapidTest):
+ """
+ Class to manage the flowsizetesting
+ """
+ def __init__(self, test_param, lat_percentile, runtime, pushgateway,
+ environment_file, gen_machine, sut_machine, background_machines):
+ self.test = test_param
+ self.gen_machine = gen_machine
+ self.sut_machine = sut_machine
+ self.background_machines = background_machines
+ self.test['lat_percentile'] = lat_percentile
+ self.test['runtime'] = runtime
+ self.test['pushgateway'] = pushgateway
+ self.test['environment_file'] = environment_file
+ if 'maxr' not in self.test.keys():
+ self.test['maxr'] = 1
+ if 'maxz' not in self.test.keys():
+ self.test['maxz'] = inf
+ if self.test['test'] == 'TST009test':
+ # This test implements some of the testing as defined in https://docbox.etsi.org/ISG/NFV/open/Publications_pdf/Specs-Reports/NFV-TST%20009v3.2.1%20-%20GS%20-%20NFVI_Benchmarks.pdf
+ self.test['TST009_n'] = int(ceil(old_div(self.test['maxframespersecondallingress'], self.test['stepsize'])))
+ self.test['TST009'] = True
+ self.test['TST009_L'] = 0
+ self.test['TST009_R'] = self.test['TST009_n'] - 1
+ self.test['TST009_S']= []
+ for m in range(0, self.test['TST009_n']):
+ self.test['TST009_S'].append((m+1) * self.test['stepsize'])
+ self.test['lat_avg_threshold'] = inf
+ self.test['lat_perc_threshold'] = inf
+ self.test['lat_max_threshold'] = inf
+ elif self.test['test'] == 'fixed_rate':
+ for key in['drop_rate_threshold','lat_avg_threshold','lat_perc_threshold','lat_max_threshold']:
+ self.test[key] = inf
+
+ def new_speed(self, speed,size,success):
+ if self.test['test'] == 'fixed_rate':
+ return (self.test['startspeed'])
+ elif 'TST009' in self.test.keys():
+ if success:
+ self.test['TST009_L'] = self.test['TST009_m'] + 1
+ else:
+ self.test['TST009_R'] = max(self.test['TST009_m'] - 1, self.test['TST009_L'])
+ self.test['TST009_m'] = int (old_div((self.test['TST009_L'] + self.test['TST009_R']),2))
+ return (self.get_percentageof10Gbps(self.test['TST009_S'][self.test['TST009_m']],size))
+ else:
+ if success:
+ self.test['minspeed'] = speed
+ else:
+ self.test['maxspeed'] = speed
+ return (old_div((self.test['minspeed'] + self.test['maxspeed']),2.0))
+
+ def get_start_speed_and_init(self, size):
+ if self.test['test'] == 'fixed_rate':
+ return (self.test['startspeed'])
+ elif 'TST009' in self.test.keys():
+ self.test['TST009_L'] = 0
+ self.test['TST009_R'] = self.test['TST009_n'] - 1
+ self.test['TST009_m'] = int(old_div((self.test['TST009_L'] + self.test['TST009_R']), 2))
+ return (self.get_percentageof10Gbps(self.test['TST009_S'][self.test['TST009_m']],size))
+ else:
+ self.test['minspeed'] = 0
+ self.test['maxspeed'] = self.test['startspeed']
+ return (self.test['startspeed'])
+
+ def resolution_achieved(self):
+ if self.test['test'] == 'fixed_rate':
+ return (True)
+ elif 'TST009' in self.test.keys():
+ return (self.test['TST009_L'] == self.test['TST009_R'])
+ else:
+ return ((self.test['maxspeed'] - self.test['minspeed']) <= self.test['accuracy'])
+
+ def run(self):
+ # global fieldnames
+ # global writer
+ # #fieldnames = ['Flows','PacketSize','Gbps','Mpps','AvgLatency','MaxLatency','PacketsDropped','PacketDropRate']
+ # fieldnames = ['Flows','PacketSize','RequestedPPS','GeneratedPPS','SentPPS','ForwardedPPS','ReceivedPPS','AvgLatencyUSEC','MaxLatencyUSEC','Sent','Received','Lost','LostTotal']
+ # writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
+ # writer.writeheader()
+ self.gen_machine.start_latency_cores()
+ TestPassed = True
+ for size in self.test['packetsizes']:
+ self.gen_machine.set_udp_packet_size(size)
+ if self.background_machines:
+ backgroundinfo = '{}Running {} x background traffic not represented in the table{}'.format(bcolors.FLASH,len(self.background_machines),bcolors.ENDC)
+ else:
+ backgroundinfo = '{}{}'.format(bcolors.FLASH,bcolors.ENDC)
+ self.set_background_size(self.background_machines, size)
+ RapidLog.info("+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+")
+ RapidLog.info('| UDP, {:>5} bytes, different number of flows by randomizing SRC & DST UDP port. {:116.116}|'.format(size, backgroundinfo))
+ RapidLog.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
+ RapidLog.info('| Flows | Speed requested | Gen by core | Sent by NIC | Fwrd by SUT | Rec. by core | Avg. Lat.|{:.0f} Pcentil| Max. Lat.| Sent | Received | Lost | Total Lost|L.Ratio|Time|'.format(self.test['lat_percentile']*100))
+ RapidLog.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
+ for flow_number in self.test['flows']:
+ attempts = 0
+ self.gen_machine.reset_stats()
+ if self.sut_machine:
+ self.sut_machine.reset_stats()
+ self.gen_machine.set_flows(flow_number)
+ self.set_background_flows(self.background_machines, flow_number)
+ endspeed = None
+ speed = self.get_start_speed_and_init(size)
+ while True:
+ attempts += 1
+ endwarning = False
+ print(str(flow_number)+' flows: Measurement ongoing at speed: ' + str(round(speed,2)) + '% ',end='\r')
+ sys.stdout.flush()
+ # Start generating packets at requested speed (in % of a 10Gb/s link)
+ self.gen_machine.set_generator_speed(speed)
+ self.set_background_speed(self.background_machines, speed)
+ self.start_background_traffic(self.background_machines)
+ # Get statistics now that the generation is stable and initial ARP messages are dealt with
+ pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc , lat_perc_max, lat_max, abs_tx,abs_rx,abs_dropped, abs_tx_fail, drop_rate, lat_min, lat_used, r, actual_duration = self.run_iteration(float(self.test['runtime']),flow_number,size,speed)
+ self.stop_background_traffic(self.background_machines)
+ if r > 1:
+ retry_warning = bcolors.WARNING + ' {:1} retries needed'.format(r) + bcolors.ENDC
+ else:
+ retry_warning = ''
+ # Drop rate is expressed in percentage. lat_used is a ratio (0 to 1). The sum of these 2 should be 100%.
+ # If the sum is lower than 95, it means that more than 5% of the latency measurements where dropped for accuracy reasons.
+ if (drop_rate + lat_used * 100) < 95:
+ lat_warning = bcolors.WARNING + ' Latency accuracy issue?: {:>3.0f}%'.format(lat_used*100) + bcolors.ENDC
+ else:
+ lat_warning = ''
+ if self.test['test'] == 'fixed_rate':
+ endspeed = speed
+ endpps_req_tx = None
+ endpps_tx = None
+ endpps_sut_tx = None
+ endpps_rx = None
+ endlat_avg = lat_avg
+ endlat_perc = lat_perc
+ endlat_perc_max = lat_perc_max
+ endlat_max = lat_max
+ endabs_dropped = abs_dropped
+ enddrop_rate = drop_rate
+ endabs_tx = abs_tx
+ endabs_rx = abs_rx
+ if lat_warning or retry_warning:
+ endwarning = '| | {:177.177} |'.format(retry_warning + lat_warning)
+ success = True
+ TestPassed = False # fixed rate testing cannot be True, it is just reported numbers every second
+ speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
+ # The following if statement is testing if we pass the success criteria of a certain drop rate, average latency and maximum latency below the threshold
+ # The drop rate success can be achieved in 2 ways: either the drop rate is below a treshold, either we want that no packet has been lost during the test
+ # This can be specified by putting 0 in the .test file
+ elif ((drop_rate < self.test['drop_rate_threshold']) or (abs_dropped==self.test['drop_rate_threshold']==0)) and (lat_avg< self.test['lat_avg_threshold']) and (lat_perc< self.test['lat_perc_threshold']) and (lat_max < self.test['lat_max_threshold']):
+ if (old_div((self.get_pps(speed,size) - pps_tx),self.get_pps(speed,size)))>0.01:
+ speed_prefix = bcolors.WARNING
+ if abs_tx_fail > 0:
+ gen_warning = bcolors.WARNING + ' Network limit?: requesting {:<.3f} Mpps and getting {:<.3f} Mpps - {} failed to be transmitted'.format(self.get_pps(speed,size), pps_tx, abs_tx_fail) + bcolors.ENDC
+ else:
+ gen_warning = bcolors.WARNING + ' Generator limit?: requesting {:<.3f} Mpps and getting {:<.3f} Mpps'.format(self.get_pps(speed,size), pps_tx) + bcolors.ENDC
+ else:
+ speed_prefix = bcolors.ENDC
+ gen_warning = ''
+ endspeed = speed
+ endspeed_prefix = speed_prefix
+ endpps_req_tx = pps_req_tx
+ endpps_tx = pps_tx
+ endpps_sut_tx = pps_sut_tx
+ endpps_rx = pps_rx
+ endlat_avg = lat_avg
+ endlat_perc = lat_perc
+ endlat_perc_max = lat_perc_max
+ endlat_max = lat_max
+ endabs_dropped = None
+ enddrop_rate = drop_rate
+ endabs_tx = abs_tx
+ endabs_rx = abs_rx
+ if lat_warning or gen_warning or retry_warning:
+ endwarning = '| | {:177.177} |'.format(retry_warning + lat_warning + gen_warning)
+ success = True
+ success_message=' SUCCESS'
+ speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
+ RapidLog.debug(self.report_result(-attempts,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,abs_tx,abs_rx,abs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix)+ success_message + retry_warning + lat_warning + gen_warning)
+ else:
+ success_message=' FAILED'
+ abs_drop_rate_prefix = bcolors.ENDC
+ if ((abs_dropped>0) and (self.test['drop_rate_threshold'] ==0)):
+ abs_drop_rate_prefix = bcolors.FAIL
+ if (drop_rate < self.test['drop_rate_threshold']):
+ drop_rate_prefix = bcolors.ENDC
+ else:
+ drop_rate_prefix = bcolors.FAIL
+ if (lat_avg< self.test['lat_avg_threshold']):
+ lat_avg_prefix = bcolors.ENDC
+ else:
+ lat_avg_prefix = bcolors.FAIL
+ if (lat_perc< self.test['lat_perc_threshold']):
+ lat_perc_prefix = bcolors.ENDC
+ else:
+ lat_perc_prefix = bcolors.FAIL
+ if (lat_max< self.test['lat_max_threshold']):
+ lat_max_prefix = bcolors.ENDC
+ else:
+ lat_max_prefix = bcolors.FAIL
+ if ((old_div((self.get_pps(speed,size) - pps_tx),self.get_pps(speed,size)))<0.001):
+ speed_prefix = bcolors.ENDC
+ else:
+ speed_prefix = bcolors.FAIL
+ success = False
+ RapidLog.debug(self.report_result(-attempts,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,abs_tx,abs_rx,abs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_perc_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix)+ success_message + retry_warning + lat_warning)
+ speed = self.new_speed(speed, size, success)
+ if self.resolution_achieved():
+ break
+ if endspeed is not None:
+ if TestPassed and (endpps_rx < self.test['pass_threshold']):
+ TestPassed = False
+ speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
+ RapidLog.info(self.report_result(flow_number,size,endspeed,endpps_req_tx,endpps_tx,endpps_sut_tx,endpps_rx,endlat_avg,endlat_perc,endlat_perc_max,endlat_max,endabs_tx,endabs_rx,endabs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_perc_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix))
+ if endwarning:
+ RapidLog.info (endwarning)
+ RapidLog.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
+ # writer.writerow({'Flows':flow_number,'PacketSize':(size+4),'RequestedPPS':self.get_pps(endspeed,size),'GeneratedPPS':endpps_req_tx,'SentPPS':endpps_tx,'ForwardedPPS':endpps_sut_tx,'ReceivedPPS':endpps_rx,'AvgLatencyUSEC':endlat_avg,'MaxLatencyUSEC':endlat_max,'Sent':endabs_tx,'Received':endabs_rx,'Lost':endabs_dropped,'LostTotal':endabs_dropped})
+ if self.test['pushgateway']:
+ URL = self.test['pushgateway'] + '/metrics/job/' + self.test['test']+ '/instance/' + self.test['environment_file']
+ if endabs_dropped == None:
+ ead = 0
+ else:
+ ead = endabs_dropped
+ DATA = 'Flows {}\nPacketSize {}\nRequestedPPS {}\nGeneratedPPS {}\nSentPPS {}\nForwardedPPS {}\nReceivedPPS {}\nAvgLatencyUSEC {}\nMaxLatencyUSEC {}\nSent {}\nReceived {}\nLost {}\nLostTotal {}\n'.format(flow_number,size+4,self.get_pps(endspeed,size),endpps_req_tx,endpps_tx,endpps_sut_tx,endpps_rx,endlat_avg,endlat_max,endabs_tx,endabs_rx,ead,ead)
+ HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
+ response = requests.post(url=URL, data=DATA,headers=HEADERS)
+ if (response.status_code != 202) and (response.status_code != 200):
+ RapidLog.info('Cannot send metrics to {}'.format(URL))
+ RapidLog.info(DATA)
+ else:
+ RapidLog.info('|{:>7}'.format(str(flow_number))+" | Speed 0 or close to 0")
+ self.gen_machine.stop_latency_cores()
+ return (TestPassed)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_generator_machine.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_generator_machine.py
new file mode 100644
index 00000000..553907b0
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_generator_machine.py
@@ -0,0 +1,112 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+from rapid_log import RapidLog
+from prox_ctrl import prox_ctrl
+from rapid_machine import RapidMachine
+from math import ceil, log2
+
+
+class RandomPortBits(object):
+ """
+ Class to generate PROX bitmaps for random bit generation
+ in source & dst UPD ports to emulate mutiple flows
+ """
+ @staticmethod
+ def get_bitmap(flow_number):
+ number_of_random_bits = ceil(log2(flow_number))
+ if number_of_random_bits > 30:
+ raise Exception("Not able to support that many flows")
+ # throw exeption since we need the first bit to be 1
+ # Otherwise, the randomization could results in all 0's
+ # and that might be an invalid UDP port and result in
+ # packets begin discarded
+ src_number_of_random_bits = number_of_random_bits // 2
+ dst_number_of_random_bits = number_of_random_bits - src_number_of_random_bits
+ src_port_bitmap = '1000000000000000'.replace ('0','X',src_number_of_random_bits)
+ dst_port_bitmap = '1000000000000000'.replace ('0','X',dst_number_of_random_bits)
+ return [src_port_bitmap, dst_port_bitmap]
+
+class RapidGeneratorMachine(RapidMachine):
+ """
+ Class to deal with rapid configuration files
+ """
+ def get_cores(self):
+ return (self.machine_params['gencores'] + self.machine_params['latcores'])
+
+ def generate_lua(self, vim):
+ appendix = 'gencores="%s"\n'% ','.join(map(str, self.machine_params['gencores']))
+ appendix = appendix + 'latcores="%s"\n'% ','.join(map(str, self.machine_params['latcores']))
+ if 'gw_vm' in self.machine_params.keys():
+ for index, gw_ip in enumerate(self.machine_params['gw_ips'], start = 1):
+ appendix = appendix + 'gw_ip{}="{}"\n'.format(index, gw_ip)
+ appendix = appendix + 'gw_hex_ip{}="{}"\n'.format(index, self.ip2hex(gw_ip))
+ if 'bucket_size_exp' in self.machine_params.keys():
+ self.bucket_size_exp = self.machine_params['bucket_size_exp']
+ else:
+ self.bucket_size_exp = 11
+ appendix = appendix + 'bucket_size_exp="{}"\n'.format(self.bucket_size_exp)
+ if 'heartbeat' in self.machine_params.keys():
+ appendix = appendix + 'heartbeat="%s"\n'% self.machine_params['heartbeat']
+ else:
+ appendix = appendix + 'heartbeat="60"\n'
+ super().generate_lua(vim, appendix)
+
+ def start_prox(self):
+ # Start the generator with the -e option so that the cores don't
+ # start automatically
+ super().start_prox('-e')
+
+ def set_generator_speed(self, speed):
+ # The assumption is that we only use task 0 for generating
+ # We should check the gen.cfg file to make sure there is only task=0
+ speed_per_gen_core = speed / len(self.machine_params['gencores'])
+ self.socket.speed(speed_per_gen_core, self.machine_params['gencores'])
+
+ def set_udp_packet_size(self, size):
+ # We should check the gen.cfg to make sure we only send UDP packets
+ # Frame size is PROX pkt size + 4 bytes CRC
+ # PROX "pkt_size" i.e. 14-bytes L2 frame header + VLAN 4 bytes header + IP packet size
+ self.socket.set_size(self.machine_params['gencores'], 0, size)
+ # 18 is the difference between the frame size and IP size = size of (MAC addresses, ethertype and FCS)
+ self.socket.set_value(self.machine_params['gencores'], 0, 16, size-18, 2)
+ # 38 is the difference between the frame size and UDP size = 18 + size of IP header (=20)
+ self.socket.set_value(self.machine_params['gencores'], 0, 38, size-38, 2)
+
+ def set_flows(self, number_of_flows):
+ source_port,destination_port = RandomPortBits.get_bitmap(number_of_flows)
+ self.socket.set_random(self.machine_params['gencores'],0,34,source_port,2)
+ self.socket.set_random(self.machine_params['gencores'],0,36,destination_port,2)
+
+ def start_gen_cores(self):
+ self.socket.start(self.machine_params['gencores'])
+
+ def stop_gen_cores(self):
+ self.socket.stop(self.machine_params['gencores'])
+
+ def start_latency_cores(self):
+ self.socket.start(self.machine_params['latcores'])
+
+ def stop_latency_cores(self):
+ self.socket.stop(self.machine_params['latcores'])
+
+ def lat_stats(self):
+ # Checking all tasks in the cfg file. In this way, we can have more
+ # latency tasks on the same core
+ return (self.socket.lat_stats(self.machine_params['latcores'],
+ self.all_tasks_for_this_cfg))
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_impairtest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_impairtest.py
new file mode 100644
index 00000000..295cb799
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_impairtest.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import sys
+import time
+from rapid_log import RapidLog
+from rapid_test import RapidTest
+
+class ImpairTest(RapidTest):
+ """
+ Class to manage the impair testing
+ """
+ def __init__(self, test_param, lat_percentile, runtime, pushgateway,
+ environment_file, gen_machine):
+ self.test = test_param
+ self.gen_machine = gen_machine
+ self.sut_machine = sut_machine
+ self.test['lat_percentile'] = lat_percentile
+ self.test['runtime'] = runtime
+ self.test['pushgateway'] = pushgateway
+ self.test['environment_file'] = environment_file
+
+ def run(self):
+ # fieldnames = ['Flows','PacketSize','RequestedPPS','GeneratedPPS','SentPPS','ForwardedPPS','ReceivedPPS','AvgLatencyUSEC','MaxLatencyUSEC','Dropped','DropRate']
+ # writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
+ # writer.writeheader()
+ size = self.test['packetsize']
+ flow_number = self.test['flowsize']
+ RapidLog.info("+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+")
+ RapidLog.info("| Generator is sending UDP ("+'{:>5}'.format(flow_number)+" flow) packets ("+ '{:>5}'.format(size) +" bytes) to SUT via GW dropping and delaying packets. SUT sends packets back. Use ctrl-c to stop the test |")
+ RapidLog.info("+--------+--------------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+------------+")
+ RapidLog.info("| Test | Speed requested | Sent to NIC | Sent by Gen | Forward by SUT | Rec. by Gen | Avg. Latency | Max. Latency | Packets Lost | Loss Ratio |")
+ RapidLog.info("+--------+--------------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+------------+")
+ attempts = 0
+ self.gen_machine.set_udp_packet_size(size)
+ self.gen_machine.set_flows(flow_number)
+ self.gen_machine.start_latency_cores()
+ speed = self.test['startspeed']
+ self.gen_machine.set_generator_speed(speed)
+ while True:
+ attempts += 1
+ print('Measurement ongoing at speed: ' + str(round(speed,2)) + '% ',end='\r')
+ sys.stdout.flush()
+ time.sleep(1)
+ # Get statistics now that the generation is stable and NO ARP messages any more
+ pps_req_tx,pps_tx,pps_sut_tx_str,pps_rx,lat_avg, lat_perc, lat_perc_max, lat_max, abs_dropped, abs_tx_fail, abs_tx, lat_min, lat_used, r, actual_duration = run_iteration(float(self.test['runtime']),flow_number,size,speed)
+ drop_rate = 100.0*abs_dropped/abs_tx
+ if lat_used < 0.95:
+ lat_warning = bcolors.FAIL + ' Potential latency accuracy problem: {:>3.0f}%'.format(lat_used*100) + bcolors.ENDC
+ else:
+ lat_warning = ''
+ RapidLog.info('|{:>7}'.format(str(attempts))+" | " + '{:>5.1f}'.format(speed) + '% ' +'{:>6.3f}'.format(get_pps(speed,size)) + ' Mpps | '+ '{:>9.3f}'.format(pps_req_tx)+' Mpps | '+ '{:>9.3f}'.format(pps_tx) +' Mpps | ' + '{:>9}'.format(pps_sut_tx_str) +' Mpps | '+ '{:>9.3f}'.format(pps_rx)+' Mpps | '+ '{:>9.0f}'.format(lat_avg)+' us | '+ '{:>9.0f}'.format(lat_max)+' us | '+ '{:>14d}'.format(abs_dropped)+ ' |''{:>9.2f}'.format(drop_rate)+ '% |'+lat_warning)
+ # writer.writerow({'Flows':flow_number,'PacketSize':(size+4),'RequestedPPS':get_pps(speed,size),'GeneratedPPS':pps_req_tx,'SentPPS':pps_tx,'ForwardedPPS':pps_sut_tx_str,'ReceivedPPS':pps_rx,'AvgLatencyUSEC':lat_avg,'MaxLatencyUSEC':lat_max,'Dropped':abs_dropped,'DropRate':drop_rate})
+ if self.test['pushgateway']:
+ URL = self.test['pushgateway'] + '/metrics/job/' + TestName + '/instance/' + self.test['environment_file']
+ DATA = 'Flows {}\nPacketSize {}\nRequestedPPS {}\nGeneratedPPS {}\nSentPPS {}\nForwardedPPS {}\nReceivedPPS {}\nAvgLatencyUSEC {}\nMaxLatencyUSEC {}\nDropped {}\nDropRate {}\n'.format(flow_number,size+4,get_pps(speed,size),pps_req_tx,pps_tx,pps_sut_tx_str,pps_rx,lat_avg,lat_max,abs_dropped,drop_rate)
+ HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
+ response = requests.post(url=URL, data=DATA,headers=HEADERS)
+ if (response.status_code != 202) and (response.status_code != 200):
+ RapidLog.info('Cannot send metrics to {}'.format(URL))
+ RapidLog.info(DATA)
+ self.gen_machine.stop_latency_cores()
+ return (True)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_irqtest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_irqtest.py
new file mode 100644
index 00000000..2f69fdb5
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_irqtest.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+from past.utils import old_div
+import sys
+import time
+from rapid_log import RapidLog
+from rapid_test import RapidTest
+
+class IrqTest(RapidTest):
+ """
+ Class to manage the irq testing
+ """
+ def __init__(self, runtime, machines):
+ self.runtime = runtime
+ self.machines = machines
+
+ def run(self):
+ RapidLog.info("+----------------------------------------------------------------------------------------------------------------------------")
+ RapidLog.info("| Measuring time probably spent dealing with an interrupt. Interrupting DPDK cores for more than 50us might be problematic ")
+ RapidLog.info("| and result in packet loss. The first row shows the interrupted time buckets: first number is the bucket between 0us and ")
+ RapidLog.info("| that number expressed in us and so on. The numbers in the other rows show how many times per second, the program was ")
+ RapidLog.info("| interrupted for a time as specified by its bucket. '0' is printed when there are no interrupts in this bucket throughout ")
+ RapidLog.info("| the duration of the test. 0.00 means there were interrupts in this bucket but very few. Due to rounding this shows as 0.00 ")
+ RapidLog.info("+----------------------------------------------------------------------------------------------------------------------------")
+ sys.stdout.flush()
+ for machine in self.machines:
+ buckets=machine.socket.show_irq_buckets(1)
+ print('Measurement ongoing ... ',end='\r')
+ machine.stop()
+ old_irq = [[0 for x in range(len(buckets)+1)] for y in range(len(machine.get_cores())+1)]
+ irq = [[0 for x in range(len(buckets)+1)] for y in range(len(machine.get_cores())+1)]
+ irq[0][0] = 'bucket us'
+ for j,bucket in enumerate(buckets,start=1):
+ irq[0][j] = '<'+ bucket
+ irq[0][-1] = '>'+ buckets [-2]
+ machine.start()
+ time.sleep(2)
+ for j,bucket in enumerate(buckets,start=1):
+ for i,irqcore in enumerate(machine.get_cores(),start=1):
+ old_irq[i][j] = machine.socket.irq_stats(irqcore,j-1)
+ time.sleep(float(self.runtime))
+ machine.stop()
+ for i,irqcore in enumerate(machine.get_cores(),start=1):
+ irq[i][0]='core %s '%irqcore
+ for j,bucket in enumerate(buckets,start=1):
+ diff = machine.socket.irq_stats(irqcore,j-1) - old_irq[i][j]
+ if diff == 0:
+ irq[i][j] = '0'
+ else:
+ irq[i][j] = str(round(old_div(diff,float(self.runtime)), 2))
+ RapidLog.info('Results for PROX instance %s'%machine.name)
+ for row in irq:
+ RapidLog.info(''.join(['{:>12}'.format(item) for item in row]))
+ return (True)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_log.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_log.py
new file mode 100644
index 00000000..bd25845f
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_log.py
@@ -0,0 +1,122 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import logging
+from logging.handlers import RotatingFileHandler
+from logging import handlers
+import os
+import sys
+import time
+
+class bcolors(object):
+ HEADER = '\033[95m'
+ OKBLUE = '\033[94m'
+ OKGREEN = '\033[92m'
+ WARNING = '\033[93m'
+ FAIL = '\033[91m'
+ ENDC = '\033[0m'
+ BOLD = '\033[1m'
+ UNDERLINE = '\033[4m'
+ FLASH = '\033[5m'
+
+class RapidLog(object):
+ """
+ Class to deal with rapid logging
+ """
+ log = None
+
+ @staticmethod
+ def log_init(test_params):
+ # create formatters
+ screen_formatter = logging.Formatter("%(message)s")
+ file_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
+
+ # get a top-level logger,
+ # set its log level,
+ # BUT PREVENT IT from propagating messages to the root logger
+ #
+ log = logging.getLogger()
+ numeric_level = getattr(logging, test_params['loglevel'].upper(), None)
+ if not isinstance(numeric_level, int):
+ raise ValueError('Invalid log level: %s' % loglevel)
+ log.setLevel(numeric_level)
+ log.propagate = 0
+
+ # create a console handler
+ # and set its log level to the command-line option
+ #
+ console_handler = logging.StreamHandler(sys.stdout)
+ #console_handler.setLevel(logging.INFO)
+ numeric_screenlevel = getattr(logging, test_params['screenloglevel'].upper(), None)
+ if not isinstance(numeric_screenlevel, int):
+ raise ValueError('Invalid screenlog level: %s' % screenloglevel)
+ console_handler.setLevel(numeric_screenlevel)
+ console_handler.setFormatter(screen_formatter)
+
+ # create a file handler
+ # and set its log level
+ #
+ log_file = 'RUN{}.{}.log'.format(test_params['environment_file'],test_params['test_file'])
+ file_handler = logging.handlers.RotatingFileHandler(log_file, backupCount=10)
+ #file_handler = log.handlers.TimedRotatingFileHandler(log_file, 'D', 1, 5)
+ file_handler.setLevel(numeric_level)
+ file_handler.setFormatter(file_formatter)
+
+ # add handlers to the logger
+ #
+ log.addHandler(file_handler)
+ log.addHandler(console_handler)
+
+ # Check if log exists and should therefore be rolled
+ needRoll = os.path.isfile(log_file)
+
+
+ # This is a stale log, so roll it
+ if needRoll:
+ # Add timestamp
+ log.debug('\n---------\nLog closed on %s.\n---------\n' % time.asctime())
+
+ # Roll over on application start
+ log.handlers[0].doRollover()
+
+ # Add timestamp
+ log.debug('\n---------\nLog started on %s.\n---------\n' % time.asctime())
+
+ log.debug("runrapid.py version: " + test_params['version'])
+ RapidLog.log = log
+
+ @staticmethod
+ def exception(exception_info):
+ RapidLog.log.exception(exception_info)
+ raise Exception(exception_info)
+
+ def critical(critical_info):
+ RapidLog.log.critical(critical_info)
+ raise Exception(critical_info)
+
+ @staticmethod
+ def error(error_info):
+ RapidLog.log.error(error_info)
+
+ @staticmethod
+ def debug(debug_info):
+ RapidLog.log.debug(debug_info)
+
+ @staticmethod
+ def info(info):
+ RapidLog.log.info(info)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py
new file mode 100644
index 00000000..b5b90d65
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py
@@ -0,0 +1,122 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+from rapid_log import RapidLog
+from prox_ctrl import prox_ctrl
+import re
+
+class RapidMachine(object):
+ """
+ Class to deal with rapid configuration files
+ """
+ @staticmethod
+ def ip2hex(ip):
+ ip = ip.split('.')
+ return(hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2))
+
+ def __init__(self, key, user, vim, rundir, machine_params):
+ self.name = machine_params['name']
+ self.ip = machine_params['admin_ip']
+ self.key = key
+ self.user = user
+ self.rundir = rundir
+ self.dp_ports = []
+ self.dpdk_port_index = []
+ index = 1
+ while True:
+ ip_key = 'dp_ip{}'.format(index)
+ mac_key = 'dp_mac{}'.format(index)
+ if ip_key in machine_params.keys() and mac_key in machine_params.keys():
+ dp_port = {'ip': machine_params[ip_key], 'mac' : machine_params[mac_key]}
+ self.dp_ports.append(dict(dp_port))
+ self.dpdk_port_index.append(index - 1)
+ index += 1
+ else:
+ break
+ self.rundir = rundir
+ self.machine_params = machine_params
+ self._client = prox_ctrl(self.ip, self.key, self.user)
+ self._client.connect()
+ if vim in ['OpenStack']:
+ self.devbind()
+ self.generate_lua(vim)
+ self._client.scp_put(self.machine_params['config_file'], '{}/{}'.format(self.rundir, machine_params['config_file']))
+
+ def get_cores(self):
+ return (self.machine_params['cores'])
+
+ def devbind(self):
+ # Script to bind the right network interface to the poll mode driver
+ for index, dp_port in enumerate(self.dp_ports, start = 1):
+ DevBindFileName = self.rundir + '/devbind-{}-port{}.sh'.format(self.ip, index)
+ self._client.scp_put('./devbind.sh', DevBindFileName)
+ cmd = 'sed -i \'s/MACADDRESS/' + dp_port['mac'] + '/\' ' + DevBindFileName
+ result = self._client.run_cmd(cmd)
+ RapidLog.debug('devbind.sh MAC updated for port {} on {} {}'.format(index, self.name, result))
+ result = self._client.run_cmd(DevBindFileName)
+ RapidLog.debug('devbind.sh running for port {} on {} {}'.format(index, self.name, result))
+
+ def generate_lua(self, vim, appendix = ''):
+ PROXConfigfile = open (self.machine_params['config_file'], 'r')
+ PROXConfig = PROXConfigfile.read()
+ PROXConfigfile.close()
+ self.all_tasks_for_this_cfg = set(re.findall("task\s*=\s*(\d+)",PROXConfig))
+ self.LuaFileName = 'parameters-{}.lua'.format(self.ip)
+ with open(self.LuaFileName, "w") as LuaFile:
+ LuaFile.write('name="%s"\n'% self.name)
+ for index, dp_port in enumerate(self.dp_ports, start = 1):
+ LuaFile.write('local_ip{}="{}"\n'.format(index, dp_port['ip']))
+ LuaFile.write('local_hex_ip{}="{}"\n'.format(index, self.ip2hex(dp_port['ip'])))
+ if vim in ['kubernetes']:
+ LuaFile.write("eal=\"--socket-mem=512,0 --file-prefix %s --pci-whitelist %s\"\n" % (self.name, self.machine_params['dp_pci_dev']))
+ else:
+ LuaFile.write("eal=\"\"\n")
+ if 'cores' in self.machine_params.keys():
+ LuaFile.write('cores="%s"\n'% ','.join(map(str, self.machine_params['cores'])))
+ if 'ports' in self.machine_params.keys():
+ LuaFile.write('ports="%s"\n'% ','.join(map(str, self.machine_params['ports'])))
+ if 'dest_ports' in self.machine_params.keys():
+ for index, dest_port in enumerate(self.machine_params['dest_ports'], start = 1):
+ LuaFile.write('dest_ip{}="{}"\n'.format(index, dest_port['ip']))
+ LuaFile.write('dest_hex_ip{}="{}"\n'.format(index, self.ip2hex(dest_port['ip'])))
+ LuaFile.write('dest_hex_ip{}="{}"\n'.format(index, self.ip2hex(dest_port['ip'])))
+ LuaFile.write('dest_hex_mac{}="{}"\n'.format(index , dest_port['mac'].replace(':',' ')))
+ LuaFile.write(appendix)
+ self._client.scp_put(self.LuaFileName, self.rundir + '/parameters.lua')
+
+ def start_prox(self, autostart=''):
+ if self.machine_params['prox_launch_exit']:
+ cmd = 'sudo {}/prox {} -t -o cli -f {}/{}'.format(self.rundir, autostart, self.rundir, self.machine_params['config_file'])
+ result = self._client.fork_cmd(cmd, 'PROX Testing on {}'.format(self.name))
+ RapidLog.debug("Starting PROX on {}: {}, {}".format(self.name, cmd, result))
+ self.socket = self._client.connect_socket()
+
+ def start(self):
+ self.socket.start(self.get_cores())
+
+ def stop(self):
+ self.socket.stop(self.get_cores())
+
+ def reset_stats(self):
+ self.socket.reset_stats()
+
+ def core_stats(self):
+ return (self.socket.core_stats(self.get_cores(), self.all_tasks_for_this_cfg))
+
+ def multi_port_stats(self):
+ return (self.socket.multi_port_stats(self.self.dpdk_port_index))
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py
new file mode 100644
index 00000000..864f84b8
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+from rapid_log import RapidLog
+from past.utils import old_div
+try:
+ import configparser
+except ImportError:
+ # Python 2.x fallback
+ import ConfigParser as configparser
+import ast
+
+class RapidConfigParser(object):
+ """
+ Class to deal with rapid configuration files
+ """
+ @staticmethod
+ def parse_config(test_params):
+ testconfig = configparser.RawConfigParser()
+ testconfig.read(test_params['test_file'])
+ test_params['required_number_of_test_machines'] = int(testconfig.get('TestParameters', 'total_number_of_test_machines'))
+ test_params['number_of_tests'] = int(testconfig.get('TestParameters', 'number_of_tests'))
+ test_params['TestName'] = testconfig.get('TestParameters', 'name')
+ if testconfig.has_option('TestParameters', 'lat_percentile'):
+ test_params['lat_percentile'] = old_div(float(testconfig.get('TestParameters', 'lat_percentile')),100.0)
+ else:
+ test_params['lat_percentile'] = 0.99
+ RapidLog.info('Latency percentile measured at {:.0f}%'.format(test_params['lat_percentile']*100))
+ config = configparser.RawConfigParser()
+ config.read(test_params['environment_file'])
+ test_params['vim_type'] = config.get('Varia', 'vim')
+ test_params['key'] = config.get('ssh', 'key')
+ test_params['user'] = config.get('ssh', 'user')
+ test_params['total_number_of_machines'] = int(config.get('rapid', 'total_number_of_machines'))
+ if config.has_option('TestParameters', 'pushgateway'):
+ test_params['pushgateway'] = config.get('TestParameters', 'pushgateway')
+ RapidLog.info('Measurements will be pushed to %s'%test_params['pushgateway'])
+ else:
+ test_params['pushgateway'] = None
+ tests = []
+ test = {}
+ for test_index in range(1, test_params['number_of_tests']+1):
+ test.clear()
+ section = 'test%d'%test_index
+ options = testconfig.options(section)
+ for option in options:
+ if option in ['packetsizes','flows']:
+ test[option] = ast.literal_eval(testconfig.get(section, option))
+ test[option] = [int(i) for i in test[option]]
+ elif option in ['maxframespersecondallingress','stepsize']:
+ test[option] = int(testconfig.get(section, option))
+ elif option in ['startspeed','drop_rate_threshold','lat_avg_threshold','lat_perc_threshold','lat_max_threshold','accuracy','maxr','maxz','pass_threshold']:
+ test[option] = float(testconfig.get(section, option))
+ else:
+ test[option] = testconfig.get(section, option)
+ tests.append(dict(test))
+ for test in tests:
+ if test['test'] in ['flowsizetest','TST009test']:
+ if 'drop_rate_threshold' not in test.keys():
+ test['drop_rate_threshold'] = 0
+ test_params['tests'] = tests
+ if test_params['required_number_of_test_machines'] > test_params['total_number_of_machines']:
+ RapidLog.exception("Not enough VMs for this test: %d needed and only %d available" % (required_number_of_test_machines,total_number_of_machines))
+ raise Exception("Not enough VMs for this test: %d needed and only %d available" % (required_number_of_test_machines,total_number_of_machines))
+ machine_map = configparser.RawConfigParser()
+ machine_map.read(test_params['machine_map_file'])
+ machines = []
+ machine = {}
+ for test_machine in range(1, test_params['required_number_of_test_machines']+1):
+ machine.clear()
+ if not(testconfig.has_option('TestM%d'%test_machine, 'prox_socket') and not testconfig.getboolean('TestM%d'%test_machine, 'prox_socket')):
+ section = 'TestM%d'%test_machine
+ options = testconfig.options(section)
+ for option in options:
+ if option in ['prox_socket','prox_launch_exit']:
+ machine[option] = testconfig.getboolean(section, option)
+ elif option in ['cores', 'gencores','latcores']:
+ machine[option] = ast.literal_eval(testconfig.get(section, option))
+ else:
+ machine[option] = testconfig.get(section, option)
+ for key in ['prox_socket','prox_launch_exit']:
+ if key not in machine.keys():
+ machine[key] = True
+ index = int(machine_map.get('TestM%d'%test_machine, 'machine_index'))
+ section = 'M%d'%index
+ options = config.options(section)
+ for option in options:
+ machine[option] = config.get(section, option)
+ if 'monitor' not in machine.keys():
+ machine['monitor'] = True
+ else:
+ machine['monitor'] = config.getboolean(section, option)
+ machines.append(dict(machine))
+ for machine in machines:
+ dp_ports = []
+ if 'dest_vm' in machine.keys():
+ index = 1
+ dp_ip_key = 'dp_ip{}'.format(index)
+ dp_mac_key = 'dp_mac{}'.format(index)
+ if dp_ip_key in machines[int(machine['dest_vm'])-1].keys() and \
+ dp_mac_key in machines[int(machine['dest_vm'])-1].keys():
+ dp_port = {'ip': machines[int(machine['dest_vm'])-1][dp_ip_key],
+ 'mac' : machines[int(machine['dest_vm'])-1][dp_mac_key]}
+ dp_ports.append(dict(dp_port))
+ index += 1
+ else:
+ break
+ machine['dest_ports'] = list(dp_ports)
+ gw_ips = []
+ if 'gw_vm' in machine.keys():
+ index = 1
+ gw_ip_key = 'dp_ip{}'.format(index)
+ if gw_ip_key in machines[int(machine['gw_vm'])-1].keys():
+ gw_ip = machines[int(machine['dest_vm'])-1][gw_ip_key]
+ gw_ips.append(gw_ip)
+ index += 1
+ else:
+ break
+ machine['gw_ips'] = list(gw_ips)
+ test_params['machines'] = machines
+ return (test_params)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_portstatstest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_portstatstest.py
new file mode 100644
index 00000000..45a9fc2a
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_portstatstest.py
@@ -0,0 +1,85 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import sys
+import time
+from rapid_log import RapidLog
+from rapid_test import RapidTest
+
+class PortStatsTest(RapidTest):
+ """
+ Class to manage the portstatstesting
+ """
+ def __init__(self, runtime, pushgateway, environment_file, machines):
+ self.runtime = runtime
+ self.pushgateway = pushgateway
+ self.environment_file = environment_file
+ self.machines = machines
+
+ def run(self):
+ # fieldnames = ['PROXID','Time','Received','Sent','NoMbufs','iErrMiss']
+ # writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
+ # writer.writeheader()
+ RapidLog.info("+---------------------------------------------------------------------------+")
+ RapidLog.info("| Measuring port statistics on 1 or more PROX instances |")
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
+ RapidLog.info("| PROX ID | Time | RX | TX | no MBUFS | ierr&imiss |")
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
+ duration = float(runtime)
+ old_rx = []; old_tx = []; old_no_mbufs = []; old_errors = []; old_tsc = []
+ new_rx = []; new_tx = []; new_no_mbufs = []; new_errors = []; new_tsc = []
+ machines_to_go = len (self.machines)
+ for machine in self.machines:
+ machine.reset_stats()
+ old_rx.append(0); old_tx.append(0); old_no_mbufs.append(0); old_errors.append(0); old_tsc.append(0)
+ old_rx[-1], old_tx[-1], old_no_mbufs[-1], old_errors[-1], old_tsc[-1] = machine.multi_port_stats()
+ new_rx.append(0); new_tx.append(0); new_no_mbufs.append(0); new_errors.append(0); new_tsc.append(0)
+ while (duration > 0):
+ time.sleep(0.5)
+ # Get statistics after some execution time
+ for i, machine in enumerate(self.machines, start=0):
+ new_rx[i], new_tx[i], new_no_mbufs[i], new_errors[i], new_tsc[i] = machine.multi_port_stats()
+ rx = new_rx[i] - old_rx[i]
+ tx = new_tx[i] - old_tx[i]
+ no_mbufs = new_no_mbufs[i] - old_no_mbufs[i]
+ errors = new_errors[i] - old_errors[i]
+ tsc = new_tsc[i] - old_tsc[i]
+ if tsc == 0 :
+ continue
+ machines_to_go -= 1
+ old_rx[i] = new_rx[i]
+ old_tx[i] = new_tx[i]
+ old_no_mbufs[i] = new_no_mbufs[i]
+ old_errors[i] = new_errors[i]
+ old_tsc[i] = new_tsc[i]
+ RapidLog.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(no_mbufs)+' | '+'{:>10.0f}'.format(errors)+' |')
+ # writer.writerow({'PROXID':i,'Time':duration,'Received':rx,'Sent':tx,'NoMbufs':no_mbufs,'iErrMiss':errors})
+ if self.pushgateway:
+ URL = self.pushgateway + '/metrics/job/' + TestName + '/instance/' + self.environment_file + str(i)
+ DATA = 'PROXID {}\nTime {}\n Received {}\nSent {}\nNoMbufs {}\niErrMiss {}\n'.format(i,duration,rx,tx,no_mbufs,errors)
+ HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
+ response = requests.post(url=URL, data=DATA,headers=HEADERS)
+ if (response.status_code != 202) and (response.status_code != 200):
+ RapidLog.info('Cannot send metrics to {}'.format(URL))
+ RapidLog.info(DATA)
+ if machines_to_go == 0:
+ duration = duration - 1
+ machines_to_go = len (self.machines)
+ RapidLog.info("+-----------+-----------+------------+------------+------------+------------+")
+ return (True)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_test.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_test.py
new file mode 100644
index 00000000..261c8bb1
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_test.py
@@ -0,0 +1,290 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import time
+from past.utils import old_div
+from rapid_log import RapidLog
+from rapid_log import bcolors
+
+class RapidTest(object):
+ """
+ Class to manage the flowsizetesting
+ """
+ @staticmethod
+ def get_percentageof10Gbps(pps_speed,size):
+ # speed is given in pps, returning % of 10Gb/s
+ return (pps_speed / 1000000.0 * 0.08 * (size+28))
+
+ @staticmethod
+ def get_pps(speed,size):
+ # speed is given in % of 10Gb/s, returning Mpps
+ return (speed * 100.0 / (8*(size+28)))
+
+ @staticmethod
+ def get_speed(packet_speed,size):
+ # return speed in Gb/s
+ return (packet_speed / 1000.0 * (8*(size+28)))
+
+ @staticmethod
+ def set_background_flows(background_machines, number_of_flows):
+ for machine in background_machines:
+ machine.set_flows(number_of_flows)
+
+ @staticmethod
+ def set_background_speed(background_machines, speed):
+ for machine in background_machines:
+ machine.set_generator_speed(speed)
+
+ @staticmethod
+ def set_background_size(background_machines, size):
+ for machine in background_machines:
+ machine.set_udp_packet_size(size)
+
+ @staticmethod
+ def start_background_traffic(background_machines):
+ for machine in background_machines:
+ machine.start()
+
+ @staticmethod
+ def stop_background_traffic(background_machines):
+ for machine in background_machines:
+ machine.stop()
+
+ @staticmethod
+ def report_result(flow_number, size, speed, pps_req_tx, pps_tx, pps_sut_tx,
+ pps_rx, lat_avg, lat_perc, lat_perc_max, lat_max, tx, rx, tot_drop,
+ elapsed_time,speed_prefix='', lat_avg_prefix='', lat_perc_prefix='',
+ lat_max_prefix='', abs_drop_rate_prefix='', drop_rate_prefix=''):
+ if flow_number < 0:
+ flow_number_str = '| ({:>4}) |'.format(abs(flow_number))
+ else:
+ flow_number_str = '|{:>7} |'.format(flow_number)
+ if pps_req_tx is None:
+ pps_req_tx_str = '{0: >14}'.format(' NA |')
+ else:
+ pps_req_tx_str = '{:>7.3f} Mpps |'.format(pps_req_tx)
+ if pps_tx is None:
+ pps_tx_str = '{0: >14}'.format(' NA |')
+ else:
+ pps_tx_str = '{:>7.3f} Mpps |'.format(pps_tx)
+ if pps_sut_tx is None:
+ pps_sut_tx_str = '{0: >14}'.format(' NA |')
+ else:
+ pps_sut_tx_str = '{:>7.3f} Mpps |'.format(pps_sut_tx)
+ if pps_rx is None:
+ pps_rx_str = '{0: >25}'.format('NA |')
+ else:
+ pps_rx_str = bcolors.OKBLUE + '{:>4.1f} Gb/s |{:7.3f} Mpps {}|'.format(RapidTest.get_speed(pps_rx,size),pps_rx,bcolors.ENDC)
+ if tot_drop is None:
+ tot_drop_str = ' | NA | '
+ else:
+ tot_drop_str = ' | {:>9.0f} | '.format(tot_drop)
+ if lat_perc is None:
+ lat_perc_str = ' |{:^10.10}|'.format('NA')
+ elif lat_perc_max == True:
+ lat_perc_str = '|>{}{:>5.0f} us{} |'.format(lat_perc_prefix,float(lat_perc), bcolors.ENDC)
+ else:
+ lat_perc_str = '| {}{:>5.0f} us{} |'.format(lat_perc_prefix,float(lat_perc), bcolors.ENDC)
+ if elapsed_time is None:
+ elapsed_time_str = ' NA |'
+ else:
+ elapsed_time_str = '{:>3.0f} |'.format(elapsed_time)
+ return(flow_number_str + '{:>5.1f}'.format(speed) + '% '+speed_prefix +'{:>6.3f}'.format(RapidTest.get_pps(speed,size)) + ' Mpps|'+ pps_req_tx_str + pps_tx_str + bcolors.ENDC + pps_sut_tx_str + pps_rx_str +lat_avg_prefix+ ' {:>6.0f}'.format(lat_avg)+' us'+lat_perc_str+lat_max_prefix+'{:>6.0f}'.format(lat_max)+' us | ' + '{:>9.0f}'.format(tx) + ' | {:>9.0f}'.format(rx) + ' | '+ abs_drop_rate_prefix+ '{:>9.0f}'.format(tx-rx) + tot_drop_str +drop_rate_prefix+ '{:>5.2f}'.format(old_div(float(tx-rx),tx)) +bcolors.ENDC+' |' + elapsed_time_str)
+
+ def run_iteration(self, requested_duration, flow_number, size, speed):
+ BUCKET_SIZE_EXP = self.gen_machine.bucket_size_exp
+ LAT_PERCENTILE = self.test['lat_percentile']
+ r = 0;
+ sleep_time = 2
+ while (r < self.test['maxr']):
+ time.sleep(sleep_time)
+ # Sleep_time is needed to be able to do accurate measurements to check for packet loss. We need to make this time large enough so that we do not take the first measurement while some packets from the previous tests migth still be in flight
+ t1_rx, t1_non_dp_rx, t1_tx, t1_non_dp_tx, t1_drop, t1_tx_fail, t1_tsc, abs_tsc_hz = self.gen_machine.core_stats()
+ t1_dp_rx = t1_rx - t1_non_dp_rx
+ t1_dp_tx = t1_tx - t1_non_dp_tx
+ self.gen_machine.start_gen_cores()
+ time.sleep(2) ## Needs to be 2 seconds since this 1 sec is the time that PROX uses to refresh the stats. Note that this can be changed in PROX!! Don't do it.
+ if self.sut_machine!= None:
+ t2_sut_rx, t2_sut_non_dp_rx, t2_sut_tx, t2_sut_non_dp_tx, t2_sut_drop, t2_sut_tx_fail, t2_sut_tsc, sut_tsc_hz = self.sut_machine.core_stats()
+ t2_rx, t2_non_dp_rx, t2_tx, t2_non_dp_tx, t2_drop, t2_tx_fail, t2_tsc, tsc_hz = self.gen_machine.core_stats()
+ tx = t2_tx - t1_tx
+ dp_tx = tx - (t2_non_dp_tx - t1_non_dp_tx )
+ dp_rx = t2_rx - t1_rx - (t2_non_dp_rx - t1_non_dp_rx)
+ tot_dp_drop = dp_tx - dp_rx
+ if tx == 0:
+ RapidLog.critical("TX = 0. Test interrupted since no packet has been sent.")
+ if dp_tx == 0:
+ RapidLog.critical("Only non-dataplane packets (e.g. ARP) sent. Test interrupted since no packet has been sent.")
+ # Ask PROX to calibrate the bucket size once we have a PROX function to do this.
+ # Measure latency statistics per second
+ lat_min, lat_max, lat_avg, used_avg, t2_lat_tsc, lat_hz, buckets = self.gen_machine.lat_stats()
+ lat_samples = sum(buckets)
+ sample_count = 0
+ for sample_percentile, bucket in enumerate(buckets,start=1):
+ sample_count += bucket
+ if sample_count > (lat_samples * LAT_PERCENTILE):
+ break
+ percentile_max = (sample_percentile == len(buckets))
+ sample_percentile = sample_percentile * float(2 ** BUCKET_SIZE_EXP) / (old_div(float(lat_hz),float(10**6)))
+ if self.test['test'] == 'fixed_rate':
+ RapidLog.info(self.report_result(flow_number,size,speed,None,None,None,None,lat_avg,sample_percentile,percentile_max,lat_max, dp_tx, dp_rx , None, None))
+ tot_rx = tot_non_dp_rx = tot_tx = tot_non_dp_tx = tot_drop = 0
+ lat_avg = used_avg = 0
+ buckets_total = [0] * 128
+ tot_lat_samples = 0
+ tot_lat_measurement_duration = float(0)
+ tot_core_measurement_duration = float(0)
+ tot_sut_core_measurement_duration = float(0)
+ tot_sut_rx = tot_sut_non_dp_rx = tot_sut_tx = tot_sut_non_dp_tx = tot_sut_drop = tot_sut_tx_fail = tot_sut_tsc = 0
+ lat_avail = core_avail = sut_avail = False
+ while (tot_core_measurement_duration - float(requested_duration) <= 0.1) or (tot_lat_measurement_duration - float(requested_duration) <= 0.1):
+ time.sleep(0.5)
+ lat_min_sample, lat_max_sample, lat_avg_sample, used_sample, t3_lat_tsc, lat_hz, buckets = self.gen_machine.lat_stats()
+ # Get statistics after some execution time
+ if t3_lat_tsc != t2_lat_tsc:
+ single_lat_measurement_duration = (t3_lat_tsc - t2_lat_tsc) * 1.0 / lat_hz # time difference between the 2 measurements, expressed in seconds.
+ # A second has passed in between to lat_stats requests. Hence we need to process the results
+ tot_lat_measurement_duration = tot_lat_measurement_duration + single_lat_measurement_duration
+ if lat_min > lat_min_sample:
+ lat_min = lat_min_sample
+ if lat_max < lat_max_sample:
+ lat_max = lat_max_sample
+ lat_avg = lat_avg + lat_avg_sample * single_lat_measurement_duration # Sometimes, There is more than 1 second between 2 lat_stats. Hence we will take the latest measurement
+ used_avg = used_avg + used_sample * single_lat_measurement_duration # and give it more weigth.
+ lat_samples = sum(buckets)
+ tot_lat_samples += lat_samples
+ sample_count = 0
+ for sample_percentile, bucket in enumerate(buckets,start=1):
+ sample_count += bucket
+ if sample_count > lat_samples * LAT_PERCENTILE:
+ break
+ percentile_max = (sample_percentile == len(buckets))
+ sample_percentile = sample_percentile * float(2 ** BUCKET_SIZE_EXP) / (old_div(float(lat_hz),float(10**6)))
+ buckets_total = [buckets_total[i] + buckets[i] for i in range(len(buckets_total))]
+ t2_lat_tsc = t3_lat_tsc
+ lat_avail = True
+ t3_rx, t3_non_dp_rx, t3_tx, t3_non_dp_tx, t3_drop, t3_tx_fail, t3_tsc, tsc_hz = self.gen_machine.core_stats()
+ if t3_tsc != t2_tsc:
+ single_core_measurement_duration = (t3_tsc - t2_tsc) * 1.0 / tsc_hz # time difference between the 2 measurements, expressed in seconds.
+ tot_core_measurement_duration = tot_core_measurement_duration + single_core_measurement_duration
+ delta_rx = t3_rx - t2_rx
+ tot_rx += delta_rx
+ delta_non_dp_rx = t3_non_dp_rx - t2_non_dp_rx
+ tot_non_dp_rx += delta_non_dp_rx
+ delta_tx = t3_tx - t2_tx
+ tot_tx += delta_tx
+ delta_non_dp_tx = t3_non_dp_tx - t2_non_dp_tx
+ tot_non_dp_tx += delta_non_dp_tx
+ delta_dp_tx = delta_tx -delta_non_dp_tx
+ delta_dp_rx = delta_rx -delta_non_dp_rx
+ delta_dp_drop = delta_dp_tx - delta_dp_rx
+ tot_dp_drop += delta_dp_drop
+ delta_drop = t3_drop - t2_drop
+ tot_drop += delta_drop
+ t2_rx, t2_non_dp_rx, t2_tx, t2_non_dp_tx, t2_drop, t2_tx_fail, t2_tsc = t3_rx, t3_non_dp_rx, t3_tx, t3_non_dp_tx, t3_drop, t3_tx_fail, t3_tsc
+ core_avail = True
+ if self.sut_machine!=None:
+ t3_sut_rx, t3_sut_non_dp_rx, t3_sut_tx, t3_sut_non_dp_tx, t3_sut_drop, t3_sut_tx_fail, t3_sut_tsc, sut_tsc_hz = self.sut_machine.core_stats()
+ if t3_sut_tsc != t2_sut_tsc:
+ single_sut_core_measurement_duration = (t3_sut_tsc - t2_sut_tsc) * 1.0 / tsc_hz # time difference between the 2 measurements, expressed in seconds.
+ tot_sut_core_measurement_duration = tot_sut_core_measurement_duration + single_sut_core_measurement_duration
+ tot_sut_rx += t3_sut_rx - t2_sut_rx
+ tot_sut_non_dp_rx += t3_sut_non_dp_rx - t2_sut_non_dp_rx
+ delta_sut_tx = t3_sut_tx - t2_sut_tx
+ tot_sut_tx += delta_sut_tx
+ delta_sut_non_dp_tx = t3_sut_non_dp_tx - t2_sut_non_dp_tx
+ tot_sut_non_dp_tx += delta_sut_non_dp_tx
+ t2_sut_rx, t2_sut_non_dp_rx, t2_sut_tx, t2_sut_non_dp_tx, t2_sut_drop, t2_sut_tx_fail, t2_sut_tsc = t3_sut_rx, t3_sut_non_dp_rx, t3_sut_tx, t3_sut_non_dp_tx, t3_sut_drop, t3_sut_tx_fail, t3_sut_tsc
+ sut_avail = True
+ if self.test['test'] == 'fixed_rate':
+ if lat_avail == core_avail == True:
+ lat_avail = core_avail = False
+ pps_req_tx = (delta_tx + delta_drop - delta_rx)/single_core_measurement_duration/1000000
+ pps_tx = delta_tx/single_core_measurement_duration/1000000
+ if self.sut_machine != None and sut_avail:
+ pps_sut_tx = delta_sut_tx/single_sut_core_measurement_duration/1000000
+ sut_avail = False
+ else:
+ pps_sut_tx = None
+ pps_rx = delta_rx/single_core_measurement_duration/1000000
+ RapidLog.info(self.report_result(flow_number, size,
+ speed, pps_req_tx, pps_tx, pps_sut_tx, pps_rx,
+ lat_avg_sample, sample_percentile, percentile_max,
+ lat_max_sample, delta_dp_tx, delta_dp_rx,
+ tot_dp_drop, single_core_measurement_duration))
+ #Stop generating
+ self.gen_machine.stop_gen_cores()
+ r += 1
+ lat_avg = old_div(lat_avg, float(tot_lat_measurement_duration))
+ used_avg = old_div(used_avg, float(tot_lat_measurement_duration))
+ t4_tsc = t2_tsc
+ while t4_tsc == t2_tsc:
+ t4_rx, t4_non_dp_rx, t4_tx, t4_non_dp_tx, t4_drop, t4_tx_fail, t4_tsc, abs_tsc_hz = self.gen_machine.core_stats()
+ if self.test['test'] == 'fixed_rate':
+ t4_lat_tsc = t2_lat_tsc
+ while t4_lat_tsc == t2_lat_tsc:
+ lat_min_sample, lat_max_sample, lat_avg_sample, used_sample, t4_lat_tsc, lat_hz, buckets = self.gen_machine.lat_stats()
+ sample_count = 0
+ lat_samples = sum(buckets)
+ for percentile, bucket in enumerate(buckets,start=1):
+ sample_count += bucket
+ if sample_count > lat_samples * LAT_PERCENTILE:
+ break
+ percentile_max = (percentile == len(buckets))
+ percentile = percentile * float(2 ** BUCKET_SIZE_EXP) / (old_div(float(lat_hz),float(10**6)))
+ lat_max = lat_max_sample
+ lat_avg = lat_avg_sample
+ delta_rx = t4_rx - t2_rx
+ delta_non_dp_rx = t4_non_dp_rx - t2_non_dp_rx
+ delta_tx = t4_tx - t2_tx
+ delta_non_dp_tx = t4_non_dp_tx - t2_non_dp_tx
+ delta_dp_tx = delta_tx -delta_non_dp_tx
+ delta_dp_rx = delta_rx -delta_non_dp_rx
+ dp_tx = delta_dp_tx
+ dp_rx = delta_dp_rx
+ tot_dp_drop += delta_dp_tx - delta_dp_rx
+ pps_req_tx = None
+ pps_tx = None
+ pps_sut_tx = None
+ pps_rx = None
+ drop_rate = 100.0*(dp_tx-dp_rx)/dp_tx
+ tot_core_measurement_duration = None
+ break ## Not really needed since the while loop will stop when evaluating the value of r
+ else:
+ sample_count = 0
+ for percentile, bucket in enumerate(buckets_total,start=1):
+ sample_count += bucket
+ if sample_count > tot_lat_samples * LAT_PERCENTILE:
+ break
+ percentile_max = (percentile == len(buckets_total))
+ percentile = percentile * float(2 ** BUCKET_SIZE_EXP) / (old_div(float(lat_hz),float(10**6)))
+ pps_req_tx = (tot_tx + tot_drop - tot_rx)/tot_core_measurement_duration/1000000.0 # tot_drop is all packets dropped by all tasks. This includes packets dropped at the generator task + packets dropped by the nop task. In steady state, this equals to the number of packets received by this VM
+ pps_tx = tot_tx/tot_core_measurement_duration/1000000.0 # tot_tx is all generated packets actually accepted by the interface
+ pps_rx = tot_rx/tot_core_measurement_duration/1000000.0 # tot_rx is all packets received by the nop task = all packets received in the gen VM
+ if self.sut_machine != None and sut_avail:
+ pps_sut_tx = tot_sut_tx / tot_sut_core_measurement_duration / 1000000.0
+ else:
+ pps_sut_tx = None
+ dp_tx = (t4_tx - t1_tx) - (t4_non_dp_tx - t1_non_dp_tx)
+ dp_rx = (t4_rx - t1_rx) - (t4_non_dp_rx - t1_non_dp_rx)
+ tot_dp_drop = dp_tx - dp_rx
+ drop_rate = 100.0*tot_dp_drop/dp_tx
+ if ((drop_rate < self.test['drop_rate_threshold']) or (tot_dp_drop == self.test['drop_rate_threshold'] ==0) or (tot_dp_drop > self.test['maxz'])):
+ break
+ return(pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,percentile,percentile_max,lat_max,dp_tx,dp_rx,tot_dp_drop,(t4_tx_fail - t1_tx_fail),drop_rate,lat_min,used_avg,r,tot_core_measurement_duration)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_warmuptest.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_warmuptest.py
new file mode 100644
index 00000000..6a9daa73
--- /dev/null
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_warmuptest.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+##
+## Copyright (c) 2010-2020 Intel Corporation
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+
+import sys
+import time
+from rapid_log import RapidLog
+from rapid_test import RapidTest
+
+class WarmupTest(RapidTest):
+ """
+ Class to manage the warmup testing
+ """
+ def __init__(self, test_param, gen_machine):
+ self.test = test_param
+ self.gen_machine = gen_machine
+
+ def run(self):
+ # Running at low speed to make sure the ARP messages can get through.
+ # If not doing this, the ARP message could be dropped by a switch in overload and then the test will not give proper results
+ # Note hoever that if we would run the test steps during a very long time, the ARP would expire in the switch.
+ # PROX will send a new ARP request every seconds so chances are very low that they will all fail to get through
+ size = int(self.test['packetsize'])
+ FLOWSIZE = int(self.test['flowsize'])
+ WARMUPSPEED = int(self.test['warmupspeed'])
+ WARMUPTIME = int(self.test['warmuptime'])
+ self.gen_machine.set_generator_speed(WARMUPSPEED)
+ self.gen_machine.set_udp_packet_size(size)
+ # gen_machine['socket'].set_value(gencores,0,56,1,1)
+ self.gen_machine.set_flows(FLOWSIZE)
+ self.gen_machine.start()
+ time.sleep(WARMUPTIME)
+ self.gen_machine.stop()
+ # gen_machine['socket'].set_value(gencores,0,56,50,1)
+ time.sleep(WARMUPTIME)
+ return (True)
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py b/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
index 5520d139..1e6818e6 100755
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/runrapid.py
@@ -15,1217 +15,112 @@
## See the License for the specific language governing permissions and
## limitations under the License.
##
-
from __future__ import print_function
+from __future__ import print_function
+from __future__ import division
-import os
-import stat
+from future import standard_library
+standard_library.install_aliases()
+from builtins import object
import sys
-import time
-import subprocess
-import getopt
-import re
-import logging
-from logging.handlers import RotatingFileHandler
-from logging import handlers
-from prox_ctrl import prox_ctrl
-import ConfigParser
-import ast
-import atexit
-import csv
-import requests
-from math import ceil
-inf = float("inf")
-
-version="20.03.23"
-env = "rapid.env" #Default string for environment
-test_file = "basicrapid.test" #Default string for test
-machine_map_file = "machine.map" #Default string for machine map file
-loglevel="DEBUG" # sets log level for writing to file
-screenloglevel="INFO" # sets log level for writing to screen
-runtime=10 # time in seconds for 1 test run
-configonly = False # IF True, the system will upload all the necessary config fiels to the VMs, but not start PROX and the actual testing
-#rundir = "/home/centos" # Directory where to find the tools in the machines running PROX
-rundir = "~" # Directory where to find the tools in the machines running PROX
-
-def usage():
- print("usage: runrapid [--version] [-v]")
- print(" [--env ENVIRONMENT_NAME]")
- print(" [--test TEST_NAME]")
- print(" [--map MACHINE_MAP_FILE]")
- print(" [--runtime TIME_FOR_TEST]")
- print(" [--configonly False|True]")
- print(" [--log DEBUG|INFO|WARNING|ERROR|CRITICAL]")
- print(" [-h] [--help]")
- print("")
- print("Command-line interface to runrapid")
- print("")
- print("optional arguments:")
- print(" -v, --version Show program's version number and exit")
- print(" --env ENVIRONMENT_NAME Parameters will be read from ENVIRONMENT_NAME. Default is %s."%env)
- print(" --test TEST_NAME Test cases will be read from TEST_NAME. Default is %s."%test_file)
- print(" --map MACHINE_MAP_FILE Machine mapping will be read from MACHINE_MAP_FILE. Default is %s."%machine_map_file)
- print(" --runtime Specify time in seconds for 1 test run")
- print(" --configonly If this option is specified, only upload all config files to the VMs, do not run the tests")
- print(" --log Specify logging level for log file output, default is DEBUG")
- print(" --screenlog Specify logging level for screen output, default is INFO")
- print(" -h, --help Show help message and exit.")
- print("")
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "vh", ["version","help", "env=", "test=", "map=", "runtime=","configonly","log=","screenlog="])
-except getopt.GetoptError as err:
- print("===========================================")
- print(str(err))
- print("===========================================")
- usage()
- sys.exit(2)
-if args:
- usage()
- sys.exit(2)
-for opt, arg in opts:
- if opt in ["-h", "--help"]:
- usage()
- sys.exit()
- if opt in ["-v", "--version"]:
- print("Rapid Automated Performance Indication for Dataplane "+version)
- sys.exit()
- if opt in ["--env"]:
- env = arg
- if opt in ["--test"]:
- test_file = arg
- if opt in ["--map"]:
- machine_map_file = arg
- if opt in ["--runtime"]:
- runtime = arg
- if opt in ["--configonly"]:
- configonly = True
- print('No actual runs, only uploading configuration files')
- if opt in ["--log"]:
- loglevel = arg
- print ("Log level: "+ loglevel)
- if opt in ["--screenlog"]:
- screenloglevel = arg
- print ("Screen Log level: "+ screenloglevel)
-
-print ("Using '"+env+"' as name for the environment")
-print ("Using '"+test_file+"' for test case definition")
-print ("Using '"+machine_map_file+"' for machine mapping")
-print ("Runtime: "+ str(runtime))
-
-class bcolors:
- HEADER = '\033[95m'
- OKBLUE = '\033[94m'
- OKGREEN = '\033[92m'
- WARNING = '\033[93m'
- FAIL = '\033[91m'
- ENDC = '\033[0m'
- BOLD = '\033[1m'
- UNDERLINE = '\033[4m'
- FLASH = '\033[5m'
-
-# create formatters
-screen_formatter = logging.Formatter("%(message)s")
-file_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
-
-# get a top-level logger,
-# set its log level,
-# BUT PREVENT IT from propagating messages to the root logger
-#
-log = logging.getLogger()
-numeric_level = getattr(logging, loglevel.upper(), None)
-if not isinstance(numeric_level, int):
- raise ValueError('Invalid log level: %s' % loglevel)
-log.setLevel(numeric_level)
-log.propagate = 0
-
-# create a console handler
-# and set its log level to the command-line option
-#
-console_handler = logging.StreamHandler(sys.stdout)
-#console_handler.setLevel(logging.INFO)
-numeric_screenlevel = getattr(logging, screenloglevel.upper(), None)
-if not isinstance(numeric_screenlevel, int):
- raise ValueError('Invalid screenlog level: %s' % screenloglevel)
-console_handler.setLevel(numeric_screenlevel)
-console_handler.setFormatter(screen_formatter)
-
-# create a file handler
-# and set its log level
-#
-log_file = 'RUN{}.{}.log'.format(env,test_file)
-file_handler = logging.handlers.RotatingFileHandler(log_file, backupCount=10)
-#file_handler = log.handlers.TimedRotatingFileHandler(log_file, 'D', 1, 5)
-file_handler.setLevel(numeric_level)
-file_handler.setFormatter(file_formatter)
-
-# add handlers to the logger
-#
-log.addHandler(file_handler)
-log.addHandler(console_handler)
-
-# Check if log exists and should therefore be rolled
-needRoll = os.path.isfile(log_file)
-
-
-# This is a stale log, so roll it
-if needRoll:
- # Add timestamp
- log.debug('\n---------\nLog closed on %s.\n---------\n' % time.asctime())
-
- # Roll over on application start
- log.handlers[0].doRollover()
-
-# Add timestamp
-log.debug('\n---------\nLog started on %s.\n---------\n' % time.asctime())
-
-log.debug("runrapid.py version: "+version)
-#========================================================================
-def connect_socket(client):
- attempts = 1
- log.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (client.ip(), attempts))
- sock = None
- while True:
- sock = client.prox_sock()
- if sock is not None:
- break
- attempts += 1
- if attempts > 20:
- log.exception("Failed to connect to PROX on %s after %d attempts" % (client.ip(), attempts))
- raise Exception("Failed to connect to PROX on %s after %d attempts" % (client.ip(), attempts))
- time.sleep(2)
- log.debug("Trying to connect to PROX (just launched) on %s, attempt: %d" % (client.ip(), attempts))
- log.info("Connected to PROX on %s" % client.ip())
- return sock
-
-def connect_client(client):
- attempts = 1
- log.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (client.ip(), attempts))
- while True:
- try:
- client.connect()
- break
- except RuntimeWarning, ex:
- attempts += 1
- if attempts > 20:
- log.exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex))
- raise Exception("Failed to connect to VM after %d attempts:\n%s" % (attempts, ex))
- time.sleep(2)
- log.debug("Trying to connect to VM which was just launched on %s, attempt: %d" % (client.ip(), attempts))
- log.debug("Connected to VM on %s" % client.ip())
-
-def report_result(flow_number,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,tx,rx,tot_drop,elapsed_time,speed_prefix='',lat_avg_prefix='',lat_perc_prefix='',lat_max_prefix='',abs_drop_rate_prefix='',drop_rate_prefix=''):
- if flow_number < 0:
- flow_number_str = '| ({:>4}) |'.format(abs(flow_number))
- else:
- flow_number_str = '|{:>7} |'.format(flow_number)
- if pps_req_tx is None:
- pps_req_tx_str = '{0: >14}'.format(' NA |')
- else:
- pps_req_tx_str = '{:>7.3f} Mpps |'.format(pps_req_tx)
- if pps_tx is None:
- pps_tx_str = '{0: >14}'.format(' NA |')
- else:
- pps_tx_str = '{:>7.3f} Mpps |'.format(pps_tx)
- if pps_sut_tx is None:
- pps_sut_tx_str = '{0: >14}'.format(' NA |')
- else:
- pps_sut_tx_str = '{:>7.3f} Mpps |'.format(pps_sut_tx)
- if pps_rx is None:
- pps_rx_str = '{0: >25}'.format('NA |')
- else:
- pps_rx_str = bcolors.OKBLUE + '{:>4.1f} Gb/s |{:7.3f} Mpps {}|'.format(get_speed(pps_rx,size),pps_rx,bcolors.ENDC)
- if tot_drop is None:
- tot_drop_str = ' | NA | '
- else:
- tot_drop_str = ' | {:>9.0f} | '.format(tot_drop)
- if lat_perc is None:
- lat_perc_str = ' |{:^10.10}|'.format('NA')
- elif lat_perc_max == True:
- lat_perc_str = '|>{}{:>5.0f} us{} |'.format(lat_perc_prefix,float(lat_perc), bcolors.ENDC)
- else:
- lat_perc_str = '| {}{:>5.0f} us{} |'.format(lat_perc_prefix,float(lat_perc), bcolors.ENDC)
- if elapsed_time is None:
- elapsed_time_str = ' NA |'
- else:
- elapsed_time_str = '{:>3.0f} |'.format(elapsed_time)
- return(flow_number_str + '{:>5.1f}'.format(speed) + '% '+speed_prefix +'{:>6.3f}'.format(get_pps(speed,size)) + ' Mpps|'+ pps_req_tx_str + pps_tx_str + bcolors.ENDC + pps_sut_tx_str + pps_rx_str +lat_avg_prefix+ ' {:>6.0f}'.format(lat_avg)+' us'+lat_perc_str+lat_max_prefix+'{:>6.0f}'.format(lat_max)+' us | ' + '{:>9.0f}'.format(tx) + ' | {:>9.0f}'.format(rx) + ' | '+ abs_drop_rate_prefix+ '{:>9.0f}'.format(tx-rx) + tot_drop_str +drop_rate_prefix+ '{:>5.2f}'.format(float(tx-rx)/tx) +bcolors.ENDC+' |' + elapsed_time_str)
-
-def run_iteration(gensock, sutsock, requested_duration,flow_number,size,speed):
- r = 0;
- sleep_time = 2
- while (r < TST009_MAXr):
- time.sleep(sleep_time)
- # Sleep_time is needed to be able to do accurate measurements to check for packet loss. We need to make this time large enough so that we do not take the first measurement while some packets from the previous tests migth still be in flight
- t1_rx, t1_non_dp_rx, t1_tx, t1_non_dp_tx, t1_drop, t1_tx_fail, t1_tsc, abs_tsc_hz = gensock.core_stats(genstatcores,gentasks)
- t1_dp_rx = t1_rx - t1_non_dp_rx
- t1_dp_tx = t1_tx - t1_non_dp_tx
- gensock.start(gencores)
- time.sleep(2) ## Needs to be 2 seconds since this 1 sec is the time that PROX uses to refresh the stats. Note that this can be changed in PROX!! Don't do it.
- if sutsock!='none':
- t2_sut_rx, t2_sut_non_dp_rx, t2_sut_tx, t2_sut_non_dp_tx, t2_sut_drop, t2_sut_tx_fail, t2_sut_tsc, sut_tsc_hz = sutsock.core_stats(sutstatcores,tasks)
- t2_rx, t2_non_dp_rx, t2_tx, t2_non_dp_tx, t2_drop, t2_tx_fail, t2_tsc, tsc_hz = gensock.core_stats(genstatcores,gentasks)
- tx = t2_tx - t1_tx
- dp_tx = tx - (t2_non_dp_tx - t1_non_dp_tx )
- dp_rx = t2_rx - t1_rx - (t2_non_dp_rx - t1_non_dp_rx)
- tot_dp_drop = dp_tx - dp_rx
- if tx == 0:
- log.critical("TX = 0. Test interrupted since no packet has been sent.")
- raise Exception("TX = 0")
- if dp_tx == 0:
- log.critical("Only non-dataplane packets (e.g. ARP) sent. Test interrupted since no packet has been sent.")
- raise Exception("Only non-dataplane packets (e.g. ARP) sent")
- # Ask PROX to calibrate the bucket size once we have a PROX function to do this.
- # Measure latency statistics per second
- lat_min, lat_max, lat_avg, used_avg, t2_lat_tsc, lat_hz, buckets = gensock.lat_stats(latcores)
- lat_samples = sum(buckets)
- sample_count = 0
- for sample_percentile, bucket in enumerate(buckets,start=1):
- sample_count += bucket
- if sample_count > (lat_samples * LAT_PERCENTILE):
- break
- percentile_max = (sample_percentile == len(buckets))
- sample_percentile = sample_percentile * float(2 ** BUCKET_SIZE_EXP) / (float(lat_hz)/float(10**6))
- if test == 'fixed_rate':
- log.info(report_result(flow_number,size,speed,None,None,None,None,lat_avg,sample_percentile,percentile_max,lat_max, dp_tx, dp_rx , None, None))
- tot_rx = tot_non_dp_rx = tot_tx = tot_non_dp_tx = tot_drop = 0
- lat_avg = used_avg = 0
- buckets_total = [0] * 128
- tot_lat_samples = 0
- tot_lat_measurement_duration = float(0)
- tot_core_measurement_duration = float(0)
- tot_sut_core_measurement_duration = float(0)
- tot_sut_rx = tot_sut_non_dp_rx = tot_sut_tx = tot_sut_non_dp_tx = tot_sut_drop = tot_sut_tx_fail = tot_sut_tsc = 0
- lat_avail = core_avail = sut_avail = False
- while (tot_core_measurement_duration - float(requested_duration) <= 0.1) or (tot_lat_measurement_duration - float(requested_duration) <= 0.1):
- time.sleep(0.5)
- lat_min_sample, lat_max_sample, lat_avg_sample, used_sample, t3_lat_tsc, lat_hz, buckets = gensock.lat_stats(latcores)
- # Get statistics after some execution time
- if t3_lat_tsc != t2_lat_tsc:
- single_lat_measurement_duration = (t3_lat_tsc - t2_lat_tsc) * 1.0 / lat_hz # time difference between the 2 measurements, expressed in seconds.
- # A second has passed in between to lat_stats requests. Hence we need to process the results
- tot_lat_measurement_duration = tot_lat_measurement_duration + single_lat_measurement_duration
- if lat_min > lat_min_sample:
- lat_min = lat_min_sample
- if lat_max < lat_max_sample:
- lat_max = lat_max_sample
- lat_avg = lat_avg + lat_avg_sample * single_lat_measurement_duration # Sometimes, There is more than 1 second between 2 lat_stats. Hence we will take the latest measurement
- used_avg = used_avg + used_sample * single_lat_measurement_duration # and give it more weigth.
- lat_samples = sum(buckets)
- tot_lat_samples += lat_samples
- sample_count = 0
- for sample_percentile, bucket in enumerate(buckets,start=1):
- sample_count += bucket
- if sample_count > lat_samples * LAT_PERCENTILE:
- break
- percentile_max = (sample_percentile == len(buckets))
- sample_percentile = sample_percentile * float(2 ** BUCKET_SIZE_EXP) / (float(lat_hz)/float(10**6))
- buckets_total = [buckets_total[i] + buckets[i] for i in range(len(buckets_total))]
- t2_lat_tsc = t3_lat_tsc
- lat_avail = True
- t3_rx, t3_non_dp_rx, t3_tx, t3_non_dp_tx, t3_drop, t3_tx_fail, t3_tsc, tsc_hz = gensock.core_stats(genstatcores,gentasks)
- if t3_tsc != t2_tsc:
- single_core_measurement_duration = (t3_tsc - t2_tsc) * 1.0 / tsc_hz # time difference between the 2 measurements, expressed in seconds.
- tot_core_measurement_duration = tot_core_measurement_duration + single_core_measurement_duration
- delta_rx = t3_rx - t2_rx
- tot_rx += delta_rx
- delta_non_dp_rx = t3_non_dp_rx - t2_non_dp_rx
- tot_non_dp_rx += delta_non_dp_rx
- delta_tx = t3_tx - t2_tx
- tot_tx += delta_tx
- delta_non_dp_tx = t3_non_dp_tx - t2_non_dp_tx
- tot_non_dp_tx += delta_non_dp_tx
- delta_dp_tx = delta_tx -delta_non_dp_tx
- delta_dp_rx = delta_rx -delta_non_dp_rx
- delta_dp_drop = delta_dp_tx - delta_dp_rx
- tot_dp_drop += delta_dp_drop
- delta_drop = t3_drop - t2_drop
- tot_drop += delta_drop
- t2_rx, t2_non_dp_rx, t2_tx, t2_non_dp_tx, t2_drop, t2_tx_fail, t2_tsc = t3_rx, t3_non_dp_rx, t3_tx, t3_non_dp_tx, t3_drop, t3_tx_fail, t3_tsc
- core_avail = True
- if sutsock!='none':
- t3_sut_rx, t3_sut_non_dp_rx, t3_sut_tx, t3_sut_non_dp_tx, t3_sut_drop, t3_sut_tx_fail, t3_sut_tsc, sut_tsc_hz = sutsock.core_stats(sutstatcores,tasks)
- if t3_sut_tsc != t2_sut_tsc:
- single_sut_core_measurement_duration = (t3_sut_tsc - t2_sut_tsc) * 1.0 / tsc_hz # time difference between the 2 measurements, expressed in seconds.
- tot_sut_core_measurement_duration = tot_sut_core_measurement_duration + single_sut_core_measurement_duration
- tot_sut_rx += t3_sut_rx - t2_sut_rx
- tot_sut_non_dp_rx += t3_sut_non_dp_rx - t2_sut_non_dp_rx
- delta_sut_tx = t3_sut_tx - t2_sut_tx
- tot_sut_tx += delta_sut_tx
- delta_sut_non_dp_tx = t3_sut_non_dp_tx - t2_sut_non_dp_tx
- tot_sut_non_dp_tx += delta_sut_non_dp_tx
- t2_sut_rx, t2_sut_non_dp_rx, t2_sut_tx, t2_sut_non_dp_tx, t2_sut_drop, t2_sut_tx_fail, t2_sut_tsc = t3_sut_rx, t3_sut_non_dp_rx, t3_sut_tx, t3_sut_non_dp_tx, t3_sut_drop, t3_sut_tx_fail, t3_sut_tsc
- sut_avail = True
- if test == 'fixed_rate':
- if lat_avail == core_avail == True:
- lat_avail = core_avail = False
- pps_req_tx = (delta_tx + delta_drop - delta_rx)/single_core_measurement_duration/1000000
- pps_tx = delta_tx/single_core_measurement_duration/1000000
- if sutsock!='none' and sut_avail:
- pps_sut_tx = delta_sut_tx/single_sut_core_measurement_duration/1000000
- sut_avail = False
- else:
- pps_sut_tx = None
- pps_rx = delta_rx/single_core_measurement_duration/1000000
- log.info(report_result(flow_number,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg_sample,sample_percentile,percentile_max,lat_max_sample,delta_dp_tx,delta_dp_rx,tot_dp_drop,single_core_measurement_duration))
- #Stop generating
- gensock.stop(gencores)
- r += 1
- lat_avg = lat_avg / float(tot_lat_measurement_duration)
- used_avg = used_avg / float(tot_lat_measurement_duration)
- t4_tsc = t2_tsc
- while t4_tsc == t2_tsc:
- t4_rx, t4_non_dp_rx, t4_tx, t4_non_dp_tx, t4_drop, t4_tx_fail, t4_tsc, abs_tsc_hz = gensock.core_stats(genstatcores,gentasks)
- if test == 'fixed_rate':
- t4_lat_tsc = t2_lat_tsc
- while t4_lat_tsc == t2_lat_tsc:
- lat_min_sample, lat_max_sample, lat_avg_sample, used_sample, t4_lat_tsc, lat_hz, buckets = gensock.lat_stats(latcores)
- sample_count = 0
- lat_samples = sum(buckets)
- for percentile, bucket in enumerate(buckets,start=1):
- sample_count += bucket
- if sample_count > lat_samples * LAT_PERCENTILE:
- break
- percentile_max = (percentile == len(buckets))
- percentile = percentile * float(2 ** BUCKET_SIZE_EXP) / (float(lat_hz)/float(10**6))
- lat_max = lat_max_sample
- lat_avg = lat_avg_sample
- delta_rx = t4_rx - t2_rx
- delta_non_dp_rx = t4_non_dp_rx - t2_non_dp_rx
- delta_tx = t4_tx - t2_tx
- delta_non_dp_tx = t4_non_dp_tx - t2_non_dp_tx
- delta_dp_tx = delta_tx -delta_non_dp_tx
- delta_dp_rx = delta_rx -delta_non_dp_rx
- dp_tx = delta_dp_tx
- dp_rx = delta_dp_rx
- tot_dp_drop += delta_dp_tx - delta_dp_rx
- pps_req_tx = None
- pps_tx = None
- pps_sut_tx = None
- pps_rx = None
- drop_rate = 100.0*(dp_tx-dp_rx)/dp_tx
- tot_core_measurement_duration = None
- break ## Not really needed since the while loop will stop when evaluating the value of r
- else:
- sample_count = 0
- for percentile, bucket in enumerate(buckets_total,start=1):
- sample_count += bucket
- if sample_count > tot_lat_samples * LAT_PERCENTILE:
- break
- percentile_max = (percentile == len(buckets_total))
- percentile = percentile * float(2 ** BUCKET_SIZE_EXP) / (float(lat_hz)/float(10**6))
- pps_req_tx = (tot_tx + tot_drop - tot_rx)/tot_core_measurement_duration/1000000.0 # tot_drop is all packets dropped by all tasks. This includes packets dropped at the generator task + packets dropped by the nop task. In steady state, this equals to the number of packets received by this VM
- pps_tx = tot_tx/tot_core_measurement_duration/1000000.0 # tot_tx is all generated packets actually accepted by the interface
- pps_rx = tot_rx/tot_core_measurement_duration/1000000.0 # tot_rx is all packets received by the nop task = all packets received in the gen VM
- if sutsock!='none' and sut_avail:
- pps_sut_tx = tot_sut_tx / tot_sut_core_measurement_duration / 1000000.0
- else:
- pps_sut_tx = None
- dp_tx = (t4_tx - t1_tx) - (t4_non_dp_tx - t1_non_dp_tx)
- dp_rx = (t4_rx - t1_rx) - (t4_non_dp_rx - t1_non_dp_rx)
- tot_dp_drop = dp_tx - dp_rx
- drop_rate = 100.0*tot_dp_drop/dp_tx
- if ((drop_rate < DROP_RATE_TRESHOLD) or (tot_dp_drop == DROP_RATE_TRESHOLD ==0) or (tot_dp_drop > TST009_MAXz)):
- break
- return(pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,percentile,percentile_max,lat_max,dp_tx,dp_rx,tot_dp_drop,(t4_tx_fail - t1_tx_fail),drop_rate,lat_min,used_avg,r,tot_core_measurement_duration)
-
-def new_speed(speed,size,success):
- if test == 'fixed_rate':
- return (STARTSPEED)
- elif TST009:
- global TST009_m
- global TST009_L
- global TST009_R
- if success:
- TST009_L = TST009_m + 1
- else:
- TST009_R = max(TST009_m - 1, TST009_L)
- TST009_m = int ((TST009_L + TST009_R)/2)
- return (get_percentageof10Gbps(TST009_S[TST009_m],size))
- else:
- global minspeed
- global maxspeed
- if success:
- minspeed = speed
- else:
- maxspeed = speed
- return ((minspeed + maxspeed)/2.0)
-
-def get_start_speed_and_init(size):
- if test == 'fixed_rate':
- return (STARTSPEED)
- elif TST009:
- global TST009_L
- global TST009_R
- global TST009_m
- TST009_L = 0
- TST009_R = TST009_n - 1
- TST009_m = int((TST009_L + TST009_R) / 2)
- return (get_percentageof10Gbps(TST009_S[TST009_m],size))
- else:
- global minspeed
- global maxspeed
- minspeed = 0
- maxspeed = STARTSPEED
- return (STARTSPEED)
-
-def resolution_achieved():
- if test == 'fixed_rate':
- return (True)
- elif TST009:
- return (TST009_L == TST009_R)
- else:
- return ((maxspeed - minspeed) <= ACCURACY)
-
-def get_percentageof10Gbps(pps_speed,size):
- # speed is given in pps, returning % of 10Gb/s
- return (pps_speed / 1000000.0 * 0.08 * (size+24))
-
-def get_pps(speed,size):
- # speed is given in % of 10Gb/s, returning Mpps
- return (speed * 100.0 / (8*(size+24)))
-
-def get_speed(packet_speed,size):
- # return speed in Gb/s
- return (packet_speed / 1000.0 * (8*(size+24)))
-
-def set_background_flows(source_port,destination_port):
- for sock in background_gen_socks:
- sock.set_random(gencores,0,34,source_port,2)
- sock.set_random(gencores,0,36,destination_port,2)
-
-def set_background_speed(speed):
- for sock in background_gen_socks:
- sock.speed(speed / len(gencores) / len (gentasks), gencores, gentasks)
-
-def start_background_traffic():
- for sock in background_gen_socks:
- sock.start(gencores+latcores)
-
-def stop_background_traffic():
- for sock in background_gen_socks:
- sock.stop(gencores+latcores)
-
-def run_flow_size_test(gensock,sutsock):
- global fieldnames
- global writer
- #fieldnames = ['Flows','PacketSize','Gbps','Mpps','AvgLatency','MaxLatency','PacketsDropped','PacketDropRate']
- fieldnames = ['Flows','PacketSize','RequestedPPS','GeneratedPPS','SentPPS','ForwardedPPS','ReceivedPPS','AvgLatencyUSEC','MaxLatencyUSEC','Sent','Received','Lost','LostTotal']
- writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
- writer.writeheader()
- gensock.start(latcores)
- for size in packet_size_list:
- size = size-4
- gensock.set_size(gencores,0,size) # This is setting the frame size
- gensock.set_value(gencores,0,16,(size-14),2) # 18 is the difference between the frame size and IP size = size of (MAC addresses, ethertype and FCS)
- gensock.set_value(gencores,0,38,(size-34),2) # 38 is the difference between the frame size and UDP size = 18 + size of IP header (=20)
- # This will only work when using sending UDP packets. For different protocols and ethernet types, we would need a different calculation
- if background_gen_socks:
- backgroundinfo = '{}Running {} x background traffic not represented in the table{}'.format(bcolors.FLASH,len(background_gen_socks),bcolors.ENDC)
- else:
- backgroundinfo = '{}{}'.format(bcolors.FLASH,bcolors.ENDC)
- log.info("+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+")
- log.info('| UDP, {:>5} bytes, different number of flows by randomizing SRC & DST UDP port. {:116.116}|'.format((size+4),backgroundinfo))
- log.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
- log.info('| Flows | Speed requested | Gen by core | Sent by NIC | Fwrd by SUT | Rec. by core | Avg. Lat.|{:.0f} Pcentil| Max. Lat.| Sent | Received | Lost | Total Lost|L.Ratio|Time|'.format(LAT_PERCENTILE*100))
- log.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
- for flow_number in flow_size_list:
- attempts = 0
- gensock.reset_stats()
- if sutsock!='none':
- sutsock.reset_stats()
- source_port,destination_port = flows[flow_number]
- gensock.set_random(gencores,0,34,source_port,2)
- gensock.set_random(gencores,0,36,destination_port,2)
- set_background_flows(source_port,destination_port)
- endspeed = None
- speed = get_start_speed_and_init(size)
- while True:
- attempts += 1
- endwarning = False
- print(str(flow_number)+' flows: Measurement ongoing at speed: ' + str(round(speed,2)) + '% ',end='\r')
- sys.stdout.flush()
- # Start generating packets at requested speed (in % of a 10Gb/s link)
- gensock.speed(speed / len(gencores) / len (gentasks), gencores, gentasks)
- set_background_speed(speed)
- start_background_traffic()
- ##time.sleep(1)
- # Get statistics now that the generation is stable and initial ARP messages are dealt with
- pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc , lat_perc_max, lat_max, abs_tx,abs_rx,abs_dropped, abs_tx_fail, drop_rate, lat_min, lat_used, r, actual_duration = run_iteration(gensock,sutsock,float(runtime),flow_number,size,speed)
- stop_background_traffic()
- if r > 1:
- retry_warning = bcolors.WARNING + ' {:1} retries needed'.format(r) + bcolors.ENDC
- else:
- retry_warning = ''
- # Drop rate is expressed in percentage. lat_used is a ratio (0 to 1). The sum of these 2 should be 100%.
- # If the sum is lower than 95, it means that more than 5% of the latency measurements where dropped for accuracy reasons.
- if (drop_rate + lat_used * 100) < 95:
- lat_warning = bcolors.WARNING + ' Latency accuracy issue?: {:>3.0f}%'.format(lat_used*100) + bcolors.ENDC
- else:
- lat_warning = ''
- if test == 'fixed_rate':
- endspeed = speed
- endpps_req_tx = None
- endpps_tx = None
- endpps_sut_tx = None
- endpps_rx = None
- endlat_avg = lat_avg
- endlat_perc = lat_perc
- endlat_perc_max = lat_perc_max
- endlat_max = lat_max
- endabs_dropped = abs_dropped
- enddrop_rate = drop_rate
- endabs_tx = abs_tx
- endabs_rx = abs_rx
- if lat_warning or retry_warning:
- endwarning = '| | {:177.177} |'.format(retry_warning + lat_warning)
- success = True
- speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
- # The following if statement is testing if we pass the success criteria of a certain drop rate, average latency and maximum latency below the threshold
- # The drop rate success can be achieved in 2 ways: either the drop rate is below a treshold, either we want that no packet has been lost during the test
- # This can be specified by putting 0 in the .test file
- elif ((drop_rate < DROP_RATE_TRESHOLD) or (abs_dropped==DROP_RATE_TRESHOLD==0)) and (lat_avg< LAT_AVG_TRESHOLD) and (lat_perc< LAT_PERC_TRESHOLD) and (lat_max < LAT_MAX_TRESHOLD):
- if ((get_pps(speed,size) - pps_tx)/get_pps(speed,size))>0.01:
- speed_prefix = bcolors.WARNING
- if abs_tx_fail > 0:
- gen_warning = bcolors.WARNING + ' Network limit?: requesting {:<.3f} Mpps and getting {:<.3f} Mpps - {} failed to be transmitted'.format(get_pps(speed,size), pps_tx, abs_tx_fail) + bcolors.ENDC
- else:
- gen_warning = bcolors.WARNING + ' Generator limit?: requesting {:<.3f} Mpps and getting {:<.3f} Mpps'.format(get_pps(speed,size), pps_tx) + bcolors.ENDC
- else:
- speed_prefix = bcolors.ENDC
- gen_warning = ''
- endspeed = speed
- endspeed_prefix = speed_prefix
- endpps_req_tx = pps_req_tx
- endpps_tx = pps_tx
- endpps_sut_tx = pps_sut_tx
- endpps_rx = pps_rx
- endlat_avg = lat_avg
- endlat_perc = lat_perc
- endlat_perc_max = lat_perc_max
- endlat_max = lat_max
- endabs_dropped = None
- enddrop_rate = drop_rate
- endabs_tx = abs_tx
- endabs_rx = abs_rx
- if lat_warning or gen_warning or retry_warning:
- endwarning = '| | {:177.177} |'.format(retry_warning + lat_warning + gen_warning)
- success = True
- success_message=' SUCCESS'
- speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
- log.debug(report_result(-attempts,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,abs_tx,abs_rx,abs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix)+ success_message + retry_warning + lat_warning + gen_warning)
- else:
- success_message=' FAILED'
- gen_warning = ''
- abs_drop_rate_prefix = bcolors.ENDC
- if ((abs_dropped>0) and (DROP_RATE_TRESHOLD ==0)):
- abs_drop_rate_prefix = bcolors.FAIL
- if (drop_rate < DROP_RATE_TRESHOLD):
- drop_rate_prefix = bcolors.ENDC
- else:
- drop_rate_prefix = bcolors.FAIL
- if (lat_avg< LAT_AVG_TRESHOLD):
- lat_avg_prefix = bcolors.ENDC
- else:
- lat_avg_prefix = bcolors.FAIL
- if (lat_perc< LAT_PERC_TRESHOLD):
- lat_perc_prefix = bcolors.ENDC
- else:
- lat_perc_prefix = bcolors.FAIL
- if (lat_max< LAT_MAX_TRESHOLD):
- lat_max_prefix = bcolors.ENDC
- else:
- lat_max_prefix = bcolors.FAIL
- if (((get_pps(speed,size) - pps_tx)/get_pps(speed,size))<0.001):
- speed_prefix = bcolors.ENDC
- else:
- speed_prefix = bcolors.FAIL
- success = False
- log.debug(report_result(-attempts,size,speed,pps_req_tx,pps_tx,pps_sut_tx,pps_rx,lat_avg,lat_perc,lat_perc_max,lat_max,abs_tx,abs_rx,abs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_perc_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix)+ success_message + retry_warning + lat_warning + gen_warning)
- speed = new_speed(speed, size, success)
- if resolution_achieved():
- break
- if endspeed is not None:
- speed_prefix = lat_avg_prefix = lat_perc_prefix = lat_max_prefix = abs_drop_rate_prefix = drop_rate_prefix = bcolors.ENDC
- log.info(report_result(flow_number,size,endspeed,endpps_req_tx,endpps_tx,endpps_sut_tx,endpps_rx,endlat_avg,endlat_perc,endlat_perc_max,endlat_max,endabs_tx,endabs_rx,endabs_dropped,actual_duration,speed_prefix,lat_avg_prefix,lat_perc_prefix,lat_max_prefix,abs_drop_rate_prefix,drop_rate_prefix))
- if endwarning:
- log.info (endwarning)
- log.info("+--------+------------------+-------------+-------------+-------------+------------------------+----------+----------+----------+-----------+-----------+-----------+-----------+-------+----+")
- writer.writerow({'Flows':flow_number,'PacketSize':(size+4),'RequestedPPS':get_pps(endspeed,size),'GeneratedPPS':endpps_req_tx,'SentPPS':endpps_tx,'ForwardedPPS':endpps_sut_tx,'ReceivedPPS':endpps_rx,'AvgLatencyUSEC':endlat_avg,'MaxLatencyUSEC':endlat_max,'Sent':endabs_tx,'Received':endabs_rx,'Lost':endabs_dropped,'LostTotal':endabs_dropped})
- if PushGateway:
- URL = PushGateway + '/metrics/job/' + TestName + '/instance/' + env
- if endabs_dropped == None:
- ead = 0
- else:
- ead = endabs_dropped
- DATA = 'Flows {}\nPacketSize {}\nRequestedPPS {}\nGeneratedPPS {}\nSentPPS {}\nForwardedPPS {}\nReceivedPPS {}\nAvgLatencyUSEC {}\nMaxLatencyUSEC {}\nSent {}\nReceived {}\nLost {}\nLostTotal {}\n'.format(flow_number,size+4,get_pps(endspeed,size),endpps_req_tx,endpps_tx,endpps_sut_tx,endpps_rx,endlat_avg,endlat_max,endabs_tx,endabs_rx,ead,ead)
- HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
- response = requests.post(url=URL, data=DATA,headers=HEADERS)
- if (response.status_code != 202) and (response.status_code != 200):
- log.info('Cannot send metrics to {}'.format(URL))
- log.info(DATA)
- else:
- log.info('|{:>7}'.format(str(flow_number))+" | Speed 0 or close to 0")
- gensock.stop(latcores)
-
-def run_core_stats(socks):
- fieldnames = ['PROXID','Time','Received','Sent','NonDPReceived','NonDPSent','Delta','NonDPDelta','Dropped']
- writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
- writer.writeheader()
- log.info("+------------------------------------------------------------------------------------------------------------------+")
- log.info("| Measuring core statistics on 1 or more PROX instances |")
- log.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
- log.info("| PROX ID | Time | RX | TX | non DP RX | non DP TX | TX - RX | nonDP TX-RX| DROP TOT |")
- log.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
- for sock in socks:
- sock.reset_stats()
- duration = float(runtime)
- tot_drop = []
- old_rx = []; old_non_dp_rx = []; old_tx = []; old_non_dp_tx = []; old_drop = []; old_tx_fail = []; old_tsc = []
- new_rx = []; new_non_dp_rx = []; new_tx = []; new_non_dp_tx = []; new_drop = []; new_tx_fail = []; new_tsc = []
- sockets_to_go = len (socks)
- for i,sock in enumerate(socks,start=0):
- tot_drop.append(0)
- old_rx.append(0); old_non_dp_rx.append(0); old_tx.append(0); old_non_dp_tx.append(0); old_drop.append(0); old_tx_fail.append(0); old_tsc.append(0)
- old_rx[-1], old_non_dp_rx[-1], old_tx[-1], old_non_dp_tx[-1], old_drop[-1], old_tx_fail[-1], old_tsc[-1], tsc_hz = sock.core_stats(cores[i],tasks)
- new_rx.append(0); new_non_dp_rx.append(0); new_tx.append(0); new_non_dp_tx.append(0); new_drop.append(0); new_tx_fail.append(0); new_tsc.append(0)
- while (duration > 0):
- time.sleep(0.5)
- # Get statistics after some execution time
- for i,sock in enumerate(socks,start=0):
- new_rx[i], new_non_dp_rx[i], new_tx[i], new_non_dp_tx[i], new_drop[i], new_tx_fail[i], new_tsc[i], tsc_hz = sock.core_stats(cores[i],tasks)
- drop = new_drop[i]-old_drop[i]
- rx = new_rx[i] - old_rx[i]
- tx = new_tx[i] - old_tx[i]
- non_dp_rx = new_non_dp_rx[i] - old_non_dp_rx[i]
- non_dp_tx = new_non_dp_tx[i] - old_non_dp_tx[i]
- tsc = new_tsc[i] - old_tsc[i]
- if tsc == 0 :
- continue
- sockets_to_go -= 1
- old_drop[i] = new_drop[i]
- old_rx[i] = new_rx[i]
- old_tx[i] = new_tx[i]
- old_non_dp_rx[i] = new_non_dp_rx[i]
- old_non_dp_tx[i] = new_non_dp_tx[i]
- old_tsc[i] = new_tsc[i]
- tot_drop[i] = tot_drop[i] + tx - rx
- log.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(non_dp_rx)+' | '+'{:>10.0f}'.format(non_dp_tx)+' | ' + '{:>10.0f}'.format(tx-rx) + ' | '+ '{:>10.0f}'.format(non_dp_tx-non_dp_rx) + ' | '+'{:>10.0f}'.format(tot_drop[i]) +' |')
- writer.writerow({'PROXID':i,'Time':duration,'Received':rx,'Sent':tx,'NonDPReceived':non_dp_rx,'NonDPSent':non_dp_tx,'Delta':tx-rx,'NonDPDelta':non_dp_tx-non_dp_rx,'Dropped':tot_drop[i]})
- if PushGateway:
- URL = PushGateway + '/metrics/job/' + TestName + '/instance/' + env + str(i)
- DATA = 'PROXID {}\nTime {}\n Received {}\nSent {}\nNonDPReceived {}\nNonDPSent {}\nDelta {}\nNonDPDelta {}\nDropped {}\n'.format(i,duration,rx,tx,non_dp_rx,non_dp_tx,tx-rx,non_dp_tx-non_dp_rx,tot_drop[i])
- HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
- response = requests.post(url=URL, data=DATA,headers=HEADERS)
- if (response.status_code != 202) and (response.status_code != 200):
- log.info('Cannot send metrics to {}'.format(URL))
- log.info(DATA)
- if sockets_to_go == 0:
- duration = duration - 1
- sockets_to_go = len (socks)
- log.info("+-----------+-----------+------------+------------+------------+------------+------------+------------+------------+")
-
-def run_port_stats(socks):
- fieldnames = ['PROXID','Time','Received','Sent','NoMbufs','iErrMiss']
- writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
- writer.writeheader()
- log.info("+---------------------------------------------------------------------------+")
- log.info("| Measuring port statistics on 1 or more PROX instances |")
- log.info("+-----------+-----------+------------+------------+------------+------------+")
- log.info("| PROX ID | Time | RX | TX | no MBUFS | ierr&imiss |")
- log.info("+-----------+-----------+------------+------------+------------+------------+")
- for sock in socks:
- sock.reset_stats()
- duration = float(runtime)
- old_rx = []; old_tx = []; old_no_mbufs = []; old_errors = []; old_tsc = []
- new_rx = []; new_tx = []; new_no_mbufs = []; new_errors = []; new_tsc = []
- sockets_to_go = len (socks)
- for i,sock in enumerate(socks,start=0):
- old_rx.append(0); old_tx.append(0); old_no_mbufs.append(0); old_errors.append(0); old_tsc.append(0)
- old_rx[-1], old_tx[-1], old_no_mbufs[-1], old_errors[-1], old_tsc[-1] = sock.multi_port_stats(ports[i])
- new_rx.append(0); new_tx.append(0); new_no_mbufs.append(0); new_errors.append(0); new_tsc.append(0)
- while (duration > 0):
- time.sleep(0.5)
- # Get statistics after some execution time
- for i,sock in enumerate(socks,start=0):
- new_rx[i], new_tx[i], new_no_mbufs[i], new_errors[i], new_tsc[i] = sock.multi_port_stats(ports[i])
- rx = new_rx[i] - old_rx[i]
- tx = new_tx[i] - old_tx[i]
- no_mbufs = new_no_mbufs[i] - old_no_mbufs[i]
- errors = new_errors[i] - old_errors[i]
- tsc = new_tsc[i] - old_tsc[i]
- if tsc == 0 :
- continue
- sockets_to_go -= 1
- old_rx[i] = new_rx[i]
- old_tx[i] = new_tx[i]
- old_no_mbufs[i] = new_no_mbufs[i]
- old_errors[i] = new_errors[i]
- old_tsc[i] = new_tsc[i]
- log.info('|{:>10.0f}'.format(i)+ ' |{:>10.0f}'.format(duration)+' | ' + '{:>10.0f}'.format(rx) + ' | ' +'{:>10.0f}'.format(tx) + ' | '+'{:>10.0f}'.format(no_mbufs)+' | '+'{:>10.0f}'.format(errors)+' |')
- writer.writerow({'PROXID':i,'Time':duration,'Received':rx,'Sent':tx,'NoMbufs':no_mbufs,'iErrMiss':errors})
- if PushGateway:
- URL = PushGateway + '/metrics/job/' + TestName + '/instance/' + env + str(i)
- DATA = 'PROXID {}\nTime {}\n Received {}\nSent {}\nNoMbufs {}\niErrMiss {}\n'.format(i,duration,rx,tx,no_mbufs,errors)
- HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
- response = requests.post(url=URL, data=DATA,headers=HEADERS)
- if (response.status_code != 202) and (response.status_code != 200):
- log.info('Cannot send metrics to {}'.format(URL))
- log.info(DATA)
- if sockets_to_go == 0:
- duration = duration - 1
- sockets_to_go = len (socks)
- log.info("+-----------+-----------+------------+------------+------------+------------+")
-
-def run_irqtest(socks):
- log.info("+----------------------------------------------------------------------------------------------------------------------------")
- log.info("| Measuring time probably spent dealing with an interrupt. Interrupting DPDK cores for more than 50us might be problematic ")
- log.info("| and result in packet loss. The first row shows the interrupted time buckets: first number is the bucket between 0us and ")
- log.info("| that number expressed in us and so on. The numbers in the other rows show how many times per second, the program was ")
- log.info("| interrupted for a time as specified by its bucket. '0' is printed when there are no interrupts in this bucket throughout ")
- log.info("| the duration of the test. 0.00 means there were interrupts in this bucket but very few. Due to rounding this shows as 0.00 ")
- log.info("+----------------------------------------------------------------------------------------------------------------------------")
- sys.stdout.flush()
- for sock_index,sock in enumerate(socks,start=0):
- buckets=socks[sock_index].show_irq_buckets(1)
- print('Measurement ongoing ... ',end='\r')
- socks[sock_index].stop(cores[sock_index])
- old_irq = [[0 for x in range(len(buckets)+1)] for y in range(len(cores[sock_index])+1)]
- irq = [[0 for x in range(len(buckets)+1)] for y in range(len(cores[sock_index])+1)]
- irq[0][0] = 'bucket us'
- for j,bucket in enumerate(buckets,start=1):
- irq[0][j] = '<'+ bucket
- irq[0][-1] = '>'+ buckets [-2]
- socks[sock_index].start(cores[sock_index])
- time.sleep(2)
- for j,bucket in enumerate(buckets,start=1):
- for i,irqcore in enumerate(cores[sock_index],start=1):
- old_irq[i][j] = socks[sock_index].irq_stats(irqcore,j-1)
- time.sleep(float(runtime))
- socks[sock_index].stop(cores[sock_index])
- for i,irqcore in enumerate(cores[sock_index],start=1):
- irq[i][0]='core %s '%irqcore
- for j,bucket in enumerate(buckets,start=1):
- diff = socks[sock_index].irq_stats(irqcore,j-1) - old_irq[i][j]
- if diff == 0:
- irq[i][j] = '0'
- else:
- irq[i][j] = str(round(diff/float(runtime), 2))
- log.info('Results for PROX instance %s'%sock_index)
- for row in irq:
- log.info(''.join(['{:>12}'.format(item) for item in row]))
-
-def run_impairtest(gensock,sutsock):
- fieldnames = ['Flows','PacketSize','RequestedPPS','GeneratedPPS','SentPPS','ForwardedPPS','ReceivedPPS','AvgLatencyUSEC','MaxLatencyUSEC','Dropped','DropRate']
- writer = csv.DictWriter(data_csv_file, fieldnames=fieldnames)
- writer.writeheader()
- size=PACKETSIZE-4
- log.info("+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+")
- log.info("| Generator is sending UDP ("+'{:>5}'.format(FLOWSIZE)+" flow) packets ("+ '{:>5}'.format(size+4) +" bytes) to SUT via GW dropping and delaying packets. SUT sends packets back. Use ctrl-c to stop the test |")
- log.info("+--------+--------------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+------------+")
- log.info("| Test | Speed requested | Sent to NIC | Sent by Gen | Forward by SUT | Rec. by Gen | Avg. Latency | Max. Latency | Packets Lost | Loss Ratio |")
- log.info("+--------+--------------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+------------+")
- attempts = 0
- gensock.set_size(gencores,0,size) # This is setting the frame size
- gensock.set_value(gencores,0,16,(size-14),2) # 18 is the difference between the frame size and IP size = size of (MAC addresses, ethertype and FCS)
- gensock.set_value(gencores,0,38,(size-34),2) # 38 is the difference between the frame size and UDP size = 18 + size of IP header (=20)
- # This will only work when using sending UDP packets. For different protocols and ethernet types, we would need a different calculation
- source_port,destination_port = flows[FLOWSIZE]
- gensock.set_random(gencores,0,34,source_port,2)
- gensock.set_random(gencores,0,36,destination_port,2)
- gensock.start(latcores)
- speed = STARTSPEED
- gensock.speed(speed / len(gencores) / len(gentasks), gencores, gentasks)
- while True:
- attempts += 1
- print('Measurement ongoing at speed: ' + str(round(speed,2)) + '% ',end='\r')
- sys.stdout.flush()
- time.sleep(1)
- # Get statistics now that the generation is stable and NO ARP messages any more
- pps_req_tx,pps_tx,pps_sut_tx_str,pps_rx,lat_avg, lat_perc, lat_perc_max, lat_max, abs_dropped, abs_tx_fail, abs_tx, lat_min, lat_used, r, actual_duration = run_iteration(gensock,sutsock,runtime)
- drop_rate = 100.0*abs_dropped/abs_tx
- if lat_used < 0.95:
- lat_warning = bcolors.FAIL + ' Potential latency accuracy problem: {:>3.0f}%'.format(lat_used*100) + bcolors.ENDC
- else:
- lat_warning = ''
- log.info('|{:>7}'.format(str(attempts))+" | " + '{:>5.1f}'.format(speed) + '% ' +'{:>6.3f}'.format(get_pps(speed,size)) + ' Mpps | '+ '{:>9.3f}'.format(pps_req_tx)+' Mpps | '+ '{:>9.3f}'.format(pps_tx) +' Mpps | ' + '{:>9}'.format(pps_sut_tx_str) +' Mpps | '+ '{:>9.3f}'.format(pps_rx)+' Mpps | '+ '{:>9.0f}'.format(lat_avg)+' us | '+ '{:>9.0f}'.format(lat_max)+' us | '+ '{:>14d}'.format(abs_dropped)+ ' |''{:>9.2f}'.format(drop_rate)+ '% |'+lat_warning)
- writer.writerow({'Flows':FLOWSIZE,'PacketSize':(size+4),'RequestedPPS':get_pps(speed,size),'GeneratedPPS':pps_req_tx,'SentPPS':pps_tx,'ForwardedPPS':pps_sut_tx_str,'ReceivedPPS':pps_rx,'AvgLatencyUSEC':lat_avg,'MaxLatencyUSEC':lat_max,'Dropped':abs_dropped,'DropRate':drop_rate})
- if PushGateway:
- URL = PushGateway + '/metrics/job/' + TestName + '/instance/' + env
- DATA = 'Flows {}\nPacketSize {}\nRequestedPPS {}\nGeneratedPPS {}\nSentPPS {}\nForwardedPPS {}\nReceivedPPS {}\nAvgLatencyUSEC {}\nMaxLatencyUSEC {}\nDropped {}\nDropRate {}\n'.format(FLOWSIZE,size+4,get_pps(speed,size),pps_req_tx,pps_tx,pps_sut_tx_str,pps_rx,lat_avg,lat_max,abs_dropped,drop_rate)
- HEADERS = {'X-Requested-With': 'Python requests', 'Content-type': 'text/xml'}
- response = requests.post(url=URL, data=DATA,headers=HEADERS)
- if (response.status_code != 202) and (response.status_code != 200):
- log.info('Cannot send metrics to {}'.format(URL))
- log.info(DATA)
-
-def run_warmuptest(gensock):
-# Running at low speed to make sure the ARP messages can get through.
-# If not doing this, the ARP message could be dropped by a switch in overload and then the test will not give proper results
-# Note hoever that if we would run the test steps during a very long time, the ARP would expire in the switch.
-# PROX will send a new ARP request every seconds so chances are very low that they will all fail to get through
- gensock.speed(WARMUPSPEED / len(gencores) /len (gentasks), gencores, gentasks)
- size=PACKETSIZE-4
- gensock.set_size(gencores,0,size) # This is setting the frame size
- gensock.set_value(gencores,0,16,(size-14),2) # 18 is the difference between the frame size and IP size = size of (MAC addresses, ethertype and FCS)
- gensock.set_value(gencores,0,38,(size-34),2) # 38 is the difference between the frame size and UDP size = 18 + size of IP header (=20)
- gensock.set_value(gencores,0,56,1,1)
- # This will only work when using sending UDP packets. For different protocols and ethernet types, we would need a different calculation
- source_port,destination_port = flows[FLOWSIZE]
- gensock.set_random(gencores,0,34,source_port,2)
- gensock.set_random(gencores,0,36,destination_port,2)
- gensock.start(genstatcores)
- time.sleep(WARMUPTIME)
- gensock.stop(genstatcores)
- gensock.set_value(gencores,0,56,50,1)
- time.sleep(WARMUPTIME)
-
-def exit_handler():
- log.debug ('exit cleanup')
- for index, sock in enumerate(socks):
- if socks_control[index]:
- sock.quit()
- for client in clients:
- client.close()
- data_csv_file.close
- sys.exit(0)
-
-def get_BinarySearchParams() :
- global DROP_RATE_TRESHOLD
- global LAT_AVG_TRESHOLD
- global LAT_PERC_TRESHOLD
- global LAT_MAX_TRESHOLD
- global ACCURACY
- global STARTSPEED
- global TST009
- global TST009_MAXr
- global TST009_MAXz
- DROP_RATE_TRESHOLD = float(testconfig.get('BinarySearchParams', 'drop_rate_threshold'))
- LAT_AVG_TRESHOLD = float(testconfig.get('BinarySearchParams', 'lat_avg_threshold'))
- LAT_PERC_TRESHOLD = float(testconfig.get('BinarySearchParams', 'lat_perc_threshold'))
- LAT_MAX_TRESHOLD = float(testconfig.get('BinarySearchParams', 'lat_max_threshold'))
- ACCURACY = float(testconfig.get('BinarySearchParams', 'accuracy'))
- STARTSPEED = float(testconfig.get('BinarySearchParams', 'startspeed'))
- TST009_MAXr = 1
- TST009_MAXz = inf
- TST009 = False
-
-def get_FixedRateParams() :
- global DROP_RATE_TRESHOLD
- global LAT_AVG_TRESHOLD
- global LAT_PERC_TRESHOLD
- global LAT_MAX_TRESHOLD
- global flow_size_list
- global packet_size_list
- global STARTSPEED
- global TST009
- global TST009_MAXr
- global TST009_MAXz
- DROP_RATE_TRESHOLD = inf
- LAT_AVG_TRESHOLD = inf
- LAT_PERC_TRESHOLD = inf
- LAT_MAX_TRESHOLD = inf
- TST009_MAXr = 1
- TST009_MAXz = inf
- TST009 = False
- packet_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'packetsizes'))
- flow_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'flows'))
- STARTSPEED = float(testconfig.get('test%d'%test_nr, 'speed'))
-
-def get_TST009SearchParams() :
- global DROP_RATE_TRESHOLD
- global LAT_AVG_TRESHOLD
- global LAT_PERC_TRESHOLD
- global LAT_MAX_TRESHOLD
- global TST009
- global TST009_MAXr
- global TST009_MAXz
- global TST009_MAXFramesAllIngress
- global TST009_StepSize
- global TST009_n
- global TST009_L
- global TST009_R
- global TST009_S
- if testconfig.has_option('TST009SearchParams', 'drop_rate_threshold'):
- DROP_RATE_TRESHOLD = float(testconfig.get('TST009SearchParams', 'drop_rate_threshold'))
- else:
- DROP_RATE_TRESHOLD = 0
- LAT_AVG_TRESHOLD = inf
- LAT_PERC_TRESHOLD = inf
- LAT_MAX_TRESHOLD = inf
- TST009_MAXr = float(testconfig.get('TST009SearchParams', 'MAXr'))
- TST009_MAXz = float(testconfig.get('TST009SearchParams', 'MAXz'))
- TST009_MAXFramesAllIngress = int(testconfig.get('TST009SearchParams', 'MAXFramesPerSecondAllIngress'))
- TST009_StepSize = int(testconfig.get('TST009SearchParams', 'StepSize'))
- TST009_n = int(ceil(TST009_MAXFramesAllIngress / TST009_StepSize))
- TST009 = True
- TST009_L = 0
- TST009_R = TST009_n - 1
- for m in range(0, TST009_n):
- TST009_S.append((m+1) * TST009_StepSize)
-# To generate a desired number of flows, PROX will randomize the bits in source and destination ports, as specified by the bit masks in the flows variable.
-flows={\
-1: ['1000000000000000','1000000000000000'],\
-2: ['1000000000000000','100000000000000X'],\
-4: ['100000000000000X','100000000000000X'],\
-8: ['100000000000000X','10000000000000XX'],\
-16: ['10000000000000XX','10000000000000XX'],\
-32: ['10000000000000XX','1000000000000XXX'],\
-64: ['1000000000000XXX','1000000000000XXX'],\
-128: ['1000000000000XXX','100000000000XXXX'],\
-256: ['100000000000XXXX','100000000000XXXX'],\
-512: ['100000000000XXXX','10000000000XXXXX'],\
-1024: ['10000000000XXXXX','10000000000XXXXX'],\
-2048: ['10000000000XXXXX','1000000000XXXXXX'],\
-4096: ['1000000000XXXXXX','1000000000XXXXXX'],\
-8192: ['1000000000XXXXXX','100000000XXXXXXX'],\
-16384: ['100000000XXXXXXX','100000000XXXXXXX'],\
-32768: ['100000000XXXXXXX','10000000XXXXXXXX'],\
-65536: ['10000000XXXXXXXX','10000000XXXXXXXX'],\
-131072: ['10000000XXXXXXXX','1000000XXXXXXXXX'],\
-262144: ['1000000XXXXXXXXX','1000000XXXXXXXXX'],\
-524288: ['1000000XXXXXXXXX','100000XXXXXXXXXX'],\
-1048576:['100000XXXXXXXXXX','100000XXXXXXXXXX'],}
-clients =[]
-socks =[]
-socks_control =[]
-vmDPIP =[]
-vmAdminIP =[]
-vmDPmac =[]
-hexDPIP =[]
-vmDPPCIDEV =[]
-config_file =[]
-prox_socket =[]
-prox_launch_exit =[]
-mach_type =[]
-sock_type =[]
-monitor =[]
-sock_monitor =[]
-cores = []
-ports = []
-tasks = {}
-TST009_S = []
-
-data_file = 'RUN{}.{}.csv'.format(env,test_file)
-data_csv_file = open(data_file,'w')
-testconfig = ConfigParser.RawConfigParser()
-testconfig.read(test_file)
-required_number_of_test_machines = testconfig.get('DEFAULT', 'total_number_of_test_machines')
-TestName = testconfig.get('DEFAULT', 'name')
-if testconfig.has_option('DEFAULT', 'PushGateway'):
- PushGateway = testconfig.get('DEFAULT', 'PushGateway')
- log.info('Measurements will be pushed to %s'%PushGateway)
-else:
- PushGateway = None
-if testconfig.has_option('DEFAULT', 'lat_percentile'):
- LAT_PERCENTILE = float(testconfig.get('DEFAULT', 'lat_percentile')) /100.0
-else:
- LAT_PERCENTILE = 0.99
-log.info('Latency percentile measured at {:.0f}%'.format(LAT_PERCENTILE*100))
-config = ConfigParser.RawConfigParser()
-config.read(env)
-machine_map = ConfigParser.RawConfigParser()
-machine_map.read(machine_map_file)
-vim_type = config.get('Varia', 'vim')
-key = config.get('ssh', 'key')
-user = config.get('ssh', 'user')
-total_number_of_machines = config.get('rapid', 'total_number_of_machines')
-if int(required_number_of_test_machines) > int(total_number_of_machines):
- log.exception("Not enough VMs for this test: %s needed and only %s available" % (required_number_of_test_machines,total_number_of_machines))
- raise Exception("Not enough VMs for this test: %s needed and only %s available" % (required_number_of_test_machines,total_number_of_machines))
-for vm in range(1, int(total_number_of_machines)+1):
- vmAdminIP.append(config.get('M%d'%vm, 'admin_ip'))
- vmDPmac.append(config.get('M%d'%vm, 'dp_mac'))
- vmDPIP.append(config.get('M%d'%vm, 'dp_ip'))
- ip = vmDPIP[-1].split('.')
- hexDPIP.append(hex(int(ip[0]))[2:].zfill(2) + ' ' + hex(int(ip[1]))[2:].zfill(2) + ' ' + hex(int(ip[2]))[2:].zfill(2) + ' ' + hex(int(ip[3]))[2:].zfill(2))
- if (vim_type == "kubernetes"):
- vmDPPCIDEV.append(config.get('M%d'%vm, 'dp_pci_dev'))
-machine_index = []
-atexit.register(exit_handler)
-for vm in range(1, int(required_number_of_test_machines)+1):
- machine_index.append(int(machine_map.get('TestM%d'%vm, 'machine_index'))-1)
- prox_socket.append(testconfig.getboolean('TestM%d'%vm, 'prox_socket'))
-for vm in range(1, int(required_number_of_test_machines)+1):
- if prox_socket[vm-1]:
- prox_launch_exit.append(testconfig.getboolean('TestM%d'%vm, 'prox_launch_exit'))
- config_file.append(testconfig.get('TestM%d'%vm, 'config_file'))
- # Looking for all task definitions in the PROX cfg files. Constructing a list of all tasks used
- textfile = open (config_file[-1], 'r')
- filetext = textfile.read()
- textfile.close()
- tasks_for_this_cfg = set(re.findall("task\s*=\s*(\d+)",filetext))
- with open('{}_{}_parameters{}.lua'.format(env,test_file,vm), "w") as f:
- f.write('name="%s"\n'% testconfig.get('TestM%d'%vm, 'name'))
- f.write('local_ip="%s"\n'% vmDPIP[machine_index[vm-1]])
- f.write('local_hex_ip="%s"\n'% hexDPIP[machine_index[vm-1]])
- if (vim_type == "kubernetes"):
- f.write("eal=\"--socket-mem=512,0 --file-prefix %s-%s-%s --pci-whitelist %s\"\n" % (env, test_file, vm, vmDPPCIDEV[machine_index[vm-1]]))
- else:
- f.write("eal=\"\"\n")
- if testconfig.has_option('TestM%d'%vm, 'cores'):
- cores.append(ast.literal_eval(testconfig.get('TestM%d'%vm, 'cores')))
- f.write('cores="%s"\n'% ','.join(map(str, cores[-1])))
- else:
- cores.append(None)
- if testconfig.has_option('TestM%d'%vm, 'ports'):
- ports.append(ast.literal_eval(testconfig.get('TestM%d'%vm, 'ports')))
- f.write('ports="%s"\n'% ','.join(map(str, ports[-1])))
- else:
- ports.append(None)
- if testconfig.has_option('TestM%d'%vm, 'monitor'):
- monitor.append(testconfig.getboolean('TestM%d'%vm, 'monitor'))
- else:
- monitor.append(True)
- if testconfig.has_option('TestM%d'%vm, 'gencores'):
- # This must be a generator VM
- gencores = ast.literal_eval(testconfig.get('TestM%d'%vm, 'gencores'))
- latcores = ast.literal_eval(testconfig.get('TestM%d'%vm, 'latcores'))
- genstatcores = gencores + latcores
- gentasks = tasks_for_this_cfg
- mach_type.append('gen')
- f.write('gencores="%s"\n'% ','.join(map(str, gencores)))
- f.write('latcores="%s"\n'% ','.join(map(str, latcores)))
- destVMindex = int(testconfig.get('TestM%d'%vm, 'dest_vm'))-1
- f.write('dest_ip="%s"\n'% vmDPIP[machine_index[destVMindex]])
- f.write('dest_hex_ip="%s"\n'% hexDPIP[machine_index[destVMindex]])
- f.write('dest_hex_mac="%s"\n'% vmDPmac[machine_index[destVMindex]].replace(':',' '))
- if testconfig.has_option('TestM%d'%vm, 'gw_vm'):
- gwVMindex = int(testconfig.get('TestM%d'%vm, 'gw_vm')) -1
- f.write('gw_ip="%s"\n'% vmDPIP[machine_index[gwVMindex]])
- f.write('gw_hex_ip="%s"\n'% hexDPIP[machine_index[gwVMindex]])
- if testconfig.has_option('TestM%d'%vm, 'bucket_size_exp'):
- BUCKET_SIZE_EXP = int(testconfig.get('TestM%d'%vm, 'bucket_size_exp'))
- else:
- BUCKET_SIZE_EXP = 11
- f.write('bucket_size_exp="%s"\n'% BUCKET_SIZE_EXP)
- if testconfig.has_option('TestM%d'%vm, 'heartbeat'):
- heartbeat = int(testconfig.get('TestM%d'%vm, 'heartbeat'))
- else:
- heartbeat = 60
- f.write('heartbeat="%s"\n'% heartbeat)
- elif testconfig.has_option('TestM%d'%vm, 'dest_vm'):
- # This must be a machine acting as a GW that we will not monitor
- mach_type.append('none')
- destVMindex = int(testconfig.get('TestM%d'%vm, 'dest_vm'))-1
- f.write('dest_ip="%s"\n'% vmDPIP[machine_index[destVMindex]])
- f.write('dest_hex_ip="%s"\n'% hexDPIP[machine_index[destVMindex]])
- f.write('dest_hex_mac="%s"\n'% vmDPmac[machine_index[destVMindex]].replace(':',' '))
- elif re.findall('mode\s*=\s*(swap|esp_dec)',filetext,re.MULTILINE):
- sutstatcores = cores[-1]
- mach_type.append('sut')
- else:
- mach_type.append('none')
- f.close
- tasks = tasks_for_this_cfg.union(tasks)
-log.debug("Tasks detected in all PROX config files %r"%tasks)
-#####################################################################################
-for vm in range(0, int(required_number_of_test_machines)):
- if prox_socket[vm]:
- clients.append(prox_ctrl(vmAdminIP[machine_index[vm]], key,user))
- connect_client(clients[-1])
- if (vim_type == "OpenStack"):
-# Creating script to bind the right network interface to the poll mode driver
- devbindfile = '{}_{}_devbindvm{}.sh'.format(env,test_file, vm+1)
- with open(devbindfile, "w") as f:
- newText= 'link="$(ip -o link | grep '+vmDPmac[machine_index[vm]]+' |cut -d":" -f 2)"\n'
- f.write(newText)
- newText= 'if [ -n "$link" ];\n'
- f.write(newText)
- newText= 'then\n'
- f.write(newText)
- newText= ' echo Need to bind\n'
- f.write(newText)
- newText= ' sudo ' + rundir + '/dpdk/usertools/dpdk-devbind.py --force --bind igb_uio $('+rundir+'/dpdk/usertools/dpdk-devbind.py --status |grep $link | cut -d" " -f 1)\n'
- f.write(newText)
- newText= 'else\n'
- f.write(newText)
- newText= ' echo Assuming port is already bound to DPDK\n'
- f.write(newText)
- newText= 'fi\n'
- f.write(newText)
- newText= 'exit 0\n'
- f.write(newText)
- st = os.stat(devbindfile)
- os.chmod(devbindfile, st.st_mode | stat.S_IEXEC)
- clients[-1].scp_put('./%s'%devbindfile, rundir+'/devbind.sh')
- cmd = 'sudo ' + rundir+ '/devbind.sh'
- clients[-1].run_cmd(cmd)
- log.debug("devbind.sh running on VM%d"%(vm+1))
-
- clients[-1].scp_put('./%s'%config_file[vm], rundir+'/%s'%config_file[vm])
- clients[-1].scp_put('./{}_{}_parameters{}.lua'.format(env,test_file, vm+1), rundir + '/parameters.lua')
- if not configonly:
- if prox_launch_exit[vm]:
- if mach_type[vm] == 'gen':
- cmd = 'sudo ' + rundir + '/prox -e -t -o cli -f ' + rundir + '/%s'%config_file[vm]
- else:
- cmd = 'sudo ' + rundir + '/prox -t -o cli -f ' + rundir + '/%s'%config_file[vm]
- log.debug("Starting PROX on VM{}: {}".format((vm+1),cmd))
- clients[-1].fork_cmd(cmd, 'PROX Testing on TestM%d'%(vm+1))
- socks_control.append(prox_launch_exit[vm])
- socks.append(connect_socket(clients[-1]))
- sock_type.append(mach_type[vm])
- sock_monitor.append(monitor[vm])
-monitor_gen = monitor_sut = False
-background_gen_socks =[]
-for index, sock in enumerate(socks, start=0):
- if sock_type[index] == 'gen':
- if sock_monitor[index]:
- if monitor_gen:
- log.exception("Can only monitor 1 generator")
- raise Exception("Can only monitor 1 generator")
- else:
- monitor_gen = True
- gensock_index = index
- else:
- background_gen_socks.append(sock)
- elif sock_type[index] == 'sut' and sock_monitor[index]:
- if monitor_sut:
- log.exception("Can only monitor 1 sut")
- raise Exception("Can only monitor 1 sut")
- else:
- monitor_sut = True
- sutsock_index = index
-if configonly:
- sys.exit()
-####################################################
-# Run test cases
-# Best to run the flow test at the end since otherwise the tests coming after might be influenced by the big number of entries in the switch flow tables
-####################################################
-number_of_tests = testconfig.get('DEFAULT', 'number_of_tests')
-for test_nr in range(1, int(number_of_tests)+1):
- test=testconfig.get('test%d'%test_nr,'test')
- log.info(test)
- if test == 'flowsizetest':
- get_BinarySearchParams()
- packet_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'packetsizes'))
- flow_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'flows'))
- run_flow_size_test(socks[gensock_index],socks[sutsock_index])
- elif test == 'TST009test':
- # This test implements some of the testing as defined in https://docbox.etsi.org/ISG/NFV/open/Publications_pdf/Specs-Reports/NFV-TST%20009v3.2.1%20-%20GS%20-%20NFVI_Benchmarks.pdf
- get_TST009SearchParams()
- packet_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'packetsizes'))
- flow_size_list = ast.literal_eval(testconfig.get('test%d'%test_nr, 'flows'))
- run_flow_size_test(socks[gensock_index],socks[sutsock_index])
- elif test == 'fixed_rate':
- get_FixedRateParams()
- run_flow_size_test(socks[gensock_index],socks[sutsock_index])
- elif test == 'corestats':
- run_core_stats(socks)
- elif test == 'portstats':
- run_port_stats(socks)
- elif test == 'impairtest':
- get_BinarySearchParams()
- PACKETSIZE = int(testconfig.get('test%d'%test_nr, 'packetsize'))
- FLOWSIZE = int(testconfig.get('test%d'%test_nr, 'flowsize'))
- run_impairtest(socks[gensock_index],socks[sutsock_index])
- elif test == 'irqtest':
- run_irqtest(socks)
- elif test == 'warmuptest':
- PACKETSIZE = int(testconfig.get('test%d'%test_nr, 'packetsize'))
- FLOWSIZE = int(testconfig.get('test%d'%test_nr, 'flowsize'))
- WARMUPSPEED = int(testconfig.get('test%d'%test_nr, 'warmupspeed'))
- WARMUPTIME = int(testconfig.get('test%d'%test_nr, 'warmuptime'))
- run_warmuptest(socks[gensock_index])
-####################################################
+from rapid_cli import RapidCli
+from rapid_log import RapidLog
+from rapid_parser import RapidConfigParser
+from rapid_defaults import RapidDefaults
+from rapid_machine import RapidMachine
+from rapid_generator_machine import RapidGeneratorMachine
+from rapid_flowsizetest import FlowSizeTest
+from rapid_corestatstest import CoreStatsTest
+from rapid_portstatstest import PortStatsTest
+from rapid_impairtest import ImpairTest
+from rapid_irqtest import IrqTest
+from rapid_warmuptest import WarmupTest
+
+class RapidTestManager(object):
+ """
+ RapidTestManager Class
+ """
+ @staticmethod
+ def get_defaults():
+ return (RapidDefaults.test_params)
+
+ @staticmethod
+ def run_tests(test_params):
+ RapidLog.log_init(test_params)
+ test_params = RapidConfigParser.parse_config(test_params)
+ RapidLog.debug(test_params)
+ monitor_gen = monitor_sut = False
+ background_machines = []
+ sut_machine = gen_machine = None
+ machines = []
+ for machine_params in test_params['machines']:
+ if 'gencores' in machine_params.keys():
+ machine = RapidGeneratorMachine(test_params['key'], test_params['user'], test_params['vim_type'], test_params['rundir'], machine_params)
+ if machine_params['monitor']:
+ if monitor_gen:
+ RapidLog.exception("Can only monitor 1 generator")
+ raise Exception("Can only monitor 1 generator")
+ else:
+ monitor_gen = True
+ gen_machine = machine
+ else:
+ background_machines.append(machine)
+ else:
+ machine = RapidMachine(test_params['key'], test_params['user'], test_params['vim_type'], test_params['rundir'], machine_params)
+ if machine_params['monitor']:
+ if monitor_sut:
+ RapidLog.exception("Can only monitor 1 sut")
+ raise Exception("Can only monitor 1 sut")
+ else:
+ monitor_sut = True
+ sut_machine = machine
+ machines.append(machine)
+ if test_params['configonly']:
+ sys.exit()
+ for machine in machines:
+ machine.start_prox()
+ result = True
+ for test_param in test_params['tests']:
+ RapidLog.info(test_param['test'])
+ if test_param['test'] in ['flowsizetest', 'TST009test', 'fixed_rate']:
+ test = FlowSizeTest(test_param, test_params['lat_percentile'],
+ test_params['runtime'], test_params['pushgateway'],
+ test_params['environment_file'], gen_machine,
+ sut_machine, background_machines)
+ elif test_param['test'] in ['corestats']:
+ test = CoreStatsTest(test_params['runtime'],
+ test_params['pushgateway'],
+ test_params['environment_file'], machines)
+ elif test_param['test'] in ['portstats']:
+ test = PortStatsTest(test_params['runtime'],
+ test_params['pushgateway'],
+ test_params['environment_file'], machines)
+ elif test_param['test'] in ['impairtest']:
+ test = ImpairTest(test_param, test_params['lat_percentile'],
+ test_params['runtime'], test_params['pushgateway'],
+ test_params['environment_file'], gen_machine,
+ sut_machine)
+ elif test_param['test'] in ['irqtest']:
+ test = IrqTest(test_params['runtime'], machines)
+ elif test_param['test'] in ['warmuptest']:
+ test = WarmupTest(test_param, gen_machine)
+ else:
+ RapidLog.debug('Test name ({}) is not valid:'.format(
+ test_param['test']))
+ single_test_result = test.run()
+ if not single_test_result:
+ result = False
+ return (result)
+
+def main():
+ """Main function.
+ """
+ test_params = RapidDefaults.test_params
+ # When no cli is used, the process_cli can be replaced by code modifying
+ # test_params
+ test_params = RapidCli.process_cli(test_params)
+ test_result = RapidTestManager.run_tests(test_params)
+ RapidLog.info('Test result is : {}'.format(test_result))
+
+if __name__ == "__main__":
+ main()
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw.test b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw.test
index f4b4a8d7..2f09aaf6 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw.test
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw.test
@@ -14,12 +14,10 @@
## limitations under the License.
##
-[DEFAULT]
+[TestParameters]
name = GWTesting
number_of_tests = 2
total_number_of_test_machines = 3
-prox_socket = true
-prox_launch_exit = true
[TestM1]
name = Generator
@@ -40,13 +38,6 @@ name = GW2
config_file = secgw2.cfg
cores = [1]
-[BinarySearchParams]
-drop_rate_threshold = 0.1
-lat_avg_threshold = 500
-lat_max_threshold = 1000
-accuracy = 0.1
-startspeed = 10
-
[test1]
test=warmuptest
flowsize=512
@@ -60,3 +51,8 @@ packetsizes=[64]
# the number of flows in the list need to be powers of 2, max 2^20
# Select from following numbers: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
flows=[512]
+drop_rate_threshold = 0.1
+lat_avg_threshold = 500
+lat_max_threshold = 1000
+accuracy = 0.1
+startspeed = 10
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw1.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw1.cfg
index 38f36a59..1897bbdc 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw1.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw1.cfg
@@ -49,7 +49,7 @@ name=esp_enc
task=0
mode=esp_enc
sub mode=l3
-local ipv4=${local_ip}
+local ipv4=${local_ip1}
remote ipv4=${dest_ip}
rx port=if
tx port=if
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw2.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw2.cfg
index daeb18a8..2fe3291a 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/secgw2.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/secgw2.cfg
@@ -49,7 +49,7 @@ name=esp_dec
task=0
mode=esp_dec
sub mode=l3
-local ipv4=${local_ip}
+local ipv4=${local_ip1}
rx port=if
tx port=if
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/swap.cfg b/VNFs/DPPD-PROX/helper-scripts/rapid/swap.cfg
index b72fc001..a3d4d260 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/swap.cfg
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/swap.cfg
@@ -43,6 +43,6 @@ mode=swap
sub mode=l3
rx port=if0
tx port=if0
-local ipv4=${local_ip}
+local ipv4=${local_ip1}
drop=no
;arp update time=1