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

Side by Side Diff: milo/buildsource/buildbot/pubsub_test.go

Issue 2955223002: Milo: Buildbucket PubSub ingestion outline (Closed)
Patch Set: rebase Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « milo/buildsource/buildbot/pubsub.go ('k') | milo/buildsource/buildbucket/builder_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/zlib" 9 "compress/zlib"
10 "encoding/base64" 10 "encoding/base64"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 bm, _ := json.Marshal(bmsg) 65 bm, _ := json.Marshal(bmsg)
66 var b bytes.Buffer 66 var b bytes.Buffer
67 zw := zlib.NewWriter(&b) 67 zw := zlib.NewWriter(&b)
68 zw.Write(bm) 68 zw.Write(bm)
69 zw.Close() 69 zw.Close()
70 sub := "projects/luci-milo/subscriptions/buildbot-public" 70 sub := "projects/luci-milo/subscriptions/buildbot-public"
71 if internal { 71 if internal {
72 sub = "projects/luci-milo/subscriptions/buildbot-private" 72 sub = "projects/luci-milo/subscriptions/buildbot-private"
73 } 73 }
74 » msg := pubSubSubscription{ 74 » msg := common.PubSubSubscription{
75 Subscription: sub, 75 Subscription: sub,
76 » » Message: pubSubMessage{ 76 » » Message: common.PubSubMessage{
77 Data: base64.StdEncoding.EncodeToString(b.Bytes()), 77 Data: base64.StdEncoding.EncodeToString(b.Bytes()),
78 }, 78 },
79 } 79 }
80 jmsg, _ := json.Marshal(msg) 80 jmsg, _ := json.Marshal(msg)
81 return ioutil.NopCloser(bytes.NewReader(jmsg)) 81 return ioutil.NopCloser(bytes.NewReader(jmsg))
82 } 82 }
83 83
84 func TestPubSub(t *testing.T) { 84 func TestPubSub(t *testing.T) {
85 Convey(`A test Environment`, t, func() { 85 Convey(`A test Environment`, t, func() {
86 c := memory.UseWithAppID(context.Background(), "dev~luci-milo") 86 c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
87 c = gologger.StdConfig.Use(c) 87 c = gologger.StdConfig.Use(c)
88 c, _ = testclock.UseTime(c, fakeTime) 88 c, _ = testclock.UseTime(c, fakeTime)
89 c = testconfig.WithCommonClient(c, memcfg.New(bbAclConfigs)) 89 c = testconfig.WithCommonClient(c, memcfg.New(bbAclConfigs))
90 c = auth.WithState(c, &authtest.FakeState{ 90 c = auth.WithState(c, &authtest.FakeState{
91 Identity: identity.AnonymousIdentity, 91 Identity: identity.AnonymousIdentity,
92 IdentityGroups: []string{"all"}, 92 IdentityGroups: []string{"all"},
93 }) 93 })
94 // Update the service config so that the settings are loaded. 94 // Update the service config so that the settings are loaded.
95 » » err := common.UpdateServiceConfig(c) 95 » » _, err := common.UpdateServiceConfig(c)
96 So(err, ShouldBeNil) 96 So(err, ShouldBeNil)
97 97
98 rand.Seed(5) 98 rand.Seed(5)
99 99
100 Convey("Remove source changes", func() { 100 Convey("Remove source changes", func() {
101 m := &buildbotMaster{ 101 m := &buildbotMaster{
102 Name: "fake", 102 Name: "fake",
103 Builders: map[string]*buildbotBuilder{ 103 Builders: map[string]*buildbotBuilder{
104 "fake builder": { 104 "fake builder": {
105 PendingBuildStates: []*buildbotP ending{ 105 PendingBuildStates: []*buildbotP ending{
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 So(m.Project.Title, ShouldEqual, "some title") 485 So(m.Project.Title, ShouldEqual, "some title")
486 So(m.Slaves["testslave"].Name, ShouldEqual, "tes tslave") 486 So(m.Slaves["testslave"].Name, ShouldEqual, "tes tslave")
487 So(len(m.Slaves["testslave"].Runningbuilds), Sho uldEqual, 0) 487 So(len(m.Slaves["testslave"].Runningbuilds), Sho uldEqual, 0)
488 So(len(m.Slaves["testslave"].RunningbuildsMap), ShouldEqual, 1) 488 So(len(m.Slaves["testslave"].RunningbuildsMap), ShouldEqual, 1)
489 So(m.Slaves["testslave"].RunningbuildsMap["Fake buildername"][0], 489 So(m.Slaves["testslave"].RunningbuildsMap["Fake buildername"][0],
490 ShouldEqual, 2222) 490 ShouldEqual, 2222)
491 }) 491 })
492 }) 492 })
493 }) 493 })
494 } 494 }
OLDNEW
« no previous file with comments | « milo/buildsource/buildbot/pubsub.go ('k') | milo/buildsource/buildbucket/builder_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698