aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api/python
diff options
context:
space:
mode:
authorShwetha Bhandari <shwethab@cisco.com>2016-12-17 11:56:29 +0530
committerShwetha Bhandari <shwethab@cisco.com>2016-12-17 13:01:12 +0530
commitc294c4c92e3e58bccc6926a5e9f96d302018238e (patch)
tree5a1a6ba2488c8b86796dc2e25dc662199809c209 /vpp-api/python
parentbd6462e16a55a63561bfaaf75018aa378f201343 (diff)
VPP-563: Fix inter plugin dependency in ioam vxlan-gpe
Change-Id: I31684b3844cd02ba0d0b046d621db59ecac3992d Signed-off-by: Shwetha Bhandari <shwethab@cisco.com>
Diffstat (limited to 'vpp-api/python')
0 files changed, 0 insertions, 0 deletions
ighlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/router/bin/python
from .stl_general_test import CStlGeneral_Test, CTRexScenario
from trex_stl_lib.api import *
import os, sys
from collections import deque
from time import time, sleep

class STLBenchmark_Test(CStlGeneral_Test):
    """Benchark stateless performance"""

    def test_CPU_benchmark(self):
        critical_test = CTRexScenario.setup_name in ('kiwi02', 'trex08', 'trex09') # temporary patch, this test needs to be fixed
        timeout       = 60 # max time to wait for stabilization
        stabilize     = 5  # ensure stabilization over this period
        print('')

        for profile_bench in self.get_benchmark_param('profiles'):
            cpu_utils    = deque([0] * stabilize, maxlen = stabilize)
            bws_per_core = deque([0] * stabilize, maxlen = stabilize)
            kwargs = profile_bench.get('kwargs', {})
            print('Testing profile %s, kwargs: %s' % (profile_bench['name'], kwargs))
            profile = STLProfile.load(os.path.join(CTRexScenario.scripts_path, profile_bench['name']), **kwargs)

            self.stl_trex.reset()
            self.stl_trex.clear_stats()
            sleep(1)
            self.stl_trex.add_streams(profile)
            mult = '1%' if self.is_virt_nics else '10%'
            self.stl_trex.start(mult = mult)
            start_time = time()

            for i in range(timeout + 1):
                stats = self.stl_trex.get_stats()
                cpu_utils.append(stats['global']['cpu_util'])
                bws_per_core.append(stats['global']['bw_per_core'])
                if i > stabilize and min(cpu_utils) > max(cpu_utils) * 0.95:
                    break
                sleep(0.5)

            agv_cpu_util    = sum(cpu_utils) / stabilize
            agv_bw_per_core = sum(bws_per_core) / stabilize

            if critical_test and i == timeout and agv_cpu_util > 10:
                raise Exception('Timeout on waiting for stabilization, last CPU util values: %s' % list(cpu_utils))
            if stats[0]['opackets'] < 300 or stats[1]['opackets'] < 300:
                raise Exception('Too few opackets, port0: %s, port1: %s' % (stats[0]['opackets'], stats[1]['opackets']))
            if stats['global']['queue_full'] > 100000:
                raise Exception('Too much queue_full: %s' % stats['global']['queue_full'])
            if not cpu_utils[-1]:
                raise Exception('CPU util is zero, last values: %s' % list(cpu_utils))
            print('Done (%ss), CPU util: %4g, bw_per_core: %6sGb/core' % (int(time() - start_time), agv_cpu_util, round(agv_bw_per_core, 2)))
            # TODO: add check of benchmark based on results from regression

            # report benchmarks
            if self.GAManager:
                try:
                    profile_repr = '%s.%s %s' % (CTRexScenario.setup_name,
                                                os.path.basename(profile_bench['name']),
                                                repr(kwargs).replace("'", ''))
                    self.GAManager.gaAddAction(Event = 'stateless_test', action = profile_repr,
                                            label = 'bw_per_core', value = int(agv_bw_per_core))
                    # TODO: report expected once acquired
                    #self.GAManager.gaAddAction(Event = 'stateless_test', action = profile_repr,
                    #                           label = 'bw_per_core_exp', value = int(expected_norm_cpu))
                    self.GAManager.emptyAndReportQ()
                except Exception as e:
                    print('Sending GA failed: %s' % e)

    def tearDown(self):
        self.stl_trex.reset()
        self.stl_trex.clear_stats()
        sleep(1)
        CStlGeneral_Test.tearDown(self)