Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Splunk Uploads for Flakeguard #1621

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions tools/flakeguard/reports/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,6 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
fullReport.SelectedTests = append(fullReport.SelectedTests, test)
}

// Get the report without any results to send to splunk
splunkReport := *fullReport

// Prepare final results
var (
aggregatedResults []TestResult
Expand All @@ -497,14 +494,16 @@ func aggregate(reportChan <-chan *TestReport, errChan <-chan error, opts *aggreg
GenerateSummaryData(fullReport)

if sendToSplunk {
err = sendDataToSplunk(opts, splunkReport, aggregatedResults...)
err = sendDataToSplunk(opts, *fullReport)
}
return fullReport, err
}

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

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

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

var (
splunkErrs = []error{}
Expand Down
2 changes: 2 additions & 0 deletions tools/flakeguard/reports/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func TestAggregateResultFilesSplunk(t *testing.T) {
require.Equal(t, splunkEvent, report.Event.Event, "event mismatch")
require.Equal(t, reportID, report.Event.Data.ID, "report ID mismatch")
require.False(t, report.Event.Incomplete, "report should not be incomplete")
require.NotNil(t, report.Event.Data.SummaryData, "report summary data is nil")
require.Len(t, report.Event.Data.Results, 0, "shouldn't send all result data to splunk")
reportRequestsReceived++
} else {
results, err := unBatchSplunkResults(bodyBytes)
Expand Down
Loading