gofmt
This commit is contained in:
parent
be6b88f406
commit
2e557573f4
@ -30,11 +30,11 @@ func TestWithPriority(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type schedTestWorker struct {
|
type schedTestWorker struct {
|
||||||
name string
|
name string
|
||||||
taskTypes map[sealtasks.TaskType]struct{}
|
taskTypes map[sealtasks.TaskType]struct{}
|
||||||
paths []stores.StoragePath
|
paths []stores.StoragePath
|
||||||
|
|
||||||
closed bool
|
closed bool
|
||||||
closing chan struct{}
|
closing chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ func (s *schedTestWorker) Paths(ctx context.Context) ([]stores.StoragePath, erro
|
|||||||
|
|
||||||
func (s *schedTestWorker) Info(ctx context.Context) (storiface.WorkerInfo, error) {
|
func (s *schedTestWorker) Info(ctx context.Context) (storiface.WorkerInfo, error) {
|
||||||
return storiface.WorkerInfo{
|
return storiface.WorkerInfo{
|
||||||
Hostname: s.name,
|
Hostname: s.name,
|
||||||
Resources: storiface.WorkerResources{
|
Resources: storiface.WorkerResources{
|
||||||
MemPhysical: 128 << 30,
|
MemPhysical: 128 << 30,
|
||||||
MemSwap: 200 << 30,
|
MemSwap: 200 << 30,
|
||||||
@ -127,20 +127,20 @@ var _ Worker = &schedTestWorker{}
|
|||||||
|
|
||||||
func addTestWorker(t *testing.T, sched *scheduler, index *stores.Index, name string, taskTypes map[sealtasks.TaskType]struct{}) {
|
func addTestWorker(t *testing.T, sched *scheduler, index *stores.Index, name string, taskTypes map[sealtasks.TaskType]struct{}) {
|
||||||
w := &schedTestWorker{
|
w := &schedTestWorker{
|
||||||
name: name,
|
name: name,
|
||||||
taskTypes: taskTypes,
|
taskTypes: taskTypes,
|
||||||
paths: []stores.StoragePath{{ID: "bb-8", Weight: 2, LocalPath: "<octopus>food</octopus>", CanSeal: true, CanStore: true}},
|
paths: []stores.StoragePath{{ID: "bb-8", Weight: 2, LocalPath: "<octopus>food</octopus>", CanSeal: true, CanStore: true}},
|
||||||
|
|
||||||
closing: make(chan struct{}),
|
closing: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range w.paths {
|
for _, path := range w.paths {
|
||||||
err := index.StorageAttach(context.TODO(), stores.StorageInfo{
|
err := index.StorageAttach(context.TODO(), stores.StorageInfo{
|
||||||
ID: path.ID,
|
ID: path.ID,
|
||||||
URLs: nil,
|
URLs: nil,
|
||||||
Weight: path.Weight,
|
Weight: path.Weight,
|
||||||
CanSeal: path.CanSeal,
|
CanSeal: path.CanSeal,
|
||||||
CanStore: path.CanStore,
|
CanStore: path.CanStore,
|
||||||
}, fsutil.FsStat{
|
}, fsutil.FsStat{
|
||||||
Capacity: 1 << 40,
|
Capacity: 1 << 40,
|
||||||
Available: 1 << 40,
|
Available: 1 << 40,
|
||||||
@ -180,7 +180,7 @@ func TestSched(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type workerSpec struct {
|
type workerSpec struct {
|
||||||
name string
|
name string
|
||||||
taskTypes map[sealtasks.TaskType]struct{}
|
taskTypes map[sealtasks.TaskType]struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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"),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user