Declare the vault service port and bound integration HTTP calls
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/integration Pipeline was canceled

This commit is contained in:
2026-09-19 12:18:08 +10:00
parent fde942d831
commit 36c506918d
2 changed files with 14 additions and 2 deletions
+4
View File
@@ -6,6 +6,10 @@ when:
services:
- name: vault
image: hashicorp/vault:1.20
# The kubernetes backend builds the Service from this list; without it the
# service resolves but carries no port.
ports:
- 8200
environment:
# Throwaway dev-mode server; this token grants nothing outside this pod.
VAULT_DEV_ROOT_TOKEN_ID: dev-root-token
+10 -2
View File
@@ -50,6 +50,10 @@ func itVaultToken() string {
return "root"
}
// Every call is bounded so an unreachable server fails the suite instead of
// hanging a CI step on a blackholed connect.
var itClient = &http.Client{Timeout: 15 * time.Second}
func itWaitForVault(t *testing.T) {
t.Helper()
@@ -57,7 +61,11 @@ func itWaitForVault(t *testing.T) {
url := itVaultAddr() + "/v1/sys/health?standbyok=true"
var last error
for time.Now().Before(deadline) {
resp, err := http.Get(url) // #nosec G107
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
t.Fatalf("building health request: %v", err)
}
resp, err := itClient.Do(req)
if err == nil {
_ = resp.Body.Close()
if resp.StatusCode == http.StatusOK {
@@ -91,7 +99,7 @@ func itVaultAPI(t *testing.T, method, path string, body any) map[string]any {
req.Header.Set("X-Vault-Token", itVaultToken())
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
resp, err := itClient.Do(req)
if err != nil {
t.Fatalf("%s %s: %v", method, path, err)
}