Exemple #1
0
    def test_interfaces(self):
        interfaces_template = os.path.join(self.test_dir, '..', '..', '..',
                                           'files', 'image_config',
                                           'interfaces', 'interfaces.j2')
        argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(
            utils.cmp(
                os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR,
                             'interfaces'), self.output_file))

        argument = '-m ' + self.t0_mvrf_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(
            utils.cmp(
                os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR,
                             'mvrf_interfaces'), self.output_file))

        argument = '-m ' + self.t0_two_mgmt_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(
            utils.cmp(
                os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR,
                             'two_mgmt_interfaces'), self.output_file),
            self.output_file)
Exemple #2
0
    def test_dhcp_relay(self):
        # Test generation of wait_for_intf.sh
        template_path = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-dhcp-relay', 'wait_for_intf.sh.j2')
        argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + template_path + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'wait_for_intf.sh'), self.output_file))

        # Test generation of docker-dhcp-relay.supervisord.conf
        template_path = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-dhcp-relay', 'docker-dhcp-relay.supervisord.conf.j2')
        argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + template_path + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'docker-dhcp-relay.supervisord.conf'), self.output_file), self.output_file)
 def test_swss_switch_render_template(self):
     switch_template = os.path.join(self.test_dir, '..', '..', '..',
                                    'dockers', 'docker-orchagent',
                                    'switch.json.j2')
     constants_yml = os.path.join(self.test_dir, '..', '..', '..', 'files',
                                  'image_config', 'constants',
                                  'constants.yml')
     test_list = {
         "t1": {
             "graph": self.t1_mlnx_minigraph,
             "port_config": self.mlnx_port_config,
             "output": "t1-switch.json"
         },
         "t0": {
             "graph": self.t0_minigraph,
             "port_config": self.t0_port_config,
             "output": "t0-switch.json"
         },
     }
     for _, v in test_list.items():
         argument = " -m {} -p {} -y {} -t {} > {}".format(
             v["graph"], v["port_config"], constants_yml, switch_template,
             self.output_file)
         sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                           v["output"])
         self.run_script(argument)
         assert utils.cmp(sample_output_file,
                          self.output_file), self.run_diff(
                              sample_output_file, self.output_file)
 def test_ipinip_multi_asic(self):
     ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
     argument = '-m ' + self.multi_asic_minigraph + ' -p ' + self.multi_asic_port_config + ' -t ' + ipinip_file  +  ' -n asic0 '  + ' > ' + self.output_file
     print(argument)
     self.run_script(argument) 
     sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', utils.PYvX_DIR, 'ipinip.json')
     assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
    def _test_buffers_render_template(self, vendor, platform, sku, minigraph, buffer_template, expected):
        file_exist, dir_exist = self.create_machine_conf(platform, vendor)
        dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', vendor, platform, sku)
        buffers_file = os.path.join(dir_path, buffer_template)
        port_config_ini_file = os.path.join(dir_path, 'port_config.ini')

        # copy buffers_config.j2 to the SKU directory to have all templates in one directory
        buffers_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'buffers_config.j2')
        shutil.copy2(buffers_config_file, dir_path)

        minigraph = os.path.join(self.test_dir, minigraph)
        argument = '-m ' + minigraph + ' -p ' + port_config_ini_file + ' -t ' + buffers_file + ' > ' + self.output_file
        self.run_script(argument)

        # cleanup
        buffers_config_file_new = os.path.join(dir_path, 'buffers_config.j2')
        os.remove(buffers_config_file_new)
        self.remove_machine_conf(file_exist, dir_exist)

        out_file_dir = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR)
        expected_files = [expected, self.modify_cable_len(expected, out_file_dir)]
        match = False
        diff = ''
        for out_file in expected_files:
            sample_output_file = os.path.join(out_file_dir, out_file)
            if utils.cmp(sample_output_file, self.output_file):
                match = True
                break
            else:
                diff = diff + str(self.run_diff(sample_output_file, self.output_file))

        os.remove(os.path.join(out_file_dir, expected_files[1]))

        assert match, diff
    def test_config_brcm_render_template(self):
        if utils.PYvX_DIR != 'py3':
            #Skip on python2 as the change will not be backported to previous version
            return

        config_bcm_sample_outputs = [
            'arista7050cx3-dualtor.config.bcm',
            'arista7260-dualtor.config.bcm',
            'arista7260-t1.config.bcm'
        ]
        sample_minigraph_files = [
            'sample-arista-7050cx3-dualtor-minigraph.xml',
            'sample-arista-7260-dualtor-minigraph.xml',
            'sample-arista-7260-t1-minigraph.xml'
        ]
        for i, config in enumerate(config_bcm_sample_outputs):
            device_template_path = os.path.join(self.test_dir, './data/j2_template')
            config_sample_output = config_bcm_sample_outputs[i]
            sample_minigraph_file = os.path.join(self.test_dir,sample_minigraph_files[i])
            port_config_ini_file = os.path.join(device_template_path, 'port_config.ini')
            config_bcm_file = os.path.join(device_template_path, 'config.bcm.j2')
            config_test_output = os.path.join(self.test_dir, 'config_output.bcm')

            argument = '-m ' + sample_minigraph_file + ' -p ' + port_config_ini_file + ' -t ' + config_bcm_file + ' > ' + config_test_output
            self.run_script(argument)

            #check output config.bcm
            config_sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, config_sample_output)
            assert utils.cmp(config_sample_output_file, config_test_output)
            os.remove(config_test_output)
    def test_qos_arista7050_render_template(self):
        arista_dir_path = os.path.join(self.test_dir, '..', '..', '..',
                                       'device', 'arista',
                                       'x86_64-arista_7050_qx32s',
                                       'Arista-7050-QX-32S')
        qos_file = os.path.join(arista_dir_path, 'qos.json.j2')
        port_config_ini_file = os.path.join(arista_dir_path, 'port_config.ini')

        # copy qos_config.j2 to the Arista 7050 directory to have all templates in one directory
        qos_config_file = os.path.join(self.test_dir, '..', '..', '..',
                                       'files', 'build_templates',
                                       'qos_config.j2')
        shutil.copy2(qos_config_file, arista_dir_path)

        argument = '-m ' + self.arista7050_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self.output_file
        self.run_script(argument)

        # cleanup
        qos_config_file_new = os.path.join(arista_dir_path, 'qos_config.j2')
        os.remove(qos_config_file_new)

        sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                          utils.PYvX_DIR,
                                          'qos-arista7050.json')
        assert utils.cmp(sample_output_file, self.output_file)
 def test_swss_switch_render_template_multi_asic(self):
     # verify the ECMP hash seed changes per namespace
     switch_template = os.path.join(self.test_dir, '..', '..', '..',
                                    'dockers', 'docker-orchagent',
                                    'switch.json.j2')
     constants_yml = os.path.join(self.test_dir, '..', '..', '..', 'files',
                                  'image_config', 'constants',
                                  'constants.yml')
     test_list = {
         "0": {
             "namespace_id": "1",
             "output": "t0-switch-masic1.json"
         },
         "1": {
             "namespace_id": "3",
             "output": "t0-switch-masic3.json"
         },
     }
     for _, v in test_list.items():
         os.environ["NAMESPACE_ID"] = v["namespace_id"]
         argument = " -m {} -y {} -t {} > {}".format(
             self.t1_mlnx_minigraph, constants_yml, switch_template,
             self.output_file)
         sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                           v["output"])
         self.run_script(argument)
         assert utils.cmp(sample_output_file, self.output_file)
     os.environ["NAMESPACE_ID"] = ""
    def test_ipinip(self):
        ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
        argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file
        self.run_script(argument)

        sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'ipinip.json')
        assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
    def _test_buffers_render_template(self, vendor, platform, sku, minigraph,
                                      buffer_template, expected):
        dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device',
                                vendor, platform, sku)
        buffers_file = os.path.join(dir_path, buffer_template)
        port_config_ini_file = os.path.join(dir_path, 'port_config.ini')

        # copy buffers_config.j2 to the SKU directory to have all templates in one directory
        buffers_config_file = os.path.join(self.test_dir, '..', '..', '..',
                                           'files', 'build_templates',
                                           'buffers_config.j2')
        shutil.copy2(buffers_config_file, dir_path)

        minigraph = os.path.join(self.test_dir, minigraph)
        argument = '-m ' + minigraph + ' -p ' + port_config_ini_file + ' -t ' + buffers_file + ' > ' + self.output_file
        self.run_script(argument)

        # cleanup
        buffers_config_file_new = os.path.join(dir_path, 'buffers_config.j2')
        os.remove(buffers_config_file_new)

        sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                          utils.PYvX_DIR, expected)
        assert utils.cmp(sample_output_file, self.output_file), self.run_diff(
            sample_output_file, self.output_file)
    def test_ntp_conf(self):
        conf_template = os.path.join(self.test_dir, "ntp.conf.j2")
        ntp_interfaces_json = os.path.join(self.test_dir, "data", "ntp", "ntp_interfaces.json")
        expected = os.path.join(self.test_dir, "sample_output", utils.PYvX_DIR, "ntp.conf")

        argument = '-j {} -t {} > {}'.format(ntp_interfaces_json, conf_template, self.output_file)
        self.run_script(argument)
        assert utils.cmp(expected, self.output_file), self.run_diff(expected, self.output_file)
Exemple #12
0
    def test_qos_dscp_remapping_render_template(self):
        if utils.PYvX_DIR != 'py3':
            # Skip on python2 as the change will not be backported to previous version
            return

        dir_paths = [
            '../../../device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8',
            '../../../device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8',
            '../../../device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64',
            '../../../device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8',
            '../../../device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-D108C8',
            '../../../device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-C64'
        ]
        sample_outputs = [
            'qos-arista7050cx3-dualtor.json', 'qos-arista7260-dualtor.json',
            'qos-arista7260-t1.json',
            'qos-arista7050cx3-dualtor-remap-disabled.json',
            'qos-arista7260-dualtor-remap-disabled.json',
            'qos-arista7260-t1-remap-disabled.json'
        ]
        sample_minigraph_files = [
            'sample-arista-7050cx3-dualtor-minigraph.xml',
            'sample-arista-7260-dualtor-minigraph.xml',
            'sample-arista-7260-t1-minigraph.xml',
            'sample-arista-7050cx3-dualtor-minigraph-remap-disabled.xml',
            'sample-arista-7260-dualtor-minigraph-remap-disabled.xml',
            'sample-arista-7260-t1-minigraph-remap-disabled.xml'
        ]
        for i, path in enumerate(dir_paths):
            device_template_path = os.path.join(self.test_dir, path)
            sample_output = sample_outputs[i]
            sample_minigraph_file = os.path.join(self.test_dir,
                                                 sample_minigraph_files[i])
            qos_file = os.path.join(device_template_path, 'qos.json.j2')
            port_config_ini_file = os.path.join(device_template_path,
                                                'port_config.ini')
            test_output = os.path.join(self.test_dir, 'output.json')

            # copy qos_config.j2 to the target directory to have all templates in one directory
            qos_config_file = os.path.join(self.test_dir, '..', '..', '..',
                                           'files', 'build_templates',
                                           'qos_config.j2')
            shutil.copy2(qos_config_file, device_template_path)

            argument = '-m ' + sample_minigraph_file + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + test_output
            self.run_script(argument)

            # cleanup
            qos_config_file_new = os.path.join(device_template_path,
                                               'qos_config.j2')
            os.remove(qos_config_file_new)

            sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                              utils.PYvX_DIR, sample_output)
            assert utils.cmp(sample_output_file, test_output)
            os.remove(test_output)
 def test_ports_json(self):
     ports_template = os.path.join(self.test_dir, '..', '..', '..',
                                   'dockers', 'docker-orchagent',
                                   'ports.json.j2')
     argument = '-m ' + self.simple_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ports_template + ' > ' + self.output_file
     self.run_script(argument)
     self.assertTrue(
         utils.cmp(
             os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR,
                          'ports.json'), self.output_file))
 def test_radv(self):
     # Test generation of radvd.conf with multiple ipv6 prefixes
     template_path = os.path.join(self.test_dir, '..', '..', '..',
                                  'dockers', 'docker-router-advertiser',
                                  'radvd.conf.j2')
     argument = '-m ' + self.radv_test_minigraph + ' -p ' + self.t0_port_config + ' -t ' + template_path + ' > ' + self.output_file
     self.run_script(argument)
     self.assertTrue(
         utils.cmp(
             os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR,
                          'radvd.conf'), self.output_file))
    def test_lldp(self):
        lldpd_conf_template = os.path.join(self.test_dir, '..', '..', '..',
                                           'dockers', 'docker-lldp',
                                           'lldpd.conf.j2')

        expected_mgmt_ipv4 = os.path.join(self.test_dir, 'sample_output',
                                          utils.PYvX_DIR, 'lldp_conf',
                                          'lldpd-ipv4-iface.conf')
        expected_mgmt_ipv6 = os.path.join(self.test_dir, 'sample_output',
                                          utils.PYvX_DIR, 'lldp_conf',
                                          'lldpd-ipv6-iface.conf')
        expected_mgmt_ipv4_and_ipv6 = expected_mgmt_ipv4

        # Test generation of lldpd.conf if IPv4 and IPv6 management interfaces exist
        mgmt_iface_ipv4_and_ipv6_json = os.path.join(
            self.test_dir, "data", "lldp", "mgmt_iface_ipv4_and_ipv6.json")
        argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv4_and_ipv6_json,
                                             lldpd_conf_template,
                                             self.output_file)
        self.run_script(argument)
        self.assertTrue(
            utils.cmp(expected_mgmt_ipv4_and_ipv6, self.output_file))

        # Test generation of lldpd.conf if management interface IPv4 only exist
        mgmt_iface_ipv4_json = os.path.join(self.test_dir, "data", "lldp",
                                            "mgmt_iface_ipv4.json")
        argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv4_json,
                                             lldpd_conf_template,
                                             self.output_file)
        self.run_script(argument)
        self.assertTrue(utils.cmp(expected_mgmt_ipv4, self.output_file))

        # Test generation of lldpd.conf if Management interface IPv6 only exist
        mgmt_iface_ipv6_json = os.path.join(self.test_dir, "data", "lldp",
                                            "mgmt_iface_ipv6.json")
        argument = '-j {} -t {} > {}'.format(mgmt_iface_ipv6_json,
                                             lldpd_conf_template,
                                             self.output_file)
        self.run_script(argument)
        self.assertTrue(utils.cmp(expected_mgmt_ipv6, self.output_file))
    def test_qos_dell6100_render_template(self):
        dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'dell', 'x86_64-dell_s6100_c2538-r0', 'Force10-S6100')
        qos_file = os.path.join(dell_dir_path, 'qos.json.j2')
        port_config_ini_file = os.path.join(dell_dir_path, 'port_config.ini')

        # copy qos_config.j2 to the Dell S6100 directory to have all templates in one directory
        qos_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'qos_config.j2')
        shutil.copy2(qos_config_file, dell_dir_path)

        argument = '-m ' + self.dell6100_t0_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self.output_file
        self.run_script(argument)

        # cleanup
        qos_config_file_new = os.path.join(dell_dir_path, 'qos_config.j2')
        os.remove(qos_config_file_new)

        sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'qos-dell6100.json')
        assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
    def test_interfaces(self):
        interfaces_template = os.path.join(self.test_dir, '..', '..', '..', 'files', 'image_config', 'interfaces', 'interfaces.j2')

        # ZTP enabled
        argument = '-m ' + self.t0_minigraph_nomgmt + ' -p ' + self.t0_port_config_tiny + ' -j ' + self.ztp + ' -j ' + self.port_data + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + '> ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces_nomgmt_ztp'), self.output_file))

        argument = '-m ' + self.t0_minigraph_nomgmt + ' -p ' + self.t0_port_config_tiny + ' -j ' + self.ztp_inband + ' -j ' + self.port_data + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + '> ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces_nomgmt_ztp_inband'), self.output_file))

        argument = '-m ' + self.t0_minigraph_nomgmt + ' -p ' + self.t0_port_config_tiny + ' -j ' + self.ztp_ip + ' -j ' + self.port_data + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + '> ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces_nomgmt_ztp_ip'), self.output_file))

        argument = '-m ' + self.t0_minigraph_nomgmt + ' -p ' + self.t0_port_config_tiny + ' -j ' + self.ztp_inband_ip + ' -j ' + self.port_data + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + '> ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces_nomgmt_ztp_inband_ip'), self.output_file))

        # ZTP disabled, MGMT_INTERFACE defined
        argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces'), self.output_file))

        argument = '-m ' + self.t0_mvrf_minigraph + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'mvrf_interfaces'), self.output_file))

        # ZTP disabled, no MGMT_INTERFACE defined
        argument = '-m ' + self.t0_minigraph_nomgmt + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'interfaces_nomgmt'), self.output_file))

        argument = '-m ' + self.t0_mvrf_minigraph_nomgmt + ' -p ' + self.t0_port_config + ' -a \'{\"hwaddr\":\"e4:1d:2d:a5:f3:ad\"}\' -t ' + interfaces_template + ' > ' + self.output_file
        self.run_script(argument)
        self.assertTrue(utils.cmp(os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'mvrf_interfaces_nomgmt'), self.output_file))
    def do_test_qos_and_buffer_arista7800r3_48cq2_lc_render_template(self, platform, hwsku):
        arista_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device', 'arista', platform, hwsku)
        qos_file = os.path.join(arista_dir_path, 'qos.json.j2')
        buffer_file = os.path.join(arista_dir_path, 'buffers.json.j2')
        port_config_ini_file = os.path.join(arista_dir_path, 'port_config.ini')

        # copy qos_config.j2 and buffer_config.j2 to the Arista 7800r3_48cq2_lc directory to have all templates in one directory
        qos_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'qos_config.j2')
        shutil.copy2(qos_config_file, arista_dir_path)
        buffer_config_file = os.path.join(self.test_dir, '..', '..', '..', 'files', 'build_templates', 'buffers_config.j2')
        shutil.copy2(buffer_config_file, arista_dir_path)

        for template_file, cfg_file, sample_output_file in [(qos_file, 'qos_config.j2', 'qos-arista7800r3-48cq2-lc.json'),
                                                            (buffer_file, 'buffers_config.j2', 'buffer-arista7800r3-48cq2-lc.json') ]:
            argument = '-m ' + self.arista7800r3_48cq2_lc_t2_minigraph + ' -p ' + port_config_ini_file + ' -t ' + template_file + ' > ' + self.output_file
            self.run_script(argument)

            # cleanup
            cfg_file_new = os.path.join(arista_dir_path, cfg_file)
            os.remove(cfg_file_new)

            sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, sample_output_file)
            assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
    def test_qos_dell9332_render_template(self):
        dell_dir_path = os.path.join(self.test_dir, '..', '..', '..', 'device',
                                     'dell', 'x86_64-dellemc_z9332f_d1508-r0',
                                     'DellEMC-Z9332f-O32')
        qos_file = os.path.join(dell_dir_path, 'qos.json.j2')
        port_config_ini_file = os.path.join(dell_dir_path, 'port_config.ini')

        # copy qos_config.j2 to the Dell Z9332 directory to have all templates in one directory
        qos_config_file = os.path.join(self.test_dir, '..', '..', '..',
                                       'files', 'build_templates',
                                       'qos_config.j2')
        shutil.copy2(qos_config_file, dell_dir_path)

        argument = '-m ' + self.dell9332_t1_minigraph + ' -p ' + port_config_ini_file + ' -t ' + qos_file + ' > ' + self.output_file
        self.run_script(argument)

        # cleanup
        qos_config_file_new = os.path.join(dell_dir_path, 'qos_config.j2')
        os.remove(qos_config_file_new)

        sample_output_file = os.path.join(self.test_dir, 'sample_output',
                                          utils.PYvX_DIR, 'qos-dell9332.json')
        assert utils.cmp(sample_output_file, self.output_file)