mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
github.com/argoproj/pkg/v2 was one of two live argoproj dependencies. It is 11 files and 176K total, and we used five packages from it: grpc/http, kubeclientmetrics, stats, sync, time. Vendored into util/vendored/ and the dependency dropped from go.mod, so the gRPC surface (2 references, in grpc-http/forwarders.go) is now ours to remove on our own schedule rather than upstream's. Kubernetes client-go pulls gRPC transitively regardless, so this is isolation — a realistic first step — not a claim that gRPC is gone. Internalized rather than forked to a shared repo because the only other consumer, hanzo/gitops, has zero live deployments and zero dependents. A second repo would be a second thing to version for one caller. NOTICE carries the Apache-2.0 attribution. go build ./... exit 0. Co-authored-by: Hanzo Dev <[email protected]>
110 lines
1.3 KiB
Go
110 lines
1.3 KiB
Go
package sync
|
|
|
|
import (
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestLockLock(t *testing.T) {
|
|
l := NewKeyLock()
|
|
|
|
l.Lock("my-key")
|
|
|
|
unlocked := false
|
|
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(1)
|
|
go func() {
|
|
l.Lock("my-key")
|
|
unlocked = true
|
|
wg.Done()
|
|
}()
|
|
|
|
assert.False(t, unlocked)
|
|
|
|
l.Unlock("my-key")
|
|
|
|
wg.Wait()
|
|
|
|
assert.True(t, unlocked)
|
|
|
|
l.Unlock("my-key")
|
|
}
|
|
|
|
func TestLockRLock(t *testing.T) {
|
|
l := NewKeyLock()
|
|
|
|
l.Lock("my-key")
|
|
|
|
unlocked := false
|
|
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(1)
|
|
go func() {
|
|
l.RLock("my-key")
|
|
unlocked = true
|
|
wg.Done()
|
|
}()
|
|
|
|
assert.False(t, unlocked)
|
|
|
|
l.Unlock("my-key")
|
|
|
|
wg.Wait()
|
|
|
|
assert.True(t, unlocked)
|
|
|
|
l.RUnlock("my-key")
|
|
}
|
|
|
|
func TestRLockLock(t *testing.T) {
|
|
l := NewKeyLock()
|
|
|
|
l.RLock("my-key")
|
|
|
|
unlocked := false
|
|
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(1)
|
|
go func() {
|
|
l.Lock("my-key")
|
|
unlocked = true
|
|
wg.Done()
|
|
}()
|
|
|
|
assert.False(t, unlocked)
|
|
|
|
l.RUnlock("my-key")
|
|
|
|
wg.Wait()
|
|
|
|
assert.True(t, unlocked)
|
|
|
|
l.Unlock("my-key")
|
|
}
|
|
|
|
func TestRLockRLock(t *testing.T) {
|
|
l := NewKeyLock()
|
|
|
|
l.RLock("my-key")
|
|
|
|
unlocked := false
|
|
|
|
wg := sync.WaitGroup{}
|
|
wg.Add(1)
|
|
go func() {
|
|
l.RLock("my-key")
|
|
unlocked = true
|
|
wg.Done()
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
assert.True(t, unlocked)
|
|
|
|
l.RUnlock("my-key")
|
|
l.RUnlock("my-key")
|
|
}
|