BuildParallel: test with 3 parallel builds
This commit is contained in:
parent
9281fada2d
commit
852af993e6
|
@ -75,8 +75,8 @@ func testMetaParallel(t *testing.T, builder *ParallelTestBuilder, locked *Locked
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildParallel_1(t *testing.T) {
|
func TestBuildParallel_1(t *testing.T) {
|
||||||
// testfile that running 6 builds, with first one locks 'forever', other
|
// testfile has 6 builds, with first one locks 'forever', other builds
|
||||||
// builds should go through.
|
// should go through.
|
||||||
b := NewParallelTestBuilder(5)
|
b := NewParallelTestBuilder(5)
|
||||||
locked := &LockedBuilder{unlock: make(chan interface{})}
|
locked := &LockedBuilder{unlock: make(chan interface{})}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ func TestBuildParallel_1(t *testing.T) {
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
fmt.Sprintf("-parallel=true"),
|
fmt.Sprintf("-parallel=true"),
|
||||||
filepath.Join(testFixture("parallel"), "template.json"),
|
filepath.Join(testFixture("parallel"), "1lock.json"),
|
||||||
}
|
}
|
||||||
|
|
||||||
wg := errgroup.Group{}
|
wg := errgroup.Group{}
|
||||||
|
@ -102,3 +102,32 @@ func TestBuildParallel_1(t *testing.T) {
|
||||||
close(locked.unlock) // unlock locking one
|
close(locked.unlock) // unlock locking one
|
||||||
wg.Wait() // wait for termination
|
wg.Wait() // wait for termination
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildParallel_2(t *testing.T) {
|
||||||
|
// testfile has 6 builds, 2 of them lock 'forever', other builds
|
||||||
|
// should go through.
|
||||||
|
b := NewParallelTestBuilder(4)
|
||||||
|
locked := &LockedBuilder{unlock: make(chan interface{})}
|
||||||
|
|
||||||
|
c := &BuildCommand{
|
||||||
|
Meta: testMetaParallel(t, b, locked),
|
||||||
|
}
|
||||||
|
|
||||||
|
args := []string{
|
||||||
|
fmt.Sprintf("-parallel-builds=3"),
|
||||||
|
filepath.Join(testFixture("parallel"), "2lock.json"),
|
||||||
|
}
|
||||||
|
|
||||||
|
wg := errgroup.Group{}
|
||||||
|
|
||||||
|
wg.Go(func() error {
|
||||||
|
if code := c.Run(args); code != 0 {
|
||||||
|
fatalCommand(t, c.Meta)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
b.wg.Wait() // ran 4 times
|
||||||
|
close(locked.unlock) // unlock locking one
|
||||||
|
wg.Wait() // wait for termination
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"builders": [
|
||||||
|
{"type": "lock", "name": "build0"},
|
||||||
|
{"type": "parallel-test", "name": "build1"},
|
||||||
|
{"type": "parallel-test", "name": "build2"},
|
||||||
|
{"type": "lock", "name": "build3"},
|
||||||
|
{"type": "parallel-test", "name": "build4"},
|
||||||
|
{"type": "parallel-test", "name": "build5"}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue