MCPcopy
hub / github.com/hashicorp/packer / TestBuildParallel_1

Function TestBuildParallel_1

command/build_parallel_test.go:92–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestBuildParallel_1(t *testing.T) {
93 // testfile has 6 builds, with first one locks 'forever', other builds
94 // should go through.
95 b := NewParallelTestBuilder(5)
96 locked := &LockedBuilder{unlock: make(chan interface{})}
97
98 c := &BuildCommand{
99 Meta: testMetaParallel(t, b, locked),
100 }
101
102 args := []string{
103 "-parallel-builds=10",
104 filepath.Join(testFixture("parallel"), "1lock-5wg.json"),
105 }
106
107 wg := errgroup.Group{}
108
109 wg.Go(func() error {
110 if code := c.Run(args); code != 0 {
111 fatalCommand(t, c.Meta)
112 }
113 return nil
114 })
115
116 b.wg.Wait() // ran 5 times
117 close(locked.unlock) // unlock locking one
118 wg.Wait() // wait for termination
119}
120
121func TestBuildParallel_2(t *testing.T) {
122 // testfile has 6 builds, 2 of them lock 'forever', other builds

Callers

nothing calls this directly

Calls 5

RunMethod · 0.95
NewParallelTestBuilderFunction · 0.85
testMetaParallelFunction · 0.85
testFixtureFunction · 0.85
fatalCommandFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…