This commit is contained in:
Łukasz Magiera 2020-07-16 23:41:15 +02:00
parent be6b88f406
commit 2e557573f4
2 changed files with 30 additions and 31 deletions

View File

@ -289,30 +289,30 @@ func TestSched(t *testing.T) {
} }
t.Run("one-pc1", testFunc([]workerSpec{ t.Run("one-pc1", testFunc([]workerSpec{
{name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}}}, {name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}}},
}, []task{ }, []task{
sched("pc1-1", "fred", sealtasks.TTPreCommit1), sched("pc1-1", "fred", sealtasks.TTPreCommit1),
taskDone("pc1-1"), taskDone("pc1-1"),
})) }))
t.Run("pc1-2workers-1", testFunc([]workerSpec{ t.Run("pc1-2workers-1", testFunc([]workerSpec{
{name: "fred2", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit2:{}}}, {name: "fred2", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit2: {}}},
{name: "fred1", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}}}, {name: "fred1", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}}},
}, []task{ }, []task{
sched("pc1-1", "fred1", sealtasks.TTPreCommit1), sched("pc1-1", "fred1", sealtasks.TTPreCommit1),
taskDone("pc1-1"), taskDone("pc1-1"),
})) }))
t.Run("pc1-2workers-2", testFunc([]workerSpec{ t.Run("pc1-2workers-2", testFunc([]workerSpec{
{name: "fred1", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}}}, {name: "fred1", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}}},
{name: "fred2", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit2:{}}}, {name: "fred2", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit2: {}}},
}, []task{ }, []task{
sched("pc1-1", "fred1", sealtasks.TTPreCommit1), sched("pc1-1", "fred1", sealtasks.TTPreCommit1),
taskDone("pc1-1"), taskDone("pc1-1"),
})) }))
t.Run("pc1-block-pc2", testFunc([]workerSpec{ t.Run("pc1-block-pc2", testFunc([]workerSpec{
{name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}, sealtasks.TTPreCommit2:{}}}, {name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}, sealtasks.TTPreCommit2: {}}},
}, []task{ }, []task{
sched("pc1", "fred", sealtasks.TTPreCommit1), sched("pc1", "fred", sealtasks.TTPreCommit1),
taskStarted("pc1"), taskStarted("pc1"),
@ -325,7 +325,7 @@ func TestSched(t *testing.T) {
})) }))
t.Run("pc2-block-pc1", testFunc([]workerSpec{ t.Run("pc2-block-pc1", testFunc([]workerSpec{
{name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}, sealtasks.TTPreCommit2:{}}}, {name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}, sealtasks.TTPreCommit2: {}}},
}, []task{ }, []task{
sched("pc2", "fred", sealtasks.TTPreCommit2), sched("pc2", "fred", sealtasks.TTPreCommit2),
taskStarted("pc2"), taskStarted("pc2"),
@ -338,7 +338,7 @@ func TestSched(t *testing.T) {
})) }))
t.Run("pc1-batching", testFunc([]workerSpec{ t.Run("pc1-batching", testFunc([]workerSpec{
{name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}}}, {name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}}},
}, []task{ }, []task{
sched("t1", "fred", sealtasks.TTPreCommit1), sched("t1", "fred", sealtasks.TTPreCommit1),
taskStarted("t1"), taskStarted("t1"),
@ -368,23 +368,23 @@ func TestSched(t *testing.T) {
twoPC1 := func(prefix string, schedAssert func(name string) task) task { twoPC1 := func(prefix string, schedAssert func(name string) task) task {
return multTask( return multTask(
sched(prefix + "-a", "fred", sealtasks.TTPreCommit1), sched(prefix+"-a", "fred", sealtasks.TTPreCommit1),
schedAssert(prefix + "-a"), schedAssert(prefix+"-a"),
sched(prefix + "-b", "fred", sealtasks.TTPreCommit1), sched(prefix+"-b", "fred", sealtasks.TTPreCommit1),
schedAssert(prefix + "-b"), schedAssert(prefix+"-b"),
) )
} }
twoPC1Done := func(prefix string) task { twoPC1Done := func(prefix string) task {
return multTask( return multTask(
taskDone(prefix + "-1"), taskDone(prefix+"-1"),
taskDone(prefix + "-b"), taskDone(prefix+"-b"),
) )
} }
t.Run("pc1-pc2-prio", testFunc([]workerSpec{ t.Run("pc1-pc2-prio", testFunc([]workerSpec{
{name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1:{}, sealtasks.TTPreCommit2: {}}}, {name: "fred", taskTypes: map[sealtasks.TaskType]struct{}{sealtasks.TTPreCommit1: {}, sealtasks.TTPreCommit2: {}}},
}, []task{ }, []task{
// fill exec/fetch buffers // fill exec/fetch buffers
twoPC1("w0", taskStarted), twoPC1("w0", taskStarted),
@ -423,4 +423,3 @@ func TestSched(t *testing.T) {
taskDone("t3"), taskDone("t3"),
})) }))
} }

View File

@ -17,7 +17,7 @@ type allocSelector struct {
ptype stores.PathType ptype stores.PathType
} }
func newAllocSelector(ctx context.Context, index stores.SectorIndex, alloc stores.SectorFileType, ptype stores.PathType) (*allocSelector) { func newAllocSelector(ctx context.Context, index stores.SectorIndex, alloc stores.SectorFileType, ptype stores.PathType) *allocSelector {
return &allocSelector{ return &allocSelector{
index: index, index: index,
alloc: alloc, alloc: alloc,