Skip to content

Commit

Permalink
Fix how default app constraint it set
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Jun 10, 2021
1 parent 40b9026 commit 87bcd18
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 187 deletions.
10 changes: 5 additions & 5 deletions apiserver/facades/client/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (s *applicationSuite) TestApplicationDeployWithStorage(c *gc.C) {
},
}

cons := constraints.MustParse("arch=amd64")
var cons constraints.Value
args := params.ApplicationDeploy{
ApplicationName: "application",
CharmURL: curl.String(),
Expand Down Expand Up @@ -485,7 +485,7 @@ func (s *applicationSuite) TestApplicationDeployDefaultFilesystemStorage(c *gc.C
URL: curl.String(),
}, s.openRepo)
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=amd64")
var cons constraints.Value
args := params.ApplicationDeploy{
ApplicationName: "application",
CharmURL: curl.String(),
Expand Down Expand Up @@ -518,7 +518,7 @@ func (s *applicationSuite) TestApplicationDeploy(c *gc.C) {
URL: curl.String(),
}, s.openRepo)
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=amd64")
var cons constraints.Value
args := params.ApplicationDeploy{
ApplicationName: "application",
CharmURL: curl.String(),
Expand Down Expand Up @@ -684,7 +684,7 @@ func (s *applicationSuite) TestApplicationDeploymentWithTrust(c *gc.C) {
URL: curl.String(),
}, s.openRepo)
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=amd64")
var cons constraints.Value
config := map[string]string{"trust": "true"}
args := params.ApplicationDeploy{
ApplicationName: "application",
Expand Down Expand Up @@ -722,7 +722,7 @@ func (s *applicationSuite) TestApplicationDeploymentNoTrust(c *gc.C) {
URL: curl.String(),
}, s.openRepo)
c.Assert(err, jc.ErrorIsNil)
cons := constraints.MustParse("arch=amd64")
var cons constraints.Value
args := params.ApplicationDeploy{
ApplicationName: "application",
CharmURL: curl.String(),
Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/client/application/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *DeployLocalSuite) TestDeployMinimal(c *gc.C) {
s.assertCharm(c, app, s.charm.URL())
s.assertSettings(c, app, charm.Settings{})
s.assertApplicationConfig(c, app, coreapplication.ConfigAttributes(nil))
s.assertConstraints(c, app, constraints.MustParse("arch=amd64"))
s.assertConstraints(c, app, constraints.Value{})
s.assertMachines(c, app, constraints.Value{})
}

Expand Down Expand Up @@ -306,7 +306,7 @@ func (s *DeployLocalSuite) TestDeployWithApplicationConfig(c *gc.C) {
func (s *DeployLocalSuite) TestDeployConstraints(c *gc.C) {
err := s.State.SetModelConstraints(constraints.MustParse("mem=2G"))
c.Assert(err, jc.ErrorIsNil)
applicationCons := constraints.MustParse("arch=amd64 cores=2")
applicationCons := constraints.MustParse("cores=2")
app, err := application.DeployApplication(stateDeployer{s.State},
application.DeployApplicationParams{
ApplicationName: "bob",
Expand Down
8 changes: 2 additions & 6 deletions apiserver/facades/client/application/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func (s *getSuite) TestClientApplicationGetSmokeTestV4(c *gc.C) {
c.Assert(results, gc.DeepEquals, params.ApplicationGetResults{
Application: "wordpress",
Charm: "wordpress",
Constraints: constraints.MustParse("arch=amd64"),
CharmConfig: map[string]interface{}{
"blog-title": map[string]interface{}{
"default": true,
Expand Down Expand Up @@ -129,7 +128,6 @@ func (s *getSuite) TestClientApplicationGetSmokeTestV5(c *gc.C) {
c.Assert(results, gc.DeepEquals, params.ApplicationGetResults{
Application: "wordpress",
Charm: "wordpress",
Constraints: constraints.MustParse("arch=amd64"),
CharmConfig: map[string]interface{}{
"blog-title": map[string]interface{}{
"default": "My Title",
Expand All @@ -151,7 +149,6 @@ func (s *getSuite) TestClientApplicationGetIAASModelSmokeTest(c *gc.C) {
c.Assert(results, jc.DeepEquals, params.ApplicationGetResults{
Application: "wordpress",
Charm: "wordpress",
Constraints: constraints.MustParse("arch=amd64"),
CharmConfig: map[string]interface{}{
"blog-title": map[string]interface{}{
"default": "My Title",
Expand Down Expand Up @@ -359,9 +356,8 @@ var getTests = []struct {
},
},
}, {
about: "deployed application #2",
charm: "dummy",
constraints: "arch=amd64",
about: "deployed application #2",
charm: "dummy",
config: charm.Settings{
// Set title to default.
"title": nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
)

func AssertPrincipalApplicationDeployed(c *gc.C, st *state.State, applicationName string, curl *charm.URL, forced bool, bundle charm.Charm, cons constraints.Value) *state.Application {
service, err := st.Application(applicationName)
app, err := st.Application(applicationName)
c.Assert(err, jc.ErrorIsNil)
charm, force, err := service.Charm()
charm, force, err := app.Charm()
c.Assert(err, jc.ErrorIsNil)
c.Assert(force, gc.Equals, forced)
c.Assert(charm.URL(), gc.DeepEquals, curl)
Expand All @@ -33,12 +33,12 @@ func AssertPrincipalApplicationDeployed(c *gc.C, st *state.State, applicationNam
c.Assert(charm.Meta(), jc.DeepEquals, bundle.Meta())
c.Assert(charm.Config(), jc.DeepEquals, bundle.Config())

serviceCons, err := service.Constraints()
appCons, err := app.Constraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(serviceCons, gc.DeepEquals, cons)
c.Assert(appCons, gc.DeepEquals, cons)

for a := coretesting.LongAttempt.Start(); a.Next(); {
units, err := service.AllUnits()
units, err := app.AllUnits()
c.Assert(err, jc.ErrorIsNil)
for _, unit := range units {
mid, err := unit.AssignedMachineId()
Expand All @@ -55,5 +55,5 @@ func AssertPrincipalApplicationDeployed(c *gc.C, st *state.State, applicationNam
}
break
}
return service
return app
}
94 changes: 33 additions & 61 deletions cmd/juju/application/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,12 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleEndpointBindingsSuccess(c

s.assertApplicationsDeployed(c, map[string]applicationInfo{
"mysql": {
charm: "cs:xenial/mysql-42",
config: mysqlch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/mysql-42",
config: mysqlch.Config().DefaultSettings(),
},
"wordpress-extra-bindings": {
charm: "cs:xenial/wordpress-extra-bindings-47",
config: wpch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/wordpress-extra-bindings-47",
config: wpch.Config().DefaultSettings(),
},
})
s.assertDeployedApplicationBindings(c, map[string]applicationInfo{
Expand Down Expand Up @@ -216,14 +214,10 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleTwice(c *gc.C) {
stdOut, stdErr, err = s.runDeployWithOutput(c, "cs:bundle/wordpress-simple")
c.Assert(err, jc.ErrorIsNil)
// Nothing to do... not quite...
c.Check(stdOut, gc.Equals, ""+
"Executing changes:\n"+
"- set constraints for mysql to \"\"\n"+
"- set constraints for wordpress to \"\"",
)
c.Check(stdOut, gc.Equals, "")
c.Check(stdErr, gc.Equals, ""+
"Located bundle \"wordpress-simple\" in charm-store, revision 1\n"+
"Deploy of bundle completed.",
"No changes to apply.",
)

s.assertCharmsUploaded(c, "cs:xenial/mysql-42", "cs:xenial/wordpress-47")
Expand Down Expand Up @@ -289,9 +283,8 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleLocalPath(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"dummy": {
charm: "local:xenial/dummy-1",
config: ch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "local:xenial/dummy-1",
config: ch.Config().DefaultSettings(),
},
})
}
Expand Down Expand Up @@ -332,9 +325,8 @@ func (s *BundleDeployCharmStoreSuite) assertDeployBundleLocalPathInvalidSeriesWi
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"dummy": {
charm: "local:quantal/dummy-1",
config: ch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "local:quantal/dummy-1",
config: ch.Config().DefaultSettings(),
},
})
}
Expand Down Expand Up @@ -362,9 +354,8 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleLocalResources(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"dummy-resource": {
charm: "local:bionic/dummy-resource-0",
config: ch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "local:bionic/dummy-resource-0",
config: ch.Config().DefaultSettings(),
},
})
}
Expand All @@ -389,9 +380,8 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleNoSeriesInCharmURL(c *gc.C
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"dummy": {
charm: "cs:~who/multi-series-0",
config: ch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:~who/multi-series-0",
config: ch.Config().DefaultSettings(),
},
})
}
Expand Down Expand Up @@ -764,9 +754,8 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleLocalDeploymentLXDProfile(
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"lxd-profile": {
charm: "local:bionic/lxd-profile-0",
config: lxdProfile.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "local:bionic/lxd-profile-0",
config: lxdProfile.Config().DefaultSettings(),
},
})
s.assertUnitsCreated(c, map[string]string{
Expand Down Expand Up @@ -888,14 +877,12 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleLocalAndCharmStoreCharms(c
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"mysql": {
charm: "local:xenial/mysql-1",
config: mysqlch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "local:xenial/mysql-1",
config: mysqlch.Config().DefaultSettings(),
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
config: wpch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/wordpress-42",
config: wpch.Config().DefaultSettings(),
},
})
s.assertRelationsEstablished(c, "wordpress:db mysql:server")
Expand Down Expand Up @@ -926,14 +913,12 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationOptions(c *gc.C
s.assertCharmsUploaded(c, "cs:bionic/dummy-0", "cs:xenial/wordpress-42")
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"customized": {
charm: "cs:bionic/dummy-0",
config: s.combinedSettings(dch, charm.Settings{"username": "who", "skill-level": int64(47)}),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:bionic/dummy-0",
config: s.combinedSettings(dch, charm.Settings{"username": "who", "skill-level": int64(47)}),
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
config: s.combinedSettings(wpch, charm.Settings{"blog-title": "these are the voyages"}),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/wordpress-42",
config: s.combinedSettings(wpch, charm.Settings{"blog-title": "these are the voyages"}),
},
})
s.assertUnitsCreated(c, map[string]string{
Expand Down Expand Up @@ -966,7 +951,7 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationDefaultArchCons
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
constraints: constraints.MustParse("arch=amd64 mem=4G cores=2"),
constraints: constraints.MustParse("mem=4G cores=2"),
config: wpch.Config().DefaultSettings(),
},
})
Expand Down Expand Up @@ -999,7 +984,7 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationConstraints(c *
},
"wordpress": {
charm: "cs:xenial/wordpress-42",
constraints: constraints.MustParse("arch=amd64 mem=4G cores=2"),
constraints: constraints.MustParse("mem=4G cores=2"),
config: wpch.Config().DefaultSettings(),
},
})
Expand Down Expand Up @@ -1069,7 +1054,6 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleApplicationUpgrade(c *gc.C
"Executing changes:\n"+
"- upload charm upgrade from charm-store for series trusty with architecture=amd64\n"+
"- upgrade up from charm-store using charm upgrade for series trusty\n"+
"- set constraints for up to \"mem=8G\"\n"+
"- set application options for wordpress\n"+
`- set constraints for wordpress to "spaces=new cores=8"`,
)
Expand Down Expand Up @@ -1150,9 +1134,6 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleNewRelations(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Assert(stdOut, gc.Equals, ""+
"Executing changes:\n"+
"- set constraints for mysql to \"\"\n"+
"- set constraints for varnish to \"\"\n"+
"- set constraints for wp to \"\"\n"+
"- add relation varnish:webcache - wp:cache",
)
s.assertRelationsEstablished(c, "wp:db mysql:server", "wp:cache varnish:webcache")
Expand Down Expand Up @@ -1192,14 +1173,12 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleMachinesUnitsPlacement(c *
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"sql": {
charm: "cs:xenial/mysql-2",
config: mysqlch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/mysql-2",
config: mysqlch.Config().DefaultSettings(),
},
"wp": {
charm: "cs:xenial/wordpress-0",
config: s.combinedSettings(wpch, charm.Settings{"blog-title": "these are the voyages"}),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/wordpress-0",
config: s.combinedSettings(wpch, charm.Settings{"blog-title": "these are the voyages"}),
},
})
s.assertRelationsEstablished(c)
Expand Down Expand Up @@ -1297,9 +1276,8 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleMachineAttributes(c *gc.C)
c.Assert(err, jc.ErrorIsNil)
s.assertApplicationsDeployed(c, map[string]applicationInfo{
"django": {
charm: "cs:xenial/django-42",
config: ch.Config().DefaultSettings(),
constraints: constraints.MustParse("arch=amd64"),
charm: "cs:xenial/django-42",
config: ch.Config().DefaultSettings(),
},
})
s.assertRelationsEstablished(c)
Expand Down Expand Up @@ -1486,7 +1464,6 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleSwitch(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
c.Check(stdOut, gc.Equals, ""+
"Executing changes:\n"+
"- set constraints for django to \"\"\n"+
"- deploy application node from charm-store on bionic using django\n"+
"- add unit node/0 to new machine 2",
)
Expand Down Expand Up @@ -1569,19 +1546,14 @@ func (s *BundleDeployCharmStoreSuite) TestDeployBundleMassiveUnitColocation(c *g
c.Assert(err, jc.ErrorIsNil)
c.Check(stdOut, gc.Equals, ""+
"Executing changes:\n"+
"- set constraints for django to \"\"\n"+
"- set constraints for memcached to \"\"\n"+
"- deploy application node from charm-store on bionic using django\n"+
"- add unit node/0 to 0/lxd/0 to satisfy [lxd:memcached]",
)

// Redeploy the same bundle again and check that nothing happens.
stdOut, _, err = s.DeployBundleYAMLWithOutput(c, content)
c.Assert(err, jc.ErrorIsNil)
c.Assert(stdOut, gc.Equals, ""+
"Executing changes:\n"+
"- set constraints for node to \"\"",
)
c.Assert(stdOut, gc.Equals, "")
s.assertUnitsCreated(c, map[string]string{
"django/0": "0",
"django/1": "0/lxd/0",
Expand Down
2 changes: 1 addition & 1 deletion cmd/juju/application/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ func (s *DeploySuite) TestConstraints(c *gc.C) {
app, _ := s.AssertApplication(c, "multi-series", curl, 1, 0)
cons, err := app.Constraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, jc.DeepEquals, constraints.MustParse("arch=amd64 mem=2G cores=2"))
c.Assert(cons, jc.DeepEquals, constraints.MustParse("mem=2G cores=2"))
}

func (s *DeploySuite) TestResources(c *gc.C) {
Expand Down
4 changes: 0 additions & 4 deletions featuretests/cmd_juju_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ func (s *cmdApplicationSuite) TestShowApplicationOne(c *gc.C) {
wordpress:
charm: wordpress
series: quantal
constraints:
arch: amd64
principal: true
exposed: false
remote: false
Expand Down Expand Up @@ -108,8 +106,6 @@ logging:
wordpress:
charm: wordpress
series: quantal
constraints:
arch: amd64
principal: true
exposed: false
remote: false
Expand Down
1 change: 0 additions & 1 deletion featuretests/cmd_juju_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ applications:
logging-directory: alpha
wordpress:
charm: cs:quantal/wordpress-23
constraints: arch=amd64
bindings:
"": alpha
admin-api: alpha
Expand Down
Loading

0 comments on commit 87bcd18

Please sign in to comment.