-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathazure_test.go
More file actions
63 lines (52 loc) · 1.44 KB
/
azure_test.go
File metadata and controls
63 lines (52 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package azure_test
import (
"fmt"
"os"
"testing"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute"
"github.com/Azure/go-autorest/autorest/to"
"github.com/libopenstorage/cloudops"
"github.com/libopenstorage/cloudops/azure"
"github.com/libopenstorage/cloudops/test"
"github.com/pborman/uuid"
)
const (
newDiskSizeInGB = 10
newDiskPrefix = "openstorage-test"
)
var diskName = fmt.Sprintf("%s-%s", newDiskPrefix, uuid.New())
func initAzure(t *testing.T) (cloudops.Ops, map[string]interface{}) {
driver, err := azure.NewEnvClient()
if err != nil {
t.Skipf("skipping Azure tests as environment is not set...\n")
}
region, present := os.LookupEnv("AZURE_INSTANCE_REGION")
if !present {
t.Skipf("skipping Azure tests as AZURE_INSTANCE_REGION is not set...\n")
}
size := int32(newDiskSizeInGB)
name := diskName
template := &compute.Disk{
Name: &name,
Location: ®ion,
DiskProperties: &compute.DiskProperties{
DiskSizeGB: &size,
DiskIOPSReadWrite: to.Int64Ptr(1350),
DiskMBpsReadWrite: to.Int32Ptr(550),
},
Sku: &compute.DiskSku{
Name: compute.PremiumLRS,
},
}
return driver, map[string]interface{}{
diskName: template,
}
}
func TestAll(t *testing.T) {
drivers := make(map[string]cloudops.Ops)
diskTemplates := make(map[string]map[string]interface{})
d, disks := initAzure(t)
drivers[d.Name()] = d
diskTemplates[d.Name()] = disks
test.RunTest(drivers, diskTemplates, nil, t)
}