| 1 | package ecs |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/denverdino/aliyungo/common" |
| 7 | ) |
| 8 | |
| 9 | func testRouteTable(t *testing.T, client *Client, regionId common.Region, vpcId string, vrouterId string, routeTableId string, instanceId string) { |
| 10 | cidrBlock := "0.0.0.0/0" |
| 11 | createArgs := CreateRouteEntryArgs{ |
| 12 | RouteTableId: routeTableId, |
| 13 | DestinationCidrBlock: cidrBlock, |
| 14 | NextHopType: NextHopIntance, |
| 15 | NextHopId: instanceId, |
| 16 | ClientToken: client.GenerateClientToken(), |
| 17 | } |
| 18 | |
| 19 | err := client.CreateRouteEntry(&createArgs) |
| 20 | if err != nil { |
| 21 | t.Errorf("Failed to create route entry: %v", err) |
| 22 | } |
| 23 | |
| 24 | describeArgs := DescribeRouteTablesArgs{ |
| 25 | VRouterId: vrouterId, |
| 26 | } |
| 27 | |
| 28 | routeTables, _, err := client.DescribeRouteTables(&describeArgs) |
| 29 | |
| 30 | if err != nil { |
| 31 | t.Errorf("Failed to describe route tables: %v", err) |
| 32 | } else { |
| 33 | t.Logf("RouteTables of VRouter %s: %++v", vrouterId, routeTables) |
| 34 | } |
| 35 | |
| 36 | err = client.WaitForAllRouteEntriesAvailable(vrouterId, routeTableId, 60) |
| 37 | if err != nil { |
| 38 | t.Errorf("Failed to wait route entries: %v", err) |
| 39 | } |
| 40 | deleteArgs := DeleteRouteEntryArgs{ |
| 41 | RouteTableId: routeTableId, |
| 42 | DestinationCidrBlock: cidrBlock, |
| 43 | NextHopId: instanceId, |
| 44 | } |
| 45 | |
| 46 | err = client.DeleteRouteEntry(&deleteArgs) |
| 47 | if err != nil { |
| 48 | t.Errorf("Failed to delete route entry: %v", err) |
| 49 | } |
| 50 | |
| 51 | } |