Compare commits

...

2 Commits

Author SHA1 Message Date
fullstack-engineer b442797b0f test(handlers): add DB-error tests for SessionSearch and DelegationRecord
CI / Shellcheck (E2E scripts) (pull_request) Blocked by required conditions
CI / all-required (pull_request) Blocked by required conditions
Runtime PR-Built Compatibility / detect-changes (pull_request) Waiting to run
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Blocked by required conditions
Secret scan / Scan diff for credential-shaped strings (pull_request) Waiting to run
gate-check-v3 / gate-check (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 26s
Harness Replays / detect-changes (pull_request) Successful in 27s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 25s
CI / Detect changes (pull_request) Successful in 1m28s
E2E API Smoke Test / detect-changes (pull_request) Successful in 2m24s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 2m27s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m42s
qa-review / approved (pull_request) Successful in 41s
security-review / approved (pull_request) Successful in 36s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 2m2s
sop-checklist / all-items-acked (pull_request) Successful in 31s
sop-tier-check / tier-check (pull_request) Successful in 27s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 3m15s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 3m51s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 3m28s
lint-mask-pr-atomicity / lint-mask-pr-atomicity (pull_request) Successful in 4m1s
Harness Replays / Harness Replays (pull_request) Successful in 14s
CI / Python Lint & Test (pull_request) Successful in 13s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m51s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 6m20s
CI / Platform (Go) (pull_request) Failing after 20m18s
CI / Canvas (Next.js) (pull_request) Successful in 21m4s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Cherry-pick of PR #1094 (test/delegate-record-db-errors) onto current staging.

- TestSessionSearch_DBError (activity_test.go): verifies SessionSearch returns 500
  when the DB QueryContext returns context.DeadlineExceeded.
- TestDelegationRecord_DBInsertFails (delegation_test.go): verifies Record returns
  500 when the activity_logs INSERT fails (WillReturnError).

Both tests use sqlmock to simulate DB failures and verify the handlers
return the correct HTTP 500 status.

Closes #1152.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:39:07 +00:00
core-be 80938e82b5 infra(ci): apply full mc#1099 timeout fix to staging
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 26s
CI / Detect changes (pull_request) Successful in 1m28s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m40s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m22s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 19s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 31s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m37s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 2m58s
gate-check-v3 / gate-check (pull_request) Successful in 36s
qa-review / approved (pull_request) Successful in 34s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 1m25s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m51s
security-review / approved (pull_request) Successful in 26s
sop-tier-check / tier-check (pull_request) Successful in 25s
sop-checklist / all-items-acked (pull_request) Successful in 28s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 2m50s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 3m5s
lint-mask-pr-atomicity / lint-mask-pr-atomicity (pull_request) Successful in 3m16s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 12s
CI / Python Lint & Test (pull_request) Successful in 21s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 15s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 16s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 15s
CI / Platform (Go) (pull_request) Failing after 20m10s
CI / Canvas (Next.js) (pull_request) Successful in 20m26s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 5s
Apply all cold-runner CI improvements from hotfix/offsec-015-org-isolation:
- Job-level timeout: 15m → 50m (mc#1099)
- golangci-lint: --timeout 3m → --no-config --timeout 10m (mc#1099)
- Diagnostic: 60s → 600s Go-level, step ceiling 20m (mc#1099)
- Test step: Go-level timeout 10m → 40m, step ceiling 15m → 50m (mc#1099)

Without these, the 10-minute Actions default step ceiling kills the test
step on cold runners before go test -timeout can fire.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-15 10:31:15 +00:00
3 changed files with 86 additions and 15 deletions
+23 -15
View File
@@ -145,10 +145,11 @@ jobs:
# the diagnostic step with its own continue-on-error: true (line 203).
# Flip confirmed by CI / Platform (Go) status = success on main HEAD 363905d3.
continue-on-error: false
# Job-level ceiling. The go test step below runs with a per-step 10m timeout;
# this cap catches any step that leaks past that. Set well above 10m so
# the per-step timeout is the active constraint.
timeout-minutes: 15
# Job-level ceiling. The go test step below runs with a per-step 20m timeout;
# this cap catches any step that leaks past that. Set well above 20m so
# the per-step timeout is the active constraint. Raised to 50m
# to account for golangci-lint ~10m + test suite ~12m on cold runner (mc#1099).
timeout-minutes: 50
defaults:
run:
working-directory: workspace-server
@@ -172,16 +173,20 @@ jobs:
- if: always()
name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
- if: always()
- if: success()
name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run --timeout 3m ./...
- if: always()
name: Diagnostic — per-package verbose 60s
# mc#1099: --no-config bypasses .golangci.yaml ceiling; --timeout 10m
# is now the active constraint instead of the 3m config ceiling.
run: $(go env GOPATH)/bin/golangci-lint run --no-config --timeout 10m ./...
- if: success()
name: Diagnostic — per-package verbose 600s
# mc#1099: step-level ceiling above the 600s Go timeout for cold-runner headroom.
timeout-minutes: 20
run: |
set +e
go test -race -v -timeout 60s ./internal/handlers/... 2>&1 | tee /tmp/test-handlers.log
go test -race -v -timeout 600s ./internal/handlers/... 2>&1 | tee /tmp/test-handlers.log
handlers_exit=$?
go test -race -v -timeout 60s ./internal/pendinguploads/... 2>&1 | tee /tmp/test-pu.log
go test -race -v -timeout 600s ./internal/pendinguploads/... 2>&1 | tee /tmp/test-pu.log
pu_exit=$?
echo "::group::handlers exit=$handlers_exit (last 100 lines)"
tail -100 /tmp/test-handlers.log
@@ -193,11 +198,14 @@ jobs:
continue-on-error: true
- if: always()
name: Run tests with race detection and coverage
# Explicit timeout: cold runner cache causes OOM kills at ~4m39s on the
# full ./... suite with race detection + coverage. A 10m per-step timeout
# lets the suite complete on cold cache (~5-7m) while failing cleanly
# instead of OOM-killing. The job-level timeout (15m) is a backstop.
run: go test -race -timeout 10m -coverprofile=coverage.out ./...
# mc#1099: step-level ceiling above the 40m Go timeout for cold-runner headroom.
# Cold runner: golangci-lint ~10m + test suite ~16-20m = ~26-30m total.
# GitHub Actions default step ceiling is 10m — must override. Set at the
# job-level ceiling (50m) so the Go-level 40m timeout is always the active
# constraint — the suite fails cleanly at 40m instead of step-level killing
# it at 50m. Job-level (50m) is the backstop for the backstop.
timeout-minutes: 50
run: go test -race -timeout 40m -coverprofile=coverage.out ./...
- if: always()
name: Per-file coverage report
@@ -63,6 +63,33 @@ func TestSessionSearchReturnsActivityAndMemory(t *testing.T) {
}
}
func TestSessionSearch_DBError(t *testing.T) {
mock := setupTestDB(t)
setupTestRedis(t)
broadcaster := newTestBroadcaster()
handler := NewActivityHandler(broadcaster)
// Simulate a DB query failure — handler must return 500.
mock.ExpectQuery("WITH session_items AS").
WithArgs("ws-123", "", 50).
WillReturnError(context.DeadlineExceeded)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Request = httptest.NewRequest("GET", "/workspaces/ws-123/session-search", nil)
c.Request.Header.Set("Content-Type", "application/json")
c.Params = gin.Params{{Key: "id", Value: "ws-123"}}
handler.SessionSearch(c)
if w.Code != http.StatusInternalServerError {
t.Errorf("expected 500, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet sqlmock expectations: %v", err)
}
}
// ---------- Activity List source filter ----------
func TestActivityList_SourceCanvas(t *testing.T) {
@@ -523,6 +523,42 @@ func TestDelegationRecord_InsertsActivityLogRow(t *testing.T) {
}
}
func TestDelegationRecord_DBInsertFails(t *testing.T) {
mock := setupTestDB(t)
setupTestRedis(t)
broadcaster := newTestBroadcaster()
wh := NewWorkspaceHandler(broadcaster, nil, "http://localhost:8080", t.TempDir())
h := NewDelegationHandler(wh, broadcaster)
// activity_logs INSERT fails — handler must return 500.
mock.ExpectExec("INSERT INTO activity_logs").
WithArgs(
"550e8400-e29b-41d4-a716-446655440000", // workspace_id
"550e8400-e29b-41d4-a716-446655440000", // source_id
"550e8400-e29b-41d4-a716-446655440001", // target_id
sqlmock.AnyArg(), // summary
sqlmock.AnyArg(), // request_body (jsonb)
sqlmock.AnyArg(), // response_body (jsonb)
).
WillReturnError(context.DeadlineExceeded)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Params = gin.Params{{Key: "id", Value: "550e8400-e29b-41d4-a716-446655440000"}}
body := `{"target_id":"550e8400-e29b-41d4-a716-446655440001","task":"hello","delegation_id":"del-xyz"}`
c.Request = httptest.NewRequest("POST", "/delegations/record", bytes.NewBufferString(body))
c.Request.Header.Set("Content-Type", "application/json")
h.Record(c)
if w.Code != http.StatusInternalServerError {
t.Errorf("expected 500, got %d: %s", w.Code, w.Body.String())
}
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("unmet expectations: %v", err)
}
}
func TestDelegationRecord_RejectsInvalidUUID(t *testing.T) {
setupTestDB(t)
setupTestRedis(t)