diff --git a/loadtest/control/actions.go b/loadtest/control/actions.go index 34591ed4c..9743c2961 100644 --- a/loadtest/control/actions.go +++ b/loadtest/control/actions.go @@ -58,6 +58,11 @@ func Login(u user.User) UserActionResponse { return UserActionResponse{Err: NewUserError(err)} } + // Populate user config + if err := u.GetClientConfig(); err != nil { + return UserActionResponse{Err: NewUserError(err)} + } + // Populate teams and channels. teamIds, err := u.GetAllTeams(0, 100) if err != nil { diff --git a/loadtest/control/simulcontroller/actions.go b/loadtest/control/simulcontroller/actions.go index 36100f52d..782f5778d 100644 --- a/loadtest/control/simulcontroller/actions.go +++ b/loadtest/control/simulcontroller/actions.go @@ -77,7 +77,7 @@ func (c *SimulController) reload(full bool) control.UserActionResponse { } var resp control.UserActionResponse - if c.isGQLEnabled { + if c.featureFlags.GraphQLEnabled { resp = control.ReloadGQL(c.user) } else { resp = control.Reload(c.user) @@ -96,7 +96,7 @@ func (c *SimulController) reload(full bool) control.UserActionResponse { return c.switchTeam(c.user) } - if resp := loadTeam(c.user, team, c.isGQLEnabled); resp.Err != nil { + if resp := loadTeam(c.user, team, c.featureFlags.GraphQLEnabled); resp.Err != nil { return resp } @@ -274,7 +274,7 @@ func (c *SimulController) switchTeam(u user.User) control.UserActionResponse { c.status <- c.newInfoStatus(fmt.Sprintf("switched to team %s", team.Id)) - if resp := loadTeam(u, &team, c.isGQLEnabled); resp.Err != nil { + if resp := loadTeam(u, &team, c.featureFlags.GraphQLEnabled); resp.Err != nil { return resp } diff --git a/loadtest/control/simulcontroller/controller.go b/loadtest/control/simulcontroller/controller.go index cb28db7d3..3fa7388c7 100644 --- a/loadtest/control/simulcontroller/controller.go +++ b/loadtest/control/simulcontroller/controller.go @@ -27,7 +27,11 @@ type SimulController struct { connectedFlag int32 // indicates that the controller is connected wg *sync.WaitGroup // to keep the track of every goroutine created by the controller serverVersion string // stores the current server version - isGQLEnabled bool + featureFlags featureFlags // stores the server's feature flags +} + +type featureFlags struct { + GraphQLEnabled bool } // New creates and initializes a new SimulController with given parameters. @@ -77,11 +81,6 @@ func (c *SimulController) Run() { }() c.serverVersion, _ = c.user.Store().ServerVersion() - err := c.user.GetClientConfig() - if err != nil { - c.status <- c.newErrorStatus(err) - } - c.isGQLEnabled = c.user.Store().ClientConfig()["FeatureFlagGraphQL"] == "true" initActions := []userAction{ { @@ -107,6 +106,16 @@ func (c *SimulController) Run() { } } + // Populate the server feature flags struct + clientCfg := c.user.Store().ClientConfig() + if len(clientCfg) == 0 { + c.sendFailStatus("the login init action should have populated the user config, but it is empty") + return + } + c.featureFlags = featureFlags{ + GraphQLEnabled: c.user.Store().ClientConfig()["FeatureFlagGraphQL"] == "true", + } + actions := []userAction{ { run: switchChannel,