12258ea30SYaroslav Brustinov#!/router/bin/python
2d3c7c398SYaroslav Brustinovfrom .trex_general_test import CTRexGeneral_Test, CTRexScenario
3501fb3b4SYaroslav Brustinovfrom .tests_exceptions import *
42258ea30SYaroslav Brustinovimport time
52258ea30SYaroslav Brustinovfrom nose.tools import assert_equal
62258ea30SYaroslav Brustinov
72258ea30SYaroslav Brustinovclass CTRexIPv6_Test(CTRexGeneral_Test):
8d279c8c1SYaroslav Brustinov    """This class defines the IPv6 testcase of the TRex traffic generator"""
92258ea30SYaroslav Brustinov    def __init__(self, *args, **kwargs):
10501fb3b4SYaroslav Brustinov        super(CTRexIPv6_Test, self).__init__(*args, **kwargs)
112258ea30SYaroslav Brustinov
122258ea30SYaroslav Brustinov    def setUp(self):
132258ea30SYaroslav Brustinov        super(CTRexIPv6_Test, self).setUp() # launch super test class setUp process
142258ea30SYaroslav Brustinov#       print " before sleep setup !!"
152258ea30SYaroslav Brustinov#       time.sleep(100000);
162258ea30SYaroslav Brustinov#       pass
172258ea30SYaroslav Brustinov
182258ea30SYaroslav Brustinov    def test_ipv6_simple(self):
192258ea30SYaroslav Brustinov        if self.is_virt_nics:
202258ea30SYaroslav Brustinov            self.skip('--ipv6 flag does not work correctly in with virtual NICs') # TODO: fix
212258ea30SYaroslav Brustinov        # test initializtion
22d3c7c398SYaroslav Brustinov        if not self.is_loopback and not CTRexScenario.router_cfg['no_dut_config']:
232258ea30SYaroslav Brustinov            self.router.configure_basic_interfaces()
242258ea30SYaroslav Brustinov
252258ea30SYaroslav Brustinov            self.router.config_pbr(mode = "config")
262258ea30SYaroslav Brustinov            self.router.config_ipv6_pbr(mode = "config")
272258ea30SYaroslav Brustinov
282258ea30SYaroslav Brustinov        mult = self.get_benchmark_param('multiplier')
292258ea30SYaroslav Brustinov        core = self.get_benchmark_param('cores')
302258ea30SYaroslav Brustinov
312258ea30SYaroslav Brustinov        ret = self.trex.start_trex(
3268c71be2SIdo Barnea            cfg = '/etc/trex_cfg_mac.yaml',
332258ea30SYaroslav Brustinov            c = core,
342258ea30SYaroslav Brustinov            m = mult,
352258ea30SYaroslav Brustinov            p  = True,
362258ea30SYaroslav Brustinov            nc = True,
372258ea30SYaroslav Brustinov            ipv6 = True,
382258ea30SYaroslav Brustinov            d = 60,
392258ea30SYaroslav Brustinov            f = 'avl/sfr_delay_10_1g.yaml',
402258ea30SYaroslav Brustinov            l = 1000)
412258ea30SYaroslav Brustinov
422258ea30SYaroslav Brustinov        trex_res = self.trex.sample_to_run_finish()
432258ea30SYaroslav Brustinov
442258ea30SYaroslav Brustinov        # trex_res is a CTRexResult instance- and contains the summary of the test results
452258ea30SYaroslav Brustinov        # you may see all the results keys by simply calling here for 'print trex_res.result'
46501fb3b4SYaroslav Brustinov        print("\nLATEST RESULT OBJECT:")
47501fb3b4SYaroslav Brustinov        print(trex_res)
482258ea30SYaroslav Brustinov
492258ea30SYaroslav Brustinov        self.check_general_scenario_results(trex_res)
502258ea30SYaroslav Brustinov
512258ea30SYaroslav Brustinov        self.check_CPU_benchmark (trex_res, 10.0)
522258ea30SYaroslav Brustinov
532258ea30SYaroslav Brustinov        assert True
542258ea30SYaroslav Brustinov
552258ea30SYaroslav Brustinov
562258ea30SYaroslav Brustinov    def test_ipv6_negative (self):
572258ea30SYaroslav Brustinov        if self.is_loopback:
582258ea30SYaroslav Brustinov            self.skip('The test checks ipv6 drops by device and we are in loopback setup')
592258ea30SYaroslav Brustinov        # test initializtion
60d3c7c398SYaroslav Brustinov        if not CTRexScenario.router_cfg['no_dut_config']:
61d3c7c398SYaroslav Brustinov            self.router.configure_basic_interfaces()
62d3c7c398SYaroslav Brustinov            # NOT CONFIGURING IPv6 INTENTIONALLY TO GET DROPS!
63d3c7c398SYaroslav Brustinov            self.router.config_pbr(mode = "config")
642258ea30SYaroslav Brustinov
652258ea30SYaroslav Brustinov        # same params as test_ipv6_simple
662258ea30SYaroslav Brustinov        mult = self.get_benchmark_param('multiplier', test_name = 'test_ipv6_simple')
672258ea30SYaroslav Brustinov        core = self.get_benchmark_param('cores', test_name = 'test_ipv6_simple')
682258ea30SYaroslav Brustinov
692258ea30SYaroslav Brustinov        ret = self.trex.start_trex(
7068c71be2SIdo Barnea            cfg = '/etc/trex_cfg_mac.yaml',
712258ea30SYaroslav Brustinov            c = core,
722258ea30SYaroslav Brustinov            m = mult,
732258ea30SYaroslav Brustinov            p  = True,
742258ea30SYaroslav Brustinov            nc = True,
752258ea30SYaroslav Brustinov            ipv6 = True,
762258ea30SYaroslav Brustinov            d = 60,
772258ea30SYaroslav Brustinov            f = 'avl/sfr_delay_10_1g.yaml',
782258ea30SYaroslav Brustinov            l = 1000)
792258ea30SYaroslav Brustinov
802258ea30SYaroslav Brustinov        trex_res = self.trex.sample_to_run_finish()
812258ea30SYaroslav Brustinov
822258ea30SYaroslav Brustinov        # trex_res is a CTRexResult instance- and contains the summary of the test results
832258ea30SYaroslav Brustinov        # you may see all the results keys by simply calling here for 'print trex_res.result'
84501fb3b4SYaroslav Brustinov        print("\nLATEST RESULT OBJECT:")
85501fb3b4SYaroslav Brustinov        print(trex_res)
862258ea30SYaroslav Brustinov
872258ea30SYaroslav Brustinov        trex_tx_pckt    = float(trex_res.get_last_value("trex-global.data.m_total_tx_pkts"))
882258ea30SYaroslav Brustinov        trex_drops      = int(trex_res.get_total_drops())
892258ea30SYaroslav Brustinov
902258ea30SYaroslav Brustinov        trex_drop_rate  = trex_res.get_drop_rate()
912258ea30SYaroslav Brustinov
922258ea30SYaroslav Brustinov        # make sure that at least 50% of the total transmitted packets failed
932258ea30SYaroslav Brustinov        self.assert_gt((trex_drops/trex_tx_pckt), 0.5, 'packet drop ratio is not high enough')
942258ea30SYaroslav Brustinov
952258ea30SYaroslav Brustinov
962258ea30SYaroslav Brustinov
972258ea30SYaroslav Brustinov    def tearDown(self):
982258ea30SYaroslav Brustinov        CTRexGeneral_Test.tearDown(self)
99501fb3b4SYaroslav Brustinov        # remove config here
1002258ea30SYaroslav Brustinov        pass
1012258ea30SYaroslav Brustinov
1022258ea30SYaroslav Brustinovif __name__ == "__main__":
1032258ea30SYaroslav Brustinov    pass
104