Merge lp:ubuntu-push/automatic into lp:ubuntu-push

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 425
Merged at revision: 159
Proposed branch: lp:ubuntu-push/automatic
Merge into: lp:ubuntu-push
Diff against target: 218 lines (+89/-20)
7 files modified
Makefile (+2/-1)
bus/systemimage/systemimage.go (+41/-6)
bus/systemimage/systemimage_test.go (+24/-8)
client/client.go (+1/-1)
client/client_test.go (+10/-1)
debian/rules (+3/-0)
http13client/client_test.go (+8/-3)
To merge this branch: bzr merge lp:ubuntu-push/automatic
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+288639@code.launchpad.net

Commit message

* deprecate the usage of Info in the systemimage module and replace it with Information
* disable runtime cgo pointer checks

To post a comment you must log in.
lp:ubuntu-push/automatic updated
425. By Jonas G. Drange

[r=ken-vandine] stop cgo pointer checks at dh_auto_test time, and fix test after go 1.6 broke it (lp #1534417)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-11-20 14:21:38 +0000
3+++ Makefile 2016-03-10 20:37:13 +0000
4@@ -13,7 +13,8 @@
5 GODEPS += code.google.com/p/gosqlite/sqlite3
6 GODEPS += code.google.com/p/go-uuid/uuid
7
8-GOTEST := ./scripts/goctest
9+# cgocheck=0 is a workaround for lp:1555198
10+GOTEST := GODEBUG=cgocheck=0 ./scripts/goctest
11
12 TOTEST = $(shell env GOPATH=$(GOPATH) go list $(PROJECT)/...|grep -v acceptance|grep -v http13client )
13 TOBUILD = $(shell grep -lr '^package main')
14
15=== modified file 'bus/systemimage/systemimage.go'
16--- bus/systemimage/systemimage.go 2015-01-21 17:21:42 +0000
17+++ bus/systemimage/systemimage.go 2016-03-10 20:37:13 +0000
18@@ -18,6 +18,9 @@
19 package systemimage
20
21 import (
22+ "strconv"
23+ "strings"
24+
25 "launchpad.net/ubuntu-push/bus"
26 "launchpad.net/ubuntu-push/logger"
27 )
28@@ -37,11 +40,12 @@
29 // xxx channel_target missing
30 LastUpdate string
31 VersionDetail map[string]string
32+ Raw map[string]string
33 }
34
35 // A SystemImage exposes the a subset of system-image service.
36 type SystemImage interface {
37- Info() (*InfoResult, error)
38+ Information() (*InfoResult, error)
39 }
40
41 type systemImage struct {
42@@ -56,13 +60,44 @@
43
44 var _ SystemImage = &systemImage{} // ensures it conforms
45
46-func (si *systemImage) Info() (*InfoResult, error) {
47- si.log.Debugf("invoking Info")
48- res := &InfoResult{}
49- err := si.endp.Call("Info", bus.Args(), &res.BuildNumber, &res.Device, &res.Channel, &res.LastUpdate, &res.VersionDetail)
50+func (si *systemImage) Information() (*InfoResult, error) {
51+ si.log.Debugf("invoking Information")
52+ m := map[string]string{}
53+ err := si.endp.Call("Information", bus.Args(), &m)
54+
55 if err != nil {
56- si.log.Errorf("Info failed: %v", err)
57+ si.log.Errorf("Information failed: %v", err)
58 return nil, err
59 }
60+
61+ res := &InfoResult{}
62+
63+ // Try parsing the build number if it exist.
64+ if bn := m["current_build_number"]; len(bn) > 0 {
65+ bn, err := strconv.ParseInt(bn, 10, 32)
66+ if err == nil {
67+ res.BuildNumber = int32(bn)
68+ } else {
69+ res.BuildNumber = -1
70+ }
71+ }
72+
73+ res.Device = m["device_name"]
74+ res.Channel = m["channel_name"]
75+ res.LastUpdate = m["last_update_date"]
76+ res.VersionDetail = map[string]string{}
77+
78+ // Split version detail key=value,key2=value2 into a string map
79+ // Note that even if
80+ vals := strings.Split(m["version_detail"], ",")
81+ for _, val := range vals {
82+ pairs := strings.Split(val, "=")
83+ if len(pairs) != 2 {
84+ continue
85+ }
86+ res.VersionDetail[pairs[0]] = pairs[1]
87+ }
88+ res.Raw = m
89+
90 return res, err
91 }
92
93=== modified file 'bus/systemimage/systemimage_test.go'
94--- bus/systemimage/systemimage_test.go 2014-04-02 08:46:48 +0000
95+++ bus/systemimage/systemimage_test.go 2016-03-10 20:37:13 +0000
96@@ -41,22 +41,38 @@
97 }
98
99 func (s *SISuite) TestWorks(c *C) {
100- endp := testibus.NewMultiValuedTestingEndpoint(nil, condition.Work(true), []interface{}{int32(101), "mako", "daily", "Unknown", map[string]string{}})
101+ m := map[string]string{
102+ "version_detail": "ubuntu=20160304.2,device=20160304.2,custom=20160304.2,version=381",
103+ "last_update_date": "2016-03-04 15:25:31",
104+ "last_check_date": "2016-03-08 04:30:34",
105+ "target_version_detail": "-1",
106+ "device_name": "mako",
107+ "target_build_number": "-1",
108+ "channel_name": "ubuntu-touch/rc-proposed/ubuntu",
109+ "current_build_number": "381",
110+ }
111+ endp := testibus.NewMultiValuedTestingEndpoint(nil, condition.Work(true), []interface{}{m})
112 si := New(endp, s.log)
113- res, err := si.Info()
114+ res, err := si.Information()
115 c.Assert(err, IsNil)
116 c.Check(res, DeepEquals, &InfoResult{
117- BuildNumber: 101,
118- Device: "mako",
119- Channel: "daily",
120- LastUpdate: "Unknown",
121- VersionDetail: map[string]string{},
122+ BuildNumber: 381,
123+ Device: "mako",
124+ Channel: "ubuntu-touch/rc-proposed/ubuntu",
125+ LastUpdate: "2016-03-04 15:25:31",
126+ VersionDetail: map[string]string{
127+ "ubuntu": "20160304.2",
128+ "device": "20160304.2",
129+ "custom": "20160304.2",
130+ "version": "381",
131+ },
132+ Raw: m,
133 })
134 }
135
136 func (s *SISuite) TestFailsIfCallFails(c *C) {
137 endp := testibus.NewTestingEndpoint(nil, condition.Work(false))
138 si := New(endp, s.log)
139- _, err := si.Info()
140+ _, err := si.Information()
141 c.Check(err, NotNil)
142 }
143
144=== modified file 'client/client.go'
145--- client/client.go 2015-09-30 14:44:14 +0000
146+++ client/client.go 2016-03-10 20:37:13 +0000
147@@ -292,7 +292,7 @@
148 go cs.Track(client.connCh)
149 util.NewAutoRedialer(client.systemImageEndp).Redial()
150 sysimg := systemimage.New(client.systemImageEndp, client.log)
151- info, err := sysimg.Info()
152+ info, err := sysimg.Information()
153 if err != nil {
154 return err
155 }
156
157=== modified file 'client/client_test.go'
158--- client/client_test.go 2015-10-01 20:16:49 +0000
159+++ client/client_test.go 2016-03-10 20:37:13 +0000
160@@ -674,7 +674,16 @@
161 dbus.ObjectPath("hello"),
162 )
163 siCond := condition.Fail2Work(2)
164- siEndp := testibus.NewMultiValuedTestingEndpoint(siCond, condition.Work(true), []interface{}{int32(101), "mako", "daily", "Unknown", map[string]string{}})
165+ siEndp := testibus.NewMultiValuedTestingEndpoint(siCond, condition.Work(true), []interface{}{map[string]string{
166+ "version_detail": "ubuntu=20160304.2,device=20160304.2,custom=20160304.2,version=381",
167+ "last_update_date": "2016-03-04 15:25:31",
168+ "last_check_date": "2016-03-08 04:30:34",
169+ "target_version_detail": "-1",
170+ "device_name": "mako",
171+ "target_build_number": "-1",
172+ "channel_name": "ubuntu-touch/rc-proposed/ubuntu",
173+ "current_build_number": "381",
174+ }})
175 tickerCh := make(chan []interface{})
176 nopTickerCh := make(chan []interface{})
177 testibus.SetWatchSource(cEndp, "StateChanged", tickerCh)
178
179=== modified file 'debian/rules'
180--- debian/rules 2016-01-14 20:58:52 +0000
181+++ debian/rules 2016-03-10 20:37:13 +0000
182@@ -25,6 +25,9 @@
183 dh_auto_build --buildsystem=golang
184 (cd signing-helper && cmake . && make)
185
186+override_dh_auto_test:
187+ GODEBUG=cgocheck=0 dh_auto_test -O--buildsystem=golang
188+
189 override_dh_install:
190 dh_install -Xusr/bin/cmd --fail-missing
191
192
193=== modified file 'http13client/client_test.go'
194--- http13client/client_test.go 2014-06-20 12:59:40 +0000
195+++ http13client/client_test.go 2016-03-10 20:37:13 +0000
196@@ -601,14 +601,19 @@
197
198 func TestClientWithCorrectTLSServerName(t *testing.T) {
199 defer afterTest(t)
200+
201+ const serverName = "example.com"
202 ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
203- if r.TLS.ServerName != "127.0.0.1" {
204- t.Errorf("expected client to set ServerName 127.0.0.1, got: %q", r.TLS.ServerName)
205+ if r.TLS.ServerName != serverName {
206+ t.Errorf("expected client to set ServerName %q, got: %q", serverName, r.TLS.ServerName)
207 }
208 }))
209 defer ts.Close()
210
211- c := &Client{Transport: newTLSTransport(t, ts)}
212+ trans := newTLSTransport(t, ts)
213+ trans.TLSClientConfig.ServerName = serverName
214+ c := &Client{Transport: trans}
215+
216 if _, err := c.Get(ts.URL); err != nil {
217 t.Fatalf("expected successful TLS connection, got error: %v", err)
218 }

Subscribers

People subscribed via source and target branches