Skip to content

Commit

Permalink
make ensuring a poll
Browse files Browse the repository at this point in the history
  • Loading branch information
nammn committed Mar 7, 2024
1 parent b18ad3e commit 03d6d6b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/agent/replica_set_port_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (r *ReplicaSetPortManager) calculateExpectedPorts() (processPortMap map[str
for _, podState := range r.currentPodStates {
if !podState.ReachedGoalState {
r.log.Debugf("Port change required but not all pods reached goal state, abandoning port change")
return processPortMap, portChangeRequired, oldPort
return processPortMap, true, oldPort
}
}

Expand All @@ -143,5 +143,5 @@ func (r *ReplicaSetPortManager) calculateExpectedPorts() (processPortMap map[str
}
}

return processPortMap, portChangeRequired, oldPort
return processPortMap, true, oldPort
}
18 changes: 14 additions & 4 deletions test/e2e/util/mongotester/mongotester.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,24 @@ func (m *Tester) WaitForRotatedCertificate(mdb mdbv1.MongoDBCommunity, initialCe
}
}

// EnsureMongodConfig is mostly used for checking port changes. Port changes take some until they finish.
// We cannot fully rely on the statefulset or resource being ready/running since it will change its state multiple
// times during a port change. That means a resource might leave, go into and leave running multiple times until
// it truly finished its port change.
func (m *Tester) EnsureMongodConfig(selector string, expected interface{}) func(*testing.T) {
return func(t *testing.T) {
opts, err := m.getCommandLineOptions()
connectivityOpts := defaults()
err := wait.Poll(connectivityOpts.IntervalTime, connectivityOpts.TimeoutTime, func() (done bool, err error) {
opts, err := m.getCommandLineOptions()
assert.NoError(t, err)

parsed := objx.New(bsonToMap(opts)).Get("parsed").ObjxMap()

return expected == parsed.Get(selector).Data(), nil
})

assert.NoError(t, err)

// The options are stored under the key "parsed"
parsed := objx.New(bsonToMap(opts)).Get("parsed").ObjxMap()
assert.Equal(t, expected, parsed.Get(selector).Data())
}
}

Expand Down

0 comments on commit 03d6d6b

Please sign in to comment.