-
Notifications
You must be signed in to change notification settings - Fork 1
/
grid_functions_test.go
97 lines (90 loc) · 2.3 KB
/
grid_functions_test.go
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//go:build all || unittests
// +build all unittests
package infoblox
import (
"os"
"testing"
"time"
)
var (
gridConfig = Config{
Host: os.Getenv("INFOBLOX_HOST"),
Port: os.Getenv("INFOBLOX_PORT"),
Username: os.Getenv("INFOBLOX_USERNAME"),
Password: os.Getenv("INFOBLOX_PASSWORD"),
Version: os.Getenv("INFOBLOX_VERSION"),
DisableTLSVerification: true,
}
gridClient = New(gridConfig)
gridTestNetwork = Network{
CIDR: "172.19.4.0/24",
NetworkView: "default",
Comment: "testing",
ExtensibleAttributes: newExtensibleAttribute(ExtensibleAttribute{
"Owner": ExtensibleAttributeValue{
Value: "testUser",
},
"Gateway": ExtensibleAttributeValue{
Value: "172.19.4.1",
},
}),
Options: []Option{
Option{
Name: "routers",
UseOption: newBool(true),
Value: "172.19.4.1",
VendorClass: "DHCP",
},
},
}
grid Grid
gridMember GridMember
gridRestartRequest = GridServiceRestartRequest{
RestartOption: "RESTART_IF_NEEDED",
Services: []string{"DHCP"},
Members: []string{gridMember.Hostname},
}
)
func TestGridCreateNetwork(t *testing.T) {
members, err := gridClient.GetGridMembers(nil)
if err != nil {
t.Errorf("Error retrieving grid members: %s", err)
}
gridMember = members[0]
gridTestNetwork.Members = []Member{
Member{
StructType: "dhcpmember",
Name: gridMember.Hostname,
},
}
err = gridClient.CreateNetwork(&gridTestNetwork)
if err != nil {
t.Errorf("Error creating network: %s", err)
}
grids, err := gridClient.GetGrids(nil)
if err != nil {
t.Errorf("Error retrieving grids: %s", err)
}
grid = grids[0]
err = gridClient.RestartServices(grid.Ref, gridRestartRequest)
if err != nil {
t.Errorf("Error restarting grid services: %s", err)
}
time.Sleep(5 * time.Second)
}
func TestGridDeleteNetwork(t *testing.T) {
err := gridClient.DeleteNetwork(gridTestNetwork.Ref)
if err != nil {
t.Errorf("Error deleting network: %s", err)
}
err = gridClient.RestartServices(grid.Ref, gridRestartRequest)
if err != nil {
t.Errorf("Error restarting grid services: %s", err)
}
}
func TestLogoutGrid(t *testing.T) {
err := gridClient.Logout()
if err != nil {
t.Errorf("Error logging out: %s", err)
}
}