mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
The fork was already ours everywhere that matters — our image, our IAM (dex is not deployed), hanzo kv behind what the env still called REDIS. Only the vocabulary was upstream's: ARGOCD_* across the Go, the manifests, the docs and the plugin contract, and mkdocs still titled 'Argo CD' pointing at argoproj/argo-cd. ARGOCD_ -> CD_ and REDIS_ -> KV_ across 345 files, plus the 8 e2e/cmp fixtures that assert the plugin env contract — those had to move with the binary, which now emits CD_APP_NAME where they expected ARGOCD_APP_NAME. Left alone deliberately, because renaming them would be wrong: - util/helm/testdata/redis/ and gitops-engine/.../statefulset*.yaml are fixtures for a THIRD-PARTY chart named redis, not our config - util/kustomize/testdata/ likewise - generated.proto regenerates from types.go, which is already clean go build ./... exit 0. LOCKSTEP: the live StatefulSet sets 47 ARGOCD_* names the binary no longer reads. universe 4a5375735 carries the matching manifest change; they deploy together or the controller falls back to defaults. Co-authored-by: Hanzo Dev <[email protected]>
161 lines
3.6 KiB
Go
161 lines
3.6 KiB
Go
package metrics
|
|
|
|
import (
|
|
"os"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"golang.org/x/sync/semaphore"
|
|
)
|
|
|
|
var testSemaphoreMutex sync.Mutex
|
|
|
|
func TestMain(m *testing.M) {
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestEdgeCasesAndErrorHandling(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
setup func()
|
|
teardown func()
|
|
testFunc func(t *testing.T)
|
|
}{
|
|
{
|
|
name: "lsRemoteParallelismLimitSemaphore is nil",
|
|
setup: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = nil
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
testFunc: func(t *testing.T) {
|
|
t.Helper()
|
|
testSemaphoreMutex.Lock()
|
|
defer testSemaphoreMutex.Unlock()
|
|
assert.NotPanics(t, func() {
|
|
NewGitClientEventHandlers(&MetricsServer{})
|
|
})
|
|
},
|
|
},
|
|
{
|
|
name: "lsRemoteParallelismLimitSemaphore is not nil",
|
|
setup: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = semaphore.NewWeighted(1)
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
teardown: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = nil
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
testFunc: func(t *testing.T) {
|
|
t.Helper()
|
|
testSemaphoreMutex.Lock()
|
|
defer testSemaphoreMutex.Unlock()
|
|
assert.NotPanics(t, func() {
|
|
NewGitClientEventHandlers(&MetricsServer{})
|
|
})
|
|
},
|
|
},
|
|
{
|
|
name: "lsRemoteParallelismLimitSemaphore is not nil and Acquire returns error",
|
|
setup: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = semaphore.NewWeighted(1)
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
teardown: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = nil
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
testFunc: func(t *testing.T) {
|
|
t.Helper()
|
|
testSemaphoreMutex.Lock()
|
|
defer testSemaphoreMutex.Unlock()
|
|
assert.NotPanics(t, func() {
|
|
NewGitClientEventHandlers(&MetricsServer{})
|
|
})
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if tt.setup != nil {
|
|
tt.setup()
|
|
}
|
|
if tt.teardown != nil {
|
|
defer tt.teardown()
|
|
}
|
|
tt.testFunc(t)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestSemaphoreFunctionality(t *testing.T) {
|
|
t.Setenv("CD_GIT_LSREMOTE_PARALLELISM_LIMIT", "1")
|
|
|
|
tests := []struct {
|
|
name string
|
|
setup func()
|
|
teardown func()
|
|
testFunc func(t *testing.T)
|
|
}{
|
|
{
|
|
name: "lsRemoteParallelismLimitSemaphore is not nil",
|
|
setup: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = semaphore.NewWeighted(1)
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
teardown: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = nil
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
testFunc: func(t *testing.T) {
|
|
t.Helper()
|
|
testSemaphoreMutex.Lock()
|
|
defer testSemaphoreMutex.Unlock()
|
|
assert.NotPanics(t, func() {
|
|
NewGitClientEventHandlers(&MetricsServer{})
|
|
})
|
|
},
|
|
},
|
|
{
|
|
name: "lsRemoteParallelismLimitSemaphore is not nil and Acquire returns error",
|
|
setup: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = semaphore.NewWeighted(1)
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
teardown: func() {
|
|
testSemaphoreMutex.Lock()
|
|
lsRemoteParallelismLimitSemaphore = nil
|
|
testSemaphoreMutex.Unlock()
|
|
},
|
|
testFunc: func(t *testing.T) {
|
|
t.Helper()
|
|
testSemaphoreMutex.Lock()
|
|
defer testSemaphoreMutex.Unlock()
|
|
assert.NotPanics(t, func() {
|
|
NewGitClientEventHandlers(&MetricsServer{})
|
|
})
|
|
},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if tt.setup != nil {
|
|
tt.setup()
|
|
}
|
|
if tt.teardown != nil {
|
|
defer tt.teardown()
|
|
}
|
|
tt.testFunc(t)
|
|
})
|
|
}
|
|
}
|