Skip to content

Commit

Permalink
Provide deadlines for degradation detector
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Nov 17, 2023
1 parent 3df5532 commit 9c82c3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cmd/degradation-detector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ func main() {
analysisSettings = append(analysisSettings, analysis.GeneratePhpStormSettings()...)
analysisSettings = append(analysisSettings, analysis.GenerateUnitTestsSettings(backendUrl, client)...)

ctx := context.Background()
degradations := make([]detector.Degradation, 0, 1000)
for _, analysisSetting := range analysisSettings {
slog.Info("processing", "settings", analysisSetting)
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
timestamps, values, builds, err := detector.GetDataFromClickhouse(ctx, client, backendUrl, analysisSetting)
if err != nil {
slog.Error("error while getting data from clickhouse", "error", err)
}

degradations = append(degradations, detector.InferDegradations(values, builds, timestamps, analysisSetting)...)
cancel()
}

insertionResults := detector.PostDegradations(ctx, client, backendUrl, degradations)
insertionCtx, cancelInsertion := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancelInsertion()
insertionResults := detector.PostDegradations(insertionCtx, client, backendUrl, degradations)

var wg sync.WaitGroup
for _, result := range insertionResults {
Expand All @@ -59,12 +62,14 @@ func main() {
continue
}
wg.Add(1)
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
go func(result detector.InsertionResults) {
defer wg.Done()
err := detector.SendSlackMessage(ctx, client, result.Degradation)
if err != nil {
slog.Error("error while sending slack message", "error", err)
}
cancel()
}(result)
}
wg.Wait()
Expand Down
4 changes: 3 additions & 1 deletion pkg/degradation-detector/fetchTestNames.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import (
"fmt"
dataQuery "github.com/JetBrains/ij-perf-report-aggregator/pkg/data-query"
"net/http"
"time"
)

func GetAllTests(backendUrl string, client *http.Client, settings Settings) ([]string, error) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
query := []dataQuery.DataQuery{
{
Database: settings.Db,
Expand Down

0 comments on commit 9c82c3d

Please sign in to comment.