parallelism
하는 일
이 스킬은 시간을 줄이기 위해 Ginkgo 테스트를 여러 프로세스에서 동시에 실행하는 방법을 보여 줍니다. 테스트 묶음이 오래 걸리는 개발자를 위한 것입니다.
사용하는 경우
- ✓Ginkgo 테스트 묶음이 실행하기에 너무 오래 걸릴 때.
- ✓테스트가 여러 CPU 코어를 동시에 쓰게 하고 싶을 때.
- ✓병렬 테스트가 포트, 폴더, 데이터베이스를 공유해서 따로 설정이 필요할 때.
스킬 링크
https://github.com/onsi/ginkgo/blob/master/plugins/ginkgo/skills/parallelism/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 Go 테스트 묶음이 너무 오래 걸립니다. Ginkgo로 병렬 실행되게 해 주실 수 있나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 테스트 프로그램의 여러 복사본을 각각 별도의 프로세스로 실행하고, 각 프로세스가 테스트의 자기 몫을 맡은 뒤 결과를 하나의 보고서로 합치는 방식을 설명합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Running Ginkgo in parallel
Parallelism is where Ginkgo's "every spec is independent" assumption (ginkgo:overview) earns its keep. If your specs are independent, going parallel is one flag. If they aren't, parallelism is how you find out. Docs: https://onsi.github.io/ginkgo/#spec-parallelization, https://onsi.github.io/ginkgo/#patterns-for-parallel-integration-specs.
The flag
ginkgo -p # auto-detect optimal process count from CPU cores
ginkgo --procs=4 # pin the count explicitly
ginkgo watch -p # re-run in parallel on every file change
-p/--procs require the ginkgo CLI — go test cannot parallelize a Ginkgo suite (it has no server to coordinate processes). Most other features work under go test; parallelism is the headline exception. → ginkgo:running.
The mental model: separate processes, not goroutines
This is the one thing to internalize. Ginkgo compiles the suite once (go test -c), then launches N copies of the test binary as separate OS processes. Each process runs the full tree-construction phase independently (so all N build the identical spec list), then pulls specs to run from the CLI, which acts as a server and merges everything into one coherent output stream.
- Separate processes means separate memory. Each process has its own copy of every package-level var and closure variable. There is no shared memory, so shared-closure specs like
var bookdon't race across processes — they each get their ownbook. (Within a process specs still run one at a time.) - The flip side: a
BeforeSuiteruns on every process, so anything it creates is created N times. - You usually don't care which process runs a spec — except for the integration patterns below, which deliberately shard shared external resources by process index.
What the N processes cost
Going parallel is cheap, but not free — and the cost is rarely where people look for it.
- Compilation is once per suite, not once per process. Ginkgo builds the test binary a single time and runs N copies of it; under
-rthe CLI also overlaps compiling the next suite with running the current one. It is usually not the bottleneck it's assumed to be. - Teardown is once per process — but they overlap, so a suite pays roughly one process teardown, not N.
- Under
--racethat one teardown is ~1s. ThreadSanitizer sleeps for a second at process exit (atexit_sleep_ms, its default) so races reported by goroutines still running at exit aren't lost. Every process pays it however trivial the suite: a 2-spec package pays exactly what a 2000-spec package pays.
That flatness is the tell. The sleep lands in the gap between suites under -r, where it looks exactly like compilation — but a build cost can't be flat across package size, and a per-process cost must be. If you're auditing a slow -p --race run, precompile with ginkgo build -r so compilation is excluded by construction rather than by inference. To remove the sleep:
GORACE=atexit_sleep_ms=0 ginkgo -r -p --race
This slightly weakens detection at the very end of a suite — a reasonable trade when your races are found by your specs rather than at teardown, but a deliberate one; write the reason down where you set it. → ginkgo:ci for the whole CI flag set.
Suite setup when N copies is wrong: Synchronized*Suite
BeforeSuite runs on every process → N independent resources. Sometimes that's ideal (max isolation). When a resource is expensive or must be shared, use SynchronizedBeforeSuite: set it up once on process #1, then distribute connection info to all processes.
var dbClient *db.Client
var _ = SynchronizedBeforeSuite(func() []byte {
// runs ONLY on process #1; all others wait
dbRunner := db.NewRunner()
Expect(dbRunner.Start()).To(Succeed())
DeferCleanup(dbRunner.Stop) // runs like SynchronizedAfterSuite: after ALL procs finish
return []byte(dbRunner.Address()) // []byte passed to every process
}, func(address []byte) {
// runs on ALL processes with the data from process #1
dbClient = db.NewClient()
Expect(dbClient.Connect(string(address))).To(Succeed())
dbClient.SetNamespace(fmt.Sprintf("namespace-%d", GinkgoParallelProcess()))
DeferOnFailure(dbClient.DumpNamespace) // suite-wide failure diagnostics belong here (every process), not in the proc-#1 func
})
BeforeSuite |
SynchronizedBeforeSuite |
|
|---|---|---|
| process #1 |
자주 묻는 질문
병렬 실행이 항상 빠른가요?
보통은 그렇지만, 복사본마다 시작하는 데 시간이 걸리므로 작은 묶음에서는 이득이 상쇄될 수 있습니다.
병렬 실행에 go test를 쓰면 안 되나요?
표준 go test 명령은 별도의 프로세스를 조정할 수 없으므로 ginkgo 명령이 필요합니다.
테스트를 병렬로 실행하면 어떤 위험이 있나요?
포트나 데이터베이스를 공유하는 테스트끼리 충돌할 수 있으므로, 각 프로세스에 별도 설정이 필요합니다.
상세 정보
작성자의 원본 설명
Run Ginkgo suites in parallel — ginkgo -p / --procs, the separate-process (not goroutine) model, SynchronizedBeforeSuite/SynchronizedAfterSuite vs BeforeSuite, GinkgoParallelProcess() for sharding ports/tmpdirs/databases, building a binary once via gexec, piping child-process output to GinkgoWriter, and what N processes actually cost (compilation vs teardown, and the fixed ~1s --race adds per suite — GORACE=atexit_sleep_ms=0). Use when parallelizing a suite, speeding up integration tests, auditing why a parallel run is slow, fixing parallel-only flakes/races, sharding external resources, or ch
repo: onsi/ginkgo
인기도
- GitHub 스타
- 9.1k
- 순위
- #12304
- 라이선스
- MIT
- 업데이트
- 2026. 10. 9.
댓글
- …
이 저장소의 다른 스킬
ci
9.1k에이전트가 지속적 통합에서 Ginkgo 테스트를 설정하도록 돕습니다. 남은 focus나 pending 표시와 불안정한 테스트를 잡아내는 권장 플래그를 씁니다.
debugging-failures
9.1k에이전트가 요약 줄을 읽고 JSON 보고서에서 실패한 정확한 테스트와 메시지를 꺼내서, Ginkgo 테스트가 왜 실패했는지 알아내도록 돕습니다.
decorators
9.1k에이전트가 Serial, Ordered, Label, Focus, 제한 시간 같은 Ginkgo 테스트 데코레이터를 바르게 쓰도록 각각의 역할을 설명해 돕습니다.
filtering
9.1k에이전트가 pending, skip, focus, 라벨, 버전 조건, 파일 필터를 올바른 우선순위에 따라 써서 Ginkgo 테스트의 일부만 실행하도록 돕습니다.
비슷한 스킬
test-driven-development
311k에이전트가 기능이나 수정을 만들기 전에 실패하는 테스트를 먼저 쓰고, 그것을 통과시키는 가장 작은 코드를 작성하도록 가르칩니다.
verification-before-completion
311k에이전트가 작업, 수정, 빌드가 완료되었거나 통과했다고 말하기 전에 실제 점검을 실행하고 결과를 읽도록 가르칩니다.
migrate-to-shoehorn
310k테스트 파일의 위험한 타입 캐스팅을 shoehorn 라이브러리로 바꿔, 테스트가 일부 데이터만 써도 타입 검사를 통과하도록 돕습니다.