OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package main | 4 package main |
5 | 5 |
6 import ( | 6 import ( |
7 "archive/tar" | 7 "archive/tar" |
8 "bytes" | 8 "bytes" |
9 "compress/gzip" | 9 "compress/gzip" |
10 "io" | 10 "io" |
(...skipping 15 matching lines...) Expand all Loading... |
26 ) | 26 ) |
27 | 27 |
28 type UpgradeJujuSuite struct { | 28 type UpgradeJujuSuite struct { |
29 testing.JujuConnSuite | 29 testing.JujuConnSuite |
30 } | 30 } |
31 | 31 |
32 var _ = gc.Suite(&UpgradeJujuSuite{}) | 32 var _ = gc.Suite(&UpgradeJujuSuite{}) |
33 | 33 |
34 var upgradeJujuTests = []struct { | 34 var upgradeJujuTests = []struct { |
35 about string | 35 about string |
36 » private []string | 36 » tools []string |
37 » public []string | |
38 currentVersion string | 37 currentVersion string |
39 agentVersion string | 38 agentVersion string |
40 development bool | |
41 | 39 |
42 args []string | 40 args []string |
43 expectInitErr string | 41 expectInitErr string |
44 expectErr string | 42 expectErr string |
45 expectVersion string | 43 expectVersion string |
46 expectUploaded []string | 44 expectUploaded []string |
47 }{{ | 45 }{{ |
48 about: "unwanted extra argument", | 46 about: "unwanted extra argument", |
49 currentVersion: "1.0.0-quantal-amd64", | 47 currentVersion: "1.0.0-quantal-amd64", |
50 args: []string{"foo"}, | 48 args: []string{"foo"}, |
51 expectInitErr: "unrecognized args:.*", | 49 expectInitErr: "unrecognized args:.*", |
52 }, { | 50 }, { |
| 51 about: "removed arg --dev specified", |
| 52 currentVersion: "1.0.0-quantal-amd64", |
| 53 args: []string{"--dev"}, |
| 54 expectInitErr: "flag provided but not defined: --dev", |
| 55 }, { |
53 about: "invalid --version value", | 56 about: "invalid --version value", |
54 currentVersion: "1.0.0-quantal-amd64", | 57 currentVersion: "1.0.0-quantal-amd64", |
55 args: []string{"--version", "invalid-version"}, | 58 args: []string{"--version", "invalid-version"}, |
56 expectInitErr: "invalid version .*", | 59 expectInitErr: "invalid version .*", |
57 }, { | 60 }, { |
| 61 about: "just major version, no minor specified", |
| 62 currentVersion: "4.2.0-quantal-amd64", |
| 63 args: []string{"--version", "4"}, |
| 64 expectInitErr: `invalid version "4"`, |
| 65 }, { |
58 about: "major version upgrade to incompatible version", | 66 about: "major version upgrade to incompatible version", |
59 currentVersion: "2.0.0-quantal-amd64", | 67 currentVersion: "2.0.0-quantal-amd64", |
60 args: []string{"--version", "5.2.0"}, | 68 args: []string{"--version", "5.2.0"}, |
61 expectInitErr: "cannot upgrade to version incompatible with CLI", | 69 expectInitErr: "cannot upgrade to version incompatible with CLI", |
62 }, { | 70 }, { |
63 about: "major version downgrade to incompatible version", | 71 about: "major version downgrade to incompatible version", |
64 currentVersion: "4.2.0-quantal-amd64", | 72 currentVersion: "4.2.0-quantal-amd64", |
65 args: []string{"--version", "3.2.0"}, | 73 args: []string{"--version", "3.2.0"}, |
66 expectInitErr: "cannot upgrade to version incompatible with CLI", | 74 expectInitErr: "cannot upgrade to version incompatible with CLI", |
67 }, { | 75 }, { |
(...skipping 10 matching lines...) Expand all Loading... |
78 about: "--upload-tools with inappropriate version 1", | 86 about: "--upload-tools with inappropriate version 1", |
79 currentVersion: "4.2.0-quantal-amd64", | 87 currentVersion: "4.2.0-quantal-amd64", |
80 args: []string{"--upload-tools", "--version", "3.1.0"}, | 88 args: []string{"--upload-tools", "--version", "3.1.0"}, |
81 expectInitErr: "cannot upgrade to version incompatible with CLI", | 89 expectInitErr: "cannot upgrade to version incompatible with CLI", |
82 }, { | 90 }, { |
83 about: "--upload-tools with inappropriate version 2", | 91 about: "--upload-tools with inappropriate version 2", |
84 currentVersion: "3.2.7-quantal-amd64", | 92 currentVersion: "3.2.7-quantal-amd64", |
85 args: []string{"--upload-tools", "--version", "3.1.0.4"}, | 93 args: []string{"--upload-tools", "--version", "3.1.0.4"}, |
86 expectInitErr: "cannot specify build number when uploading tools", | 94 expectInitErr: "cannot specify build number when uploading tools", |
87 }, { | 95 }, { |
88 » about: "latest release from private storage", | 96 » about: "latest supported stable release", |
89 » private: []string{"2.0.0-quantal-amd64", "2.0.2-quantal-i386", "2
.0.3-quantal-amd64"}, | 97 » tools: []string{"2.2.0-quantal-amd64", "2.2.2-quantal-i386", "2
.2.3-quantal-amd64"}, |
90 » public: []string{"2.0.0-quantal-amd64", "2.0.4-quantal-amd64", "
2.0.5-quantal-amd64"}, | |
91 currentVersion: "2.0.0-quantal-amd64", | 98 currentVersion: "2.0.0-quantal-amd64", |
92 agentVersion: "2.0.0", | 99 agentVersion: "2.0.0", |
93 » expectVersion: "2.0.3", | 100 » expectVersion: "2.2.3", |
94 }, { | 101 }, { |
95 » about: "latest dev from private storage (because client is dev)
", | 102 » about: "latest current release", |
96 » private: []string{"2.0.0-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64", "3.0.1-quantal-amd64"}, | 103 » tools: []string{"2.0.5-quantal-amd64", "2.0.1-quantal-i386", "2
.3.3-quantal-amd64"}, |
97 » public: []string{"2.0.0-quantal-amd64", "2.4.0-quantal-amd64", "
2.5.0-quantal-amd64"}, | 104 » currentVersion: "2.0.0-quantal-amd64", |
| 105 » agentVersion: "2.0.0", |
| 106 » expectVersion: "2.0.5", |
| 107 }, { |
| 108 » about: "no next supported available", |
| 109 » tools: []string{"2.1.0-quantal-amd64", "2.1.5-quantal-i386", "2
.3.3-quantal-amd64"}, |
| 110 » currentVersion: "2.0.0-quantal-amd64", |
| 111 » agentVersion: "2.0.0", |
| 112 » expectErr: "no more recent supported versions available", |
| 113 }, { |
| 114 » about: "latest supported stable, when client is dev", |
| 115 » tools: []string{"2.1.1-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64", "3.0.1-quantal-amd64"}, |
98 currentVersion: "2.1.0-quantal-amd64", | 116 currentVersion: "2.1.0-quantal-amd64", |
99 agentVersion: "2.0.0", | 117 agentVersion: "2.0.0", |
100 » expectVersion: "2.3.0", | 118 » expectVersion: "2.2.0", |
101 }, { | 119 }, { |
102 » about: "latest dev from private storage (because agent is dev)"
, | 120 » about: "latest current, when agent is dev", |
103 » private: []string{"2.0.0-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64", "3.0.1-quantal-amd64"}, | 121 » tools: []string{"2.1.1-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64", "3.0.1-quantal-amd64"}, |
104 » public: []string{"2.0.0-quantal-amd64", "2.4.0-quantal-amd64", "
2.5.0-quantal-amd64"}, | |
105 currentVersion: "2.0.0-quantal-amd64", | 122 currentVersion: "2.0.0-quantal-amd64", |
106 agentVersion: "2.1.0", | 123 agentVersion: "2.1.0", |
107 » expectVersion: "2.3.0", | 124 » expectVersion: "2.2.0", |
108 }, { | |
109 » about: "latest dev from private storage (because --dev flag)", | |
110 » private: []string{"2.0.0-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64"}, | |
111 » public: []string{"2.0.0-quantal-amd64", "2.4.0-quantal-amd64", "
2.5.0-quantal-amd64"}, | |
112 » currentVersion: "2.0.0-quantal-amd64", | |
113 » args: []string{"--dev"}, | |
114 » agentVersion: "2.0.0", | |
115 » expectVersion: "2.3.0", | |
116 }, { | |
117 » about: "latest dev from private storage (because dev env settin
g)", | |
118 » private: []string{"2.0.0-quantal-amd64", "2.2.0-quantal-amd64", "
2.3.0-quantal-amd64"}, | |
119 » public: []string{"2.0.0-quantal-amd64", "2.4.0-quantal-amd64", "
2.5.0-quantal-amd64"}, | |
120 » currentVersion: "2.0.0-quantal-amd64", | |
121 » development: true, | |
122 » agentVersion: "2.0.0", | |
123 » expectVersion: "2.3.0", | |
124 }, { | 125 }, { |
125 about: "specified version", | 126 about: "specified version", |
126 » private: []string{"2.3.0-quantal-amd64"}, | 127 » tools: []string{"2.3.0-quantal-amd64"}, |
127 currentVersion: "2.0.0-quantal-amd64", | 128 currentVersion: "2.0.0-quantal-amd64", |
128 agentVersion: "2.0.0", | 129 agentVersion: "2.0.0", |
129 args: []string{"--version", "2.3.0"}, | 130 args: []string{"--version", "2.3.0"}, |
130 expectVersion: "2.3.0", | 131 expectVersion: "2.3.0", |
131 }, { | 132 }, { |
132 about: "specified version missing, but already set", | 133 about: "specified version missing, but already set", |
133 currentVersion: "3.0.0-quantal-amd64", | 134 currentVersion: "3.0.0-quantal-amd64", |
134 agentVersion: "3.0.0", | 135 agentVersion: "3.0.0", |
135 args: []string{"--version", "3.0.0"}, | 136 args: []string{"--version", "3.0.0"}, |
136 expectVersion: "3.0.0", | 137 expectVersion: "3.0.0", |
137 }, { | 138 }, { |
138 about: "specified version, no tools", | 139 about: "specified version, no tools", |
139 currentVersion: "3.0.0-quantal-amd64", | 140 currentVersion: "3.0.0-quantal-amd64", |
140 agentVersion: "3.0.0", | 141 agentVersion: "3.0.0", |
141 args: []string{"--version", "3.2.0"}, | 142 args: []string{"--version", "3.2.0"}, |
142 expectErr: "no matching tools available", | 143 expectErr: "no matching tools available", |
143 }, { | 144 }, { |
144 about: "specified version, no matching major version", | 145 about: "specified version, no matching major version", |
145 » private: []string{"4.2.0-quantal-amd64"}, | 146 » tools: []string{"4.2.0-quantal-amd64"}, |
146 currentVersion: "3.0.0-quantal-amd64", | 147 currentVersion: "3.0.0-quantal-amd64", |
147 agentVersion: "3.0.0", | 148 agentVersion: "3.0.0", |
148 args: []string{"--version", "3.2.0"}, | 149 args: []string{"--version", "3.2.0"}, |
149 expectErr: "no matching tools available", | 150 expectErr: "no matching tools available", |
150 }, { | 151 }, { |
151 about: "specified version, no matching minor version", | 152 about: "specified version, no matching minor version", |
152 » private: []string{"3.4.0-quantal-amd64"}, | 153 » tools: []string{"3.4.0-quantal-amd64"}, |
153 currentVersion: "3.0.0-quantal-amd64", | 154 currentVersion: "3.0.0-quantal-amd64", |
154 agentVersion: "3.0.0", | 155 agentVersion: "3.0.0", |
155 args: []string{"--version", "3.2.0"}, | 156 args: []string{"--version", "3.2.0"}, |
156 expectErr: "no matching tools available", | 157 expectErr: "no matching tools available", |
157 }, { | 158 }, { |
158 about: "specified version, no matching patch version", | 159 about: "specified version, no matching patch version", |
159 » private: []string{"3.2.5-quantal-amd64"}, | 160 » tools: []string{"3.2.5-quantal-amd64"}, |
160 currentVersion: "3.0.0-quantal-amd64", | 161 currentVersion: "3.0.0-quantal-amd64", |
161 agentVersion: "3.0.0", | 162 agentVersion: "3.0.0", |
162 args: []string{"--version", "3.2.0"}, | 163 args: []string{"--version", "3.2.0"}, |
163 expectErr: "no matching tools available", | 164 expectErr: "no matching tools available", |
164 }, { | 165 }, { |
165 about: "specified version, no matching build version", | 166 about: "specified version, no matching build version", |
166 » private: []string{"3.2.0.2-quantal-amd64"}, | 167 » tools: []string{"3.2.0.2-quantal-amd64"}, |
167 currentVersion: "3.0.0-quantal-amd64", | 168 currentVersion: "3.0.0-quantal-amd64", |
168 agentVersion: "3.0.0", | 169 agentVersion: "3.0.0", |
169 args: []string{"--version", "3.2.0"}, | 170 args: []string{"--version", "3.2.0"}, |
170 expectErr: "no matching tools available", | 171 expectErr: "no matching tools available", |
171 }, { | 172 }, { |
172 about: "major version downgrade to incompatible version", | 173 about: "major version downgrade to incompatible version", |
173 » private: []string{"3.2.0-quantal-amd64"}, | 174 » tools: []string{"3.2.0-quantal-amd64"}, |
174 currentVersion: "3.2.0-quantal-amd64", | 175 currentVersion: "3.2.0-quantal-amd64", |
175 agentVersion: "4.2.0", | 176 agentVersion: "4.2.0", |
176 args: []string{"--version", "3.2.0"}, | 177 args: []string{"--version", "3.2.0"}, |
177 expectErr: "cannot change major version from 4 to 3", | 178 expectErr: "cannot change major version from 4 to 3", |
178 }, { | 179 }, { |
179 about: "major version upgrade to compatible version", | 180 about: "major version upgrade to compatible version", |
180 » private: []string{"3.2.0-quantal-amd64"}, | 181 » tools: []string{"3.2.0-quantal-amd64"}, |
181 currentVersion: "3.2.0-quantal-amd64", | 182 currentVersion: "3.2.0-quantal-amd64", |
182 agentVersion: "2.8.2", | 183 agentVersion: "2.8.2", |
183 args: []string{"--version", "3.2.0"}, | 184 args: []string{"--version", "3.2.0"}, |
184 expectErr: "major version upgrades are not supported yet", | 185 expectErr: "major version upgrades are not supported yet", |
185 }, { | 186 }, { |
186 » about: "nothing available 1", | 187 » about: "nothing available", |
187 currentVersion: "2.0.0-quantal-amd64", | 188 currentVersion: "2.0.0-quantal-amd64", |
188 agentVersion: "2.0.0", | 189 agentVersion: "2.0.0", |
189 expectVersion: "2.0.0", | 190 expectVersion: "2.0.0", |
190 }, { | 191 }, { |
191 about: "nothing available 2", | 192 about: "nothing available 2", |
192 currentVersion: "2.0.0-quantal-amd64", | 193 currentVersion: "2.0.0-quantal-amd64", |
193 » public: []string{"3.2.0-quantal-amd64"}, | 194 » tools: []string{"3.2.0-quantal-amd64"}, |
194 agentVersion: "2.0.0", | 195 agentVersion: "2.0.0", |
195 expectVersion: "2.0.0", | 196 expectVersion: "2.0.0", |
196 }, { | 197 }, { |
197 about: "nothing available 3", | |
198 currentVersion: "2.0.0-quantal-amd64", | |
199 private: []string{"3.2.0-quantal-amd64"}, | |
200 public: []string{"3.4.0-quantal-amd64"}, | |
201 agentVersion: "2.0.0", | |
202 expectVersion: "2.0.0", | |
203 }, { | |
204 about: "upload with default series", | 198 about: "upload with default series", |
205 currentVersion: "2.2.0-quantal-amd64", | 199 currentVersion: "2.2.0-quantal-amd64", |
206 agentVersion: "2.0.0", | 200 agentVersion: "2.0.0", |
207 args: []string{"--upload-tools"}, | 201 args: []string{"--upload-tools"}, |
208 expectVersion: "2.2.0.1", | 202 expectVersion: "2.2.0.1", |
209 expectUploaded: []string{"2.2.0.1-quantal-amd64", "2.2.0.1-precise-amd64
", "2.2.0.1-raring-amd64"}, | 203 expectUploaded: []string{"2.2.0.1-quantal-amd64", "2.2.0.1-precise-amd64
", "2.2.0.1-raring-amd64"}, |
210 }, { | 204 }, { |
211 about: "upload with explicit version", | 205 about: "upload with explicit version", |
212 currentVersion: "2.2.0-quantal-amd64", | 206 currentVersion: "2.2.0-quantal-amd64", |
213 agentVersion: "2.0.0", | 207 agentVersion: "2.0.0", |
214 args: []string{"--upload-tools", "--version", "2.7.3"}, | 208 args: []string{"--upload-tools", "--version", "2.7.3"}, |
215 expectVersion: "2.7.3.1", | 209 expectVersion: "2.7.3.1", |
216 expectUploaded: []string{"2.7.3.1-quantal-amd64", "2.7.3.1-precise-amd64
", "2.7.3.1-raring-amd64"}, | 210 expectUploaded: []string{"2.7.3.1-quantal-amd64", "2.7.3.1-precise-amd64
", "2.7.3.1-raring-amd64"}, |
217 }, { | 211 }, { |
218 about: "upload with explicit series", | 212 about: "upload with explicit series", |
219 currentVersion: "2.2.0-quantal-amd64", | 213 currentVersion: "2.2.0-quantal-amd64", |
220 agentVersion: "2.0.0", | 214 agentVersion: "2.0.0", |
221 args: []string{"--upload-tools", "--series", "raring"}, | 215 args: []string{"--upload-tools", "--series", "raring"}, |
222 expectVersion: "2.2.0.1", | 216 expectVersion: "2.2.0.1", |
223 expectUploaded: []string{"2.2.0.1-quantal-amd64", "2.2.0.1-raring-amd64"
}, | 217 expectUploaded: []string{"2.2.0.1-quantal-amd64", "2.2.0.1-raring-amd64"
}, |
224 }, { | 218 }, { |
225 about: "upload dev version, currently on release version", | 219 about: "upload dev version, currently on release version", |
226 currentVersion: "2.1.0-quantal-amd64", | 220 currentVersion: "2.1.0-quantal-amd64", |
227 agentVersion: "2.0.0", | 221 agentVersion: "2.0.0", |
228 args: []string{"--upload-tools"}, | 222 args: []string{"--upload-tools"}, |
229 expectVersion: "2.1.0.1", | 223 expectVersion: "2.1.0.1", |
230 expectUploaded: []string{"2.1.0.1-quantal-amd64", "2.1.0.1-precise-amd64
", "2.1.0.1-raring-amd64"}, | 224 expectUploaded: []string{"2.1.0.1-quantal-amd64", "2.1.0.1-precise-amd64
", "2.1.0.1-raring-amd64"}, |
231 }, { | 225 }, { |
232 about: "upload bumps version when necessary", | 226 about: "upload bumps version when necessary", |
233 » private: []string{"2.4.6-quantal-amd64", "2.4.8-quantal-amd64"}, | 227 » tools: []string{"2.4.6-quantal-amd64", "2.4.8-quantal-amd64"}, |
234 » public: []string{"2.4.6.4-quantal-amd64"}, //ignored | |
235 currentVersion: "2.4.6-quantal-amd64", | 228 currentVersion: "2.4.6-quantal-amd64", |
236 agentVersion: "2.4.0", | 229 agentVersion: "2.4.0", |
237 args: []string{"--upload-tools"}, | 230 args: []string{"--upload-tools"}, |
238 expectVersion: "2.4.6.1", | 231 expectVersion: "2.4.6.1", |
239 expectUploaded: []string{"2.4.6.1-quantal-amd64", "2.4.6.1-precise-amd64
", "2.4.6.1-raring-amd64"}, | 232 expectUploaded: []string{"2.4.6.1-quantal-amd64", "2.4.6.1-precise-amd64
", "2.4.6.1-raring-amd64"}, |
240 }, { | 233 }, { |
241 about: "upload re-bumps version when necessary", | 234 about: "upload re-bumps version when necessary", |
242 » private: []string{"2.4.6-quantal-amd64", "2.4.6.2-saucy-i386", "2
.4.8-quantal-amd64"}, | 235 » tools: []string{"2.4.6-quantal-amd64", "2.4.6.2-saucy-i386", "2
.4.8-quantal-amd64"}, |
243 » public: []string{"2.4.6.10-quantal-amd64"}, //ignored | |
244 currentVersion: "2.4.6-quantal-amd64", | 236 currentVersion: "2.4.6-quantal-amd64", |
245 agentVersion: "2.4.6.2", | 237 agentVersion: "2.4.6.2", |
246 args: []string{"--upload-tools"}, | 238 args: []string{"--upload-tools"}, |
247 expectVersion: "2.4.6.3", | 239 expectVersion: "2.4.6.3", |
248 expectUploaded: []string{"2.4.6.3-quantal-amd64", "2.4.6.3-precise-amd64
", "2.4.6.3-raring-amd64"}, | 240 expectUploaded: []string{"2.4.6.3-quantal-amd64", "2.4.6.3-precise-amd64
", "2.4.6.3-raring-amd64"}, |
249 }, { | 241 }, { |
250 about: "upload with explicit version bumps when necessary", | 242 about: "upload with explicit version bumps when necessary", |
251 currentVersion: "2.2.0-quantal-amd64", | 243 currentVersion: "2.2.0-quantal-amd64", |
252 » private: []string{"2.7.3.1-quantal-amd64"}, | 244 » tools: []string{"2.7.3.1-quantal-amd64"}, |
253 agentVersion: "2.0.0", | 245 agentVersion: "2.0.0", |
254 args: []string{"--upload-tools", "--version", "2.7.3"}, | 246 args: []string{"--upload-tools", "--version", "2.7.3"}, |
255 expectVersion: "2.7.3.2", | 247 expectVersion: "2.7.3.2", |
256 expectUploaded: []string{"2.7.3.2-quantal-amd64", "2.7.3.2-precise-amd64
", "2.7.3.2-raring-amd64"}, | 248 expectUploaded: []string{"2.7.3.2-quantal-amd64", "2.7.3.2-precise-amd64
", "2.7.3.2-raring-amd64"}, |
257 }} | 249 }} |
258 | 250 |
259 // mockUploadTools simulates the effect of tools.Upload, but skips the time- | 251 // mockUploadTools simulates the effect of tools.Upload, but skips the time- |
260 // consuming build from source. | 252 // consuming build from source. |
261 // TODO(fwereade) better factor agent/tools such that build logic is | 253 // TODO(fwereade) better factor agent/tools such that build logic is |
262 // exposed and can itself be neatly mocked? | 254 // exposed and can itself be neatly mocked? |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 295 } |
304 continue | 296 continue |
305 } | 297 } |
306 | 298 |
307 // Set up state and environ, and run the command. | 299 // Set up state and environ, and run the command. |
308 cfg, err := s.State.EnvironConfig() | 300 cfg, err := s.State.EnvironConfig() |
309 c.Assert(err, gc.IsNil) | 301 c.Assert(err, gc.IsNil) |
310 toolsDir := c.MkDir() | 302 toolsDir := c.MkDir() |
311 cfg, err = cfg.Apply(map[string]interface{}{ | 303 cfg, err = cfg.Apply(map[string]interface{}{ |
312 "agent-version": test.agentVersion, | 304 "agent-version": test.agentVersion, |
313 "development": test.development, | |
314 "tools-metadata-url": "file://" + toolsDir, | 305 "tools-metadata-url": "file://" + toolsDir, |
315 }) | 306 }) |
316 c.Assert(err, gc.IsNil) | 307 c.Assert(err, gc.IsNil) |
317 err = s.State.SetEnvironConfig(cfg) | 308 err = s.State.SetEnvironConfig(cfg) |
318 c.Assert(err, gc.IsNil) | 309 c.Assert(err, gc.IsNil) |
319 » » versions := make([]version.Binary, len(test.private)) | 310 » » versions := make([]version.Binary, len(test.tools)) |
320 » » for i, v := range test.private { | 311 » » for i, v := range test.tools { |
321 versions[i] = version.MustParseBinary(v) | 312 versions[i] = version.MustParseBinary(v) |
322 | 313 |
323 } | 314 } |
324 envtesting.MustUploadFakeToolsVersions(s.Conn.Environ.Storage(),
versions...) | 315 envtesting.MustUploadFakeToolsVersions(s.Conn.Environ.Storage(),
versions...) |
325 versions = make([]version.Binary, len(test.public)) | |
326 for i, v := range test.public { | |
327 versions[i] = version.MustParseBinary(v) | |
328 } | |
329 stor, err := filestorage.NewFileStorageWriter(toolsDir, "") | 316 stor, err := filestorage.NewFileStorageWriter(toolsDir, "") |
330 c.Assert(err, gc.IsNil) | 317 c.Assert(err, gc.IsNil) |
331 envtesting.MustUploadFakeToolsVersions(stor, versions...) | 318 envtesting.MustUploadFakeToolsVersions(stor, versions...) |
332 err = com.Run(coretesting.Context(c)) | 319 err = com.Run(coretesting.Context(c)) |
333 if test.expectErr != "" { | 320 if test.expectErr != "" { |
334 c.Check(err, gc.ErrorMatches, test.expectErr) | 321 c.Check(err, gc.ErrorMatches, test.expectErr) |
335 continue | 322 continue |
336 } else if !c.Check(err, gc.IsNil) { | 323 } else if !c.Check(err, gc.IsNil) { |
337 continue | 324 continue |
338 } | 325 } |
339 | 326 |
340 // Check expected changes to environ/state. | 327 // Check expected changes to environ/state. |
341 cfg, err = s.State.EnvironConfig() | 328 cfg, err = s.State.EnvironConfig() |
342 c.Check(err, gc.IsNil) | 329 c.Check(err, gc.IsNil) |
343 agentVersion, ok := cfg.AgentVersion() | 330 agentVersion, ok := cfg.AgentVersion() |
344 c.Check(ok, gc.Equals, true) | 331 c.Check(ok, gc.Equals, true) |
345 c.Check(agentVersion, gc.Equals, version.MustParse(test.expectVe
rsion)) | 332 c.Check(agentVersion, gc.Equals, version.MustParse(test.expectVe
rsion)) |
346 c.Check(cfg.Development(), gc.Equals, test.development) | |
347 | 333 |
348 for _, uploaded := range test.expectUploaded { | 334 for _, uploaded := range test.expectUploaded { |
349 vers := version.MustParseBinary(uploaded) | 335 vers := version.MustParseBinary(uploaded) |
350 r, err := storage.Get(s.Conn.Environ.Storage(), envtools
.StorageName(vers)) | 336 r, err := storage.Get(s.Conn.Environ.Storage(), envtools
.StorageName(vers)) |
351 if !c.Check(err, gc.IsNil) { | 337 if !c.Check(err, gc.IsNil) { |
352 continue | 338 continue |
353 } | 339 } |
354 data, err := ioutil.ReadAll(r) | 340 data, err := ioutil.ReadAll(r) |
355 r.Close() | 341 r.Close() |
356 c.Check(err, gc.IsNil) | 342 c.Check(err, gc.IsNil) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *gc.C) { | 392 func (s *UpgradeJujuSuite) TestUpgradeJujuWithRealUpload(c *gc.C) { |
407 s.Reset(c) | 393 s.Reset(c) |
408 _, err := coretesting.RunCommand(c, &UpgradeJujuCommand{}, []string{"--u
pload-tools"}) | 394 _, err := coretesting.RunCommand(c, &UpgradeJujuCommand{}, []string{"--u
pload-tools"}) |
409 c.Assert(err, gc.IsNil) | 395 c.Assert(err, gc.IsNil) |
410 vers := version.Current | 396 vers := version.Current |
411 vers.Build = 1 | 397 vers.Build = 1 |
412 tools, err := envtools.FindInstanceTools(s.Conn.Environ, vers.Number, ve
rs.Series, &vers.Arch) | 398 tools, err := envtools.FindInstanceTools(s.Conn.Environ, vers.Number, ve
rs.Series, &vers.Arch) |
413 c.Assert(err, gc.IsNil) | 399 c.Assert(err, gc.IsNil) |
414 c.Assert(len(tools), gc.Equals, 1) | 400 c.Assert(len(tools), gc.Equals, 1) |
415 } | 401 } |
OLD | NEW |