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

Delta Between Two Patch Sets: state/apiserver/server_test.go

Issue 9738043: cmd/jujud: do not change password
Left Patch Set: cmd/jujud: do not change password Created 11 years, 9 months ago
Right Patch Set: cmd/jujud: do not change password Created 11 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « state/apiserver/root.go ('k') | state/conn_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package apiserver_test 4 package apiserver_test
5 5
6 import ( 6 import (
7 "io" 7 "io"
8 . "launchpad.net/gocheck" 8 . "launchpad.net/gocheck"
9 "launchpad.net/juju-core/rpc" 9 "launchpad.net/juju-core/rpc"
10 "launchpad.net/juju-core/state" 10 "launchpad.net/juju-core/state"
11 "launchpad.net/juju-core/state/api" 11 "launchpad.net/juju-core/state/api"
12 "launchpad.net/juju-core/state/apiserver" 12 "launchpad.net/juju-core/state/apiserver"
13 coretesting "launchpad.net/juju-core/testing" 13 coretesting "launchpad.net/juju-core/testing"
14 ) 14 )
15
16 var fastDialOpts = api.DialOpts{}
15 17
16 type serverSuite struct { 18 type serverSuite struct {
17 baseSuite 19 baseSuite
18 } 20 }
19 21
20 var _ = Suite(&serverSuite{}) 22 var _ = Suite(&serverSuite{})
21 23
22 func (s *serverSuite) TestStop(c *C) { 24 func (s *serverSuite) TestStop(c *C) {
23 // Start our own instance of the server so we have 25 // Start our own instance of the server so we have
24 // a handle on it to stop it. 26 // a handle on it to stop it.
25 srv, err := apiserver.NewServer(s.State, "localhost:0", []byte(coretesti ng.ServerCert), []byte(coretesting.ServerKey)) 27 srv, err := apiserver.NewServer(s.State, "localhost:0", []byte(coretesti ng.ServerCert), []byte(coretesting.ServerKey))
26 c.Assert(err, IsNil) 28 c.Assert(err, IsNil)
27 29
28 stm, err := s.State.AddMachine("series", state.JobHostUnits) 30 stm, err := s.State.AddMachine("series", state.JobHostUnits)
29 c.Assert(err, IsNil) 31 c.Assert(err, IsNil)
30 err = stm.SetProvisioned("foo", "fake_nonce") 32 err = stm.SetProvisioned("foo", "fake_nonce")
31 c.Assert(err, IsNil) 33 c.Assert(err, IsNil)
32 err = stm.SetPassword("password") 34 err = stm.SetPassword("password")
33 c.Assert(err, IsNil) 35 c.Assert(err, IsNil)
34 36
35 // Note we can't use openAs because we're not connecting to 37 // Note we can't use openAs because we're not connecting to
36 // s.APIConn. 38 // s.APIConn.
37 st, err := api.Open(&api.Info{ 39 st, err := api.Open(&api.Info{
38 Tag: stm.Tag(), 40 Tag: stm.Tag(),
39 Password: "password", 41 Password: "password",
40 Addrs: []string{srv.Addr()}, 42 Addrs: []string{srv.Addr()},
41 CACert: []byte(coretesting.CACert), 43 CACert: []byte(coretesting.CACert),
42 » }) 44 » }, fastDialOpts)
43 c.Assert(err, IsNil) 45 c.Assert(err, IsNil)
44 defer st.Close() 46 defer st.Close()
45 47
46 » _, err = st.Machiner() 48 » _, err = st.Machiner().Machine(stm.Id())
47 c.Assert(err, IsNil) 49 c.Assert(err, IsNil)
48 50
49 err = srv.Stop() 51 err = srv.Stop()
50 c.Assert(err, IsNil) 52 c.Assert(err, IsNil)
51 53
52 » _, err = st.Machiner() 54 » _, err = st.Machiner().Machine(stm.Id())
53 // The client has not necessarily seen the server shutdown yet, 55 // The client has not necessarily seen the server shutdown yet,
54 // so there are two possible errors. 56 // so there are two possible errors.
55 if err != rpc.ErrShutdown && err != io.ErrUnexpectedEOF { 57 if err != rpc.ErrShutdown && err != io.ErrUnexpectedEOF {
56 c.Fatalf("unexpected error from request: %v", err) 58 c.Fatalf("unexpected error from request: %v", err)
57 } 59 }
58 60
59 // Check it can be stopped twice. 61 // Check it can be stopped twice.
60 err = srv.Stop() 62 err = srv.Stop()
61 c.Assert(err, IsNil) 63 c.Assert(err, IsNil)
62 } 64 }
LEFTRIGHT

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