goimports formatting
This commit is contained in:
parent
f23118d73f
commit
a643e7ca0c
5 changed files with 39 additions and 40 deletions
|
@ -32,7 +32,7 @@ func NewJobUpdate() *JobUpdate {
|
||||||
newTask := NewTask()
|
newTask := NewTask()
|
||||||
|
|
||||||
return &JobUpdate{
|
return &JobUpdate{
|
||||||
task: newTask,
|
task: newTask,
|
||||||
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,10 +44,11 @@ func JobUpdateFromAuroraTask(task *AuroraTask) *JobUpdate {
|
||||||
newTask := task.Clone()
|
newTask := task.Clone()
|
||||||
|
|
||||||
return &JobUpdate{
|
return &JobUpdate{
|
||||||
task: newTask,
|
task: newTask,
|
||||||
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// JobUpdateFromConfig creates an update with default values using an aurora.TaskConfig
|
// JobUpdateFromConfig creates an update with default values using an aurora.TaskConfig
|
||||||
// primitive as the underlying task configuration.
|
// primitive as the underlying task configuration.
|
||||||
// This function should not be used unless the implications of using a primitive value are understood.
|
// This function should not be used unless the implications of using a primitive value are understood.
|
||||||
|
@ -57,7 +58,7 @@ func JobUpdateFromConfig(task *aurora.TaskConfig) *JobUpdate {
|
||||||
newTask := TaskFromThrift(task)
|
newTask := TaskFromThrift(task)
|
||||||
|
|
||||||
return &JobUpdate{
|
return &JobUpdate{
|
||||||
task: newTask,
|
task: newTask,
|
||||||
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +124,7 @@ func (j *JobUpdate) QueueUpdateStrategy(groupSize int32) *JobUpdate {
|
||||||
return j
|
return j
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JobUpdate) VariableBatchStrategy(autoPause bool, batchSizes... int32) *JobUpdate {
|
func (j *JobUpdate) VariableBatchStrategy(autoPause bool, batchSizes ...int32) *JobUpdate {
|
||||||
j.request.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{
|
j.request.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{
|
||||||
VarBatchStrategy: &aurora.VariableBatchJobUpdateStrategy{GroupSizes: batchSizes, AutopauseAfterBatch: autoPause},
|
VarBatchStrategy: &aurora.VariableBatchJobUpdateStrategy{GroupSizes: batchSizes, AutopauseAfterBatch: autoPause},
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,4 +308,4 @@ func (c *Client) MonitorAutoPausedUpdate(key aurora.JobUpdateKey, interval, time
|
||||||
}
|
}
|
||||||
|
|
||||||
return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil
|
return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -724,7 +724,6 @@ func TestRealisClient_PartitionPolicy(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func TestRealisClient_UpdateStrategies(t *testing.T) {
|
func TestRealisClient_UpdateStrategies(t *testing.T) {
|
||||||
// Create a single job
|
// Create a single job
|
||||||
job := realis.NewJob().
|
job := realis.NewJob().
|
||||||
|
@ -737,7 +736,6 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
|
||||||
InstanceCount(6).
|
InstanceCount(6).
|
||||||
IsService(true)
|
IsService(true)
|
||||||
|
|
||||||
|
|
||||||
// Needed to populate the task config correctly
|
// Needed to populate the task config correctly
|
||||||
assert.NoError(t, job.BuildThermosPayload())
|
assert.NoError(t, job.BuildThermosPayload())
|
||||||
|
|
||||||
|
@ -747,7 +745,7 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
|
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
|
||||||
QueueUpdateStrategy( 2).
|
QueueUpdateStrategy(2).
|
||||||
InstanceCount(6).
|
InstanceCount(6).
|
||||||
WatchTime(1000),
|
WatchTime(1000),
|
||||||
Name: "Queue",
|
Name: "Queue",
|
||||||
|
@ -761,7 +759,7 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
|
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
|
||||||
VariableBatchStrategy(false, 1, 2, 3).
|
VariableBatchStrategy(false, 1, 2, 3).
|
||||||
InstanceCount(6).
|
InstanceCount(6).
|
||||||
WatchTime(1000),
|
WatchTime(1000),
|
||||||
Name: "VarBatch",
|
Name: "VarBatch",
|
||||||
|
|
2
util.go
2
util.go
|
@ -103,4 +103,4 @@ func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int {
|
||||||
batchCount++
|
batchCount++
|
||||||
}
|
}
|
||||||
return batchCount
|
return batchCount
|
||||||
}
|
}
|
||||||
|
|
60
util_test.go
60
util_test.go
|
@ -15,44 +15,44 @@
|
||||||
package realis
|
package realis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCurrentBatchCalculator(t *testing.T) {
|
func TestCurrentBatchCalculator(t *testing.T) {
|
||||||
t.Run("singleBatchOverflow", func(t *testing.T) {
|
t.Run("singleBatchOverflow", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(10, []int32{2})
|
curBatch := calculateCurrentBatch(10, []int32{2})
|
||||||
assert.Equal(t, 4, curBatch)
|
assert.Equal(t, 4, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("noInstancesUpdating", func(t *testing.T) {
|
t.Run("noInstancesUpdating", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(0, []int32{2})
|
curBatch := calculateCurrentBatch(0, []int32{2})
|
||||||
assert.Equal(t, 0, curBatch)
|
assert.Equal(t, 0, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("evenMatchSingleBatch", func(t *testing.T) {
|
t.Run("evenMatchSingleBatch", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(2, []int32{2})
|
curBatch := calculateCurrentBatch(2, []int32{2})
|
||||||
assert.Equal(t, 0, curBatch)
|
assert.Equal(t, 0, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("moreInstancesThanBatches", func(t *testing.T) {
|
t.Run("moreInstancesThanBatches", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(5, []int32{1, 2})
|
curBatch := calculateCurrentBatch(5, []int32{1, 2})
|
||||||
assert.Equal(t, 2, curBatch)
|
assert.Equal(t, 2, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) {
|
t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(5, []int32{2, 1})
|
curBatch := calculateCurrentBatch(5, []int32{2, 1})
|
||||||
assert.Equal(t, 3, curBatch)
|
assert.Equal(t, 3, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("unevenFit", func(t *testing.T) {
|
t.Run("unevenFit", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(2, []int32{1, 2})
|
curBatch := calculateCurrentBatch(2, []int32{1, 2})
|
||||||
assert.Equal(t, 1, curBatch)
|
assert.Equal(t, 1, curBatch)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("halfWay", func(t *testing.T) {
|
t.Run("halfWay", func(t *testing.T) {
|
||||||
curBatch := calculateCurrentBatch(1, []int32{1, 2})
|
curBatch := calculateCurrentBatch(1, []int32{1, 2})
|
||||||
assert.Equal(t, 0, curBatch)
|
assert.Equal(t, 0, curBatch)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue