goimports formatting

This commit is contained in:
Renan DelValle 2020-05-05 20:54:10 -07:00
parent f23118d73f
commit a643e7ca0c
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
5 changed files with 39 additions and 40 deletions

View file

@ -32,7 +32,7 @@ func NewJobUpdate() *JobUpdate {
newTask := NewTask()
return &JobUpdate{
task: newTask,
task: newTask,
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
}
@ -44,10 +44,11 @@ func JobUpdateFromAuroraTask(task *AuroraTask) *JobUpdate {
newTask := task.Clone()
return &JobUpdate{
task: newTask,
task: newTask,
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
}
// JobUpdateFromConfig creates an update with default values using an aurora.TaskConfig
// primitive as the underlying task configuration.
// 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)
return &JobUpdate{
task: newTask,
task: newTask,
request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
}
@ -123,7 +124,7 @@ func (j *JobUpdate) QueueUpdateStrategy(groupSize int32) *JobUpdate {
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{
VarBatchStrategy: &aurora.VariableBatchJobUpdateStrategy{GroupSizes: batchSizes, AutopauseAfterBatch: autoPause},
}

View file

@ -308,4 +308,4 @@ func (c *Client) MonitorAutoPausedUpdate(key aurora.JobUpdateKey, interval, time
}
return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil
}
}

View file

@ -724,7 +724,6 @@ func TestRealisClient_PartitionPolicy(t *testing.T) {
}
func TestRealisClient_UpdateStrategies(t *testing.T) {
// Create a single job
job := realis.NewJob().
@ -737,7 +736,6 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
InstanceCount(6).
IsService(true)
// Needed to populate the task config correctly
assert.NoError(t, job.BuildThermosPayload())
@ -747,7 +745,7 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
}{
{
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
QueueUpdateStrategy( 2).
QueueUpdateStrategy(2).
InstanceCount(6).
WatchTime(1000),
Name: "Queue",
@ -761,7 +759,7 @@ func TestRealisClient_UpdateStrategies(t *testing.T) {
},
{
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
VariableBatchStrategy(false, 1, 2, 3).
VariableBatchStrategy(false, 1, 2, 3).
InstanceCount(6).
WatchTime(1000),
Name: "VarBatch",

View file

@ -103,4 +103,4 @@ func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int {
batchCount++
}
return batchCount
}
}

View file

@ -15,44 +15,44 @@
package realis
import (
"testing"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
func TestCurrentBatchCalculator(t *testing.T) {
t.Run("singleBatchOverflow", func(t *testing.T) {
curBatch := calculateCurrentBatch(10, []int32{2})
assert.Equal(t, 4, curBatch)
})
t.Run("singleBatchOverflow", func(t *testing.T) {
curBatch := calculateCurrentBatch(10, []int32{2})
assert.Equal(t, 4, curBatch)
})
t.Run("noInstancesUpdating", func(t *testing.T) {
curBatch := calculateCurrentBatch(0, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("noInstancesUpdating", func(t *testing.T) {
curBatch := calculateCurrentBatch(0, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("evenMatchSingleBatch", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("evenMatchSingleBatch", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("moreInstancesThanBatches", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{1, 2})
assert.Equal(t, 2, curBatch)
})
t.Run("moreInstancesThanBatches", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{1, 2})
assert.Equal(t, 2, curBatch)
})
t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{2, 1})
assert.Equal(t, 3, curBatch)
})
t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{2, 1})
assert.Equal(t, 3, curBatch)
})
t.Run("unevenFit", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{1, 2})
assert.Equal(t, 1, curBatch)
})
t.Run("unevenFit", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{1, 2})
assert.Equal(t, 1, curBatch)
})
t.Run("halfWay", func(t *testing.T) {
curBatch := calculateCurrentBatch(1, []int32{1, 2})
assert.Equal(t, 0, curBatch)
})
t.Run("halfWay", func(t *testing.T) {
curBatch := calculateCurrentBatch(1, []int32{1, 2})
assert.Equal(t, 0, curBatch)
})
}