molecule-core/workspace-server/internal/provisioner/isrunning_test.go
Hongming Wang d8026347e5 chore: open-source restructure — rename dirs, remove internal files, scrub secrets
Renames:
- platform/ → workspace-server/ (Go module path stays as "platform" for
  external dep compat — will update after plugin module republish)
- workspace-template/ → workspace/

Removed (moved to separate repos or deleted):
- PLAN.md — internal roadmap (move to private project board)
- HANDOFF.md, AGENTS.md — one-time internal session docs
- .claude/ — gitignored entirely (local agent config)
- infra/cloudflare-worker/ → Molecule-AI/molecule-tenant-proxy
- org-templates/molecule-dev/ → standalone template repo
- .mcp-eval/ → molecule-mcp-server repo
- test-results/ — ephemeral, gitignored

Security scrubbing:
- Cloudflare account/zone/KV IDs → placeholders
- Real EC2 IPs → <EC2_IP> in all docs
- CF token prefix, Neon project ID, Fly app names → redacted
- Langfuse dev credentials → parameterized
- Personal runner username/machine name → generic

Community files:
- CONTRIBUTING.md — build, test, branch conventions
- CODE_OF_CONDUCT.md — Contributor Covenant 2.1

All Dockerfiles, CI workflows, docker-compose, railway.toml, render.yaml,
README, CLAUDE.md updated for new directory names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-18 00:24:44 -07:00

52 lines
1.4 KiB
Go

package provisioner
import (
"errors"
"testing"
)
// isContainerNotFound is the chokepoint that decides whether IsRunning
// tears down a workspace. Getting this wrong (false positive) causes
// the restart cascade observed 2026-04-16 09:10 UTC when 6 containers
// got simultaneous A2A forward failures, their reactive IsRunning
// checks all hit a busy Docker daemon, timed out, and got flipped to
// "dead" in parallel. These tests pin the truth table.
func TestIsContainerNotFound(t *testing.T) {
cases := []struct {
name string
err error
want bool
}{
{"nil", nil, false},
{"docker not-found message",
errors.New(`Error response from daemon: No such container: ws-abc123`),
true},
{"generic not found",
errors.New("container not found"),
true},
{"context deadline",
errors.New("context deadline exceeded"),
false},
{"socket EOF",
errors.New(`Get "http://%2Fvar%2Frun%2Fdocker.sock/...": EOF`),
false},
{"daemon connection refused",
errors.New("dial unix /var/run/docker.sock: connect: connection refused"),
false},
{"i/o timeout",
errors.New("read unix @->/var/run/docker.sock: i/o timeout"),
false},
{"empty string",
errors.New(""),
false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := isContainerNotFound(tc.err); got != tc.want {
t.Errorf("isContainerNotFound(%q) = %v, want %v", tc.err, got, tc.want)
}
})
}
}