Skip to content

Commit

Permalink
CLOUDP-89947: Add new memberConfig's secondaryDelaySecs field for FCV…
Browse files Browse the repository at this point in the history
… > 5 (#95)

Merging on behalf of Stanislav Putrya <[email protected]>
  • Loading branch information
svagner authored May 17, 2021
1 parent 06046ed commit e8d06fc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
8 changes: 5 additions & 3 deletions atmcfg/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
)

func automationConfigWithOneReplicaSet(name string, disabled bool) *opsmngr.AutomationConfig {
slaveDelay := float64(0)
return &opsmngr.AutomationConfig{
Processes: []*opsmngr.Process{
{
Expand Down Expand Up @@ -53,7 +54,7 @@ func automationConfigWithOneReplicaSet(name string, disabled bool) *opsmngr.Auto
Hidden: false,
Host: name + "_0",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand All @@ -65,6 +66,7 @@ func automationConfigWithOneReplicaSet(name string, disabled bool) *opsmngr.Auto
func automationConfigWithOneShardedCluster(name string, disabled bool) *opsmngr.AutomationConfig {
configRSPort := defaultMongoPort + 1
mongosPort := configRSPort + 1
slaveDelay := float64(0)
return &opsmngr.AutomationConfig{
Processes: []*opsmngr.Process{
{
Expand Down Expand Up @@ -165,7 +167,7 @@ func automationConfigWithOneShardedCluster(name string, disabled bool) *opsmngr.
Hidden: false,
Host: name + "_shard_0_0",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand All @@ -180,7 +182,7 @@ func automationConfigWithOneShardedCluster(name string, disabled bool) *opsmngr.
Hidden: false,
Host: name + "_configRS_0",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand Down
19 changes: 10 additions & 9 deletions opsmngr/automation_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ type ScramShaCreds struct {

// Member configs
type Member struct {
ID int `json:"_id"`
ArbiterOnly bool `json:"arbiterOnly"`
BuildIndexes bool `json:"buildIndexes"`
Hidden bool `json:"hidden"`
Host string `json:"host"`
Priority float64 `json:"priority"`
SlaveDelay float64 `json:"slaveDelay"`
Tags *map[string]interface{} `json:"tags,omitempty"`
Votes float64 `json:"votes"`
ID int `json:"_id"`
ArbiterOnly bool `json:"arbiterOnly"`
BuildIndexes bool `json:"buildIndexes"`
Hidden bool `json:"hidden"`
Host string `json:"host"`
Priority float64 `json:"priority"`
SlaveDelay *float64 `json:"slaveDelay,omitempty"`
SecondaryDelaySecs *float64 `json:"secondaryDelaySecs,omitempty"`
Tags *map[string]interface{} `json:"tags,omitempty"`
Votes float64 `json:"votes"`
}

// ReplicaSet configs
Expand Down
14 changes: 8 additions & 6 deletions opsmngr/automation_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestAutomation_GetConfig(t *testing.T) {
t.Fatalf("Automation.GetConfig returned error: %v", err)
}

slaveDelay := float64(0)
expected := &AutomationConfig{
Auth: Auth{
AutoAuthMechanism: "MONGODB-CR",
Expand Down Expand Up @@ -329,7 +330,7 @@ func TestAutomation_GetConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_1",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -339,7 +340,7 @@ func TestAutomation_GetConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_2",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -349,7 +350,7 @@ func TestAutomation_GetConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_3",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand All @@ -368,6 +369,7 @@ func TestAutomation_UpdateConfig(t *testing.T) {
defer teardown()

clusterName := "myReplicaSet"
slaveDelay := float64(0)
updateRequest := &AutomationConfig{
Auth: Auth{
AutoAuthMechanism: "MONGODB-CR",
Expand Down Expand Up @@ -480,7 +482,7 @@ func TestAutomation_UpdateConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_1",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -490,7 +492,7 @@ func TestAutomation_UpdateConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_2",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -500,7 +502,7 @@ func TestAutomation_UpdateConfig(t *testing.T) {
Hidden: false,
Host: "myReplicaSet_3",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand Down
8 changes: 5 additions & 3 deletions search/example_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (

const rsName = "myReplicaSet_1"

var slaveDelay = float64(0)

var fixture = &opsmngr.AutomationConfig{
Auth: opsmngr.Auth{
AutoAuthMechanism: "MONGODB-CR",
Expand Down Expand Up @@ -149,7 +151,7 @@ var fixture = &opsmngr.AutomationConfig{
Hidden: false,
Host: rsName,
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -159,7 +161,7 @@ var fixture = &opsmngr.AutomationConfig{
Hidden: false,
Host: "myReplicaSet_2",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
{
Expand All @@ -169,7 +171,7 @@ var fixture = &opsmngr.AutomationConfig{
Hidden: false,
Host: "myReplicaSet_3",
Priority: 1,
SlaveDelay: 0,
SlaveDelay: &slaveDelay,
Votes: 1,
},
},
Expand Down

0 comments on commit e8d06fc

Please sign in to comment.