93.2.1
by Jeroen Vermeulen
Extract test helpers. |
1 |
// Copyright 2013 Canonical Ltd. This software is licensed under the
|
2 |
// GNU Lesser General Public License version 3 (see the file COPYING).
|
|
3 |
//
|
|
4 |
// Test helpers to fake objects that go into, or come out of, the Azure API.
|
|
5 |
||
6 |
package gwacl |
|
7 |
||
182.1.5
by Gavin Panella
Ditch makeEndpoint(). |
8 |
func populateEndpoint(endpoint *InputEndpoint) *InputEndpoint { |
9 |
if endpoint.LoadBalancedEndpointSetName == "" { |
|
10 |
endpoint.LoadBalancedEndpointSetName = MakeRandomString(10) |
|
11 |
}
|
|
12 |
if endpoint.LocalPort == 0 { |
|
13 |
endpoint.LocalPort = MakeRandomPort() |
|
14 |
}
|
|
15 |
if endpoint.Name == "" { |
|
16 |
endpoint.Name = MakeRandomString(10) |
|
17 |
}
|
|
18 |
if endpoint.Port == 0 { |
|
19 |
endpoint.Port = MakeRandomPort() |
|
20 |
}
|
|
182.1.6
by Gavin Panella
Add LoadBalancerProbe and VIP to InputEndpoint. |
21 |
if endpoint.LoadBalancerProbe == nil { |
22 |
endpoint.LoadBalancerProbe = &LoadBalancerProbe{} |
|
23 |
}
|
|
24 |
if endpoint.LoadBalancerProbe.Path == "" { |
|
25 |
endpoint.LoadBalancerProbe.Path = MakeRandomString(10) |
|
26 |
}
|
|
27 |
if endpoint.LoadBalancerProbe.Port == 0 { |
|
28 |
endpoint.LoadBalancerProbe.Port = MakeRandomPort() |
|
29 |
}
|
|
30 |
if endpoint.LoadBalancerProbe.Protocol == "" { |
|
31 |
endpoint.LoadBalancerProbe.Protocol = MakeRandomString(10) |
|
32 |
}
|
|
182.1.5
by Gavin Panella
Ditch makeEndpoint(). |
33 |
if endpoint.Protocol == "" { |
34 |
endpoint.Protocol = MakeRandomString(10) |
|
35 |
}
|
|
182.1.6
by Gavin Panella
Add LoadBalancerProbe and VIP to InputEndpoint. |
36 |
if endpoint.VIP == "" { |
37 |
endpoint.VIP = MakeRandomString(10) |
|
38 |
}
|
|
182.1.5
by Gavin Panella
Ditch makeEndpoint(). |
39 |
return endpoint |
93.2.1
by Jeroen Vermeulen
Extract test helpers. |
40 |
}
|
41 |
||
147.3.1
by Raphael Badin
Support for network config. |
42 |
func makeLinuxProvisioningConfiguration() *ConfigurationSet { |
93.2.1
by Jeroen Vermeulen
Extract test helpers. |
43 |
hostname := MakeRandomString(10) |
44 |
username := MakeRandomString(10) |
|
45 |
password := MakeRandomString(10) |
|
138.2.1
by Julian Edwards
Add UserData to LinuxProvisioningConfiguration |
46 |
userdata := MakeRandomString(10) |
147.3.1
by Raphael Badin
Support for network config. |
47 |
disableSSH := BoolToString(MakeRandomBool()) |
169.1.1
by Gavin Panella
Rename ConfigurationSet constructors to have Set suffix, to prevent naming conflict in upcoming work. |
48 |
return NewLinuxProvisioningConfigurationSet(hostname, username, password, userdata, disableSSH) |
93.2.1
by Jeroen Vermeulen
Extract test helpers. |
49 |
}
|
50 |
||
51 |
func makeOSVirtualHardDisk() *OSVirtualHardDisk { |
|
52 |
HostCaching := BoolToString(MakeRandomBool()) |
|
53 |
DiskLabel := MakeRandomString(10) |
|
54 |
DiskName := MakeRandomString(10) |
|
55 |
MediaLink := MakeRandomString(10) |
|
56 |
SourceImageName := MakeRandomString(10) |
|
57 |
||
58 |
return &OSVirtualHardDisk{ |
|
59 |
HostCaching: HostCaching, |
|
60 |
DiskLabel: DiskLabel, |
|
61 |
DiskName: DiskName, |
|
62 |
MediaLink: MediaLink, |
|
63 |
SourceImageName: SourceImageName} |
|
64 |
}
|
|
65 |
||
66 |
func makeRole() *Role { |
|
67 |
RoleSize := "ExtraSmall" |
|
68 |
RoleName := MakeRandomString(10) |
|
69 |
RoleType := "PersistentVMRole" |
|
70 |
config := makeLinuxProvisioningConfiguration() |
|
147.3.1
by Raphael Badin
Support for network config. |
71 |
configset := []ConfigurationSet{*config} |
93.2.1
by Jeroen Vermeulen
Extract test helpers. |
72 |
|
73 |
return &Role{ |
|
74 |
RoleSize: RoleSize, |
|
75 |
RoleName: RoleName, |
|
76 |
RoleType: RoleType, |
|
77 |
ConfigurationSets: configset} |
|
78 |
}
|
|
79 |
||
80 |
func makeDnsServer() *DnsServer { |
|
81 |
name := MakeRandomString(10) |
|
82 |
address := MakeRandomString(10) |
|
83 |
||
84 |
return &DnsServer{ |
|
85 |
Name: name, |
|
86 |
Address: address} |
|
87 |
}
|
|
88 |
||
89 |
func makeDeployment() *Deployment { |
|
90 |
Name := MakeRandomString(10) |
|
91 |
DeploymentSlot := "Staging" |
|
92 |
Label := MakeRandomString(10) |
|
93 |
VirtualNetworkName := MakeRandomString(10) |
|
94 |
role := makeRole() |
|
95 |
RoleList := []Role{*role} |
|
96 |
Dns := []DnsServer{*makeDnsServer()} |
|
97 |
||
98 |
return &Deployment{ |
|
99 |
XMLNS: XMLNS, |
|
100 |
XMLNS_I: XMLNS_I, |
|
101 |
Name: Name, |
|
102 |
DeploymentSlot: DeploymentSlot, |
|
103 |
Label: Label, |
|
104 |
RoleList: RoleList, |
|
105 |
VirtualNetworkName: VirtualNetworkName, |
|
106 |
DNS: Dns, |
|
107 |
}
|
|
108 |
}
|
|
109 |
||
110 |
func makeCreateStorageServiceInput() *CreateStorageServiceInput { |
|
111 |
ServiceName := MakeRandomString(10) |
|
112 |
Description := MakeRandomString(10) |
|
113 |
Label := MakeRandomString(10) |
|
114 |
AffinityGroup := MakeRandomString(10) |
|
115 |
Location := MakeRandomString(10) |
|
116 |
GeoReplicationEnabled := BoolToString(MakeRandomBool()) |
|
117 |
ExtendedProperties := []ExtendedProperty{{ |
|
118 |
Name: MakeRandomString(10), |
|
119 |
Value: MakeRandomString(10)}} |
|
120 |
||
121 |
return &CreateStorageServiceInput{ |
|
122 |
XMLNS: XMLNS, |
|
123 |
ServiceName: ServiceName, |
|
124 |
Description: Description, |
|
125 |
Label: Label, |
|
126 |
AffinityGroup: AffinityGroup, |
|
127 |
Location: Location, |
|
128 |
GeoReplicationEnabled: GeoReplicationEnabled, |
|
129 |
ExtendedProperties: ExtendedProperties} |
|
130 |
}
|