Merge lp:~jtv/gwacl/fix-upgrade-breakage into lp:gwacl

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: 188
Merged at revision: 187
Proposed branch: lp:~jtv/gwacl/fix-upgrade-breakage
Merge into: lp:gwacl
Diff against target: 230 lines (+28/-23)
4 files modified
management_base_test.go (+4/-1)
storage_base_test.go (+1/-1)
storage_test.go (+3/-2)
xmlobjects_test.go (+20/-19)
To merge this branch: bzr merge lp:~jtv/gwacl/fix-upgrade-breakage
Reviewer Review Type Date Requested Status
Gavin Panella Approve
Review via email: mp+175232@code.launchpad.net

Commit message

Fix the test failures (but not the horrible crashes) that happen when upgrading from go1.0.2 to go1.1.1.

Description of the change

There are also a bunch of segfaults that Julian is currently looking into. But the actual "failures" were caused by XML serialization no longer including a leading newline.

This fix is tedious and repetitive (really, it should quite literally be the exact same fix for all cases) but it has the advantage that it works on both Go versions, and will continue to work with other similar whitespace changes.

Jeroen

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'management_base_test.go'
2--- management_base_test.go 2013-07-17 01:11:29 +0000
3+++ management_base_test.go 2013-07-17 09:19:40 +0000
4@@ -256,7 +256,10 @@
5
6 func checkRequest(c *C, request *X509Request, URL, version string, payload []byte, Method string) {
7 c.Check(request.URL, Equals, URL)
8- c.Check(string(request.Payload), Equals, string(payload))
9+ c.Check(
10+ strings.TrimSpace(string(request.Payload)),
11+ Equals,
12+ strings.TrimSpace(string(payload)))
13 c.Check(request.Method, Equals, Method)
14 c.Check(request.APIVersion, Equals, version)
15 }
16
17=== modified file 'storage_base_test.go'
18--- storage_base_test.go 2013-07-02 04:18:26 +0000
19+++ storage_base_test.go 2013-07-17 09:19:40 +0000
20@@ -919,7 +919,7 @@
21 <Latest>YjE=</Latest>
22 <Latest>YjI=</Latest>
23 </BlockList>`)
24- c.Check(string(data), Equals, expected)
25+ c.Check(strings.TrimSpace(string(data)), Equals, strings.TrimSpace(expected))
26 }
27
28 // Client-side errors from the HTTP client are propagated back to the caller.
29
30=== modified file 'storage_test.go'
31--- storage_test.go 2013-07-02 14:21:28 +0000
32+++ storage_test.go 2013-07-17 09:19:40 +0000
33@@ -11,6 +11,7 @@
34 . "launchpad.net/gocheck"
35 "net/http"
36 "net/url"
37+ "strings"
38 )
39
40 type testUploadBlockBlob struct{}
41@@ -90,12 +91,12 @@
42 "?comp=blocklist", context.Account))
43 body, err := ioutil.ReadAll(exchange.Request.Body)
44 c.Check(err, IsNil)
45- expected := "\n<BlockList>\n"
46+ expected := "<BlockList>\n"
47 for _, blockID := range blockIDs {
48 expected += " <Latest>" + blockID + "</Latest>\n"
49 }
50 expected += "</BlockList>"
51- c.Check(string(body), Equals, expected)
52+ c.Check(strings.TrimSpace(string(body)), Equals, strings.TrimSpace(expected))
53 }
54
55 type testListAllBlobs struct{}
56
57=== modified file 'xmlobjects_test.go'
58--- xmlobjects_test.go 2013-07-16 16:49:18 +0000
59+++ xmlobjects_test.go 2013-07-17 09:19:40 +0000
60@@ -10,6 +10,7 @@
61 . "launchpad.net/gocheck"
62 "launchpad.net/gwacl/dedent"
63 "sort"
64+ "strings"
65 )
66
67 type xmlSuite struct{}
68@@ -37,7 +38,7 @@
69 expected := fmt.Sprintf(template, config.Hostname, config.Username,
70 config.Password, config.UserData,
71 config.DisableSSHPasswordAuthentication)
72- c.Check(xml, Equals, expected)
73+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
74 }
75
76 func (suite *xmlSuite) TestInputEndpoint(c *C) {
77@@ -63,7 +64,7 @@
78 endpoint.LocalPort, endpoint.Name, endpoint.Port,
79 endpoint.LoadBalancerProbe.Path, endpoint.LoadBalancerProbe.Port,
80 endpoint.LoadBalancerProbe.Protocol, endpoint.Protocol, endpoint.VIP)
81- c.Check(xml, Equals, expected)
82+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
83 }
84
85 func (suite *xmlSuite) TestOSVirtualHardDisk(c *C) {
86@@ -81,7 +82,7 @@
87 </OSVirtualHardDisk>`)
88 expected := fmt.Sprintf(template, disk.HostCaching, disk.DiskLabel,
89 disk.DiskName, disk.MediaLink, disk.SourceImageName)
90- c.Check(xml, Equals, expected)
91+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
92 }
93
94 func (suite *xmlSuite) TestConfigurationSetNetworkConfiguration(c *C) {
95@@ -141,7 +142,7 @@
96 endpoint2.LoadBalancerProbe.Protocol, endpoint2.Protocol,
97 endpoint2.VIP,
98 subnet1, subnet2)
99- c.Check(xml, Equals, expected)
100+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
101 }
102
103 func (suite *xmlSuite) TestRole(c *C) {
104@@ -170,7 +171,7 @@
105 config.ConfigurationSetType, config.Hostname, config.Username,
106 config.Password, config.UserData,
107 config.DisableSSHPasswordAuthentication, role.RoleSize)
108- c.Check(xml, Equals, expected)
109+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
110 }
111
112 func makePersistentVMRole(rolename string) string {
113@@ -374,7 +375,7 @@
114 observed, err := role.Serialize()
115
116 c.Assert(err, IsNil)
117- c.Assert(observed, DeepEquals, expected)
118+ c.Assert(strings.TrimSpace(observed), DeepEquals, strings.TrimSpace(expected))
119 }
120
121 func (suite *xmlSuite) TestNetworkConfigurationSerialize(c *C) {
122@@ -477,17 +478,17 @@
123
124 observed, err := input.Serialize()
125 c.Assert(err, IsNil)
126- c.Assert(observed, Equals, expected)
127+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
128 }
129
130 func (suite *xmlSuite) TestNetworkConfigurationSerializeMinimal(c *C) {
131 expected := fmt.Sprintf(
132- "\n<NetworkConfiguration xmlns=\"%s\"></NetworkConfiguration>",
133+ "<NetworkConfiguration xmlns=\"%s\"></NetworkConfiguration>",
134 XMLNS_NC)
135 input := NetworkConfiguration{XMLNS: XMLNS_NC}
136 observed, err := input.Serialize()
137 c.Assert(err, IsNil)
138- c.Assert(observed, Equals, expected)
139+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
140 }
141
142 func (suite *xmlSuite) TestNetworkConfigurationSerializeSimpleVirtualNetworkSite(c *C) {
143@@ -517,7 +518,7 @@
144 }
145 observed, err := input.Serialize()
146 c.Assert(err, IsNil)
147- c.Assert(observed, Equals, expected)
148+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
149 }
150
151 func (suite *xmlSuite) TestCreateAffinityGroup(c *C) {
152@@ -538,7 +539,7 @@
153
154 observed, err := input.Serialize()
155 c.Assert(err, IsNil)
156- c.Assert(observed, Equals, expected)
157+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
158 }
159
160 func (suite *xmlSuite) TestNewCreateAffinityGroup(c *C) {
161@@ -568,7 +569,7 @@
162
163 observed, err := input.Serialize()
164 c.Assert(err, IsNil)
165- c.Assert(observed, Equals, expected)
166+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
167 }
168
169 func (suite *xmlSuite) TestNewUpdateAffinityGroup(c *C) {
170@@ -737,7 +738,7 @@
171 config.Username, config.Password, config.UserData,
172 config.DisableSSHPasswordAuthentication, role.RoleSize,
173 deployment.VirtualNetworkName, dns.Name, dns.Address)
174- c.Check(xml, Equals, expected)
175+ c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
176 }
177
178 // From http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx
179@@ -1082,7 +1083,7 @@
180 expected := fmt.Sprintf(template, s.ServiceName, s.Label, s.Description,
181 s.Location, s.AffinityGroup, s.GeoReplicationEnabled, extProperty.Name,
182 extProperty.Value)
183- c.Assert(xml, Equals, expected)
184+ c.Assert(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected))
185 }
186
187 //
188@@ -1750,7 +1751,7 @@
189
190 observed, err := input.Serialize()
191 c.Assert(err, IsNil)
192- c.Assert(observed, Equals, expected)
193+ c.Assert(strings.TrimSpace(observed), Equals, strings.TrimSpace(expected))
194 }
195
196 func (suite *xmlSuite) TestNewUpdateHostedService(c *C) {
197@@ -1786,7 +1787,7 @@
198 <Uncommitted>c2Vjb25kLWJhc2U2NC1lbmNvZGVkLWJsb2NrLWlk</Uncommitted>
199 <Latest>dGhpcmQtYmFzZTY0LWVuY29kZWQtYmxvY2staWQ=</Latest>
200 </BlockList>`)
201- c.Assert(string(observed), Equals, expected)
202+ c.Assert(strings.TrimSpace(string(observed)), Equals, strings.TrimSpace(expected))
203 }
204
205 func (suite *xmlSuite) TestGetBlockListDeserialize(c *C) {
206@@ -1837,21 +1838,21 @@
207 expectedXML := makeOperationXML("StartRoleOperation")
208 xml, err := marshalXML(startRoleOperation)
209 c.Assert(err, IsNil)
210- c.Check(string(xml), Equals, expectedXML)
211+ c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
212 }
213
214 func (suite *managementAPISuite) TestRestartRoleOperation(c *C) {
215 expectedXML := makeOperationXML("RestartRoleOperation")
216 xml, err := marshalXML(restartRoleOperation)
217 c.Assert(err, IsNil)
218- c.Check(string(xml), Equals, expectedXML)
219+ c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
220 }
221
222 func (suite *managementAPISuite) TestShutdownRoleOperation(c *C) {
223 expectedXML := makeOperationXML("ShutdownRoleOperation")
224 xml, err := marshalXML(shutdownRoleOperation)
225 c.Assert(err, IsNil)
226- c.Check(string(xml), Equals, expectedXML)
227+ c.Check(strings.TrimSpace(string(xml)), Equals, strings.TrimSpace(expectedXML))
228 }
229
230 // TestOSImageWRTAddOSImage demonstrates the OSImage is a suitable container

Subscribers

People subscribed via source and target branches