From 3c1b63ed98a28a74a7fef9e484599e3417d4508e Mon Sep 17 00:00:00 2001 From: kudesn1k Date: Tue, 6 Oct 2026 15:00:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=B0=D0=B1=D0=B8=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=20Docker=20Desktop=20=D0=B2=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=85=20=D0=BD=D0=B0=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/testenv/testenv.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/testenv/testenv.go b/internal/testenv/testenv.go index 974651e9..90974eda 100644 --- a/internal/testenv/testenv.go +++ b/internal/testenv/testenv.go @@ -6,6 +6,9 @@ package testenv import ( "context" "fmt" + "os" + "runtime" + "sync" "testing" "github.com/jackc/pgx/v5/pgxpool" @@ -22,6 +25,17 @@ const ( ValkeyImage = "valkey/valkey:9.1.2-alpine3.24@sha256:48332870af354a799964c0012ae1194a0bf2bf894eb508f945810596dc2d8d11" ) +// useDockerDesktopPipe names the Docker Desktop engine pipe explicitly on +// Windows. Without DOCKER_HOST, testcontainers probes the pipe with a file +// stat, which fails while the pipe is busy; with several test packages +// starting containers at once that probe fails spuriously and the run panics. +// Dialling the named host instead waits for a free pipe instance. +var useDockerDesktopPipe = sync.OnceFunc(func() { + if runtime.GOOS == "windows" && os.Getenv("DOCKER_HOST") == "" { + _ = os.Setenv("DOCKER_HOST", "npipe:////./pipe/docker_engine") + } +}) + // DB is a migrated PostgreSQL instance. type DB struct { Pool *pgxpool.Pool @@ -30,6 +44,7 @@ type DB struct { } func StartPostgres(ctx context.Context) (*DB, error) { + useDockerDesktopPipe() c, err := tcpostgres.Run(ctx, PostgresImage, tcpostgres.WithDatabase("messenger"), tcpostgres.WithUsername("messenger"), @@ -94,6 +109,7 @@ type KV struct { } func StartValkey(ctx context.Context) (*KV, error) { + useDockerDesktopPipe() c, err := tcvalkey.Run(ctx, ValkeyImage) if err != nil { return nil, fmt.Errorf("start valkey: %w", err)