Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(885)

Unified Diff: milo/appengine/buildbot/pubsub_test.go

Issue 2271453002: Milo: Internal buildbot masters support (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: nit fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/buildbot/pubsub.go ('k') | milo/appengine/settings/acl.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/buildbot/pubsub_test.go
diff --git a/milo/appengine/buildbot/pubsub_test.go b/milo/appengine/buildbot/pubsub_test.go
index 21b0d0f5da6aac7925b6327e5eecfd1125619abd..19c4cb997eaeab07f7c7596483ebebbc6e1ee859 100644
--- a/milo/appengine/buildbot/pubsub_test.go
+++ b/milo/appengine/buildbot/pubsub_test.go
@@ -40,7 +40,7 @@ func buildbotTimesPending(start float64) []*float64 {
return []*float64{&start, nil}
}
-func newCombinedPsBody(bs []buildbotBuild, m *buildbotMaster) io.ReadCloser {
+func newCombinedPsBody(bs []buildbotBuild, m *buildbotMaster, internal bool) io.ReadCloser {
bmsg := buildMasterMsg{
Master: m,
Builds: bs,
@@ -50,8 +50,12 @@ func newCombinedPsBody(bs []buildbotBuild, m *buildbotMaster) io.ReadCloser {
zw := zlib.NewWriter(&b)
zw.Write(bm)
zw.Close()
+ sub := "projects/luci-milo/subscriptions/buildbot-public"
+ if internal {
+ sub = "projects/luci-milo/subscriptions/buildbot-private"
+ }
msg := pubSubSubscription{
- Subscription: "projects/luci-milo/subscriptions/buildbot-public",
+ Subscription: sub,
Message: pubSubMessage{
Data: base64.StdEncoding.EncodeToString(b.Bytes()),
},
@@ -88,6 +92,7 @@ func TestPubSub(t *testing.T) {
err = ds.Get(loadB)
So(err, ShouldBeNil)
So(loadB.Master, ShouldEqual, "Fake Master")
+ So(loadB.Internal, ShouldEqual, false)
So(loadB.Currentstep.(string), ShouldEqual, "this is a string")
So(loadB.Finished, ShouldEqual, true)
})
@@ -179,7 +184,7 @@ func TestPubSub(t *testing.T) {
Slaves: slaves,
}
r := &http.Request{
- Body: newCombinedPsBody([]buildbotBuild{b}, &ms),
+ Body: newCombinedPsBody([]buildbotBuild{b}, &ms, false),
}
p := httprouter.Params{}
PubSubHandler(&router.Context{
@@ -217,7 +222,7 @@ func TestPubSub(t *testing.T) {
ms.Project.Title = "some other title"
h = httptest.NewRecorder()
r := &http.Request{
- Body: newCombinedPsBody([]buildbotBuild{b}, &ms)}
+ Body: newCombinedPsBody([]buildbotBuild{b}, &ms, false)}
p = httprouter.Params{}
PubSubHandler(&router.Context{
Context: c,
@@ -237,7 +242,7 @@ func TestPubSub(t *testing.T) {
b.Times = buildbotTimesFinished(123.0, 124.0)
h = httptest.NewRecorder()
r = &http.Request{
- Body: newCombinedPsBody([]buildbotBuild{b}, &ms),
+ Body: newCombinedPsBody([]buildbotBuild{b}, &ms, false),
}
p = httprouter.Params{}
PubSubHandler(&router.Context{
@@ -260,7 +265,7 @@ func TestPubSub(t *testing.T) {
b.Times = buildbotTimesPending(123.0)
h = httptest.NewRecorder()
r = &http.Request{
- Body: newCombinedPsBody([]buildbotBuild{b}, &ms),
+ Body: newCombinedPsBody([]buildbotBuild{b}, &ms, false),
}
p = httprouter.Params{}
PubSubHandler(&router.Context{
@@ -295,5 +300,62 @@ func TestPubSub(t *testing.T) {
})
So(h.Code, ShouldEqual, 200)
})
+
+ Convey("Internal master + build pusbsub subscription", func() {
+ h := httptest.NewRecorder()
+ slaves := map[string]*buildbotSlave{}
+ ft := 1234.0
+ slaves["testslave"] = &buildbotSlave{
+ Name: "testslave",
+ Connected: true,
+ Runningbuilds: []buildbotBuild{
+ {
+ Master: "Fake Master",
+ Buildername: "Fake buildername",
+ Number: 2222,
+ Times: []*float64{&ft, nil},
+ },
+ },
+ }
+ ms := buildbotMaster{
+ Name: "fakename",
+ Project: buildbotProject{Title: "some title"},
+ Slaves: slaves,
+ }
+ r := &http.Request{
+ Body: newCombinedPsBody([]buildbotBuild{b}, &ms, true),
+ }
+ p := httprouter.Params{}
+ PubSubHandler(&router.Context{
+ Context: c,
+ Writer: h,
+ Request: r,
+ Params: p,
+ })
+ So(h.Code, ShouldEqual, 200)
+ Convey("And stores correctly", func() {
+ loadB := &buildbotBuild{
+ Master: "Fake Master",
+ Buildername: "Fake buildername",
+ Number: 1234,
+ }
+ err := ds.Get(loadB)
+ So(err, ShouldBeNil)
+ So(loadB.Master, ShouldEqual, "Fake Master")
+ So(loadB.Internal, ShouldEqual, true)
+ So(loadB.Currentstep.(string), ShouldEqual, "this is a string")
+ m, internal, t, err := getMasterJSON(c, "fakename")
+ So(err, ShouldBeNil)
+ So(internal, ShouldEqual, true)
+ So(t.Unix(), ShouldEqual, 981173106)
+ So(m.Name, ShouldEqual, "fakename")
+ So(m.Project.Title, ShouldEqual, "some title")
+ So(m.Slaves["testslave"].Name, ShouldEqual, "testslave")
+ So(len(m.Slaves["testslave"].Runningbuilds), ShouldEqual, 0)
+ So(len(m.Slaves["testslave"].RunningbuildsMap), ShouldEqual, 1)
+ So(m.Slaves["testslave"].RunningbuildsMap["Fake buildername"][0],
+ ShouldEqual, 2222)
+ })
+ })
})
}
« no previous file with comments | « milo/appengine/buildbot/pubsub.go ('k') | milo/appengine/settings/acl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698