Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(959)

Unified Diff: provider/maas/environ_whitebox_test.go

Issue 97400043: Change StopInstances to take []instance.Id
Patch Set: Change StopInstances to take []instance.Id Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « provider/maas/environ.go ('k') | provider/maas/util.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: provider/maas/environ_whitebox_test.go
=== modified file 'provider/maas/environ_whitebox_test.go'
--- provider/maas/environ_whitebox_test.go 2014-04-24 12:33:19 +0000
+++ provider/maas/environ_whitebox_test.go 2014-05-14 02:59:53 +0000
@@ -420,24 +420,27 @@
func (suite *environSuite) TestStopInstancesReturnsIfParameterEmpty(c *gc.C) {
suite.getInstance("test1")
- err := suite.makeEnviron().StopInstances([]instance.Instance{})
+ err := suite.makeEnviron().StopInstances()
c.Check(err, gc.IsNil)
operations := suite.testMAASObject.TestServer.NodeOperations()
c.Check(operations, gc.DeepEquals, map[string][]string{})
}
func (suite *environSuite) TestStopInstancesStopsAndReleasesInstances(c *gc.C) {
- instance1 := suite.getInstance("test1")
- instance2 := suite.getInstance("test2")
+ suite.getInstance("test1")
+ suite.getInstance("test2")
suite.getInstance("test3")
- instances := []instance.Instance{instance1, instance2}
-
- err := suite.makeEnviron().StopInstances(instances)
-
+ // mark test1 and test2 as being allocated, but not test3.
+ // The release operation will ignore test3.
+ suite.testMAASObject.TestServer.OwnedNodes()["test1"] = true
+ suite.testMAASObject.TestServer.OwnedNodes()["test2"] = true
+
+ err := suite.makeEnviron().StopInstances("test1", "test2", "test3")
c.Check(err, gc.IsNil)
- operations := suite.testMAASObject.TestServer.NodeOperations()
- expectedOperations := map[string][]string{"test1": {"release"}, "test2": {"release"}}
- c.Check(operations, gc.DeepEquals, expectedOperations)
+ operations := suite.testMAASObject.TestServer.NodesOperations()
+ c.Check(operations, gc.DeepEquals, []string{"release"})
+ c.Assert(suite.testMAASObject.TestServer.OwnedNodes()["test1"], jc.IsFalse)
+ c.Assert(suite.testMAASObject.TestServer.OwnedNodes()["test2"], jc.IsFalse)
}
func (suite *environSuite) TestStateInfo(c *gc.C) {
@@ -472,6 +475,7 @@
func (suite *environSuite) TestDestroy(c *gc.C) {
env := suite.makeEnviron()
suite.getInstance("test1")
+ suite.testMAASObject.TestServer.OwnedNodes()["test1"] = true // simulate acquire
data := makeRandomBytes(10)
suite.testMAASObject.TestServer.NewFile("filename", data)
stor := env.Storage()
@@ -480,9 +484,9 @@
c.Check(err, gc.IsNil)
// Instances have been stopped.
- operations := suite.testMAASObject.TestServer.NodeOperations()
- expectedOperations := map[string][]string{"test1": {"release"}}
- c.Check(operations, gc.DeepEquals, expectedOperations)
+ operations := suite.testMAASObject.TestServer.NodesOperations()
+ c.Check(operations, gc.DeepEquals, []string{"release"})
+ c.Check(suite.testMAASObject.TestServer.OwnedNodes()["test1"], jc.IsFalse)
// Files have been cleaned up.
listing, err := storage.List(stor, "")
c.Assert(err, gc.IsNil)
« no previous file with comments | « provider/maas/environ.go ('k') | provider/maas/util.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b