-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into add-ddm-instance
- Loading branch information
Showing
72 changed files
with
3,448 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v3 | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" | ||
hosted_connect "github.com/opentelekomcloud/gophertelekomcloud/openstack/dcaas/v3/hosted-connect" | ||
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" | ||
) | ||
|
||
func TestHostedConnectLifecycle(t *testing.T) { | ||
t.Skip("This API only available in eu-ch2 region for now") | ||
hostingId := os.Getenv("DCAAS_HOSTING_ID") | ||
if hostingId == "" { | ||
// hostingId = "45d7cbf9-b78e-4273-9a16-68f772b6c71d" | ||
t.Skip("DCAAS_HOSTING_ID must be set for test") | ||
} | ||
|
||
client, err := clients.NewDCaaSV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
// Create a hosted connect | ||
name := strings.ToLower(tools.RandomString("test-hosted-connect", 5)) | ||
createOpts := hosted_connect.CreateOpts{ | ||
Name: name, | ||
Description: "hosted", | ||
Bandwidth: 10, | ||
Vlan: 441, | ||
ResourceTenantId: client.ProjectID, | ||
HostingID: hostingId, | ||
} | ||
t.Logf("Attempting to create DCaaSv3 hosted connect") | ||
created, err := hosted_connect.Create(client, createOpts) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("Attempting to retrieve list of DCaaSv3 hosted connects") | ||
l, err := hosted_connect.List(client, hosted_connect.ListOpts{ID: []string{created.ID}}) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, name, l[0].Name) | ||
|
||
t.Logf("Attempting to retrieve DCaaSv3 hosted connect: %s", created.ID) | ||
c, err := hosted_connect.Get(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, name, c.Name) | ||
|
||
t.Logf("Attempting to update DCaaSv3 hosted connect: %s", created.ID) | ||
u, err := hosted_connect.Update(client, created.ID, hosted_connect.UpdateOpts{ | ||
Description: "update", | ||
Bandwidth: 20, | ||
}) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, "update", u.Description) | ||
th.AssertEquals(t, 20, u.Bandwidth) | ||
|
||
t.Cleanup(func() { | ||
t.Logf("Attempting to delete DCaaSv3 hosted connect: %s", created.ID) | ||
|
||
err = hosted_connect.Delete(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package v3 | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/pointerto" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dcaas/v3/virtual-gateway" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/networking/v1/vpcs" | ||
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" | ||
) | ||
|
||
func TestVirtualGatewayListing(t *testing.T) { | ||
t.Skip("This API only available in eu-ch2 region for now") | ||
client, err := clients.NewDCaaSV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
opts := virtual_gateway.ListOpts{} | ||
vgwList, err := virtual_gateway.List(client, opts) | ||
th.AssertNoErr(t, err) | ||
|
||
for _, vgw := range vgwList { | ||
tools.PrintResource(t, vgw) | ||
} | ||
} | ||
|
||
func TestVirtualGatewayLifecycle(t *testing.T) { | ||
t.Skip("This API only available in eu-ch2 region for now") | ||
vpcID := os.Getenv("OS_VPC_ID") | ||
if vpcID == "" { | ||
t.Skip("OS_VPC_ID necessary for this test") | ||
} | ||
client, err := clients.NewDCaaSV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
clientNet, err := clients.NewNetworkV1Client() | ||
th.AssertNoErr(t, err) | ||
vpc, err := vpcs.Get(clientNet, vpcID).Extract() | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("Attempting to create DCaaSv3 virtual gateway") | ||
name := strings.ToLower(tools.RandomString("acc-virtual-gateway-v3-", 5)) | ||
createOpts := virtual_gateway.CreateOpts{ | ||
Name: name, | ||
VpcId: vpcID, | ||
Description: "acc-virtual-gateway-v3", | ||
LocalEpGroup: []string{vpc.CIDR}, | ||
Tags: []tags.ResourceTag{ | ||
{ | ||
Key: "TestKey", | ||
Value: "TestValue", | ||
}, | ||
}, | ||
} | ||
|
||
created, err := virtual_gateway.Create(client, createOpts) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("Attempting to obtain DCaaSv3 virtual gateway: %s", created.ID) | ||
vgw, err := virtual_gateway.Get(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, name, vgw.Name) | ||
|
||
t.Logf("Attempting to update DCaaSv3 virtual gateway: %s", created.ID) | ||
nameUpdated := strings.ToLower(tools.RandomString("acc-virtual-gateway-v3-up", 5)) | ||
updateOpts := virtual_gateway.UpdateOpts{ | ||
Name: nameUpdated, | ||
Description: pointerto.String("acc-virtual-gateway-v3-updated"), | ||
} | ||
updated, err := virtual_gateway.Update(client, created.ID, updateOpts) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, nameUpdated, updated.Name) | ||
|
||
t.Logf("Attempting to obtain list of DCaaSv3 virtual gateways: %s", created.ID) | ||
gateways, err := virtual_gateway.List(client, virtual_gateway.ListOpts{ | ||
VpcId: vpcID, | ||
}) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, 1, len(gateways)) | ||
|
||
t.Cleanup(func() { | ||
t.Logf("Attempting to delete DCaaSv3 virtual gateway: %s", created.ID) | ||
err = virtual_gateway.Delete(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
}) | ||
} |
112 changes: 112 additions & 0 deletions
112
acceptance/openstack/dcaas/v3/virtual_interface_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package v3 | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/clients" | ||
"github.com/opentelekomcloud/gophertelekomcloud/acceptance/tools" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/pointerto" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dcaas/v3/virtual-gateway" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dcaas/v3/virtual-interface" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/networking/v1/vpcs" | ||
th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" | ||
) | ||
|
||
func TestVirtualInterfaceListing(t *testing.T) { | ||
t.Skip("This API only available in eu-ch2 region for now") | ||
client, err := clients.NewDCaaSV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
// List virtual interfaces | ||
opts := virtual_interface.ListOpts{} | ||
viList, err := virtual_interface.List(client, opts) | ||
th.AssertNoErr(t, err) | ||
|
||
for _, vi := range viList { | ||
tools.PrintResource(t, vi) | ||
} | ||
} | ||
|
||
func TestVirtualInterfaceLifecycle(t *testing.T) { | ||
t.Skip("This API only available in eu-ch2 region for now") | ||
dcID := os.Getenv("DIRECT_CONNECT_ID") | ||
vpcID := os.Getenv("OS_VPC_ID") | ||
if vpcID == "" && dcID == "" { | ||
t.Skip("DIRECT_CONNECT_ID and OS_VPC_ID necessary for this test") | ||
} | ||
client, err := clients.NewDCaaSV3Client() | ||
th.AssertNoErr(t, err) | ||
|
||
clientNet, err := clients.NewNetworkV1Client() | ||
th.AssertNoErr(t, err) | ||
vpc, err := vpcs.Get(clientNet, vpcID).Extract() | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("Attempting to create DCaaSv3 virtual gateway") | ||
name := strings.ToLower(tools.RandomString("acc-virtual-gateway-v3-", 5)) | ||
createOpts := virtual_gateway.CreateOpts{ | ||
Name: name, | ||
VpcId: vpcID, | ||
Description: "acc-virtual-gateway-v3", | ||
LocalEpGroup: []string{vpc.CIDR}, | ||
Tags: []tags.ResourceTag{ | ||
{ | ||
Key: "TestKey", | ||
Value: "TestValue", | ||
}, | ||
}, | ||
} | ||
vg, err := virtual_gateway.Create(client, createOpts) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Cleanup(func() { | ||
err = virtual_gateway.Delete(client, vg.ID) | ||
th.AssertNoErr(t, err) | ||
}) | ||
|
||
t.Logf("Attempting to create DCaaSv3 virtual interface") | ||
nameVi := tools.RandomString("acc-virtual-interface-", 5) | ||
viOpts := virtual_interface.CreateOpts{ | ||
Name: nameVi, | ||
DirectConnectID: dcID, | ||
VgwId: vg.ID, | ||
Type: "private", | ||
ServiceType: "vpc", | ||
VLAN: 100, | ||
Bandwidth: 5, | ||
LocalGatewayV4IP: "16.16.16.1/30", | ||
RemoteGatewayV4IP: "16.16.16.2/30", | ||
RouteMode: "static", | ||
RemoteEpGroup: []string{"16.16.16.0/30"}, | ||
} | ||
created, err := virtual_interface.Create(client, viOpts) | ||
th.AssertNoErr(t, err) | ||
|
||
t.Logf("Attempting to obtain DCaaSv3 virtual interface: %s", created.ID) | ||
vi, err := virtual_interface.Get(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, "16.16.16.0/30", vi.RemoteEpGroup[0]) | ||
|
||
t.Logf("Attempting to update DCaaSv3 virtual interface: %s", created.ID) | ||
updated, err := virtual_interface.Update(client, created.ID, virtual_interface.UpdateOpts{ | ||
Name: name + "-updated", | ||
Description: pointerto.String("New description"), | ||
}) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, name+"-updated", updated.Name) | ||
th.AssertEquals(t, "New description", updated.Description) | ||
|
||
t.Logf("Attempting to obtain list of DCaaSv3 virtual interfaces") | ||
viList, err := virtual_interface.List(client, virtual_interface.ListOpts{}) | ||
th.AssertNoErr(t, err) | ||
th.AssertEquals(t, 1, len(viList)) | ||
|
||
t.Cleanup(func() { | ||
t.Logf("Attempting to delete DCaaSv3 virtual interface: %s", created.ID) | ||
err = virtual_interface.Delete(client, created.ID) | ||
th.AssertNoErr(t, err) | ||
}) | ||
} |
Oops, something went wrong.