Merge lp:~rvb/gomaasapi/record-node-acquire into lp:gomaasapi

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: 44
Merged at revision: 42
Proposed branch: lp:~rvb/gomaasapi/record-node-acquire
Merge into: lp:gomaasapi
Diff against target: 55 lines (+29/-2)
2 files modified
testservice.go (+4/-2)
testservice_test.go (+25/-0)
To merge this branch: bzr merge lp:~rvb/gomaasapi/record-node-acquire
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+159404@code.launchpad.net

Commit message

Record acquire operation.

Description of the change

This is required to test that the constraints are passed correctly in the MAAS provider in juju-core.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

Thanks for the review. I'm waiting a bit to land this because this will break juju-core's tests until https://codereview.appspot.com/8842045/ is landed. Sigh.

Revision history for this message
MAAS Lander (maas-lander) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/maas-merger-gomaasapi-trunk/34/console reported an error when processing this lp:~rvb/gomaasapi/record-node-acquire branch.
Not merging it.

Revision history for this message
MAAS Lander (maas-lander) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/maas-merger-gomaasapi-trunk/35/console reported an error when processing this lp:~rvb/gomaasapi/record-node-acquire branch.
Not merging it.

Revision history for this message
Raphaël Badin (rvb) wrote :

\o/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testservice.go'
2--- testservice.go 2013-04-12 13:11:35 +0000
3+++ testservice.go 2013-04-18 07:05:29 +0000
4@@ -341,11 +341,13 @@
5 if node == nil {
6 w.WriteHeader(http.StatusConflict)
7 } else {
8- systemID, err := node.GetField("system_id")
9+ systemId, err := node.GetField("system_id")
10 checkError(err)
11- server.OwnedNodes()[systemID] = true
12+ server.OwnedNodes()[systemId] = true
13 res, err := json.Marshal(node)
14 checkError(err)
15+ // Record operation.
16+ server.addNodeOperation(systemId, "acquire", r)
17 w.WriteHeader(http.StatusOK)
18 fmt.Fprint(w, string(res))
19 }
20
21=== modified file 'testservice_test.go'
22--- testservice_test.go 2013-04-11 07:21:07 +0000
23+++ testservice_test.go 2013-04-18 07:05:29 +0000
24@@ -459,6 +459,31 @@
25 c.Check(operations, DeepEquals, []string{"start"})
26 }
27
28+func (suite *TestMAASObjectSuite) TestAcquireOperationGetsRecorded(c *C) {
29+ input := `{"system_id": "mysystemid"}`
30+ suite.TestMAASObject.TestServer.NewNode(input)
31+ nodesObj := suite.TestMAASObject.GetSubObject("nodes/")
32+ params := url.Values{"key": []string{"value"}}
33+
34+ jsonResponse, err := nodesObj.CallPost("acquire", params)
35+ c.Assert(err, IsNil)
36+ acquiredNode, err := jsonResponse.GetMAASObject()
37+ c.Assert(err, IsNil)
38+ systemId, err := acquiredNode.GetField("system_id")
39+ c.Assert(err, IsNil)
40+
41+ // The 'acquire' operation has been recorded.
42+ nodeOperations := suite.TestMAASObject.TestServer.NodeOperations()
43+ operations := nodeOperations[systemId]
44+ c.Check(operations, DeepEquals, []string{"acquire"})
45+
46+ // The parameters used to 'acquire' the node have been recorded as well.
47+ values := suite.TestMAASObject.TestServer.NodeOperationRequestValues()
48+ value := values[systemId]
49+ c.Check(len(value), Equals, 1)
50+ c.Check(value[0], DeepEquals, params)
51+}
52+
53 func (suite *TestMAASObjectSuite) TestUploadFile(c *C) {
54 const filename = "myfile.txt"
55 const fileContent = "uploaded contents"

Subscribers

People subscribed via source and target branches

to all changes: