Update sync interval seconds field. (#1698)
* Update sync interval seconds field. * If the sync interval was updated, schedule the next sync job wakeup immediately. * Calculate the next sync time for the scheduler should wake up if we only updated the sync interval.
This commit is contained in:
4 files changed
+69
-1
No files matched your search
@@ -476,6 +476,13 @@ func TestRepository_UpdateSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
changeSyncInterval := func(s int32) changeHostSetFunc {
|
||||
return func(c *HostSet) *HostSet {
|
||||
c.SyncIntervalSeconds = s
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
changePreferredEndpoints := func(s []string) changeHostSetFunc {
|
||||
return func(c *HostSet) *HostSet {
|
||||
c.PreferredEndpoints = s
|
||||
@@ -546,6 +553,13 @@ func TestRepository_UpdateSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
checkSyncInterval := func(want int32) checkHostSetFunc {
|
||||
return func(t *testing.T, got *HostSet) {
|
||||
t.Helper()
|
||||
assert.Equal(t, want, got.SyncIntervalSeconds, "checkSyncInterval")
|
||||
}
|
||||
}
|
||||
|
||||
checkNeedSync := func(want bool) checkHostSetFunc {
|
||||
return func(t *testing.T, got *HostSet) {
|
||||
t.Helper()
|
||||
@@ -889,6 +903,23 @@ func TestRepository_UpdateSet(t *testing.T) {
|
||||
checkVerifySetOplog(oplog.OpType_OP_TYPE_UPDATE),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "set sync interval",
|
||||
startingSet: setupBareHostSet,
|
||||
changeFuncs: []changeHostSetFunc{changeSyncInterval(42)},
|
||||
fieldMask: []string{"SyncIntervalSeconds"},
|
||||
wantCheckPluginReqFuncs: []checkPluginReqFunc{
|
||||
checkUpdateSetRequestPersistedSecrets(map[string]interface{}{
|
||||
"one": "two",
|
||||
}),
|
||||
},
|
||||
wantCheckSetFuncs: []checkHostSetFunc{
|
||||
checkVersion(2),
|
||||
checkNeedSync(true),
|
||||
checkSyncInterval(42),
|
||||
checkVerifySetOplog(oplog.OpType_OP_TYPE_UPDATE),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add preferred endpoints",
|
||||
startingSet: setupBareHostSet,
|
||||
|
||||
Reference in new issue
Block a user