| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 swarming | 5 package swarming |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "fmt" | 9 "fmt" |
| 10 "io/ioutil" | 10 "io/ioutil" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 return &sr | 108 return &sr |
| 109 } | 109 } |
| 110 | 110 |
| 111 func (tc *testCase) getSwarmingOutput() string { | 111 func (tc *testCase) getSwarmingOutput() string { |
| 112 return string(tc.getContent(tc.swarmOutput)) | 112 return string(tc.getContent(tc.swarmOutput)) |
| 113 } | 113 } |
| 114 | 114 |
| 115 func (tc *testCase) getAnnotation() *miloProto.Step { | 115 func (tc *testCase) getAnnotation() *miloProto.Step { |
| 116 var step miloProto.Step | 116 var step miloProto.Step |
| 117 data := tc.getContent(tc.annotations) | 117 data := tc.getContent(tc.annotations) |
| 118 if len(data) == 0 { |
| 119 return nil |
| 120 } |
| 121 |
| 118 if err := proto.UnmarshalText(string(data), &step); err != nil { | 122 if err := proto.UnmarshalText(string(data), &step); err != nil { |
| 119 panic(fmt.Errorf("failed to unmarshal text protobuf [%s]: %s", t
c.annotations, err)) | 123 panic(fmt.Errorf("failed to unmarshal text protobuf [%s]: %s", t
c.annotations, err)) |
| 120 } | 124 } |
| 121 return &step | 125 return &step |
| 122 } | 126 } |
| 123 | 127 |
| 124 type debugSwarmingService struct { | 128 type debugSwarmingService struct { |
| 125 tc *testCase | 129 tc *testCase |
| 126 } | 130 } |
| 127 | 131 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 err error | 180 err error |
| 177 } | 181 } |
| 178 | 182 |
| 179 func (tc *testLogDogClient) Tail(ctx context.Context, in *logdog.TailRequest, op
ts ...grpc.CallOption) ( | 183 func (tc *testLogDogClient) Tail(ctx context.Context, in *logdog.TailRequest, op
ts ...grpc.CallOption) ( |
| 180 *logdog.GetResponse, error) { | 184 *logdog.GetResponse, error) { |
| 181 | 185 |
| 182 tc.req = in | 186 tc.req = in |
| 183 if tc.err != nil { | 187 if tc.err != nil { |
| 184 return nil, tc.err | 188 return nil, tc.err |
| 185 } | 189 } |
| 190 if tc.resp == nil { |
| 191 return nil, coordinator.ErrNoSuchStream |
| 192 } |
| 186 return tc.resp.(*logdog.GetResponse), nil | 193 return tc.resp.(*logdog.GetResponse), nil |
| 187 } | 194 } |
| 188 | 195 |
| 189 func logDogClientFunc(tc *testCase) func(context.Context, string) (*coordinator.
Client, error) { | 196 func logDogClientFunc(tc *testCase) func(context.Context, string) (*coordinator.
Client, error) { |
| 197 anno := tc.getAnnotation() |
| 198 var resp interface{} |
| 199 if anno != nil { |
| 200 resp = datagramGetResponse("testproject", "foo/bar", tc.getAnnot
ation()) |
| 201 } |
| 202 |
| 190 return func(c context.Context, host string) (*coordinator.Client, error)
{ | 203 return func(c context.Context, host string) (*coordinator.Client, error)
{ |
| 191 return &coordinator.Client{ | 204 return &coordinator.Client{ |
| 192 » » » Host: "example.com", | 205 » » » Host: host, |
| 193 C: &testLogDogClient{ | 206 C: &testLogDogClient{ |
| 194 » » » » resp: datagramGetResponse("testproject", "foo/ba
r", tc.getAnnotation()), | 207 » » » » resp: resp, |
| 195 }, | 208 }, |
| 196 }, nil | 209 }, nil |
| 197 } | 210 } |
| 198 } | 211 } |
| 199 | 212 |
| 200 func datagramGetResponse(project, prefix string, msg proto.Message) *logdog.GetR
esponse { | 213 func datagramGetResponse(project, prefix string, msg proto.Message) *logdog.GetR
esponse { |
| 201 data, err := proto.Marshal(msg) | 214 data, err := proto.Marshal(msg) |
| 202 if err != nil { | 215 if err != nil { |
| 203 panic(err) | 216 panic(err) |
| 204 } | 217 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if err != nil { | 266 if err != nil { |
| 254 panic(fmt.Errorf("Error while processing %s: %s", tc.nam
e, err)) | 267 panic(fmt.Errorf("Error while processing %s: %s", tc.nam
e, err)) |
| 255 } | 268 } |
| 256 results = append(results, settings.TestBundle{ | 269 results = append(results, settings.TestBundle{ |
| 257 Description: tc.name, | 270 Description: tc.name, |
| 258 Data: templates.Args{"Build": build}, | 271 Data: templates.Args{"Build": build}, |
| 259 }) | 272 }) |
| 260 } | 273 } |
| 261 return results | 274 return results |
| 262 } | 275 } |
| OLD | NEW |