Skip to content

Commit

Permalink
even more intense
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
  • Loading branch information
crenshaw-dev committed Dec 14, 2024
1 parent e38d948 commit d23d5b1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions server/application/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,27 @@ func TestMergeLogStreams(t *testing.T) {

func TestMergeLogStreams_RaceCondition(t *testing.T) {
// Test for regression of this issue: https://github.com/argoproj/argo-cd/issues/7006
for i := 0; i < 1000; i++ {
for i := 0; i < 5000; i++ {
first := make(chan logEntry)
second := make(chan logEntry)

go func() {
parseLogsStream("first", io.NopCloser(strings.NewReader(`2021-02-09T00:00:01Z 1`)), first)
time.Sleep(time.Duration(i%10) * time.Millisecond)
time.Sleep(time.Duration(i%3) * time.Millisecond) // Reduce the variability in timing
close(first)
}()

go func() {
parseLogsStream("second", io.NopCloser(strings.NewReader(`2021-02-09T00:00:02Z 2`)), second)
time.Sleep(time.Duration((i+5)%10) * time.Millisecond)
time.Sleep(time.Duration((i+1)%3) * time.Millisecond)
close(second)
}()

merged := mergeLogStreams([]chan logEntry{first, second}, 5*time.Millisecond)
merged := mergeLogStreams([]chan logEntry{first, second}, 1*time.Millisecond)

var lines []string
for entry := range merged {
lines = append(lines, entry.line)
}

expected := []string{"1", "2"}
assert.Equal(t, expected, lines)
}
}

0 comments on commit d23d5b1

Please sign in to comment.