Merge lp:~axwalk/juju-core/lp1266748-state-environment-isalive-1.16 into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2191 |
Proposed branch: | lp:~axwalk/juju-core/lp1266748-state-environment-isalive-1.16 |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
102 lines (+79/-2) 2 files modified
state/compat_test.go (+68/-0) state/environ.go (+11/-2) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1266748-state-environment-isalive-1.16 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+200759@code.launchpad.net |
Commit message
state: fix Environ life assertion to handle null
If the life field is missing, it should be
considered Alive.
Fixes #1266748
Description of the change
state: fix Environ life assertion to handle null
If the life field is missing, it should be
considered Alive.
Fixes #1266748
To post a comment you must log in.
Reviewers: mp+200759_ code.launchpad. net,
Message:
Please take a look.
Description:
state: fix Environ life assertion to handle null
If the life field is missing, it should be
considered Alive.
Fixes #1266748
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1266748- state-environme nt-isalive- 1.16/+merge/ 200759
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/48670045/
Affected files (+81, -2 lines): test.go
A [revision details]
A state/compat_
M state/environ.go
Index: [revision details] 20140106181553- 6uzfea71izl68d4 l
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: state/compat_ test.go compat_ test.go' test.go 1970-01-01 00:00:00 +0000 test.go 2014-01-08 02:46:32 +0000 org/v2/ mgo/txn" net/gocheck" net/juju- core/testing" net/juju- core/testing/ testbase" LoggingSuite &compatSuite{ }) SetUpSuite( c) SetUpSuite( c) TearDownSuite( c) TearDownSuite( c) SetUpTest( c) SetUpTest( c) ze(c, nil) Environment( ) TearDownTest( c) TearDownTest( c) rtAlive( c *gc.C) { environments. Name, runTransaction( ops) runTransaction( []txn.Op{ s.env.assertAli veOp()} )
=== added file 'state/
--- state/compat_
+++ state/compat_
@@ -0,0 +1,68 @@
+// Copyright 2014 Canonical Ltd.
+// Licensed under the AGPLv3, see LICENCE file for details.
+
+package state
+
+import (
+ "labix.
+ gc "launchpad.
+
+ "launchpad.
+ "launchpad.
+)
+
+// compatSuite contains backwards compatibility tests,
+// for ensuring state operations behave correctly across
+// schema changes.
+type compatSuite struct {
+ testbase.
+ testing.MgoSuite
+ state *State
+ env *Environment
+}
+
+var _ = gc.Suite(
+
+func (s *compatSuite) SetUpSuite(c *gc.C) {
+ s.LoggingSuite.
+ s.MgoSuite.
+}
+
+func (s *compatSuite) TearDownSuite(c *gc.C) {
+ s.MgoSuite.
+ s.LoggingSuite.
+}
+
+func (s *compatSuite) SetUpTest(c *gc.C) {
+ s.LoggingSuite.
+ s.MgoSuite.
+ s.state = TestingInitiali
+ env, err := s.state.
+ c.Assert(err, gc.IsNil)
+ s.env = env
+}
+
+func (s *compatSuite) TearDownTest(c *gc.C) {
+ s.state.Close()
+ s.MgoSuite.
+ s.LoggingSuite.
+}
+
+func (s *compatSuite) TestEnvironAsse
+ // 1.17+ has a "Life" field in environment documents.
+ // We remove it here, to test 1.16 compatibility.
+ ops := []txn.Op{{
+ C: s.state.
+ Id: s.env.doc.UUID,
+ Update: D{{"$unset", D{{"life", Dying}}}},
+ }}
+ err := s.state.
+ c.Assert(err, gc.IsNil)
+
+ // Now check the assertAliveOp and Destroy work as if
+ // the environment is Alive.
+ err = s.state.
+ c.Assert(err, gc.IsNil)
+ err = s.env.Destroy()
+ c.Assert(err, gc.IsNil)
+}
Index: state/environ.go ts.Name, Op("services" , "")} tion(ops)
=== modified file 'state/environ.go'
--- state/environ.go 2013-12-11 08:50:47 +0000
+++ state/environ.go 2014-01-08 02:46:32 +0000
@@ -98,7 +98,7 @@
C: e.st.environmen
Id: e.doc.UUID,
Update: D{{"$set", D{{"life", Dying}}}},
- Assert: isAliveDoc,
+ Assert: isEnvAliveDoc,
}, e.st.newCleanup
err := e.st.runTransac
switch err {
@@ -130,6 +130,15 @@
return txn...