-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathoutput.go
712 lines (619 loc) · 20.6 KB
/
output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/*
*
* k6 - a next-generation load testing tool
* Copyright (C) 2017 Load Impact
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package cloud
import (
"errors"
"fmt"
"net/http"
"path/filepath"
"strings"
"sync"
"time"
"github.com/sirupsen/logrus"
"gopkg.in/guregu/null.v3"
"go.k6.io/k6/cloudapi"
"go.k6.io/k6/output"
"go.k6.io/k6/lib"
"go.k6.io/k6/lib/consts"
"go.k6.io/k6/lib/netext"
"go.k6.io/k6/lib/netext/httpext"
"go.k6.io/k6/metrics"
)
// TestName is the default Load Impact Cloud test name
const TestName = "k6 test"
// Output sends result data to the Load Impact cloud service.
type Output struct {
config cloudapi.Config
referenceID string
executionPlan []lib.ExecutionStep
duration int64 // in seconds
thresholds map[string][]*metrics.Threshold
client *MetricsClient
runStatus lib.RunStatus
bufferMutex sync.Mutex
bufferHTTPTrails []*httpext.Trail
bufferSamples []*Sample
logger logrus.FieldLogger
opts lib.Options
// TODO: optimize this
//
// Since the real-time metrics refactoring (https://github.com/k6io/k6/pull/678),
// we should no longer have to handle metrics that have times long in the past. So instead of a
// map, we can probably use a simple slice (or even an array!) as a ring buffer to store the
// aggregation buckets. This should save us a some time, since it would make the lookups and WaitPeriod
// checks basically O(1). And even if for some reason there are occasional metrics with past times that
// don't fit in the chosen ring buffer size, we could just send them along to the buffer unaggregated
aggrBuckets map[int64]map[[3]string]aggregationBucket
stopSendingMetrics chan struct{}
stopAggregation chan struct{}
aggregationDone *sync.WaitGroup
stopOutput chan struct{}
outputDone *sync.WaitGroup
engineStopFunc func(error)
}
// Verify that Output implements the wanted interfaces
var _ interface {
output.WithRunStatusUpdates
output.WithThresholds
output.WithTestRunStop
} = &Output{}
// New creates a new cloud output.
func New(params output.Params) (output.Output, error) {
return newOutput(params)
}
// New creates a new cloud output.
func newOutput(params output.Params) (*Output, error) {
conf, err := cloudapi.GetConsolidatedConfig(
params.JSONConfig, params.Environment, params.ConfigArgument, params.ScriptOptions.External)
if err != nil {
return nil, err
}
if err := validateRequiredSystemTags(params.ScriptOptions.SystemTags); err != nil {
return nil, err
}
logger := params.Logger.WithFields(logrus.Fields{"output": "cloud"})
if conf.AggregationPeriod.Duration > 0 &&
(params.ScriptOptions.SystemTags.Has(metrics.TagVU) || params.ScriptOptions.SystemTags.Has(metrics.TagIter)) {
return nil, errors.New("aggregation cannot be enabled if the 'vu' or 'iter' system tag is also enabled")
}
if !conf.Name.Valid || conf.Name.String == "" {
scriptPath := params.ScriptPath.String()
if scriptPath == "" {
// Script from stdin without a name, likely from stdin
return nil, errors.New("script name not set, please specify K6_CLOUD_NAME or options.ext.loadimpact.name")
}
conf.Name = null.StringFrom(filepath.Base(scriptPath))
}
if conf.Name.String == "-" {
conf.Name = null.StringFrom(TestName)
}
duration, testEnds := lib.GetEndOffset(params.ExecutionPlan)
if !testEnds {
return nil, errors.New("tests with unspecified duration are not allowed when outputting data to k6 cloud")
}
if !(conf.MetricPushConcurrency.Int64 > 0) {
return nil, fmt.Errorf("metrics push concurrency must be a positive number but is %d",
conf.MetricPushConcurrency.Int64)
}
if !(conf.MaxMetricSamplesPerPackage.Int64 > 0) {
return nil, fmt.Errorf("metric samples per package must be a positive number but is %d",
conf.MaxMetricSamplesPerPackage.Int64)
}
apiClient := cloudapi.NewClient(
logger, conf.Token.String, conf.Host.String, consts.Version, conf.Timeout.TimeDuration())
return &Output{
config: conf,
client: NewMetricsClient(apiClient, logger, conf.Host.String, conf.NoCompress.Bool),
executionPlan: params.ExecutionPlan,
duration: int64(duration / time.Second),
opts: params.ScriptOptions,
aggrBuckets: map[int64]map[[3]string]aggregationBucket{},
logger: logger,
stopSendingMetrics: make(chan struct{}),
stopAggregation: make(chan struct{}),
aggregationDone: &sync.WaitGroup{},
stopOutput: make(chan struct{}),
outputDone: &sync.WaitGroup{},
}, nil
}
// validateRequiredSystemTags checks if all required tags are present.
func validateRequiredSystemTags(scriptTags *metrics.SystemTagSet) error {
missingRequiredTags := []string{}
requiredTags := metrics.TagName |
metrics.TagMethod |
metrics.TagStatus |
metrics.TagError |
metrics.TagCheck |
metrics.TagGroup
for _, tag := range metrics.SystemTagSetValues() {
if requiredTags.Has(tag) && !scriptTags.Has(tag) {
missingRequiredTags = append(missingRequiredTags, tag.String())
}
}
if len(missingRequiredTags) > 0 {
return fmt.Errorf(
"the cloud output needs the following system tags enabled: %s",
strings.Join(missingRequiredTags, ", "),
)
}
return nil
}
// Start calls the k6 Cloud API to initialize the test run, and then starts the
// goroutine that would listen for metric samples and send them to the cloud.
func (out *Output) Start() error {
if out.config.PushRefID.Valid {
out.referenceID = out.config.PushRefID.String
out.logger.WithField("referenceId", out.referenceID).Debug("directly pushing metrics without init")
out.startBackgroundProcesses()
return nil
}
thresholds := make(map[string][]string)
for name, t := range out.thresholds {
for _, threshold := range t {
thresholds[name] = append(thresholds[name], threshold.Source)
}
}
maxVUs := lib.GetMaxPossibleVUs(out.executionPlan)
testRun := &cloudapi.TestRun{
Name: out.config.Name.String,
ProjectID: out.config.ProjectID.Int64,
VUsMax: int64(maxVUs),
Thresholds: thresholds,
Duration: out.duration,
}
response, err := out.client.CreateTestRun(testRun)
if err != nil {
return err
}
out.referenceID = response.ReferenceID
if response.ConfigOverride != nil {
out.logger.WithFields(logrus.Fields{
"override": response.ConfigOverride,
}).Debug("overriding config options")
out.config = out.config.Apply(*response.ConfigOverride)
}
out.startBackgroundProcesses()
out.logger.WithFields(logrus.Fields{
"name": out.config.Name,
"projectId": out.config.ProjectID,
"duration": out.duration,
"referenceId": out.referenceID,
}).Debug("Started!")
return nil
}
func (out *Output) startBackgroundProcesses() {
aggregationPeriod := out.config.AggregationPeriod.TimeDuration()
// If enabled, start periodically aggregating the collected HTTP trails
if aggregationPeriod > 0 {
out.aggregationDone.Add(1)
go func() {
defer out.aggregationDone.Done()
aggregationWaitPeriod := out.config.AggregationWaitPeriod.TimeDuration()
aggregationTicker := time.NewTicker(aggregationPeriod)
defer aggregationTicker.Stop()
for {
select {
case <-out.stopSendingMetrics:
return
case <-aggregationTicker.C:
out.aggregateHTTPTrails(aggregationWaitPeriod)
case <-out.stopAggregation:
out.aggregateHTTPTrails(0)
out.flushHTTPTrails()
return
}
}
}()
}
out.outputDone.Add(1)
go func() {
defer out.outputDone.Done()
pushTicker := time.NewTicker(out.config.MetricPushInterval.TimeDuration())
defer pushTicker.Stop()
for {
select {
case <-out.stopSendingMetrics:
return
default:
}
select {
case <-out.stopOutput:
out.pushMetrics()
return
case <-pushTicker.C:
out.pushMetrics()
}
}
}()
}
// Stop gracefully stops all metric emission from the output and when all metric
// samples are emitted, it sends an API to the cloud to finish the test run.
func (out *Output) Stop() error {
out.logger.Debug("Stopping the cloud output...")
close(out.stopAggregation)
out.aggregationDone.Wait() // could be a no-op, if we have never started the aggregation
out.logger.Debug("Aggregation stopped, stopping metric emission...")
close(out.stopOutput)
out.outputDone.Wait()
out.logger.Debug("Metric emission stopped, calling cloud API...")
err := out.testFinished()
if err != nil {
out.logger.WithFields(logrus.Fields{"error": err}).Warn("Failed to send test finished to the cloud")
} else {
out.logger.Debug("Cloud output successfully stopped!")
}
return err
}
// Description returns the URL with the test run results.
func (out *Output) Description() string {
return fmt.Sprintf("cloud (%s)", cloudapi.URLForResults(out.referenceID, out.config))
}
// SetRunStatus receives the latest run status from the Engine.
func (out *Output) SetRunStatus(status lib.RunStatus) {
out.runStatus = status
}
// SetThresholds receives the thresholds before the output is Start()-ed.
func (out *Output) SetThresholds(scriptThresholds map[string]metrics.Thresholds) {
thresholds := make(map[string][]*metrics.Threshold)
for name, t := range scriptThresholds {
thresholds[name] = append(thresholds[name], t.Thresholds...)
}
out.thresholds = thresholds
}
// SetTestRunStopCallback receives the function that stops the engine on error
func (out *Output) SetTestRunStopCallback(stopFunc func(error)) {
out.engineStopFunc = stopFunc
}
func useCloudTags(source *httpext.Trail) *httpext.Trail {
name, nameExist := source.Tags.Get("name")
url, urlExist := source.Tags.Get("url")
if !nameExist || !urlExist || name == url {
return source
}
newTags := source.Tags.CloneTags()
newTags["url"] = name
dest := new(httpext.Trail)
*dest = *source
dest.Tags = metrics.IntoSampleTags(&newTags)
dest.Samples = nil
return dest
}
// AddMetricSamples receives a set of metric samples. This method is never
// called concurrently, so it defers as much of the work as possible to the
// asynchronous goroutines initialized in Start().
func (out *Output) AddMetricSamples(sampleContainers []metrics.SampleContainer) {
select {
case <-out.stopSendingMetrics:
return
default:
}
if out.referenceID == "" {
return
}
newSamples := []*Sample{}
newHTTPTrails := []*httpext.Trail{}
for _, sampleContainer := range sampleContainers {
switch sc := sampleContainer.(type) {
case *httpext.Trail:
sc = useCloudTags(sc)
// Check if aggregation is enabled,
if out.config.AggregationPeriod.Duration > 0 {
newHTTPTrails = append(newHTTPTrails, sc)
} else {
newSamples = append(newSamples, NewSampleFromTrail(sc))
}
case *netext.NetTrail:
// TODO: aggregate?
values := map[string]float64{
metrics.DataSentName: float64(sc.BytesWritten),
metrics.DataReceivedName: float64(sc.BytesRead),
}
if sc.FullIteration {
values[metrics.IterationDurationName] = metrics.D(sc.EndTime.Sub(sc.StartTime))
values[metrics.IterationsName] = 1
}
newSamples = append(newSamples, &Sample{
Type: DataTypeMap,
Metric: "iter_li_all",
Data: &SampleDataMap{
Time: toMicroSecond(sc.GetTime()),
Tags: sc.GetTags(),
Values: values,
},
})
default:
for _, sample := range sampleContainer.GetSamples() {
newSamples = append(newSamples, &Sample{
Type: DataTypeSingle,
Metric: sample.Metric.Name,
Data: &SampleDataSingle{
Type: sample.Metric.Type,
Time: toMicroSecond(sample.Time),
Tags: sample.Tags,
Value: sample.Value,
},
})
}
}
}
if len(newSamples) > 0 || len(newHTTPTrails) > 0 {
out.bufferMutex.Lock()
out.bufferSamples = append(out.bufferSamples, newSamples...)
out.bufferHTTPTrails = append(out.bufferHTTPTrails, newHTTPTrails...)
out.bufferMutex.Unlock()
}
}
//nolint:funlen,nestif,gocognit
func (out *Output) aggregateHTTPTrails(waitPeriod time.Duration) {
out.bufferMutex.Lock()
newHTTPTrails := out.bufferHTTPTrails
out.bufferHTTPTrails = nil
out.bufferMutex.Unlock()
aggrPeriod := int64(out.config.AggregationPeriod.Duration)
// Distribute all newly buffered HTTP trails into buckets and sub-buckets
// this key is here specifically to not incur more allocations then necessary
// if you change this code please run the benchmarks and add the results to the commit message
var subBucketKey [3]string
for _, trail := range newHTTPTrails {
trailTags := trail.GetTags()
bucketID := trail.GetTime().UnixNano() / aggrPeriod
// Get or create a time bucket for that trail period
bucket, ok := out.aggrBuckets[bucketID]
if !ok {
bucket = make(map[[3]string]aggregationBucket)
out.aggrBuckets[bucketID] = bucket
}
subBucketKey[0], _ = trailTags.Get("name")
subBucketKey[1], _ = trailTags.Get("group")
subBucketKey[2], _ = trailTags.Get("status")
subBucket, ok := bucket[subBucketKey]
if !ok {
subBucket = aggregationBucket{}
bucket[subBucketKey] = subBucket
}
// Either use an existing subbucket key or use the trail tags as a new one
subSubBucketKey := trailTags
subSubBucket, ok := subBucket[subSubBucketKey]
if !ok {
for sbTags, sb := range subBucket {
if trailTags.IsEqual(sbTags) {
subSubBucketKey = sbTags
subSubBucket = sb
break
}
}
}
subBucket[subSubBucketKey] = append(subSubBucket, trail)
}
// Which buckets are still new and we'll wait for trails to accumulate before aggregating
bucketCutoffID := time.Now().Add(-waitPeriod).UnixNano() / aggrPeriod
iqrRadius := out.config.AggregationOutlierIqrRadius.Float64
iqrLowerCoef := out.config.AggregationOutlierIqrCoefLower.Float64
iqrUpperCoef := out.config.AggregationOutlierIqrCoefUpper.Float64
newSamples := []*Sample{}
// Handle all aggregation buckets older than bucketCutoffID
for bucketID, subBuckets := range out.aggrBuckets {
if bucketID > bucketCutoffID {
continue
}
for _, subBucket := range subBuckets {
for tags, httpTrails := range subBucket {
// start := time.Now() // this is in a combination with the log at the end
trailCount := int64(len(httpTrails))
if trailCount < out.config.AggregationMinSamples.Int64 {
for _, trail := range httpTrails {
newSamples = append(newSamples, NewSampleFromTrail(trail))
}
continue
}
aggrData := &SampleDataAggregatedHTTPReqs{
Time: toMicroSecond(time.Unix(0, bucketID*aggrPeriod+aggrPeriod/2)),
Type: "aggregated_trend",
Tags: tags,
}
if out.config.AggregationSkipOutlierDetection.Bool {
// Simply add up all HTTP trails, no outlier detection
for _, trail := range httpTrails {
aggrData.Add(trail)
}
} else {
connDurations := make(durations, trailCount)
reqDurations := make(durations, trailCount)
for i, trail := range httpTrails {
connDurations[i] = trail.ConnDuration
reqDurations[i] = trail.Duration
}
var minConnDur, maxConnDur, minReqDur, maxReqDur time.Duration
if trailCount < out.config.AggregationOutlierAlgoThreshold.Int64 {
// Since there are fewer samples, we'll use the interpolation-enabled and
// more precise sorting-based algorithm
minConnDur, maxConnDur = connDurations.SortGetNormalBounds(iqrRadius, iqrLowerCoef, iqrUpperCoef, true)
minReqDur, maxReqDur = reqDurations.SortGetNormalBounds(iqrRadius, iqrLowerCoef, iqrUpperCoef, true)
} else {
minConnDur, maxConnDur = connDurations.SelectGetNormalBounds(iqrRadius, iqrLowerCoef, iqrUpperCoef)
minReqDur, maxReqDur = reqDurations.SelectGetNormalBounds(iqrRadius, iqrLowerCoef, iqrUpperCoef)
}
for _, trail := range httpTrails {
if trail.ConnDuration < minConnDur ||
trail.ConnDuration > maxConnDur ||
trail.Duration < minReqDur ||
trail.Duration > maxReqDur {
// Seems like an outlier, add it as a standalone metric
newSamples = append(newSamples, NewSampleFromTrail(trail))
} else {
// Aggregate the trail
aggrData.Add(trail)
}
}
}
aggrData.CalcAverages()
if aggrData.Count > 0 {
/*
out.logger.WithFields(logrus.Fields{
"http_samples": aggrData.Count,
"ratio": fmt.Sprintf("%.2f", float64(aggrData.Count)/float64(trailCount)),
"t": time.Since(start),
}).Debug("Aggregated HTTP metrics")
//*/
newSamples = append(newSamples, &Sample{
Type: DataTypeAggregatedHTTPReqs,
Metric: "http_req_li_all",
Data: aggrData,
})
}
}
}
delete(out.aggrBuckets, bucketID)
}
if len(newSamples) > 0 {
out.bufferMutex.Lock()
out.bufferSamples = append(out.bufferSamples, newSamples...)
out.bufferMutex.Unlock()
}
}
func (out *Output) flushHTTPTrails() {
out.bufferMutex.Lock()
defer out.bufferMutex.Unlock()
newSamples := []*Sample{}
for _, trail := range out.bufferHTTPTrails {
newSamples = append(newSamples, NewSampleFromTrail(trail))
}
for _, bucket := range out.aggrBuckets {
for _, subBucket := range bucket {
for _, trails := range subBucket {
for _, trail := range trails {
newSamples = append(newSamples, NewSampleFromTrail(trail))
}
}
}
}
out.bufferHTTPTrails = nil
out.aggrBuckets = map[int64]map[[3]string]aggregationBucket{}
out.bufferSamples = append(out.bufferSamples, newSamples...)
}
func (out *Output) shouldStopSendingMetrics(err error) bool {
if err == nil {
return false
}
if errResp, ok := err.(cloudapi.ErrorResponse); ok && errResp.Response != nil {
return errResp.Response.StatusCode == http.StatusForbidden && errResp.Code == 4
}
return false
}
type pushJob struct {
done chan error
samples []*Sample
}
// ceil(a/b)
func ceilDiv(a, b int) int {
r := a / b
if a%b != 0 {
r++
}
return r
}
func (out *Output) pushMetrics() {
out.bufferMutex.Lock()
if len(out.bufferSamples) == 0 {
out.bufferMutex.Unlock()
return
}
buffer := out.bufferSamples
out.bufferSamples = nil
out.bufferMutex.Unlock()
count := len(buffer)
out.logger.WithFields(logrus.Fields{
"samples": count,
}).Debug("Pushing metrics to cloud")
start := time.Now()
numberOfPackages := ceilDiv(len(buffer), int(out.config.MaxMetricSamplesPerPackage.Int64))
numberOfWorkers := int(out.config.MetricPushConcurrency.Int64)
if numberOfWorkers > numberOfPackages {
numberOfWorkers = numberOfPackages
}
ch := make(chan pushJob, numberOfPackages)
for i := 0; i < numberOfWorkers; i++ {
go func() {
for job := range ch {
err := out.client.PushMetric(out.referenceID, job.samples)
job.done <- err
if out.shouldStopSendingMetrics(err) {
return
}
}
}()
}
jobs := make([]pushJob, 0, numberOfPackages)
for len(buffer) > 0 {
size := len(buffer)
if size > int(out.config.MaxMetricSamplesPerPackage.Int64) {
size = int(out.config.MaxMetricSamplesPerPackage.Int64)
}
job := pushJob{done: make(chan error, 1), samples: buffer[:size]}
ch <- job
jobs = append(jobs, job)
buffer = buffer[size:]
}
close(ch)
for _, job := range jobs {
err := <-job.done
if err != nil {
if out.shouldStopSendingMetrics(err) {
out.logger.WithError(err).Warn("Stopped sending metrics to cloud due to an error")
if out.config.StopOnError.Bool {
out.engineStopFunc(err)
}
close(out.stopSendingMetrics)
break
}
out.logger.WithError(err).Warn("Failed to send metrics to cloud")
}
}
out.logger.WithFields(logrus.Fields{
"samples": count,
"t": time.Since(start),
}).Debug("Pushing metrics to cloud finished")
}
func (out *Output) testFinished() error {
if out.referenceID == "" || out.config.PushRefID.Valid {
return nil
}
testTainted := false
thresholdResults := make(cloudapi.ThresholdResult)
for name, thresholds := range out.thresholds {
thresholdResults[name] = make(map[string]bool)
for _, t := range thresholds {
thresholdResults[name][t.Source] = t.LastFailed
if t.LastFailed {
testTainted = true
}
}
}
out.logger.WithFields(logrus.Fields{
"ref": out.referenceID,
"tainted": testTainted,
}).Debug("Sending test finished")
runStatus := lib.RunStatusFinished
if out.runStatus != lib.RunStatusQueued {
runStatus = out.runStatus
}
return out.client.TestFinished(out.referenceID, thresholdResults, testTainted, runStatus)
}
const expectedGzipRatio = 6 // based on test it is around 6.8, but we don't need to be that accurate