public void describeRouteTablesWithInvalidStateValue() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/describe_route_tables_invalid.xml"); final ImmutableList<RouteTable> routeTables = routeTableApi().describeRouteTables(DEFAULT_REGION).toList(); assertNotNull(routeTables, "Failed to create route table description object"); assertEquals(routeTables.size(), 1, "Failed to return expected entry from test data, returned: " + routeTables); assertEquals(routeTables.get(0).routeSet().get(0).state(), Route.RouteState.UNRECOGNIZED); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeRouteTables"); }
@Test(dependsOnMethods = "testDeleteRouteTableWithOptions") public void testDeleteRouteTable() { final ImmutableList<RouteTable> before = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(before.size(), 1, "Unexpected response to describe of " + routeTable.id() + ": " + before); assertEquals(before.get(0).id(), routeTable.id(), "Wrong table returned for " + routeTable.id() + ": " + before); final boolean deleted = routeTableApi.deleteRouteTable(TEST_REGION, routeTable.id()); assertTrue(deleted, "Failed to delete route table " + routeTable.id()); final ImmutableList<RouteTable> after = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(after.size(), 0, "Unexpected response to describe after deleting " + routeTable.id() + ": " + after); }
@Test(dependsOnMethods = "testDisassociateWithOptions") public void testDisassociate() { final boolean result = routeTableApi.disassociateRouteTable(TEST_REGION, associationId); assertTrue(result, "Failed to disassociate " + associationId + " from " + routeTable.id()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 0, "Found associations where none should exist in " + routeTable.id() + ": " + routeTable.associationSet()); subnetApi.deleteSubnetInRegion(TEST_REGION, subnet.getSubnetId()); }
@Test(dependsOnMethods = "testAssociateWithOptions") public void testAssociate() { associationId = routeTableApi.associateRouteTable(TEST_REGION, routeTable.id(), subnet.getSubnetId()); assertNotNull(associationId, "Failed to obtain association id for " + routeTable.id() + " and " + subnet.getSubnetId()); routeTable = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList().get(0); assertEquals(routeTable.associationSet().size(), 1, "Could not find expected association in routeTable " + routeTable.id()); }
public void describeRouteTables() throws Exception { enqueueRegions(DEFAULT_REGION); enqueue(DEFAULT_REGION, new MockResponse().setResponseCode(404)); final ImmutableList<RouteTable> routeTables = routeTableApi().describeRouteTables(DEFAULT_REGION).toList(); assertTrue(routeTables.isEmpty(), "Returned " + routeTables.size() + " results for 404 response: " + routeTables); assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeRouteTables"); }
@Test public void testDescribe() { vpc = vpcClient.createVpc(TEST_REGION, VPC_CIDR); assertNotNull(vpc, "Failed to create VPC to test attachments"); tagger.applyToResources(ImmutableMap.of("Name", simpleName), ImmutableList.of(vpc.id())); // When you create a VPC it automatically gets a route table whose single route has the CIDR of the VPC // and whose "target" is "local". final FluentIterable<RouteTable> routeTables = routeTableApi.describeRouteTables(TEST_REGION); assertNotNull(routeTables, "Failed to return list of RouteTables"); Optional<RouteTable> vpcRT = Iterables.tryFind(routeTables, new Predicate<RouteTable>() { @Override public boolean apply(RouteTable input) { return vpc.id().equals(input.vpcId()); } }); assertTrue(vpcRT.isPresent(), "Could not find VPC " + vpc.id() + " in described route tables"); RouteTable rt = vpcRT.get(); assertEquals(rt.associationSet().size(), 1, "Route for test VPC has wrong number of associations, should be 1: " + rt.associationSet()); assertTrue(rt.associationSet().get(0).main(), "Association for route " + rt.id() + "should be 'main'"); assertEquals(rt.routeSet().size(), 1, "Wrong number of routes in default route table for VPC " + vpc.id()); final String defaultCidr = rt.routeSet().get(0).destinationCidrBlock(); assertEquals(defaultCidr, vpc.cidrBlock(), "Route in default route table does not match CIDR of VPC, " + defaultCidr + " should be " + vpc.cidrBlock()); }
public void describeRouteTablesNotFound() throws Exception { enqueueRegions(DEFAULT_REGION); enqueueXml(DEFAULT_REGION, "/describe_route_tables.xml"); final ImmutableList<RouteTable> routeTables = routeTableApi().describeRouteTables(DEFAULT_REGION).toList(); assertNotNull(routeTables, "Failed to create route table description object"); assertEquals(routeTables.size(), 3, "Failed to return all entries from test data, returned: " + routeTables); for (RouteTable table : routeTables) { if (ImmutableList.of("rtb-80a3fae4", "rtb-d4605bb0").contains(table.id())) { assertRoutesForNormalVpc(table, table.id()); } else if (table.id().equals("rtb-e6c98381")) { assertRoutesForTestVpc(table, table.id()); } } assertPosted(DEFAULT_REGION, "Action=DescribeRegions"); assertPosted(DEFAULT_REGION, "Action=DescribeRouteTables"); }
@Test(dependsOnMethods = "testCreate") public void testCreateRoute() { // If you attach an Internet Gateway, Network Interface, or Virtual Private Gateway to the VPC // you can then add a route through it to the route table. Issue a CreateRoute request specifying // the gateway (or network interface id etc.) to route through, and supplying the CIDR range that should // be routed through it. This can be any CIDR. gateway = gwApi.createInternetGateway(TEST_REGION, InternetGatewayOptions.NONE); assertNotNull(gateway, "Gateway was not successfully created"); final Boolean attached = gwApi.attachInternetGateway(TEST_REGION, gateway.id(), vpc.id()); assertTrue(attached, "Gateway " + gateway.id() + " failed to attach to VPC " + vpc.id()); final boolean created = routeTableApi.createRoute(TEST_REGION, routeTable.id(), gatewayId(gateway.id()) .destinationCidrBlock(TEST_DESTINATION_CIDR)); assertTrue(created, "Failed to add route to table " + routeTable.id()); final ImmutableList<RouteTable> routeTables = routeTableApi.describeRouteTables(TEST_REGION, routeTable.id()).toList(); assertEquals(routeTables.size(), 1, "Could not find existing route table " + routeTable.id()); Optional<Route> optRoute = Iterables.tryFind(routeTables.get(0).routeSet(), new Predicate<Route>() { @Override public boolean apply(Route route) { return route.gatewayId().equals(gateway.id()); } }); assertTrue(optRoute.isPresent(), "Could not find route added to gateway " + gateway.id()); Route route = optRoute.get(); assertEquals(route.destinationCidrBlock(), TEST_DESTINATION_CIDR, "CIDR routed through " + gateway.id() + " does not match specification " + TEST_DESTINATION_CIDR); }