Merge lp:~axwalk/juju-core/lp1233601-test-network-isolation 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: 2327
Proposed branch: lp:~axwalk/juju-core/lp1233601-test-network-isolation
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 87 lines (+20/-2)
4 files modified
cmd/juju/upgradecharm_test.go (+10/-0)
utils/ssh/export_test.go (+1/-0)
utils/ssh/ssh_gocrypto.go (+3/-1)
utils/ssh/ssh_gocrypto_test.go (+6/-1)
To merge this branch: bzr merge lp:~axwalk/juju-core/lp1233601-test-network-isolation
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+206332@code.launchpad.net

Commit message

Fix test network isolation

Some tests were dialing out. We shouldn't do that.

Fixes lp:1233601

https://codereview.appspot.com/63700043/

Description of the change

Fix test network isolation

Some tests were dialing out. We shouldn't do that.

Fixes lp:1233601

https://codereview.appspot.com/63700043/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :
Download full text (3.6 KiB)

Reviewers: mp+206332_code.launchpad.net,

Message:
Please take a look.

Description:
Fix test network isolation

Some tests were dialing out. We shouldn't do that.

Fixes lp:1233601

https://code.launchpad.net/~axwalk/juju-core/lp1233601-test-network-isolation/+merge/206332

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/63700043/

Affected files (+22, -2 lines):
   A [revision details]
   M cmd/juju/upgradecharm_test.go
   M utils/ssh/export_test.go
   M utils/ssh/ssh_gocrypto.go
   M utils/ssh/ssh_gocrypto_test.go

Index: [revision details]
=== 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-20140214031125-wjgoipxnambtbvw9
+New revision: <email address hidden>

Index: cmd/juju/upgradecharm_test.go
=== modified file 'cmd/juju/upgradecharm_test.go'
--- cmd/juju/upgradecharm_test.go 2013-12-19 16:24:12 +0000
+++ cmd/juju/upgradecharm_test.go 2014-02-14 04:58:10 +0000
@@ -12,6 +12,7 @@
   gc "launchpad.net/gocheck"

   "launchpad.net/juju-core/charm"
+ charmtesting "launchpad.net/juju-core/charm/testing"
   jujutesting "launchpad.net/juju-core/juju/testing"
   "launchpad.net/juju-core/state"
   "launchpad.net/juju-core/testing"
@@ -21,6 +22,15 @@
   jujutesting.RepoSuite
  }

+func (s *UpgradeCharmErrorsSuite) SetUpTest(c *gc.C) {
+ s.RepoSuite.SetUpTest(c)
+ mockstore := charmtesting.NewMockStore(c, map[string]int{})
+ s.AddCleanup(func(*gc.C) { mockstore.Close() })
+ s.PatchValue(&charm.Store, &charm.CharmStore{
+ BaseURL: mockstore.Address(),
+ })
+}
+
  var _ = gc.Suite(&UpgradeCharmErrorsSuite{})

  func runUpgradeCharm(c *gc.C, args ...string) error {

Index: utils/ssh/export_test.go
=== modified file 'utils/ssh/export_test.go'
--- utils/ssh/export_test.go 2014-02-04 03:12:33 +0000
+++ utils/ssh/export_test.go 2014-02-14 04:58:10 +0000
@@ -8,4 +8,5 @@
   WriteAuthorisedKeys = writeAuthorisedKeys
   InitDefaultClient = initDefaultClient
   DefaultIdentities = &defaultIdentities
+ SSHDial = &sshDial
  )

Index: utils/ssh/ssh_gocrypto.go
=== modified file 'utils/ssh/ssh_gocrypto.go'
--- utils/ssh/ssh_gocrypto.go 2014-01-17 02:35:28 +0000
+++ utils/ssh/ssh_gocrypto.go 2014-02-14 04:58:10 +0000
@@ -77,6 +77,8 @@
   sess *ssh.Session
  }

+var sshDial = ssh.Dial
+
  func (c *goCryptoCommand) ensureSession() (*ssh.Session, error) {
   if c.sess != nil {
    return c.sess, nil
@@ -97,7 +99,7 @@
     ssh.ClientAuthKeyring(keyring{c.signers}),
    },
   }
- conn, err := ssh.Dial("tcp", c.addr, config)
+ conn, err := sshDial("tcp", c.addr, config)
   if err != nil {
    return nil, err
   }

Index: utils/ssh/ssh_gocrypto_test.go
=== modified file 'utils/ssh/ssh_gocrypto_test.go'
--- utils/ssh/ssh_gocrypto_test.go 2014-01-23 08:58:16 +0000
+++ utils/ssh/ssh_gocrypto_test.go 2014-02-14 04:58:10 +0000
@@ -5,6 +5,7 @@

  import (
   "encoding/binary"
+ "errors"
   "net"
   "sync"

@@ -107,10 +108,14 @@
   defer ssh.ClearClientKeys()
   err = ssh.LoadClientKeys(c.MkDir())
   c.Assert(err, gc.IsNil)
+
+ s.PatchValue(ssh.S...

Read more...

Revision history for this message
Ian Booth (wallyworld) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/upgradecharm_test.go'
2--- cmd/juju/upgradecharm_test.go 2013-12-19 16:24:12 +0000
3+++ cmd/juju/upgradecharm_test.go 2014-02-14 05:01:02 +0000
4@@ -12,6 +12,7 @@
5 gc "launchpad.net/gocheck"
6
7 "launchpad.net/juju-core/charm"
8+ charmtesting "launchpad.net/juju-core/charm/testing"
9 jujutesting "launchpad.net/juju-core/juju/testing"
10 "launchpad.net/juju-core/state"
11 "launchpad.net/juju-core/testing"
12@@ -21,6 +22,15 @@
13 jujutesting.RepoSuite
14 }
15
16+func (s *UpgradeCharmErrorsSuite) SetUpTest(c *gc.C) {
17+ s.RepoSuite.SetUpTest(c)
18+ mockstore := charmtesting.NewMockStore(c, map[string]int{})
19+ s.AddCleanup(func(*gc.C) { mockstore.Close() })
20+ s.PatchValue(&charm.Store, &charm.CharmStore{
21+ BaseURL: mockstore.Address(),
22+ })
23+}
24+
25 var _ = gc.Suite(&UpgradeCharmErrorsSuite{})
26
27 func runUpgradeCharm(c *gc.C, args ...string) error {
28
29=== modified file 'utils/ssh/export_test.go'
30--- utils/ssh/export_test.go 2014-02-04 03:12:33 +0000
31+++ utils/ssh/export_test.go 2014-02-14 05:01:02 +0000
32@@ -8,4 +8,5 @@
33 WriteAuthorisedKeys = writeAuthorisedKeys
34 InitDefaultClient = initDefaultClient
35 DefaultIdentities = &defaultIdentities
36+ SSHDial = &sshDial
37 )
38
39=== modified file 'utils/ssh/ssh_gocrypto.go'
40--- utils/ssh/ssh_gocrypto.go 2014-01-17 02:35:28 +0000
41+++ utils/ssh/ssh_gocrypto.go 2014-02-14 05:01:02 +0000
42@@ -77,6 +77,8 @@
43 sess *ssh.Session
44 }
45
46+var sshDial = ssh.Dial
47+
48 func (c *goCryptoCommand) ensureSession() (*ssh.Session, error) {
49 if c.sess != nil {
50 return c.sess, nil
51@@ -97,7 +99,7 @@
52 ssh.ClientAuthKeyring(keyring{c.signers}),
53 },
54 }
55- conn, err := ssh.Dial("tcp", c.addr, config)
56+ conn, err := sshDial("tcp", c.addr, config)
57 if err != nil {
58 return nil, err
59 }
60
61=== modified file 'utils/ssh/ssh_gocrypto_test.go'
62--- utils/ssh/ssh_gocrypto_test.go 2014-01-23 08:58:16 +0000
63+++ utils/ssh/ssh_gocrypto_test.go 2014-02-14 05:01:02 +0000
64@@ -5,6 +5,7 @@
65
66 import (
67 "encoding/binary"
68+ "errors"
69 "net"
70 "sync"
71
72@@ -107,10 +108,14 @@
73 defer ssh.ClearClientKeys()
74 err = ssh.LoadClientKeys(c.MkDir())
75 c.Assert(err, gc.IsNil)
76+
77+ s.PatchValue(ssh.SSHDial, func(network, address string, cfg *cryptossh.ClientConfig) (*cryptossh.ClientConn, error) {
78+ return nil, errors.New("ssh.Dial failed")
79+ })
80 cmd = client.Command("0.1.2.3", []string{"echo", "123"}, nil)
81 _, err = cmd.Output()
82 // error message differs based on whether using cgo or not
83- c.Assert(err, gc.ErrorMatches, `(dial tcp )?0\.1\.2\.3:22: invalid argument`)
84+ c.Assert(err, gc.ErrorMatches, "ssh.Dial failed")
85 }
86
87 func (s *SSHGoCryptoCommandSuite) TestCommand(c *gc.C) {

Subscribers

People subscribed via source and target branches

to status/vote changes: