def test_collect_testbed_prio(duthosts, tbinfo): all_prio = {} lossless_prio = {} lossy_prio = {} tbname = tbinfo['conf-name'] pytest_require(tbname, "skip test due to lack of testbed name.") for dut in duthosts: all_prio[dut.hostname] = collect_dut_all_prio(dut) lossless_prio[dut.hostname] = collect_dut_lossless_prio(dut) lossy_prio[dut.hostname] = collect_dut_lossy_prio(dut) prio_info = [all_prio, lossless_prio, lossy_prio] file_names = [ tbname + '-' + x + '.json' for x in ['all', 'lossless', 'lossy'] ] folder = 'priority' for i in range(len(file_names)): filepath = os.path.join(folder, file_names[i]) try: if not os.path.exists(folder): os.mkdir(folder) with open(filepath, 'w') as yf: json.dump({tbname: prio_info[i]}, yf, indent=4) except IOError as e: logger.warning('Unable to create file {}: {}'.format(filepath, e))
def test_update_testbed_metadata(duthosts, tbinfo): metadata = {} tbname = tbinfo['conf-name'] pytest_require(tbname, "skip test due to lack of testbed name.") for dut in duthosts: dutinfo = collect_dut_info(dut) metadata[dut.hostname] = dutinfo info = {tbname: metadata} folder = 'metadata' filepath = os.path.join(folder, tbname + '.json') try: if not os.path.exists(folder): os.mkdir(folder) with open(filepath, 'w') as yf: json.dump(info, yf, indent=4) except IOError as e: logger.warning('Unable to create file {}: {}'.format(filepath, e))