aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/ioam/lib-trace/trace_test.c
diff options
context:
space:
mode:
authorPing Yu <ping.yu@intel.com>2018-12-26 05:42:38 -0500
committerFlorin Coras <florin.coras@gmail.com>2019-01-03 00:16:46 +0000
commitd8e94ba8231138e86f31c745c82a0adf54531164 (patch)
tree8a914306c8644b012ac6510a166341fe01e64b0b /src/plugins/ioam/lib-trace/trace_test.c
parent4a7cbcd06b3fa1f44366a606d5c148cce816503b (diff)
Fix an issue in tls.c
Curernt code will overwrite parent_app_api_context, and defer the setting after this value is used in callback. Change-Id: Ie16e432fd0f4214e6deff3aa3b58b3be824b0331 Signed-off-by: Ping Yu <ping.yu@intel.com>
Diffstat (limited to 'src/plugins/ioam/lib-trace/trace_test.c')
0 files changed, 0 insertions, 0 deletions
} /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .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 .trex_general_test import CTRexGeneral_Test
from .tests_exceptions import *
import time
from CPlatform import CStaticRouteConfig, CNatConfig
from nose.tools import assert_equal


class CTRexNoNat_Test(CTRexGeneral_Test):#(unittest.TestCase):
    """This class defines the NAT testcase of the TRex traffic generator"""
    def __init__(self, *args, **kwargs):
        super(CTRexNoNat_Test, self).__init__(*args, **kwargs)
        self.unsupported_modes = ['loopback'] # NAT requires device

    def setUp(self):
        super(CTRexNoNat_Test, self).setUp() # launch super test class setUp process

    def check_nat_stats (self, nat_stats):
        pass


    def test_nat_learning(self):
        # test initializtion
        self.router.configure_basic_interfaces()

        stat_route_dict = self.get_benchmark_param('stat_route_dict')
        stat_route_obj = CStaticRouteConfig(stat_route_dict)
        self.router.config_static_routing(stat_route_obj, mode = "config")

        self.router.config_nat_verify()         # shutdown duplicate interfaces

#       self.trex.set_yaml_file('cap2/http_simple.yaml')
        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

#       trex_res = self.trex.run(multiplier = mult, cores = core, duration = 100, l = 1000, learn_verify = True)
        ret = self.trex.start_trex(
            c = core,
            m = mult,
            learn_verify = True,
            d = 100,   
            f = 'cap2/http_simple.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        print("\nLATEST RESULT OBJECT:")
        print(trex_res)
        print("\nLATEST DUMP:")
        print(trex_res.get_latest_dump())


        expected_nat_opened = self.get_benchmark_param('nat_opened')
        learning_stats = trex_res.get_last_value("trex-global.data", ".*nat.*") # extract all nat data

        if self.get_benchmark_param('allow_timeout_dev'):
            nat_timeout_ratio = float(learning_stats['m_total_nat_time_out']) / learning_stats['m_total_nat_open']
            if nat_timeout_ratio > 0.005:
                self.fail('TRex nat_timeout ratio %f > 0.5%%' % nat_timeout_ratio)
        else:
            self.check_results_eq (learning_stats, 'm_total_nat_time_out', 0.0)
        self.check_results_eq (learning_stats, 'm_total_nat_no_fid', 0.0)
        self.check_results_gt (learning_stats, 'm_total_nat_learn_error', 0.0)
#
        self.check_results_gt (learning_stats, 'm_total_nat_open', expected_nat_opened)

        self.check_general_scenario_results(trex_res)
        self.check_CPU_benchmark(trex_res, minimal_cpu = 10, maximal_cpu = 85)

    def tearDown(self):
        CTRexGeneral_Test.tearDown(self)
        pass


class CTRexNat_Test(CTRexGeneral_Test):#(unittest.TestCase):
    """This class defines the NAT testcase of the TRex traffic generator"""
    def __init__(self, *args, **kwargs):
        super(CTRexNat_Test, self).__init__(*args, **kwargs)
        self.unsupported_modes = ['loopback'] # NAT requires device

    def setUp(self):
        super(CTRexNat_Test, self).setUp() # launch super test class setUp process
        # config nat here
        

    def check_nat_stats (self, nat_stats):
        pass


    def test_nat_simple_mode1(self):
        self.nat_simple_helper(learn_mode=1)

    def test_nat_simple_mode2(self):
        self.nat_simple_helper(learn_mode=2)

    def test_nat_simple_mode3(self):
        self.nat_simple_helper(learn_mode=3)

    def nat_simple_helper(self, learn_mode=1):
        # test initializtion
        self.router.configure_basic_interfaces()

        
        stat_route_dict = self.get_benchmark_param('stat_route_dict')
        stat_route_obj = CStaticRouteConfig(stat_route_dict)
        self.router.config_static_routing(stat_route_obj, mode = "config")

        nat_dict = self.get_benchmark_param('nat_dict')
        nat_obj  = CNatConfig(nat_dict)
        self.router.config_nat(nat_obj)

#       self.trex.set_yaml_file('cap2/http_simple.yaml')
        mult = self.get_benchmark_param('multiplier')
        core = self.get_benchmark_param('cores')

#       trex_res = self.trex.run(nc=False,multiplier = mult, cores = core, duration = 100, l = 1000, learn = True)
        ret = self.trex.start_trex(
            c = core,
            m = mult,
            learn_mode = learn_mode,
            d = 100,
            f = 'cap2/http_simple.yaml',
            l = 1000)

        trex_res = self.trex.sample_to_run_finish()

        print("\nLATEST RESULT OBJECT:")
        print(trex_res)
        print("\nLATEST DUMP:")
        print(trex_res.get_latest_dump())

        trex_nat_stats = trex_res.get_last_value("trex-global.data", ".*nat.*") # extract all nat data
        if self.get_benchmark_param('allow_timeout_dev'):
            nat_timeout_ratio = float(trex_nat_stats['m_total_nat_time_out']) / trex_nat_stats['m_total_nat_open']
            if nat_timeout_ratio > 0.005:
                self.fail('TRex nat_timeout ratio %f > 0.5%%' % nat_timeout_ratio)
        else:
            self.check_results_eq (trex_nat_stats,'m_total_nat_time_out', 0.0)
        self.check_results_eq (trex_nat_stats,'m_total_nat_no_fid', 0.0)
        self.check_results_gt (trex_nat_stats,'m_total_nat_open', 6000)


        self.check_general_scenario_results(trex_res, check_latency = False) # NAT can cause latency
##       test_norm_cpu = 2*(trex_res.result['total-tx']/(core*trex_res.result['cpu_utilization']))
#        trex_tx_pckt  = trex_res.get_last_value("trex-global.data.m_total_tx_bps")
#        cpu_util = int(trex_res.get_last_value("trex-global.data.m_cpu_util"))
#        test_norm_cpu = 2*(trex_tx_pckt/(core*cpu_util))
#        print "test_norm_cpu is: ", test_norm_cpu

        self.check_CPU_benchmark(trex_res, minimal_cpu = 10, maximal_cpu = 85)

        #if ( abs((test_norm_cpu/self.get_benchmark_param('cpu_to_core_ratio')) - 1) > 0.03):
        #    raiseraise AbnormalResultError('Normalized bandwidth to CPU utilization ratio exceeds 3%')

        nat_stats = self.router.get_nat_stats()
        print(nat_stats)

        self.assert_gt(nat_stats['total_active_trans'], 5000, 'total active translations is not high enough')
        self.assert_gt(nat_stats['dynamic_active_trans'], 5000, 'total dynamic active translations is not high enough')
        self.assertEqual(nat_stats['static_active_trans'], 0, "NAT statistics nat_stats['static_active_trans'] should be zero")
        self.assert_gt(nat_stats['num_of_hits'], 50000, 'total nat hits is not high enough')

    def tearDown(self):
        self.router.clear_nat_translations()
        CTRexGeneral_Test.tearDown(self)


if __name__ == "__main__":
    pass