Adding support for staggered updates along with tests.
This commit is contained in:
parent
926f802987
commit
7384dfdde3
4 changed files with 79 additions and 3 deletions
2
CHANGELOG
Normal file
2
CHANGELOG
Normal file
|
@ -0,0 +1,2 @@
|
|||
* Changing compose environment to Aurora snapshot in order to support staggered update.
|
||||
* Adding staggered updates API.
|
|
@ -14,7 +14,7 @@ services:
|
|||
ipv4_address: 192.168.33.2
|
||||
|
||||
master:
|
||||
image: rdelvalle/mesos-master:1.5.1
|
||||
image: rdelvalle/mesos-master:1.6.1
|
||||
restart: on-failure
|
||||
ports:
|
||||
- "5050:5050"
|
||||
|
@ -32,7 +32,7 @@ services:
|
|||
- zk
|
||||
|
||||
agent-one:
|
||||
image: rdelvalle/mesos-agent:1.5.1
|
||||
image: rdelvalle/mesos-agent:1.6.1
|
||||
pid: host
|
||||
restart: on-failure
|
||||
ports:
|
||||
|
@ -56,7 +56,7 @@ services:
|
|||
- zk
|
||||
|
||||
aurora-one:
|
||||
image: rdelvalle/aurora:0.21.0
|
||||
image: rdelvalle/aurora:c17191
|
||||
pid: host
|
||||
ports:
|
||||
- "8081:8081"
|
||||
|
|
|
@ -421,6 +421,74 @@ func TestRealisClient_CreateService(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestRealisClient_UpdateStrategies(t *testing.T) {
|
||||
|
||||
// Create a single job
|
||||
job := realis.NewJob().
|
||||
Environment("prod").
|
||||
Role("vagrant").
|
||||
ExecutorName(aurora.AURORA_EXECUTOR_NAME).
|
||||
ExecutorData(string(thermosPayload)).
|
||||
CPU(.01).
|
||||
RAM(4).
|
||||
Disk(10).
|
||||
InstanceCount(6).
|
||||
IsService(true)
|
||||
|
||||
strategies := []struct {
|
||||
UpdateJob *realis.UpdateJob
|
||||
Name string
|
||||
}{
|
||||
{
|
||||
UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()).
|
||||
UpdateStrategy(&aurora.JobUpdateStrategy{QueueStrategy: &aurora.QueueJobUpdateStrategy{GroupSize: 2}}).
|
||||
InstanceCount(6).
|
||||
WatchTime(1000),
|
||||
Name: "Queue",
|
||||
},
|
||||
{
|
||||
UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()).
|
||||
UpdateStrategy(&aurora.JobUpdateStrategy{BatchStrategy: &aurora.BatchJobUpdateStrategy{GroupSize: 2}}).
|
||||
InstanceCount(6).
|
||||
WatchTime(1000),
|
||||
Name: "Batch",
|
||||
},
|
||||
{
|
||||
UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()).
|
||||
UpdateStrategy(&aurora.JobUpdateStrategy{
|
||||
VarBatchStrategy: &aurora.VariableBatchJobUpdateStrategy{GroupSizes: []int32{1, 2, 3}}}).
|
||||
InstanceCount(6).
|
||||
WatchTime(1000),
|
||||
Name: "VarBatch",
|
||||
},
|
||||
}
|
||||
|
||||
for _, strategy := range strategies {
|
||||
t.Run("TestRealisClient_UpdateStrategies_"+strategy.Name, func(t *testing.T) {
|
||||
job.Name("update_strategies_" + strategy.Name)
|
||||
resp, err := r.StartJobUpdate(strategy.UpdateJob, "")
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.NotNil(t, resp.GetResult_())
|
||||
assert.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_())
|
||||
assert.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_().GetKey())
|
||||
|
||||
var ok bool
|
||||
var mErr error
|
||||
key := *resp.GetResult_().GetStartJobUpdateResult_().GetKey()
|
||||
|
||||
if ok, mErr = monitor.JobUpdate(key, 5, 240); !ok || mErr != nil {
|
||||
// Update may already be in a terminal state so don't check for error
|
||||
_, err := r.AbortJobUpdate(key, "Monitor timed out.")
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
_, err = r.KillJob(job.JobKey())
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Test configuring an executor that doesn't exist for CreateJob API
|
||||
func TestRealisClient_CreateService_ExecutorDoesNotExist(t *testing.T) {
|
||||
|
||||
|
|
|
@ -138,6 +138,12 @@ func (u *UpdateJob) RollbackOnFail(rollback bool) *UpdateJob {
|
|||
return u
|
||||
}
|
||||
|
||||
// When False, prevents auto rollback of a failed update.
|
||||
func (u *UpdateJob) UpdateStrategy(updateStrategy *aurora.JobUpdateStrategy) *UpdateJob {
|
||||
u.req.Settings.UpdateStrategy = updateStrategy
|
||||
return u
|
||||
}
|
||||
|
||||
func NewUpdateSettings() *aurora.JobUpdateSettings {
|
||||
|
||||
us := new(aurora.JobUpdateSettings)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue