def test_restd_bgp_neighbors_post_bgp_neighbors(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing POST for BGP_Neighbors #") step("\n#####################################################\n") step('\nPOST BGP router with the asn: {}'.format( str(_DATA['configuration']['asn']))) status_code, response_data = execute_request( path_bgp, "POST", json.dumps(_DATA), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.CREATED step('\nPOST BGP neighbors with the ip: {}'.format( str(_DATA_BGP_NEIGHBORS['configuration']['ip_or_group_name']))) status_code, response_data = execute_request( path_bgp_neighbors, "POST", json.dumps(_DATA_BGP_NEIGHBORS), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.CREATED status_code, response_data = execute_request( path_bgp_neighbors_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK d = get_json(response_data) d = d['configuration'] d = sorted(d.items(), key=itemgetter(0)) aux = _DATA_BGP_NEIGHBORS_COPY['configuration'] aux = sorted(aux.items(), key=itemgetter(0)) assert d == aux
def test_restd_bgp_neighbors_put_bgp_neighbors(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing PUT for BGP_Neighbors #") step("\n#####################################################\n") aux = copy.deepcopy(_DATA_BGP_NEIGHBORS_COPY) aux['configuration']['description'] = 'BGP_Neighbors' status_code, response_data = execute_request( path_bgp_neighbors_id, "PUT", json.dumps(aux), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK status_code, response_data = execute_request( path_bgp_neighbors_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK d = get_json(response_data) d['configuration'].pop('capability', None) d = d['configuration'] d = sorted(d.items(), key=itemgetter(0)) aux = aux['configuration'] aux = sorted(aux.items(), key=itemgetter(0)) assert d == aux
def test_restd_ct_bgp_routers_put_bgp_routers(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing PUT for BGP_Routers #") step("\n#####################################################\n") aux = copy.deepcopy(_DATA_COPY) aux['configuration']['networks'] = ["10.10.1.0/24"] status_code, response_data = execute_request(path_id, "PUT", json.dumps(aux), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK status_code, response_data = execute_request(path_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) status_code == http.client.OK content = response_data d = get_json(content) d = d['configuration'] d = sorted(d.items(), key=itemgetter(0)) aux = aux['configuration'] aux = sorted(aux.items(), key=itemgetter(0)) assert d == aux
def test_restd_ct_bgp_routers_post_bgp_routers(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing POST for BGP_Routers #") step("\n#####################################################\n") status_code, response_data = execute_request(path_bgp, "POST", json.dumps(_DATA), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.CREATED status_code, response_data = execute_request(path_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK d = get_json(response_data) d = d['configuration'] d = sorted(d.items(), key=itemgetter(0)) aux = _DATA_COPY['configuration'] aux = sorted(aux.items(), key=itemgetter(0)) assert d == aux
def post_setup(): status_code, response_data = execute_request( path_bgp, "POST", json.dumps(_DATA), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.CREATED status_code, response_data = execute_request( path_bgp_neighbors, "POST", json.dumps(_DATA_BGP_NEIGHBORS), SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.CREATED
def delete_teardown(): status_code, response_data = execute_request( path_bgp_neighbors_id, "DELETE", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.NO_CONTENT or \ status_code == http.client.NOT_FOUND status_code, response_data = execute_request( path_id, "DELETE", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.NO_CONTENT or \ status_code == http.client.NOT_FOUND
def test_restd_bgp_neighbors_delete_bgp_neighbors(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing DELETE for BGP_Neighbors #") step("\n#####################################################\n") status_code, response_data = execute_request( path_bgp_neighbors_id, "DELETE", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.NO_CONTENT status_code, response_data = execute_request( path_bgp_neighbors_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.NOT_FOUND
def test_restd_ct_start_stop_restd( setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Stop/start Restd #") step("\n#####################################################\n") sw1("kill $(/bin/cat /var/run/openvswitch/restd.pid)", shell="bash") is_active = sw1("systemctl is-active restd", shell="bash") assert "inactive" != is_active sleep(2) is_active = sw1("systemctl is-active restd", shell="bash") assert "inactive" != is_active sleep(1) for i in range(1,15): step("\nExecuting GET request\n") status_code, response_data = execute_request( path_system, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) sleep(1) step("Try " + str(i) + "/15 to execute GET request") if status_code == http.client.OK: break assert status_code == http.client.OK
def test_restd_ct_bgp_routers_get_bgp_routers(setup, sanity_check, topology, step): step("\n#####################################################\n") step("# Testing GET for BGP_Routers #") step("\n#####################################################\n") step('GET for BGP router with asn: {}'.format( str(_DATA['configuration']['asn']))) status_code, response_data = execute_request(path_id, "GET", None, SWITCH_IP, False, xtra_header=cookie_header) assert status_code == http.client.OK d = get_json(response_data) d = d['configuration'] d = sorted(d.items(), key=itemgetter(0)) aux = _DATA_COPY['configuration'] aux = sorted(aux.items(), key=itemgetter(0)) assert d == aux