Skip to content

Commit

Permalink
Fixes syncer test race (#14772)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez authored Oct 16, 2024
1 parent d5dfe4a commit 2b67c54
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/services/registrysyncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (l *launcher) Launch(ctx context.Context, localRegistry *registrysyncer.Loc

type orm struct {
ormMock *syncerMocks.ORM
mu sync.RWMutex
latestLocalRegistryCh chan struct{}
addLocalRegistryCh chan struct{}
}
Expand All @@ -159,17 +160,23 @@ func newORM(t *testing.T) *orm {
}

func (o *orm) Cleanup() {
o.mu.Lock()
defer o.mu.Unlock()
close(o.latestLocalRegistryCh)
close(o.addLocalRegistryCh)
}

func (o *orm) AddLocalRegistry(ctx context.Context, localRegistry registrysyncer.LocalRegistry) error {
o.mu.Lock()
defer o.mu.Unlock()
o.addLocalRegistryCh <- struct{}{}
err := o.ormMock.AddLocalRegistry(ctx, localRegistry)
return err
}

func (o *orm) LatestLocalRegistry(ctx context.Context) (*registrysyncer.LocalRegistry, error) {
o.mu.Lock()
defer o.mu.Unlock()
o.latestLocalRegistryCh <- struct{}{}
return o.ormMock.LatestLocalRegistry(ctx)
}
Expand Down

0 comments on commit 2b67c54

Please sign in to comment.