Skip to content

Commit f139528

Browse files
committed
Fixes splunk uploads
1 parent a37d05d commit f139528

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

tools/flakeguard/reports/io.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,6 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
480480
fullReport.SelectedTests = append(fullReport.SelectedTests, test)
481481
}
482482

483-
// Get the report without any results to send to splunk
484-
splunkReport := *fullReport
485-
486483
// Prepare final results
487484
var (
488485
aggregatedResults []TestResult
@@ -497,14 +494,16 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
497494
GenerateSummaryData(fullReport)
498495

499496
if sendToSplunk {
500-
err = sendDataToSplunk(opts, splunkReport, aggregatedResults...)
497+
err = sendDataToSplunk(opts, *fullReport)
501498
}
502499
return fullReport, err
503500
}
504501

505502
// sendDataToSplunk sends a truncated TestReport and each individual TestResults to Splunk as events
506-
func sendDataToSplunk(opts *aggregateOptions, report TestReport, results ...TestResult) error {
503+
func sendDataToSplunk(opts *aggregateOptions, report TestReport) error {
507504
start := time.Now()
505+
results := report.Results
506+
report.Results = nil // Don't send results to Splunk, doing that individually
508507
// Dry-run mode for example runs
509508
isExampleRun := strings.Contains(opts.splunkURL, "splunk.example.com")
510509

@@ -515,7 +514,7 @@ func sendDataToSplunk(opts *aggregateOptions, report TestReport, results ...Test
515514
SetHeader("Content-Type", "application/json").
516515
SetLogger(ZerologRestyLogger{})
517516

518-
log.Debug().Str("report id", report.ID).Int("results", len(results)).Msg("Sending aggregated data to Splunk")
517+
log.Debug().Str("report id", report.ID).Int("results", len(report.Results)).Msg("Sending aggregated data to Splunk")
519518

520519
var (
521520
splunkErrs = []error{}

tools/flakeguard/reports/io_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func TestAggregateResultFilesSplunk(t *testing.T) {
4646
require.Equal(t, splunkEvent, report.Event.Event, "event mismatch")
4747
require.Equal(t, reportID, report.Event.Data.ID, "report ID mismatch")
4848
require.False(t, report.Event.Incomplete, "report should not be incomplete")
49+
require.NotNil(t, report.Event.Data.SummaryData, "report summary data is nil")
50+
require.Len(t, report.Event.Data.Results, 0, "shouldn't send all result data to splunk")
4951
reportRequestsReceived++
5052
} else {
5153
results, err := unBatchSplunkResults(bodyBytes)

0 commit comments

Comments
 (0)