Skip to content

Commit 3a8db2d

Browse files
author
nam
committed
acceptancetest fix: use smaller charm, make sure that we wait for the status output first
1 parent 55e4215 commit 3a8db2d

File tree

10 files changed

+45
-17
lines changed

10 files changed

+45
-17
lines changed

cmd/juju/application/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (c *configCommand) SetFlags(f *gnuflag.FlagSet) {
126126
f.Var(&c.configFile, "file", "path to yaml-formatted application config")
127127
f.Var(cmd.NewAppendStringsValue(&c.reset), "reset", "Reset the provided comma delimited keys")
128128

129-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
129+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
130130
f.StringVar(&c.branchName, "branch", "", "Specifically target config for the supplied branch")
131131
}
132132
}
@@ -190,7 +190,7 @@ func (c *configCommand) validateGeneration() error {
190190
// during development. When we remove the flag, there will be tests
191191
// (particularly feature tests) that will need to accommodate a value
192192
// for branch in the local store.
193-
if !featureflag.Enabled(feature.Branches) && !featureflag.Enabled(feature.OldBranchesName) && c.branchName == "" {
193+
if !featureflag.Enabled(feature.Branches) && !featureflag.Enabled(feature.Generations) && c.branchName == "" {
194194
c.branchName = model.GenerationMaster
195195
}
196196

@@ -429,7 +429,7 @@ func (c *configCommand) getConfig(client applicationAPI, ctx *cmd.Context) error
429429

430430
err = c.out.Write(ctx, resultsMap)
431431

432-
if (featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName)) && err == nil {
432+
if (featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations)) && err == nil {
433433
var gen string
434434
gen, err = c.ActiveBranch()
435435
if err == nil {

cmd/juju/application/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var getTests = []struct {
106106

107107
func (s *configCommandSuite) SetUpTest(c *gc.C) {
108108
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
109-
s.SetFeatureFlags(feature.Branches)
109+
s.SetFeatureFlags(feature.Generations)
110110

111111
s.defaultCharmValues = map[string]interface{}{
112112
"title": "Nearly There",

cmd/juju/commands/bootstrap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func (c *bootstrapCommand) initializeHostedModel(
502502
ModelType: hostedModelType,
503503
}
504504

505-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
505+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
506506
modelDetails.ActiveBranch = model.GenerationMaster
507507
}
508508

cmd/juju/commands/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func registerCommands(r commandRegistry, ctx *cmd.Context) {
368368
r.Register(model.NewRevokeCommand())
369369
r.Register(model.NewShowCommand())
370370
r.Register(model.NewModelCredentialCommand())
371-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
371+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
372372
r.Register(model.NewAddBranchCommand())
373373
r.Register(model.NewCommitCommand())
374374
r.Register(model.NewTrackBranchCommand())

cmd/juju/controller/addmodel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func (c *addModelCommand) Run(ctx *cmd.Context) error {
255255
ModelUUID: model.UUID,
256256
ModelType: model.Type,
257257
}
258-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
258+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
259259
// Default target is the master branch.
260260
details.ActiveBranch = coremodel.GenerationMaster
261261
}

cmd/juju/controller/addmodel_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,31 @@ func (s *AddModelSuite) TestAddExistingName(c *gc.C) {
219219
})
220220
}
221221

222+
// We support 2 flags for Generations/Branches. This test ensures that either works.
223+
func (s *AddModelSuite) TestAddExistingNameAlternativeFlagName(c *gc.C) {
224+
s.SetFeatureFlags(feature.Generations)
225+
// If there's any model details existing, we just overwrite them. The
226+
// controller will error out if the model already exists. Overwriting
227+
// means we'll replace any stale details from an previously existing
228+
// model with the same name.
229+
err := s.store.UpdateModel("test-master", "bob/test", jujuclient.ModelDetails{
230+
ModelUUID: "stale-uuid",
231+
ModelType: model.IAAS,
232+
})
233+
c.Assert(err, jc.ErrorIsNil)
234+
235+
_, err = s.run(c, "test")
236+
c.Assert(err, jc.ErrorIsNil)
237+
238+
details, err := s.store.ModelByName("test-master", "bob/test")
239+
c.Assert(err, jc.ErrorIsNil)
240+
c.Assert(details, jc.DeepEquals, &jujuclient.ModelDetails{
241+
ModelUUID: "fake-model-uuid",
242+
ModelType: model.IAAS,
243+
ActiveBranch: model.GenerationMaster,
244+
})
245+
}
246+
222247
func (s *AddModelSuite) TestAddModelUnauthorizedMentionsJujuGrant(c *gc.C) {
223248
s.fakeAddModelAPI.err = &params.Error{
224249
Message: "permission denied",

environs/bootstrap/prepare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func prepare(
225225
details.Password = args.AdminSecret
226226
details.LastKnownAccess = string(permission.SuperuserAccess)
227227
details.ModelUUID = cfg.UUID()
228-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
228+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
229229
details.ActiveBranch = model.GenerationMaster
230230
}
231231
details.ControllerDetails.Cloud = args.Cloud.Name

feature/flags.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ const OldPresence = "old-presence"
4848
const LegacyLeases = "legacy-leases"
4949

5050
// Branches will allow for model branches functionality to be used.
51-
// Historically branches feature was called generations.
5251
const Branches = "branches"
5352

54-
// OldBranchesName is the old flag name used for generations feature
55-
const OldBranchesName = "generations"
53+
// Generations will allow for model generation functionality to be used.
54+
// This is a deprecated flag name and is synonymous with "branches" above.
55+
const Generations = "generations"
5656

5757
// MongoDbSnap tells Juju to install MongoDB as a snap, rather than installing
5858
// it from APT.

jujuclient/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func ReadModelsFile(file string) (map[string]*ControllerModels, error) {
4747
if err := addModelType(models); err != nil {
4848
return nil, err
4949
}
50-
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.OldBranchesName) {
50+
if featureflag.Enabled(feature.Branches) || featureflag.Enabled(feature.Generations) {
5151
if err := addGeneration(models); err != nil {
5252
return nil, err
5353
}

tests/suites/branches/active_branch.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ run_indicate_active_branch_no_active() {
66

77
ensure "indicate-active-branch-no-active" "${file}"
88

9-
juju deploy ubuntu
9+
juju deploy cs:~jameinel/ubuntu-lite-7
1010

11-
wait_for "ubuntu" "$(idle_condition "ubuntu")"
11+
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
1212

1313
check_not_contains "$(juju status)" "Branch"
1414

@@ -28,10 +28,10 @@ run_indicate_active_branch_active() {
2828

2929
ensure "indicate-active-branch-active" "${file}"
3030

31-
juju deploy ubuntu
31+
juju deploy cs:~jameinel/ubuntu-lite-7
3232

3333
juju add-branch bla
34-
wait_for "ubuntu" "$(idle_condition "ubuntu")"
34+
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
3535

3636
check_contains "$(juju status)" "bla\*"
3737

@@ -41,7 +41,10 @@ run_indicate_active_branch_active() {
4141
fi
4242

4343
juju add-branch testtest
44-
wait_for "ubuntu" "$(idle_condition "ubuntu")"
44+
wait_for "ubuntu-lite" "$(idle_condition "ubuntu-lite")"
45+
46+
# juju status can be slow, we might need to wait for testtest to appear
47+
wait_for "active" ".branches.testtest"
4548

4649
check_contains "$(juju status)" "testtest\*"
4750
check_not_contains "$(juju status)" "bla\*"

0 commit comments

Comments
 (0)