Merge lp:~chipaca/ubuntu-push/bus-reorg into lp:ubuntu-push

Proposed by John Lenton
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 21
Merged at revision: 24
Proposed branch: lp:~chipaca/ubuntu-push/bus-reorg
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/url-dispatcher
Diff against target: 228 lines (+43/-38)
6 files modified
.precommit (+29/-0)
bus/connectivity/connectivity.go (+2/-3)
bus/connectivity/connectivity_test.go (+1/-20)
bus/connectivity/example/main.go (+2/-2)
bus/connectivity/webchecker.go (+3/-3)
bus/connectivity/webchecker_test.go (+6/-10)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/bus-reorg
Reviewer Review Type Date Requested Status
Samuele Pedroni Approve
Review via email: mp+202775@code.launchpad.net

Commit message

moved a bunch of packages under bus/

Description of the change

moved a bunch of packages under bus/

bus/networkmanager/connectivity/webchecker doesn't strictly depend on
anything above it, but I consider it a helper of connectivity and not
worthy of standing alone, hence its place. Everything else is inside
that which it depends on.

To post a comment you must log in.
Revision history for this message
Samuele Pedroni (pedronis) wrote :

looks good

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~chipaca/ubuntu-push/bus-reorg into lp:ubuntu-push failed. Below is the output from the failed tests.

mkdir -p /mnt/tarmac/cache/ubuntu-push/go-ws/bin
mkdir -p /mnt/tarmac/cache/ubuntu-push/go-ws/pkg
go get -u launchpad.net/godeps
go get -d -u launchpad.net/gocheck launchpad.net/go-dbus/v1
/mnt/tarmac/cache/ubuntu-push/go-ws/bin/godeps -u dependencies.tsv
go install launchpad.net/gocheck launchpad.net/go-dbus/v1
go test launchpad.net/ubuntu-push/...
ok launchpad.net/ubuntu-push/bus 0.007s

----------------------------------------------------------------------
FAIL: connectivity_test.go:204: ConnSuite.TestRun

connectivity_test.go:243:
    c.Check(v, Equals, expected)
... obtained bool = false
... expected bool = true

connectivity_test.go:243:
    c.Check(v, Equals, expected)
... obtained bool = true
... expected bool = false

OOPS: 11 passed, 1 FAILED
--- FAIL: Test (0.11 seconds)
OK: 12 passed
FAIL
FAIL launchpad.net/ubuntu-push/bus/connectivity 0.228s
? launchpad.net/ubuntu-push/bus/connectivity/example [no test files]
ok launchpad.net/ubuntu-push/bus/networkmanager 0.031s
ok launchpad.net/ubuntu-push/bus/notifications 0.018s
ok launchpad.net/ubuntu-push/bus/testing 0.019s
ok launchpad.net/ubuntu-push/bus/urldispatcher 0.006s
ok launchpad.net/ubuntu-push/config 0.012s
ok launchpad.net/ubuntu-push/logger 0.006s
ok launchpad.net/ubuntu-push/protocol 0.010s
ok launchpad.net/ubuntu-push/server 0.024s
ok launchpad.net/ubuntu-push/server/acceptance 0.006s
? launchpad.net/ubuntu-push/server/acceptance/cmd [no test files]
ok launchpad.net/ubuntu-push/server/api 0.013s
ok launchpad.net/ubuntu-push/server/broker 0.015s
ok launchpad.net/ubuntu-push/server/broker/simple 0.015s
? launchpad.net/ubuntu-push/server/broker/testing [no test files]
? launchpad.net/ubuntu-push/server/broker/testsuite [no test files]
? launchpad.net/ubuntu-push/server/dev [no test files]
ok launchpad.net/ubuntu-push/server/listener 0.397s
ok launchpad.net/ubuntu-push/server/session 0.075s
ok launchpad.net/ubuntu-push/server/store 0.005s
? launchpad.net/ubuntu-push/testing [no test files]
ok launchpad.net/ubuntu-push/testing/condition 0.004s
ok launchpad.net/ubuntu-push/whoopsie/identifier 0.006s
ok launchpad.net/ubuntu-push/whoopsie/identifier/testing 0.014s

make: *** [check] Error 1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.precommit'
--- .precommit 1970-01-01 00:00:00 +0000
+++ .precommit 2014-01-23 10:03:50 +0000
@@ -0,0 +1,29 @@
1#!/bin/sh
2set -e
3echo "$@"
4# put me in the project root, call me ".precommit".
5# And put this here-document in ~/.bazaar/plugins/precommit_script.py:
6<<EOF
7import os
8import subprocess
9from bzrlib.mutabletree import MutableTree
10from bzrlib import errors
11
12def start_commit_hook(*_):
13 """This hook will execute '.precommit' script from root path of the bazaar
14 branch. Commit will be canceled if precommit fails."""
15
16 # this hook only makes sense if a precommit file exist.
17 if not os.path.exists(".precommit"):
18 return
19 try:
20 subprocess.check_call(os.path.abspath(".precommit"))
21 # if precommit fails (process return not zero) cancel commit.
22 except subprocess.CalledProcessError:
23 raise errors.BzrError("pre commit check failed.")
24
25MutableTree.hooks.install_named_hook('start_commit', start_commit_hook,
26 'Run "precommit" script on start_commit')
27EOF
28
29make check-format # or whatever
030
=== renamed directory 'connectivity' => 'bus/connectivity'
=== modified file 'bus/connectivity/connectivity.go'
--- connectivity/connectivity.go 2014-01-20 17:44:24 +0000
+++ bus/connectivity/connectivity.go 2014-01-23 10:03:50 +0000
@@ -25,10 +25,9 @@
25import (25import (
26 "errors"26 "errors"
27 "launchpad.net/ubuntu-push/bus"27 "launchpad.net/ubuntu-push/bus"
28 "launchpad.net/ubuntu-push/bus/networkmanager"
28 "launchpad.net/ubuntu-push/config"29 "launchpad.net/ubuntu-push/config"
29 "launchpad.net/ubuntu-push/connectivity/webchecker"
30 "launchpad.net/ubuntu-push/logger"30 "launchpad.net/ubuntu-push/logger"
31 "launchpad.net/ubuntu-push/networkmanager"
32 "time"31 "time"
33)32)
3433
@@ -163,7 +162,7 @@
163// over the "out" channel. Sends "false" as soon as it detects trouble, "true"162// over the "out" channel. Sends "false" as soon as it detects trouble, "true"
164// after checking actual connectivity.163// after checking actual connectivity.
165func ConnectedState(busType bus.Bus, config Config, log logger.Logger, out chan<- bool) {164func ConnectedState(busType bus.Bus, config Config, log logger.Logger, out chan<- bool) {
166 wg := webchecker.New(config.ConnectivityCheckURL, config.ConnectivityCheckMD5, log)165 wg := NewWebchecker(config.ConnectivityCheckURL, config.ConnectivityCheckMD5, log)
167 cs := &connectedState{166 cs := &connectedState{
168 config: config,167 config: config,
169 log: log,168 log: log,
170169
=== modified file 'bus/connectivity/connectivity_test.go'
--- connectivity/connectivity_test.go 2014-01-22 12:27:35 +0000
+++ bus/connectivity/connectivity_test.go 2014-01-23 10:03:50 +0000
@@ -19,12 +19,11 @@
19import (19import (
20 "io/ioutil"20 "io/ioutil"
21 . "launchpad.net/gocheck"21 . "launchpad.net/gocheck"
22 "launchpad.net/ubuntu-push/bus/networkmanager"
22 testingbus "launchpad.net/ubuntu-push/bus/testing"23 testingbus "launchpad.net/ubuntu-push/bus/testing"
23 "launchpad.net/ubuntu-push/config"24 "launchpad.net/ubuntu-push/config"
24 "launchpad.net/ubuntu-push/logger"25 "launchpad.net/ubuntu-push/logger"
25 "launchpad.net/ubuntu-push/networkmanager"
26 "launchpad.net/ubuntu-push/testing/condition"26 "launchpad.net/ubuntu-push/testing/condition"
27 "net/http"
28 "net/http/httptest"27 "net/http/httptest"
29 "testing"28 "testing"
30 "time"29 "time"
@@ -201,24 +200,6 @@
201 tests for ConnectedState()200 tests for ConnectedState()
202*/201*/
203202
204// Todo: get rid of duplication between this and webchecker_test
205const (
206 staticText = "something ipsum dolor something"
207 staticHash = "6155f83b471583f47c99998a472a178f"
208)
209
210// mkHandler makes an http.HandlerFunc that returns the provided text
211// for whatever request it's given.
212func mkHandler(text string) http.HandlerFunc {
213 return func(w http.ResponseWriter, r *http.Request) {
214 w.(http.Flusher).Flush()
215 w.Write([]byte(text))
216 w.(http.Flusher).Flush()
217 }
218}
219
220// :oboT
221
222// yes, this is an integration test203// yes, this is an integration test
223func (s *ConnSuite) TestRun(c *C) {204func (s *ConnSuite) TestRun(c *C) {
224 ts := httptest.NewServer(mkHandler(staticText))205 ts := httptest.NewServer(mkHandler(staticText))
225206
=== modified file 'bus/connectivity/example/main.go'
--- connectivity/example/main.go 2014-01-20 06:27:39 +0000
+++ bus/connectivity/example/main.go 2014-01-23 10:03:50 +0000
@@ -20,8 +20,8 @@
20import (20import (
21 "fmt"21 "fmt"
22 "launchpad.net/ubuntu-push/bus"22 "launchpad.net/ubuntu-push/bus"
23 "launchpad.net/ubuntu-push/bus/connectivity"
23 "launchpad.net/ubuntu-push/config"24 "launchpad.net/ubuntu-push/config"
24 "launchpad.net/ubuntu-push/connectivity"
25 "launchpad.net/ubuntu-push/logger"25 "launchpad.net/ubuntu-push/logger"
26 "os"26 "os"
27 "strings"27 "strings"
@@ -30,7 +30,7 @@
30func main() {30func main() {
31 log := logger.NewSimpleLogger(os.Stderr, "error")31 log := logger.NewSimpleLogger(os.Stderr, "error")
3232
33 paths := []string{"thing.json", "connectivity/example/thing.json"}33 paths := []string{"thing.json", "bus/connectivity/example/thing.json"}
34 for _, path := range paths {34 for _, path := range paths {
35 cff, err := os.Open(path)35 cff, err := os.Open(path)
36 if err == nil {36 if err == nil {
3737
=== renamed file 'connectivity/webchecker/webchecker.go' => 'bus/connectivity/webchecker.go'
--- connectivity/webchecker/webchecker.go 2014-01-20 14:58:59 +0000
+++ bus/connectivity/webchecker.go 2014-01-23 10:03:50 +0000
@@ -14,13 +14,13 @@
14 with this program. If not, see <http://www.gnu.org/licenses/>.14 with this program. If not, see <http://www.gnu.org/licenses/>.
15*/15*/
1616
17// Package webchecker checks whether we're actually connected by doing an http17// webchecker checks whether we're actually connected by doing an http
18// GET to the Ubuntu connectivity check URL,18// GET to the Ubuntu connectivity check URL,
19// http://start.ubuntu.com/connectivity-check.html19// http://start.ubuntu.com/connectivity-check.html
20//20//
21// We could make it be https to make extra doubly sure, but it's expensive21// We could make it be https to make extra doubly sure, but it's expensive
22// overkill for the majority of cases.22// overkill for the majority of cases.
23package webchecker23package connectivity
2424
25import (25import (
26 "crypto/md5"26 "crypto/md5"
@@ -46,7 +46,7 @@
46}46}
4747
48// Build a webchecker for the given URL, that should match the target MD5.48// Build a webchecker for the given URL, that should match the target MD5.
49func New(url string, target string, log logger.Logger) Webchecker {49func NewWebchecker(url string, target string, log logger.Logger) Webchecker {
50 return &webchecker{log, url, target}50 return &webchecker{log, url, target}
51}51}
5252
5353
=== renamed file 'connectivity/webchecker/webchecker_test.go' => 'bus/connectivity/webchecker_test.go'
--- connectivity/webchecker/webchecker_test.go 2014-01-20 06:27:39 +0000
+++ bus/connectivity/webchecker_test.go 2014-01-23 10:03:50 +0000
@@ -14,26 +14,22 @@
14 with this program. If not, see <http://www.gnu.org/licenses/>.14 with this program. If not, see <http://www.gnu.org/licenses/>.
15*/15*/
1616
17package webchecker17package connectivity
1818
19import (19import (
20 "io/ioutil"
21 . "launchpad.net/gocheck"20 . "launchpad.net/gocheck"
22 "launchpad.net/ubuntu-push/logger"
23 "net/http"21 "net/http"
24 "net/http/httptest"22 "net/http/httptest"
25 "testing"23 "testing"
26)24)
2725
28// hook up gocheck26// hook up gocheck
29func Test(t *testing.T) { TestingT(t) }27func TestWebcheck(t *testing.T) { TestingT(t) }
3028
31type WebcheckerSuite struct{}29type WebcheckerSuite struct{}
3230
33var _ = Suite(&WebcheckerSuite{})31var _ = Suite(&WebcheckerSuite{})
3432
35var nullog = logger.NewSimpleLogger(ioutil.Discard, "error")
36
37const (33const (
38 staticText = "something ipsum dolor something"34 staticText = "something ipsum dolor something"
39 staticHash = "6155f83b471583f47c99998a472a178f"35 staticHash = "6155f83b471583f47c99998a472a178f"
@@ -69,7 +65,7 @@
69 ts := httptest.NewServer(mkHandler(staticText))65 ts := httptest.NewServer(mkHandler(staticText))
70 defer ts.Close()66 defer ts.Close()
7167
72 ck := New(ts.URL, staticHash, nullog)68 ck := NewWebchecker(ts.URL, staticHash, nullog)
73 ch := make(chan bool, 1)69 ch := make(chan bool, 1)
74 ck.Webcheck(ch)70 ck.Webcheck(ch)
75 c.Check(<-ch, Equals, true)71 c.Check(<-ch, Equals, true)
@@ -77,7 +73,7 @@
7773
78// Webchecker sends false if the download fails.74// Webchecker sends false if the download fails.
79func (s *WebcheckerSuite) TestActualFails(c *C) {75func (s *WebcheckerSuite) TestActualFails(c *C) {
80 ck := New("garbage://", "", nullog)76 ck := NewWebchecker("garbage://", "", nullog)
81 ch := make(chan bool, 1)77 ch := make(chan bool, 1)
82 ck.Webcheck(ch)78 ck.Webcheck(ch)
83 c.Check(<-ch, Equals, false)79 c.Check(<-ch, Equals, false)
@@ -88,7 +84,7 @@
88 ts := httptest.NewServer(mkHandler(""))84 ts := httptest.NewServer(mkHandler(""))
89 defer ts.Close()85 defer ts.Close()
9086
91 ck := New(ts.URL, staticHash, nullog)87 ck := NewWebchecker(ts.URL, staticHash, nullog)
92 ch := make(chan bool, 1)88 ch := make(chan bool, 1)
93 ck.Webcheck(ch)89 ck.Webcheck(ch)
94 c.Check(<-ch, Equals, false)90 c.Check(<-ch, Equals, false)
@@ -99,7 +95,7 @@
99 ts := httptest.NewServer(mkHandler(bigText))95 ts := httptest.NewServer(mkHandler(bigText))
100 defer ts.Close()96 defer ts.Close()
10197
102 ck := New(ts.URL, bigHash, nullog)98 ck := NewWebchecker(ts.URL, bigHash, nullog)
103 ch := make(chan bool, 1)99 ch := make(chan bool, 1)
104 ck.Webcheck(ch)100 ck.Webcheck(ch)
105 c.Check(<-ch, Equals, false)101 c.Check(<-ch, Equals, false)
106102
=== renamed directory 'networkmanager' => 'bus/networkmanager'
=== renamed directory 'notifications' => 'bus/notifications'
=== renamed directory 'urldispatcher' => 'bus/urldispatcher'
=== removed directory 'connectivity/webchecker'

Subscribers

People subscribed via source and target branches