Skip to content

Commit

Permalink
MM-52110: Init config on login, then populate feature flags (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
agarciamontoro authored Apr 18, 2023
1 parent 0c61e24 commit ad71e55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions loadtest/control/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions loadtest/control/simulcontroller/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
21 changes: 15 additions & 6 deletions loadtest/control/simulcontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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{
{
Expand All @@ -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,
Expand Down

0 comments on commit ad71e55

Please sign in to comment.