Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Log links merging logic should take log link names into account #32

Merged
merged 1 commit into from
Nov 9, 2019
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
16 changes: 8 additions & 8 deletions pkg/repositories/transformers/task_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ func mergeLogs(existing, latest []*core.TaskLog) []*core.TaskLog {
if len(existing) == 0 {
return latest
}
existingSet := make(map[string]*core.TaskLog, len(existing))
for _, existingLog := range existing {
existingSet[existingLog.Uri] = existingLog
}
// Copy over the existing logs from the input list so we preserve the original order.
logs := existing
latestSet := make(map[string]*core.TaskLog, len(latest))
for _, latestLog := range latest {
if _, ok := existingSet[latestLog.Uri]; !ok {
latestSet[latestLog.Uri] = latestLog
}
// Copy over the latest logs since names will change for existing logs as a task transitions across phases.
logs := latest
for _, existingLog := range existing {
if _, ok := latestSet[existingLog.Uri]; !ok {
// We haven't seen this log before: add it to the output result list.
logs = append(logs, latestLog)
logs = append(logs, existingLog)
}
}
return logs
Expand Down
24 changes: 12 additions & 12 deletions pkg/repositories/transformers/task_execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,15 @@ func TestUpdateTaskExecutionModelRunningToFailed(t *testing.T) {
Error: outputError,
},
Logs: []*core.TaskLog{
{
Uri: "uri_a",
},
{
Uri: "uri_b",
},
{
Uri: "uri_c",
},
{
Uri: "uri_a",
},
},
CustomInfo: &customInfo,
}
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestMergeLogs(t *testing.T) {
},
{
Uri: "uri_b",
Name: "name_b",
Name: "ignored_name_b",
},
{
Uri: "uri_c",
Expand All @@ -545,22 +545,22 @@ func TestMergeLogs(t *testing.T) {
},
},
expected: []*core.TaskLog{
{
Uri: "uri_a",
Name: "name_a",
},
{
Uri: "uri_b",
Name: "name_b",
},
{
Uri: "uri_c",
Name: "name_c",
},
{
Uri: "uri_d",
Name: "name_d",
},
{
Uri: "uri_a",
Name: "name_a",
},
{
Uri: "uri_c",
Name: "name_c",
},
},
name: "Merge unique logs",
},
Expand Down