def test_srv_records(): def check_port_record(task_records, task_name, record_name): record_name_prefix = "_{}.".format(record_name) matching_records = [ r for r in task_records if r["name"].startswith(record_name_prefix) ] assert len(matching_records) == 1, \ "Missing SRV record for {} (prefix={}) in task {}:\nmatching={}\nall={}".format( record_name, record_name_prefix, task_name, matching_records, task_records) log.info("Getting framework srv records for %s", config.SERVICE_NAME) fmk_srvs = sdk_networks.get_framework_srv_records(config.SERVICE_NAME) for task in TASKS_WITH_PORTS: task_records = sdk_networks.get_task_record(task, fmk_srvs) if task == "hello-overlay-0-server": check_port_record(task_records, task, "overlay-dummy") check_port_record(task_records, task, "overlay-dynport") elif task == "hello-host-vip-0-server": check_port_record(task_records, task, "host-vip") elif task == "hello-overlay-vip-0-server": check_port_record(task_records, task, "overlay-vip") elif task == "hello-host-0-server": check_port_record(task_records, task, "host-port") else: assert False, "Unknown task {}".format(task)
def test_srv_records(): fmk_srvs = networks.get_framework_srv_records(PACKAGE_NAME) for task in TASKS_WITH_PORTS: task_records = networks.get_task_record(task, fmk_srvs) if task == "hello-overlay-0-server": assert len([r for r in task_records if "dummy" in r["name"]]) == 1, "Missing SRV record for dummy and "\ "task {}".format(task) assert len([r for r in task_records if "dynport" in r["name"]]) == 1, "Missing SRV record for dynport "\ "task {}".format(task) else: assert len([r for r in task_records if "test" in r["name"]]) == 1, "Missing SRV record for test and task"\ "{}".format(task)
def test_srv_records(): def check_port_record(task_records, task_name, record_name): record_name_prefix = "_{}.".format(record_name) matching_records = [r for r in task_records if r["name"].startswith(record_name_prefix)] assert len(matching_records) == 1, \ "Missing SRV record for {} (prefix={}) in task {}:\nmatching={}\nall={}".format( record_name, record_name_prefix, task_name, matching_records, task_records) fmk_srvs = sdk_networks.get_framework_srv_records(config.SERVICE_NAME) for task in TASKS_WITH_PORTS: task_records = sdk_networks.get_task_record(task, fmk_srvs) if task == "hello-overlay-0-server": check_port_record(task_records, task, "overlay-dummy") check_port_record(task_records, task, "overlay-dynport") elif task == "hello-host-vip-0-server": check_port_record(task_records, task, "host-vip") elif task == "hello-overlay-vip-0-server": check_port_record(task_records, task, "overlay-vip") elif task == "hello-host-0-server": check_port_record(task_records, task, "host-port") else: assert False, "Unknown task {}".format(task)