MCPcopy Index your code
hub / github.com/coder/coder / scaletestWorkspaceUpdates

Method scaletestWorkspaceUpdates

cli/exp_scaletest.go:1148–1443  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1146}
1147
1148func (r *RootCmd) scaletestWorkspaceUpdates() *serpent.Command {
1149 var (
1150 workspaceCount int64
1151 powerUserWorkspaces int64
1152 powerUserPercentage float64
1153 workspaceUpdatesTimeout time.Duration
1154 dialTimeout time.Duration
1155 template string
1156 noCleanup bool
1157
1158 parameterFlags workspaceParameterFlags
1159 tracingFlags = &scaletestTracingFlags{}
1160 // This test requires unlimited concurrency
1161 timeoutStrategy = &timeoutFlags{}
1162 cleanupStrategy = newScaletestCleanupStrategy()
1163 output = &scaletestOutputFlags{}
1164 prometheusFlags = &scaletestPrometheusFlags{}
1165 )
1166
1167 cmd := &serpent.Command{
1168 Use: "workspace-updates",
1169 Short: "Simulate the load of Coder Desktop clients receiving workspace updates",
1170 Handler: func(inv *serpent.Invocation) error {
1171 ctx := inv.Context()
1172 client, err := r.TryInitClient(inv)
1173 if err != nil {
1174 return err
1175 }
1176
1177 notifyCtx, stop := signal.NotifyContext(ctx, StopSignals...) // Checked later.
1178 defer stop()
1179 ctx = notifyCtx
1180
1181 me, err := RequireAdmin(ctx, client)
1182 if err != nil {
1183 return err
1184 }
1185
1186 if workspaceCount <= 0 {
1187 return xerrors.Errorf("--workspace-count must be greater than 0")
1188 }
1189 if powerUserWorkspaces <= 1 {
1190 return xerrors.Errorf("--power-user-workspaces must be greater than 1")
1191 }
1192 if powerUserPercentage < 0 || powerUserPercentage > 100 {
1193 return xerrors.Errorf("--power-user-proportion must be between 0 and 100")
1194 }
1195
1196 powerUserWorkspaceCount := int64(float64(workspaceCount) * powerUserPercentage / 100)
1197 remainder := powerUserWorkspaceCount % powerUserWorkspaces
1198 // If the power user workspaces can't be evenly divided, round down
1199 // to the nearest multiple so that we only have two groups of users.
1200 workspaceCount -= remainder
1201 powerUserWorkspaceCount -= remainder
1202 powerUserCount := powerUserWorkspaceCount / powerUserWorkspaces
1203 regularWorkspaceCount := workspaceCount - powerUserWorkspaceCount
1204 regularUserCount := regularWorkspaceCount
1205 regularUserWorkspaceCount := 1

Callers 1

scaletestCmdMethod · 0.95

Calls 15

TryInitClientMethod · 0.95
ValidateMethod · 0.95
AddRunMethod · 0.95
RunMethod · 0.95
ResultsMethod · 0.95
CleanupMethod · 0.95
NewMetricsFunction · 0.92
NewTestHarnessFunction · 0.92
DupClientCopyingHeadersFunction · 0.92
NewRunnerFunction · 0.92
RequireAdminFunction · 0.85

Tested by

no test coverage detected