Skip to content

Commit

Permalink
[YUNIKORN-2157] Data race in TestStoreWithLimitedSize (apache#716)
Browse files Browse the repository at this point in the history
Closes: apache#716

Signed-off-by: Peter Bacsko <[email protected]>
  • Loading branch information
pbacsko committed Nov 17, 2023
1 parent c0140a9 commit 4048637
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 6 additions & 2 deletions pkg/events/event_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/apache/yunikorn-scheduler-interface/lib/go/si"
)

var defaultEventStoreSize = 1000
const defaultEventStoreSize = 1000

// The EventStore operates under the following assumptions:
// - there is a cap for the number of events stored
Expand All @@ -40,8 +40,12 @@ type EventStore struct {
}

func newEventStore() *EventStore {
return newEventStoreWithSize(defaultEventStoreSize)
}

func newEventStoreWithSize(size int) *EventStore {
return &EventStore{
events: make([]*si.EventRecord, defaultEventStoreSize),
events: make([]*si.EventRecord, size),
}
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/events/event_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ func TestStoreAndRetrieve(t *testing.T) {
// if we push more events to the EventStore than its
// allowed maximum, those that couldn't fit will be omitted
func TestStoreWithLimitedSize(t *testing.T) {
defaultEventStoreSize = 3
defer func() {
defaultEventStoreSize = 1000
}()
store := newEventStoreWithSize(3)

store := newEventStore()
for i := 0; i < 5; i++ {
event := &si.EventRecord{
Type: si.EventRecord_REQUEST,
Expand Down

0 comments on commit 4048637

Please sign in to comment.