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

Side by Side Diff: logdog/appengine/coordinator/endpoints/services/registerStream_test.go

Issue 2991253004: [logdog] Remove list functionality. (Closed)
Patch Set: fix test Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. 1 // Copyright 2015 The LUCI Authors.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 10 matching lines...) Expand all
21 "time" 21 "time"
22 22
23 "github.com/luci/gae/filter/featureBreaker" 23 "github.com/luci/gae/filter/featureBreaker"
24 ds "github.com/luci/gae/service/datastore" 24 ds "github.com/luci/gae/service/datastore"
25 "github.com/luci/luci-go/common/proto/google" 25 "github.com/luci/luci-go/common/proto/google"
26 "github.com/luci/luci-go/logdog/api/config/svcconfig" 26 "github.com/luci/luci-go/logdog/api/config/svcconfig"
27 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1" 27 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1"
28 "github.com/luci/luci-go/logdog/api/logpb" 28 "github.com/luci/luci-go/logdog/api/logpb"
29 "github.com/luci/luci-go/logdog/appengine/coordinator" 29 "github.com/luci/luci-go/logdog/appengine/coordinator"
30 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest " 30 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest "
31 "github.com/luci/luci-go/logdog/appengine/coordinator/hierarchy"
32 "github.com/luci/luci-go/logdog/common/types" 31 "github.com/luci/luci-go/logdog/common/types"
33 "github.com/luci/luci-go/luci_config/common/cfgtypes" 32 "github.com/luci/luci-go/luci_config/common/cfgtypes"
34 "golang.org/x/net/context" 33 "golang.org/x/net/context"
35 34
36 . "github.com/luci/luci-go/common/testing/assertions" 35 . "github.com/luci/luci-go/common/testing/assertions"
37 . "github.com/smartystreets/goconvey/convey" 36 . "github.com/smartystreets/goconvey/convey"
38 ) 37 )
39 38
40 func TestRegisterStream(t *testing.T) { 39 func TestRegisterStream(t *testing.T) {
41 t.Parallel() 40 t.Parallel()
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 So(tls.State.Terminated(), ShouldBeFalse ) 118 So(tls.State.Terminated(), ShouldBeFalse )
120 So(tls.State.ArchivalState(), ShouldEqua l, coordinator.NotArchived) 119 So(tls.State.ArchivalState(), ShouldEqua l, coordinator.NotArchived)
121 120
122 // Should also register the log stream P refix. 121 // Should also register the log stream P refix.
123 So(tls.Prefix.Created, ShouldResemble, c reated) 122 So(tls.Prefix.Created, ShouldResemble, c reated)
124 So(tls.Prefix.Secret, ShouldResemble, re q.Secret) 123 So(tls.Prefix.Secret, ShouldResemble, re q.Secret)
125 124
126 // No archival request yet. 125 // No archival request yet.
127 So(env.ArchivalPublisher.Hashes(), Shoul dResemble, []string{}) 126 So(env.ArchivalPublisher.Hashes(), Shoul dResemble, []string{})
128 127
129 // Should have name components.
130 getNameComponents := func(b string) []st ring {
131 l, err := hierarchy.Get(c, hiera rchy.Request{Project: string(tls.Project), PathBase: b})
132 if err != nil {
133 panic(err)
134 }
135 names := make([]string, len(l.Co mp))
136 for i, e := range l.Comp {
137 names[i] = e.Name
138 if e.Stream {
139 names[i] += "$"
140 }
141 }
142 return names
143 }
144 So(getNameComponents(""), ShouldResemble , []string{"testing"})
145 So(getNameComponents("testing"), ShouldR esemble, []string{"+"})
146 So(getNameComponents("testing/+"), Shoul dResemble, []string{"foo"})
147 So(getNameComponents("testing/+/foo"), S houldResemble, []string{"bar$"})
148
149 Convey(`Can register the stream again (i dempotent).`, func() { 128 Convey(`Can register the stream again (i dempotent).`, func() {
150 env.Clock.Set(created.Add(10 * t ime.Minute)) 129 env.Clock.Set(created.Add(10 * t ime.Minute))
151 130
152 resp, err := svr.RegisterStream( c, &req) 131 resp, err := svr.RegisterStream( c, &req)
153 So(err, ShouldBeRPCOK) 132 So(err, ShouldBeRPCOK)
154 So(resp, ShouldResemble, expResp ) 133 So(resp, ShouldResemble, expResp )
155 134
156 tls.WithProjectNamespace(c, func (c context.Context) { 135 tls.WithProjectNamespace(c, func (c context.Context) {
157 So(ds.Get(c, tls.Stream, tls.State), ShouldBeNil) 136 So(ds.Get(c, tls.Stream, tls.State), ShouldBeNil)
158 }) 137 })
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 Desc: tls.DescBytes(), 336 Desc: tls.DescBytes(),
358 TerminalIndex: -1, 337 TerminalIndex: -1,
359 } 338 }
360 339
361 _, err := svr.RegisterStream(c, &req) 340 _, err := svr.RegisterStream(c, &req)
362 if err != nil { 341 if err != nil {
363 b.Fatalf("failed to get OK response (%s)", err) 342 b.Fatalf("failed to get OK response (%s)", err)
364 } 343 }
365 } 344 }
366 } 345 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/endpoints/services/registerStream.go ('k') | logdog/appengine/coordinator/hierarchy/component.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698