client_locks_test.go 497 B

1234567891011121314151617181920212223242526
  1. package service
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestLockInboundReleasesRegistryMutexWhileWaiting(t *testing.T) {
  7. const id = 990006
  8. held := lockInbound(id)
  9. parked := make(chan struct{})
  10. go func() {
  11. close(parked)
  12. lockInbound(id).Unlock()
  13. }()
  14. <-parked
  15. time.Sleep(50 * time.Millisecond)
  16. if !inboundMutationLocksMu.TryLock() {
  17. held.Unlock()
  18. t.Fatal("registry mutex is held while a lockInbound caller waits on a busy inbound")
  19. }
  20. inboundMutationLocksMu.Unlock()
  21. held.Unlock()
  22. }