~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/commands/upgradejuju_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
        args:           []string{"--dev"},
84
84
        expectInitErr:  "flag provided but not defined: --dev",
85
85
}, {
86
 
        about:          "invalid --version value",
 
86
        about:          "invalid --agent-version value",
87
87
        currentVersion: "1.0.0-quantal-amd64",
88
 
        args:           []string{"--version", "invalid-version"},
 
88
        args:           []string{"--agent-version", "invalid-version"},
89
89
        expectInitErr:  "invalid version .*",
90
90
}, {
91
91
        about:          "just major version, no minor specified",
92
92
        currentVersion: "4.2.0-quantal-amd64",
93
 
        args:           []string{"--version", "4"},
 
93
        args:           []string{"--agent-version", "4"},
94
94
        expectInitErr:  `invalid version "4"`,
95
95
}, {
96
96
        about:          "major version upgrade to incompatible version",
97
97
        currentVersion: "2.0.0-quantal-amd64",
98
98
        agentVersion:   "2.0.0",
99
 
        args:           []string{"--version", "5.2.0"},
 
99
        args:           []string{"--agent-version", "5.2.0"},
100
100
        expectErr:      `unknown version "5.2.0"`,
101
101
}, {
102
102
        about:          "major version downgrade to incompatible version",
103
103
        currentVersion: "4.2.0-quantal-amd64",
104
104
        agentVersion:   "4.2.0",
105
 
        args:           []string{"--version", "3.2.0"},
 
105
        args:           []string{"--agent-version", "3.2.0"},
106
106
        expectErr:      "cannot change version from 4.2.0 to 3.2.0",
107
107
}, {
108
108
        about:          "--build-agent with inappropriate version 1",
109
109
        currentVersion: "4.2.0-quantal-amd64",
110
110
        agentVersion:   "4.2.0",
111
 
        args:           []string{"--build-agent", "--version", "3.1.0"},
 
111
        args:           []string{"--build-agent", "--agent-version", "3.1.0"},
112
112
        expectErr:      "cannot change version from 4.2.0 to 3.1.0",
113
113
}, {
114
114
        about:          "--build-agent with inappropriate version 2",
115
115
        currentVersion: "3.2.7-quantal-amd64",
116
 
        args:           []string{"--build-agent", "--version", "3.2.8.4"},
 
116
        args:           []string{"--build-agent", "--agent-version", "3.2.8.4"},
117
117
        expectInitErr:  "cannot specify build number when building an agent",
118
118
}, {
119
119
        about:          "latest supported stable release",
162
162
        tools:          []string{"2.3-dev0-quantal-amd64"},
163
163
        currentVersion: "2.0.0-quantal-amd64",
164
164
        agentVersion:   "2.0.0",
165
 
        args:           []string{"--version", "2.3-dev0"},
 
165
        args:           []string{"--agent-version", "2.3-dev0"},
166
166
        expectVersion:  "2.3-dev0",
167
167
}, {
168
168
        about:          "specified major version",
169
169
        tools:          []string{"3.0.2-quantal-amd64"},
170
170
        currentVersion: "3.0.2-quantal-amd64",
171
171
        agentVersion:   "2.8.2",
172
 
        args:           []string{"--version", "3.0.2"},
173
 
        expectVersion:  "3.0.2.1",
 
172
        args:           []string{"--agent-version", "3.0.2"},
 
173
        expectVersion:  "3.0.2",
174
174
        upgradeMap:     map[int]version.Number{3: version.MustParse("2.8.2")},
175
175
}, {
176
176
        about:          "specified version missing, but already set",
177
177
        currentVersion: "3.0.0-quantal-amd64",
178
178
        agentVersion:   "3.0.0",
179
 
        args:           []string{"--version", "3.0.0"},
 
179
        args:           []string{"--agent-version", "3.0.0"},
180
180
        expectVersion:  "3.0.0",
181
181
}, {
182
182
        about:          "specified version, no tools",
183
183
        currentVersion: "3.0.0-quantal-amd64",
184
184
        agentVersion:   "3.0.0",
185
 
        args:           []string{"--version", "3.2.0"},
 
185
        args:           []string{"--agent-version", "3.2.0"},
186
186
        expectErr:      "no tools available",
187
187
}, {
188
188
        about:          "specified version, no matching major version",
189
189
        tools:          []string{"4.2.0-quantal-amd64"},
190
190
        currentVersion: "3.0.0-quantal-amd64",
191
191
        agentVersion:   "3.0.0",
192
 
        args:           []string{"--version", "3.2.0"},
 
192
        args:           []string{"--agent-version", "3.2.0"},
193
193
        expectErr:      "no matching tools available",
194
194
}, {
195
195
        about:          "specified version, no matching minor version",
196
196
        tools:          []string{"3.4.0-quantal-amd64"},
197
197
        currentVersion: "3.0.0-quantal-amd64",
198
198
        agentVersion:   "3.0.0",
199
 
        args:           []string{"--version", "3.2.0"},
 
199
        args:           []string{"--agent-version", "3.2.0"},
200
200
        expectErr:      "no matching tools available",
201
201
}, {
202
202
        about:          "specified version, no matching patch version",
203
203
        tools:          []string{"3.2.5-quantal-amd64"},
204
204
        currentVersion: "3.0.0-quantal-amd64",
205
205
        agentVersion:   "3.0.0",
206
 
        args:           []string{"--version", "3.2.0"},
 
206
        args:           []string{"--agent-version", "3.2.0"},
207
207
        expectErr:      "no matching tools available",
208
208
}, {
209
209
        about:          "specified version, no matching build version",
210
210
        tools:          []string{"3.2.0.2-quantal-amd64"},
211
211
        currentVersion: "3.0.0-quantal-amd64",
212
212
        agentVersion:   "3.0.0",
213
 
        args:           []string{"--version", "3.2.0"},
 
213
        args:           []string{"--agent-version", "3.2.0"},
214
214
        expectErr:      "no matching tools available",
215
215
}, {
216
216
        about:          "incompatible version (minor != 0)",
217
217
        tools:          []string{"3.2.0-quantal-amd64"},
218
218
        currentVersion: "4.2.0-quantal-amd64",
219
219
        agentVersion:   "3.2.0",
220
 
        args:           []string{"--version", "3.2.0"},
 
220
        args:           []string{"--agent-version", "3.2.0"},
221
221
        expectErr:      "cannot upgrade a 3.2.0 model with a 4.2.0 client",
222
222
}, {
223
223
        about:          "incompatible version (model major > client major)",
224
224
        tools:          []string{"3.2.0-quantal-amd64"},
225
225
        currentVersion: "3.2.0-quantal-amd64",
226
226
        agentVersion:   "4.2.0",
227
 
        args:           []string{"--version", "3.2.0"},
 
227
        args:           []string{"--agent-version", "3.2.0"},
228
228
        expectErr:      "cannot upgrade a 4.2.0 model with a 3.2.0 client",
229
229
}, {
230
230
        about:          "incompatible version (model major < client major - 1)",
231
231
        tools:          []string{"3.2.0-quantal-amd64"},
232
232
        currentVersion: "4.0.2-quantal-amd64",
233
233
        agentVersion:   "2.0.0",
234
 
        args:           []string{"--version", "3.2.0"},
 
234
        args:           []string{"--agent-version", "3.2.0"},
235
235
        expectErr:      "cannot upgrade a 2.0.0 model with a 4.0.2 client",
236
236
}, {
237
237
        about:          "minor version downgrade to incompatible version",
238
238
        tools:          []string{"3.2.0-quantal-amd64"},
239
239
        currentVersion: "3.2.0-quantal-amd64",
240
240
        agentVersion:   "3.3-dev0",
241
 
        args:           []string{"--version", "3.2.0"},
 
241
        args:           []string{"--agent-version", "3.2.0"},
242
242
        expectErr:      "cannot change version from 3.3-dev0 to 3.2.0",
243
243
}, {
244
244
        about:          "nothing available",
262
262
        about:          "upload with explicit version",
263
263
        currentVersion: "2.2.0-quantal-amd64",
264
264
        agentVersion:   "2.0.0",
265
 
        args:           []string{"--build-agent", "--version", "2.7.3"},
 
265
        args:           []string{"--build-agent", "--agent-version", "2.7.3"},
266
266
        expectVersion:  "2.7.3.1",
267
267
        expectUploaded: []string{"2.7.3.1-quantal-amd64", "2.7.3.1-%LTS%-amd64", "2.7.3.1-raring-amd64"},
268
268
}, {
293
293
        currentVersion: "2.2.0-quantal-amd64",
294
294
        tools:          []string{"2.7.3.1-quantal-amd64"},
295
295
        agentVersion:   "2.0.0",
296
 
        args:           []string{"--build-agent", "--version", "2.7.3"},
 
296
        args:           []string{"--build-agent", "--agent-version", "2.7.3"},
297
297
        expectVersion:  "2.7.3.2",
298
298
        expectUploaded: []string{"2.7.3.2-quantal-amd64", "2.7.3.2-%LTS%-amd64", "2.7.3.2-raring-amd64"},
299
299
}, {
526
526
        // Block operation
527
527
        s.BlockAllChanges(c, "TestBlockUpgradeJujuWithRealUpload")
528
528
        _, err := coretesting.RunCommand(c, cmd, "--build-agent")
529
 
        s.AssertBlocked(c, err, ".*TestBlockUpgradeJujuWithRealUpload.*")
 
529
        coretesting.AssertOperationWasBlocked(c, err, ".*TestBlockUpgradeJujuWithRealUpload.*")
530
530
}
531
531
 
532
532
func (s *UpgradeJujuSuite) TestFailUploadOnNonController(c *gc.C) {
565
565
                        currentVersion: "2.1.3-quantal-amd64",
566
566
                        agentVersion:   "2.0.0",
567
567
                        expectedCmdOutput: `upgrade to this version by running
568
 
    juju upgrade-juju --version="2.1.3"
 
568
    juju upgrade-juju --agent-version="2.1.3"
569
569
`,
570
570
                },
571
571
                {
575
575
                        currentVersion: "2.0.0-quantal-amd64",
576
576
                        agentVersion:   "2.0.0",
577
577
                        expectedCmdOutput: `upgrade to this version by running
578
 
    juju upgrade-juju --version="2.1.3"
 
578
    juju upgrade-juju --agent-version="2.1.3"
579
579
`,
580
580
                },
581
581
                {
585
585
                        currentVersion: "2.0.0-quantal-amd64",
586
586
                        agentVersion:   "2.0.0",
587
587
                        expectedCmdOutput: `upgrade to this version by running
588
 
    juju upgrade-juju --version="2.1.3"
 
588
    juju upgrade-juju --agent-version="2.1.3"
589
589
`,
590
590
                },
591
591
        }
670
670
                agentVersion:    "4.8.5",
671
671
                expectedVersion: "4.9.0",
672
672
        }, {
673
 
                about:           "upgrade previous major to latest previous major with --version",
674
 
                cmdArgs:         []string{"--version=4.9.0"},
 
673
                about:           "upgrade previous major to latest previous major with --agent-version",
 
674
                cmdArgs:         []string{"--agent-version=4.9.0"},
675
675
                tools:           []string{"5.0.2-trusty-amd64", "4.9.0-trusty-amd64", "4.8.0-trusty-amd64"},
676
676
                currentVersion:  "5.0.2-trusty-amd64",
677
677
                agentVersion:    "4.7.5",
678
678
                expectedVersion: "4.9.0",
679
679
        }, {
680
680
                about:             "can upgrade lower major version to current major version at minimum level",
681
 
                cmdArgs:           []string{"--version=6.0.5"},
 
681
                cmdArgs:           []string{"--agent-version=6.0.5"},
682
682
                tools:             []string{"6.0.5-trusty-amd64", "5.9.9-trusty-amd64"},
683
683
                currentVersion:    "6.0.0-trusty-amd64",
684
684
                agentVersion:      "5.9.8",
685
 
                expectedVersion:   "6.0.5.1",
 
685
                expectedVersion:   "6.0.5",
686
686
                excludedLogOutput: `incompatible with this client (6.0.0)`,
687
687
                upgradeMap:        map[int]version.Number{6: version.MustParse("5.9.8")},
688
688
        }, {
689
689
                about:             "can upgrade lower major version to current major version above minimum level",
690
 
                cmdArgs:           []string{"--version=6.0.5"},
 
690
                cmdArgs:           []string{"--agent-version=6.0.5"},
691
691
                tools:             []string{"6.0.5-trusty-amd64", "5.11.0-trusty-amd64"},
692
692
                currentVersion:    "6.0.1-trusty-amd64",
693
693
                agentVersion:      "5.10.8",
694
 
                expectedVersion:   "6.0.5.1",
 
694
                expectedVersion:   "6.0.5",
695
695
                excludedLogOutput: `incompatible with this client (6.0.1)`,
696
696
                upgradeMap:        map[int]version.Number{6: version.MustParse("5.9.8")},
697
697
        }, {
698
698
                about:           "can upgrade current to next major version",
699
 
                cmdArgs:         []string{"--version=6.0.5"},
 
699
                cmdArgs:         []string{"--agent-version=6.0.5"},
700
700
                tools:           []string{"6.0.5-trusty-amd64", "5.11.0-trusty-amd64"},
701
701
                currentVersion:  "5.10.8-trusty-amd64",
702
702
                agentVersion:    "5.10.8",
704
704
                upgradeMap:      map[int]version.Number{6: version.MustParse("5.9.8")},
705
705
        }, {
706
706
                about:             "upgrade fails if not at minimum version",
707
 
                cmdArgs:           []string{"--version=7.0.1"},
 
707
                cmdArgs:           []string{"--agent-version=7.0.1"},
708
708
                tools:             []string{"7.0.1-trusty-amd64"},
709
709
                currentVersion:    "7.0.1-trusty-amd64",
710
710
                agentVersion:      "6.0.0",
714
714
                upgradeMap:        map[int]version.Number{7: version.MustParse("6.7.8")},
715
715
        }, {
716
716
                about:             "upgrade fails if not a minor of 0",
717
 
                cmdArgs:           []string{"--version=7.1.1"},
 
717
                cmdArgs:           []string{"--agent-version=7.1.1"},
718
718
                tools:             []string{"7.0.1-trusty-amd64", "7.1.1-trusty-amd64"},
719
719
                currentVersion:    "7.0.1-trusty-amd64",
720
720
                agentVersion:      "6.7.8",
724
724
                upgradeMap:        map[int]version.Number{7: version.MustParse("6.7.8")},
725
725
        }, {
726
726
                about:           "upgrade fails if not at minimum version and not a minor of 0",
727
 
                cmdArgs:         []string{"--version=7.1.1"},
 
727
                cmdArgs:         []string{"--agent-version=7.1.1"},
728
728
                tools:           []string{"7.0.1-trusty-amd64", "7.1.1-trusty-amd64"},
729
729
                currentVersion:  "7.0.1-trusty-amd64",
730
730
                agentVersion:    "6.0.0",