Files
cd/test/e2e/graceful_restart_test.go
zeekay 88d492e081 cd: rename ArgoCD-branded Go identifiers and comments to match the fork
Drops the Argo/ArgoCD prefix from our own const, type and field names
(ArgoCDConfigMapName -> ConfigMapName, ArgoCDSettings -> Settings,
ArgoCDServer -> Server, HeaderArgoCD* -> HeaderCD*, the argocd-manager
RBAC names, the CLI-facing Env* aliases, and the three separately
scoped ArgoCDNamespace test/CLI defaults) and reflows the surrounding
comments and log/help text from Argo CD to Hanzo CD.

Runtime string values are untouched (still hanzocd-*, argo-cd-cli,
argo-cd, etc.) — renaming those is a live ConfigMap/Secret/service-name
and OAuth-client-ID change that has to land with the manifests and
Hanzo IAM/dex registration together, not silently inside a naming pass.

argoproj.io, other real upstream API groups, GitHub issue/PR citations,
and external URLs are untouched throughout.

Verified with go build ./... and go vet ./... (both clean); go test
./util/... ./controller/... ./server/... has the identical 26/26
pre-existing failing packages before and after (root cause: an
unrelated redis-removal regression, not this change — see report).
2026-09-04 18:56:54 -07:00

56 lines
1.6 KiB
Go

package e2e
import (
"net/http"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/hanzoai/cd/pkg/apiclient/settings"
"github.com/hanzoai/cd/test/e2e/fixture"
)
func checkHealth(t *testing.T, requireHealthy bool) {
t.Helper()
resp, err := fixture.DoHttpRequest("GET", "/healthz?full=true", "")
if requireHealthy {
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)
} else {
if err != nil {
if !strings.Contains(err.Error(), "connection refused") && !strings.Contains(err.Error(), "connection reset by peer") {
require.NoErrorf(t, err, "If an error returned, it must be about connection refused or reset by peer")
}
} else {
require.Contains(t, []int{http.StatusOK, http.StatusServiceUnavailable}, resp.StatusCode)
}
}
}
func TestAPIServerGracefulRestart(t *testing.T) {
fixture.EnsureCleanState(t)
// Should be healthy.
checkHealth(t, true)
// Should trigger API server restart.
require.NoError(t, fixture.SetParamInSettingConfigMap("url", "http://test-api-server-graceful-restart"))
// Wait for ~5 seconds
for range 50 {
checkHealth(t, false)
time.Sleep(100 * time.Millisecond)
}
// One final time, should be healthy, or restart is considered too slow for tests
checkHealth(t, true)
closer, settingsClient, err := fixture.CDClientset.NewSettingsClient()
if closer != nil {
defer closer.Close()
}
require.NoError(t, err)
settings, err := settingsClient.Get(t.Context(), &settings.SettingsQuery{})
require.NoError(t, err)
require.Equal(t, "http://test-api-server-graceful-restart", settings.URL)
}