From a643e7ca0c2caa77c87bd7f0ccf69320798aef4b Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Tue, 5 May 2020 20:54:10 -0700 Subject: [PATCH] goimports formatting --- jobUpdate.go | 9 +++---- monitors.go | 2 +- realis_e2e_test.go | 6 ++--- util.go | 2 +- util_test.go | 60 +++++++++++++++++++++++----------------------- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/jobUpdate.go b/jobUpdate.go index 1ed2ce5..6b285df 100644 --- a/jobUpdate.go +++ b/jobUpdate.go @@ -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}, } diff --git a/monitors.go b/monitors.go index f37b18e..963c017 100644 --- a/monitors.go +++ b/monitors.go @@ -308,4 +308,4 @@ func (c *Client) MonitorAutoPausedUpdate(key aurora.JobUpdateKey, interval, time } return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil -} \ No newline at end of file +} diff --git a/realis_e2e_test.go b/realis_e2e_test.go index f0a6085..38e39e7 100644 --- a/realis_e2e_test.go +++ b/realis_e2e_test.go @@ -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", diff --git a/util.go b/util.go index 4d43aa6..90e3dcf 100644 --- a/util.go +++ b/util.go @@ -103,4 +103,4 @@ func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int { batchCount++ } return batchCount -} \ No newline at end of file +} diff --git a/util_test.go b/util_test.go index 47d2320..45aaf75 100644 --- a/util_test.go +++ b/util_test.go @@ -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) + }) }