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

Added mutex to avoid concurrency errors on SubscriptionManager #2316

Merged
merged 3 commits into from
Apr 5, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:

build-go:
name: Build go binaries (API Server and CLI)
needs: [unit-test-cli, test-server]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this dependency to avoid running tests based on build if our unit tests break by some reason.

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 5 additions & 0 deletions server/executor/eventemitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package executor

import (
"context"
"sync"

"github.com/kubeshop/tracetest/server/model"
)
Expand All @@ -17,6 +18,7 @@ type publisher interface {
type internalEventEmitter struct {
repository model.TestRunEventRepository
publisher publisher
mutex sync.Mutex
}

func NewEventEmitter(repository model.TestRunEventRepository, publisher publisher) EventEmitter {
Expand All @@ -32,6 +34,9 @@ func (em *internalEventEmitter) Emit(ctx context.Context, event model.TestRunEve
return err
}

em.mutex.Lock()
defer em.mutex.Unlock()

em.publisher.Publish(event.ResourceID(), event)

return nil
Expand Down