Merge lp:~pedronis/ubuntu-push/delivery-hosts-details into lp:ubuntu-push/automatic

Proposed by Samuele Pedroni
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 101
Merged at revision: 99
Proposed branch: lp:~pedronis/ubuntu-push/delivery-hosts-details
Merge into: lp:ubuntu-push/automatic
Diff against target: 153 lines (+52/-11)
5 files modified
client/client.go (+8/-0)
client/client_test.go (+23/-4)
client/gethosts/gethost_test.go (+5/-7)
client/session/session.go (+3/-0)
client/session/session_test.go (+13/-0)
To merge this branch: bzr merge lp:~pedronis/ubuntu-push/delivery-hosts-details
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+213487@code.launchpad.net

Commit message

various sanity details, especially don't get stuck in infinite retries if somehow no hosts are considered (shouldn't happen)

Description of the change

small sanity details:

* panic if there are no hosts specified instead of getting stuck in infinite retrying

* check that host bit of the config isn't empty

* tweak test with -race problems differently after some discussion in the golang bug tracker

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (3.9 KiB)

The attempt to merge lp:~pedronis/ubuntu-push/delivery-hosts-details into lp:ubuntu-push/automatic failed. Below is the output from the failed tests.

mkdir -p /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/bin
mkdir -p /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/pkg
go get -u launchpad.net/godeps
go get -d -u launchpad.net/gocheck launchpad.net/go-dbus/v1 launchpad.net/go-xdg/v0 code.google.com/p/gosqlite/sqlite3
/mnt/tarmac/cache/ubuntu-push-automatic/go-ws/bin/godeps -u dependencies.tsv
"/mnt/tarmac/cache/ubuntu-push-automatic/go-ws/src/launchpad.net/gocheck" now at <email address hidden>
go install launchpad.net/gocheck launchpad.net/go-dbus/v1 launchpad.net/go-xdg/v0 code.google.com/p/gosqlite/sqlite3
go test launchpad.net/ubuntu-push/...
? launchpad.net/ubuntu-push [no test files]
ok launchpad.net/ubuntu-push/bus 0.009s
ok launchpad.net/ubuntu-push/bus/connectivity 1.143s
ok launchpad.net/ubuntu-push/bus/networkmanager 0.032s
ok launchpad.net/ubuntu-push/bus/notifications 0.018s
ok launchpad.net/ubuntu-push/bus/testing 0.024s
ok launchpad.net/ubuntu-push/bus/urldispatcher 0.012s
ok launchpad.net/ubuntu-push/client 0.113s
ok launchpad.net/ubuntu-push/client/gethosts 0.717s
ok launchpad.net/ubuntu-push/client/session 0.125s
ok launchpad.net/ubuntu-push/client/session/levelmap 0.155s
ok launchpad.net/ubuntu-push/config 0.009s
ok launchpad.net/ubuntu-push/external/murmur3 0.004s
--- FAIL: TestGoroutinesRunning (0.00 seconds)
 z_last_test.go:57: num goroutines = 1
 z_last_test.go:59: Too many goroutines.
 z_last_test.go:61: 1 instances of:
  syscall.Syscall(0x3, 0x9, 0x0, 0x0, 0x0, ...)
   /usr/lib/go/src/pkg/syscall/asm_linux_amd64.s:38 +0x64
  syscall.Close(0x9, 0x0, 0x0)
   /usr/lib/go/src/pkg/syscall/zsyscall_linux_amd64.go:267 +0x54
  net.closesocket(0x9, 0x2afbbc4cc3d8, 0x9)
   /usr/lib/go/src/pkg/net/fd_unix.go:474 +0x27
  net.(*netFD).destroy(0xc2110cfc40)
   /usr/lib/go/src/pkg/net/fd_unix.go:97 +0x45
  net.(*netFD).decref(0xc2110cfc40)
   /usr/lib/go/src/pkg/net/fd_unix.go:115 +0x47
  net.(*netFD).Close(0xc2110cfc40, 0x2afbbf7fcf30, 0x0)
   /usr/lib/go/src/pkg/net/fd_unix.go:164 +0xa8
  net.(*conn).Close(0xc210077ec0, 0xc21116ade0, 0xc210077ec0)
   /usr/lib/go/src/pkg/net/net.go:138 +0x95
  launchpad.net/ubuntu-push/http13client_test.funcĀ·083()
   /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/src/launchpad.net/ubuntu-push/http13client/transport_test.go:1797 +0x13c
  created by launchpad.net/ubuntu-push/http13client_test.TestTransportTLSHandshakeTimeout
   /mnt/tarmac/cache/ubuntu-push-automatic/go-ws/src/launchpad.net/ubuntu-push/http13client/transport_test.go:1798 +0x22c
FAIL
FAIL launchpad.net/ubuntu-push/http13client 19.809s
ok launchpad.net/ubuntu-push/logger 0.026s
ok launchpad.net/ubuntu-push/protocol 0.018s
ok launchpad.net/ubuntu-push/server 0.073s
ok launchpad.net/ubuntu-push/server/acceptance 0.009s
? launchpad.net/ubuntu-push/server/acceptance/cmd [no test files]
? launchpad.net/ubuntu-push/server/acceptance/suites [no test files]
ok launchpad.net/ubuntu-push/server/api 0.031s
ok launchpad.net/ubuntu-push/server/broker 0.031s
ok launchpad.net/...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/client.go'
2--- client/client.go 2014-03-28 14:20:23 +0000
3+++ client/client.go 2014-03-31 14:34:40 +0000
4@@ -20,9 +20,11 @@
5
6 import (
7 "encoding/pem"
8+ "errors"
9 "fmt"
10 "io/ioutil"
11 "os"
12+ "strings"
13
14 "launchpad.net/go-dbus/v1"
15
16@@ -96,6 +98,12 @@
17 if err != nil {
18 return fmt.Errorf("reading config: %v", err)
19 }
20+ // ignore spaces
21+ client.config.Addr = strings.Replace(client.config.Addr, " ", "", -1)
22+ if client.config.Addr == "" {
23+ return errors.New("no hosts specified")
24+ }
25+
26 // later, we'll be specifying more logging options in the config file
27 client.log = logger.NewSimpleLogger(os.Stderr, client.config.LogLevel)
28
29
30=== modified file 'client/client_test.go'
31--- client/client_test.go 2014-03-28 14:20:23 +0000
32+++ client/client_test.go 2014-03-31 14:34:40 +0000
33@@ -88,6 +88,7 @@
34 }
35
36 func (cs *clientSuite) writeTestConfig(overrides map[string]interface{}) {
37+ pem_file := helpers.SourceRelative("../server/acceptance/config/testing.cert")
38 cfgMap := map[string]interface{}{
39 "connect_timeout": "7ms",
40 "exchange_timeout": "10ms",
41@@ -97,6 +98,7 @@
42 "connectivity_check_url": "",
43 "connectivity_check_md5": "",
44 "addr": ":0",
45+ "cert_pem_file": pem_file,
46 "recheck_timeout": "3h",
47 "log_level": "debug",
48 }
49@@ -114,10 +116,8 @@
50 cs.log = helpers.NewTestLogger(c, "debug")
51 dir := c.MkDir()
52 cs.configPath = filepath.Join(dir, "config")
53- pem_file := helpers.SourceRelative("../server/acceptance/config/testing.cert")
54- cs.writeTestConfig(map[string]interface{}{
55- "cert_pem_file": pem_file,
56- })
57+
58+ cs.writeTestConfig(nil)
59 }
60
61 type sqlientSuite struct{ clientSuite }
62@@ -215,6 +215,25 @@
63 c.Assert(err, ErrorMatches, "no PEM found.*")
64 }
65
66+func (cs *clientSuite) TestConfigureBailsOnNoHosts(c *C) {
67+ cs.writeTestConfig(map[string]interface{}{
68+ "addr": " ",
69+ })
70+ cli := NewPushClient(cs.configPath, cs.leveldbPath)
71+ err := cli.configure()
72+ c.Assert(err, ErrorMatches, "no hosts specified")
73+}
74+
75+func (cs *clientSuite) TestConfigureRemovesBlanksInAddr(c *C) {
76+ cs.writeTestConfig(map[string]interface{}{
77+ "addr": " foo: 443",
78+ })
79+ cli := NewPushClient(cs.configPath, cs.leveldbPath)
80+ err := cli.configure()
81+ c.Assert(err, IsNil)
82+ c.Check(cli.config.Addr, Equals, "foo:443")
83+}
84+
85 /*****************************************************************
86 deriveSessionConfig tests
87 ******************************************************************/
88
89=== modified file 'client/gethosts/gethost_test.go'
90--- client/gethosts/gethost_test.go 2014-03-24 15:32:29 +0000
91+++ client/gethosts/gethost_test.go 2014-03-31 14:34:40 +0000
92@@ -61,18 +61,16 @@
93 }
94
95 func (s *getHostsSuite) TestGetTimeout(c *C) {
96- finish := make(chan bool, 1)
97+ started := make(chan bool, 1)
98 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
99- <-finish
100+ started <- true
101+ time.Sleep(700 * time.Millisecond)
102 }))
103 defer func() {
104- time.Sleep(100 * time.Millisecond) // work around -race issue
105+ <-started
106 ts.Close()
107 }()
108- defer func() {
109- finish <- true
110- }()
111- gh := New("foobar", ts.URL, 1*time.Second)
112+ gh := New("foobar", ts.URL, 500*time.Millisecond)
113 _, err := gh.Get()
114 c.Check(err, ErrorMatches, ".*closed.*")
115 }
116
117=== modified file 'client/session/session.go'
118--- client/session/session.go 2014-03-28 14:49:56 +0000
119+++ client/session/session.go 2014-03-31 14:34:40 +0000
120@@ -197,6 +197,9 @@
121 sess.tryHost = 0
122 }
123 sess.leftToTry = len(sess.deliveryHosts)
124+ if sess.leftToTry == 0 {
125+ panic("should have got hosts from config or remote at this point")
126+ }
127 sess.lastAttemptTimestamp = time.Now()
128 }
129
130
131=== modified file 'client/session/session_test.go'
132--- client/session/session_test.go 2014-03-28 13:09:53 +0000
133+++ client/session/session_test.go 2014-03-31 14:34:40 +0000
134@@ -345,6 +345,19 @@
135 sess.tryHost = 2
136 }
137
138+func (cs *clientSessionSuite) TestStartConnectionAttemptNoHostsPanic(c *C) {
139+ since := time.Since(time.Time{})
140+ sess := &ClientSession{
141+ ClientSessionConfig: ClientSessionConfig{
142+ ExpectAllRepairedTime: 10 * time.Second,
143+ },
144+ timeSince: func(ts time.Time) time.Duration {
145+ return since
146+ },
147+ }
148+ c.Check(sess.startConnectionAttempt, PanicMatches, "should have got hosts from config or remote at this point")
149+}
150+
151 func (cs *clientSessionSuite) TestNextHostToTry(c *C) {
152 sess := &ClientSession{
153 deliveryHosts: []string{"foo:443", "bar:443", "baz:443"},

Subscribers

People subscribed via source and target branches