From f5116d78c398c0ee98b5af43a51679f4c445c639 Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Sun, 4 Dec 2016 09:33:12 -0500 Subject: [PATCH] ST GoBGP backend Signed-off-by: Wataru Ishida --- tests/st/bgp/test_global_config.py | 14 +++- tests/st/bgp/test_global_peers.py | 84 ++++++++++++-------- tests/st/bgp/test_node_peers.py | 15 +++- tests/st/bgp/test_route_reflector_cluster.py | 25 ++++-- tests/st/bgp/test_single_route_reflector.py | 20 ++++- 5 files changed, 108 insertions(+), 50 deletions(-) diff --git a/tests/st/bgp/test_global_config.py b/tests/st/bgp/test_global_config.py index b98a5508c..4d999fb2e 100644 --- a/tests/st/bgp/test_global_config.py +++ b/tests/st/bgp/test_global_config.py @@ -44,7 +44,7 @@ def test_defaults(self): self.assertEquals(host.calicoctl("config get nodeToNodeMesh"), "on") @attr('slow') - def test_as_num(self): + def _test_as_num(self, backend='bird'): """ Test using different AS number for the node-to-node mesh. @@ -62,8 +62,8 @@ def test_as_num(self): # Start host1 using the inherited AS, and host2 using a specified # AS (same as default). - host1.start_calico_node() - host2.start_calico_node("--as=%s" % LARGE_AS_NUM) + host1.start_calico_node("--backend=%s" % backend) + host2.start_calico_node("--backend=%s --as=%s" % (backend, LARGE_AS_NUM)) # Create a network and a couple of workloads on each host. network1 = host1.create_network("subnet1", subnet=DEFAULT_IPV4_POOL_CIDR) @@ -82,3 +82,11 @@ def test_as_num(self): # Check the BGP status on each host. check_bird_status(host1, [("node-to-node mesh", host2.ip, "Established")]) check_bird_status(host2, [("node-to-node mesh", host1.ip, "Established")]) + + @attr('slow') + def test_bird_as_num(self): + self._test_as_num(backend='bird') + + @attr('slow') + def test_gobgp_as_num(self): + self._test_as_num(backend='gobgp') diff --git a/tests/st/bgp/test_global_peers.py b/tests/st/bgp/test_global_peers.py index 4567adde1..2231cc538 100644 --- a/tests/st/bgp/test_global_peers.py +++ b/tests/st/bgp/test_global_peers.py @@ -25,53 +25,67 @@ class TestGlobalPeers(TestBase): - @attr('slow') - def test_global_peers(self): + def _test_global_peers(self, backend='bird'): """ Test global BGP peer configuration. Test by turning off the mesh and configuring the mesh as a set of global peers. """ - with DockerHost('host1', +# with DockerHost('host1', +# additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, +# start_calico=False) as host1, \ +# DockerHost('host2', +# additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, +# start_calico=False) as host2: + host1 = DockerHost('host1', additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, - start_calico=False) as host1, \ - DockerHost('host2', + start_calico=False) + host2 = DockerHost('host2', additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, - start_calico=False) as host2: - # Start both hosts using specific AS numbers. - host1.start_calico_node("--as=%s" % LARGE_AS_NUM) - host2.start_calico_node("--as=%s" % LARGE_AS_NUM) + start_calico=False) + + # Start both hosts using specific AS numbers. + host1.start_calico_node("--backend=%s --as=%s" % (backend, LARGE_AS_NUM)) + host2.start_calico_node("--backend=%s --as=%s" % (backend, LARGE_AS_NUM)) + + # Create a network and a couple of workloads on each host. + network1 = host1.create_network("subnet1", subnet=DEFAULT_IPV4_POOL_CIDR) + workload_host1 = host1.create_workload("workload1", network=network1, ip=DEFAULT_IPV4_ADDR_1) + workload_host2 = host2.create_workload("workload2", network=network1, ip=DEFAULT_IPV4_ADDR_2) - # Create a network and a couple of workloads on each host. - network1 = host1.create_network("subnet1", subnet=DEFAULT_IPV4_POOL_CIDR) - workload_host1 = host1.create_workload("workload1", network=network1, ip=DEFAULT_IPV4_ADDR_1) - workload_host2 = host2.create_workload("workload2", network=network1, ip=DEFAULT_IPV4_ADDR_2) + # Allow network to converge + self.assert_true(workload_host1.check_can_ping(DEFAULT_IPV4_ADDR_2, retries=10)) - # Allow network to converge - self.assert_true(workload_host1.check_can_ping(DEFAULT_IPV4_ADDR_2, retries=10)) + # Turn the node-to-node mesh off and wait for connectivity to drop. + host1.calicoctl("config set nodeToNodeMesh off") + self.assert_true(workload_host1.check_cant_ping(DEFAULT_IPV4_ADDR_2, retries=10)) - # Turn the node-to-node mesh off and wait for connectivity to drop. - host1.calicoctl("config set nodeToNodeMesh off") - self.assert_true(workload_host1.check_cant_ping(DEFAULT_IPV4_ADDR_2, retries=10)) + # Configure global peers to explicitly set up a mesh. This means + # each node will try to peer with itself which will fail. + create_bgp_peer(host1, 'global', host2.ip, LARGE_AS_NUM) + create_bgp_peer(host2, 'global', host1.ip, LARGE_AS_NUM) - # Configure global peers to explicitly set up a mesh. This means - # each node will try to peer with itself which will fail. - create_bgp_peer(host1, 'global', host2.ip, LARGE_AS_NUM) - create_bgp_peer(host2, 'global', host1.ip, LARGE_AS_NUM) + # Allow network to converge + self.assert_true(workload_host1.check_can_ping(DEFAULT_IPV4_ADDR_2, retries=10)) - # Allow network to converge - self.assert_true(workload_host1.check_can_ping(DEFAULT_IPV4_ADDR_2, retries=10)) + # Check connectivity in both directions + self.assert_ip_connectivity(workload_list=[workload_host1, + workload_host2], + ip_pass_list=[DEFAULT_IPV4_ADDR_1, + DEFAULT_IPV4_ADDR_2]) - # Check connectivity in both directions - self.assert_ip_connectivity(workload_list=[workload_host1, - workload_host2], - ip_pass_list=[DEFAULT_IPV4_ADDR_1, - DEFAULT_IPV4_ADDR_2]) + # Check the BGP status on each host. Connections from a node to + # itself will be idle since this is invalid BGP configuration. + check_bird_status(host1, [("global", host1.ip, ["Idle", "Active"]), + ("global", host2.ip, "Established")]) + check_bird_status(host2, [("global", host1.ip, "Established"), + ("global", host2.ip, ["Idle", "Active"])]) - # Check the BGP status on each host. Connections from a node to - # itself will be idle since this is invalid BGP configuration. - check_bird_status(host1, [("global", host1.ip, "Idle"), - ("global", host2.ip, "Established")]) - check_bird_status(host2, [("global", host1.ip, "Established"), - ("global", host2.ip, "Idle")]) +# @attr('slow') +# def test_bird_node_peers(self): +# self._test_global_peers(backend='bird') + + @attr('slow') + def test_gobgp_node_peers(self): + self._test_global_peers(backend='gobgp') diff --git a/tests/st/bgp/test_node_peers.py b/tests/st/bgp/test_node_peers.py index 6ef736915..c12209eb1 100644 --- a/tests/st/bgp/test_node_peers.py +++ b/tests/st/bgp/test_node_peers.py @@ -23,8 +23,7 @@ class TestNodePeers(TestBase): - @attr('slow') - def test_node_peers(self): + def _test_node_peers(self, backend='bird'): """ Test per-node BGP peer configuration. @@ -39,8 +38,8 @@ def test_node_peers(self): start_calico=False) as host2: # Start both hosts using specific AS numbers. - host1.start_calico_node("--as=%s" % LARGE_AS_NUM) - host2.start_calico_node("--as=%s" % LARGE_AS_NUM) + host1.start_calico_node("--backend=%s --as=%s" % (backend, LARGE_AS_NUM)) + host2.start_calico_node("--backend=%s --as=%s" % (backend, LARGE_AS_NUM)) # Create a network and a couple of workloads on each host. network1 = host1.create_network("subnet1", subnet=DEFAULT_IPV4_POOL_CIDR) @@ -72,3 +71,11 @@ def test_node_peers(self): # Check the BGP status on each host. check_bird_status(host1, [("node specific", host2.ip, "Established")]) check_bird_status(host2, [("node specific", host1.ip, "Established")]) + + @attr('slow') + def test_bird_node_peers(self): + self._test_node_peers(backend='bird') + + @attr('slow') + def test_gobgp_node_peers(self): + self._test_node_peers(backend='gobgp') diff --git a/tests/st/bgp/test_route_reflector_cluster.py b/tests/st/bgp/test_route_reflector_cluster.py index b20b05fa4..846cda120 100644 --- a/tests/st/bgp/test_route_reflector_cluster.py +++ b/tests/st/bgp/test_route_reflector_cluster.py @@ -21,20 +21,27 @@ class TestRouteReflectorCluster(TestBase): - @attr('slow') - def test_route_reflector_cluster(self): + def _test_route_reflector_cluster(self, backend='bird'): """ Run a multi-host test using a cluster of route reflectors and node specific peerings. """ with DockerHost('host1', - additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS) as host1, \ + additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, + start_calico=False) as host1, \ DockerHost('host2', - additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS) as host2, \ + additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, + start_calico=False) as host2, \ DockerHost('host3', - additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS) as host3, \ + additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, + start_calico=False) as host3, \ RouteReflectorCluster(2, 2) as rrc: + # Start both hosts using specific backends. + host1.start_calico_node("--backend=%s" % backend) + host2.start_calico_node("--backend=%s" % backend) + host3.start_calico_node("--backend=%s" % backend) + # Set the default AS number - as this is used by the RR mesh, and # turn off the node-to-node mesh (do this from any host). host1.calicoctl("config set asNumber 64513") @@ -69,3 +76,11 @@ def test_route_reflector_cluster(self): ip_pass_list=[workload_host1.ip, workload_host2.ip, workload_host3.ip]) + + @attr('slow') + def test_bird_route_reflector_cluster(self): + self._test_route_reflector_cluster(backend='bird') + + @attr('slow') + def test_gobgp_route_reflector_cluster(self): + self._test_route_reflector_cluster(backend='gobgp') diff --git a/tests/st/bgp/test_single_route_reflector.py b/tests/st/bgp/test_single_route_reflector.py index 055171e71..67ee97320 100644 --- a/tests/st/bgp/test_single_route_reflector.py +++ b/tests/st/bgp/test_single_route_reflector.py @@ -22,17 +22,23 @@ class TestSingleRouteReflector(TestBase): @attr('slow') - def test_single_route_reflector(self): + def _test_single_route_reflector(self, backend='bird'): """ Run a multi-host test using a single route reflector and global peering. """ with DockerHost('host1', - additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS) as host1, \ + additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, + start_calico=False) as host1, \ DockerHost('host2', - additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS) as host2, \ + additional_docker_options=CLUSTER_STORE_DOCKER_OPTIONS, + start_calico=False) as host2, \ RouteReflectorCluster(1, 1) as rrc: + # Start both hosts using specific backends. + host1.start_calico_node("--backend=%s" % backend) + host2.start_calico_node("--backend=%s" % backend) + # Set the default AS number - as this is used by the RR mesh, and # turn off the node-to-node mesh (do this from any host). host1.calicoctl("config set asNumber 64514") @@ -62,3 +68,11 @@ def test_single_route_reflector(self): workload_host2], ip_pass_list=[workload_host1.ip, workload_host2.ip]) + + @attr('slow') + def test_bird_single_route_reflector(self): + self._test_single_route_reflector(backend='bird') + + @attr('slow') + def test_gobgp_single_route_reflector(self): + self._test_single_route_reflector(backend='gobgp')