feat: add custom health check commands per app
All checks were successful
Check / check (pull_request) Successful in 1m53s
All checks were successful
Check / check (pull_request) Successful in 1m53s
Add configurable health check commands per app via a new 'healthcheck_command' field. When set, the command is passed to Docker as a CMD-SHELL health check on the container. When empty, the image's default health check is used. Changes: - Add migration 007 for healthcheck_command column on apps table - Add HealthcheckCommand field to App model with full CRUD support - Add buildHealthcheck() to docker client for CMD-SHELL config - Pass health check command through CreateContainerOptions - Add health check command input to app create/edit UI forms - Extract optionalNullString helper to reduce handler complexity - Update README features list closes #81
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"log/slog"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestValidBranchRegex(t *testing.T) {
|
||||
@@ -146,3 +147,52 @@ func TestCloneRepoRejectsInjection(t *testing.T) { //nolint:funlen // table-driv
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHealthcheck(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("creates CMD-SHELL health check", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cmd := "curl -f http://localhost:8080/healthz || exit 1"
|
||||
hc := buildHealthcheck(cmd)
|
||||
|
||||
if len(hc.Test) != 2 {
|
||||
t.Fatalf("expected 2 test elements, got %d", len(hc.Test))
|
||||
}
|
||||
|
||||
if hc.Test[0] != "CMD-SHELL" {
|
||||
t.Errorf("expected Test[0]=%q, got %q", "CMD-SHELL", hc.Test[0])
|
||||
}
|
||||
|
||||
if hc.Test[1] != cmd {
|
||||
t.Errorf("expected Test[1]=%q, got %q", cmd, hc.Test[1])
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("sets expected intervals", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
hc := buildHealthcheck("true")
|
||||
|
||||
expectedInterval := 30 * time.Second
|
||||
if hc.Interval != expectedInterval {
|
||||
t.Errorf("expected Interval=%v, got %v", expectedInterval, hc.Interval)
|
||||
}
|
||||
|
||||
expectedTimeout := 10 * time.Second
|
||||
if hc.Timeout != expectedTimeout {
|
||||
t.Errorf("expected Timeout=%v, got %v", expectedTimeout, hc.Timeout)
|
||||
}
|
||||
|
||||
expectedStartPeriod := 15 * time.Second
|
||||
if hc.StartPeriod != expectedStartPeriod {
|
||||
t.Errorf("expected StartPeriod=%v, got %v", expectedStartPeriod, hc.StartPeriod)
|
||||
}
|
||||
|
||||
expectedRetries := 3
|
||||
if hc.Retries != expectedRetries {
|
||||
t.Errorf("expected Retries=%d, got %d", expectedRetries, hc.Retries)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user