Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0f05ec

Browse files
committed
remove barrier
1 parentab630ec commitb0f05ec

File tree

1 file changed

+43
-53
lines changed

1 file changed

+43
-53
lines changed

‎cli/exp_scaletest.go‎

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ import (
3333
"github.com/coder/coder/v2/codersdk"
3434
"github.com/coder/coder/v2/codersdk/workspacesdk"
3535
"github.com/coder/coder/v2/scaletest/agentconn"
36-
"github.com/coder/coder/v2/scaletest/coderconnect"
36+
"github.com/coder/coder/v2/scaletest/createusers"
3737
"github.com/coder/coder/v2/scaletest/createworkspaces"
3838
"github.com/coder/coder/v2/scaletest/dashboard"
3939
"github.com/coder/coder/v2/scaletest/harness"
4040
"github.com/coder/coder/v2/scaletest/loadtestutil"
4141
"github.com/coder/coder/v2/scaletest/reconnectingpty"
4242
"github.com/coder/coder/v2/scaletest/workspacebuild"
4343
"github.com/coder/coder/v2/scaletest/workspacetraffic"
44+
"github.com/coder/coder/v2/scaletest/workspaceupdates"
4445
"github.com/coder/serpent"
4546
)
4647

@@ -57,7 +58,7 @@ func (r *RootCmd) scaletestCmd() *serpent.Command {
5758
r.scaletestCleanup(),
5859
r.scaletestDashboard(),
5960
r.scaletestCreateWorkspaces(),
60-
r.scaletestCoderConnect(),
61+
r.scaletestWorkspaceUpdates(),
6162
r.scaletestWorkspaceTraffic(),
6263
},
6364
}
@@ -856,16 +857,15 @@ func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Command {
856857
returncmd
857858
}
858859

859-
func (r*RootCmd)scaletestCoderConnect()*serpent.Command {
860+
func (r*RootCmd)scaletestWorkspaceUpdates()*serpent.Command {
860861
var (
861862
workspaceCountint64
862863
powerUserWorkspacesint64
863-
powerUserProportionfloat64
864+
powerUserPercentagefloat64
864865
workspaceUpdatesTimeout time.Duration
865866
dialTimeout time.Duration
866867
templatestring
867868
noCleanupbool
868-
noWaitForAgentsbool
869869

870870
parameterFlagsworkspaceParameterFlags
871871
tracingFlags=&scaletestTracingFlags{}
@@ -877,8 +877,8 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
877877
)
878878

879879
cmd:=&serpent.Command{
880-
Use:"coder-connect",
881-
Short:"Simulate the load of Coder Desktop clients",
880+
Use:"workspace-updates",
881+
Short:"Simulate the load of Coder Desktop clients receiving workspace updates",
882882
Handler:func(inv*serpent.Invocation)error {
883883
ctx:=inv.Context()
884884
client,err:=r.TryInitClient(inv)
@@ -910,24 +910,27 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
910910
ifpowerUserWorkspaces<=1 {
911911
returnxerrors.Errorf("--power-user-workspaces must be greater than 1")
912912
}
913-
ifpowerUserProportion<0||powerUserProportion>100 {
913+
ifpowerUserPercentage<0||powerUserPercentage>100 {
914914
returnxerrors.Errorf("--power-user-proportion must be between 0 and 100")
915915
}
916916

917-
powerUserWorkspaceCount:=int64(float64(workspaceCount)*powerUserProportion/100)
917+
powerUserWorkspaceCount:=int64(float64(workspaceCount)*powerUserPercentage/100)
918918
remainder:=powerUserWorkspaceCount%powerUserWorkspaces
919+
// If the power user workspaces can't be evenly divided, round down
920+
// to the nearest multiple so that we only have two groups of users.
919921
workspaceCount-=remainder
920922
powerUserWorkspaceCount-=remainder
921923
powerUserCount:=powerUserWorkspaceCount/powerUserWorkspaces
922924
regularWorkspaceCount:=workspaceCount-powerUserWorkspaceCount
923925
regularUserCount:=regularWorkspaceCount
926+
regularUserWorkspaceCount:=1
924927

925928
_,_=fmt.Fprintf(inv.Stderr,"Distribution plan:\n")
926929
_,_=fmt.Fprintf(inv.Stderr," Total workspaces: %d\n",workspaceCount)
927930
_,_=fmt.Fprintf(inv.Stderr," Power users: %d (each owning %d workspaces = %d total)\n",
928931
powerUserCount,powerUserWorkspaces,powerUserWorkspaceCount)
929-
_,_=fmt.Fprintf(inv.Stderr," Regular users: %d (each owning1 workspace = %d total)\n",
930-
regularUserCount,regularWorkspaceCount)
932+
_,_=fmt.Fprintf(inv.Stderr," Regular users: %d (each owning%d workspace = %d total)\n",
933+
regularUserCount,regularUserWorkspaceCount,regularWorkspaceCount)
931934

932935
outputs,err:=output.parse()
933936
iferr!=nil {
@@ -951,7 +954,6 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
951954
RichParameterFile:parameterFlags.richParameterFile,
952955
RichParameters:cliRichParameters,
953956
})
954-
_=richParameters
955957
iferr!=nil {
956958
returnxerrors.Errorf("prepare build: %w",err)
957959
}
@@ -963,7 +965,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
963965
tracer:=tracerProvider.Tracer(scaletestTracerName)
964966

965967
reg:=prometheus.NewRegistry()
966-
metrics:=coderconnect.NewMetrics(reg)
968+
metrics:=workspaceupdates.NewMetrics(reg)
967969

968970
logger:=inv.Logger
969971
prometheusSrvClose:=ServeHandler(ctx,logger,promhttp.HandlerFor(reg, promhttp.HandlerOpts{}),prometheusFlags.Address,"prometheus")
@@ -981,13 +983,14 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
981983

982984
_,_=fmt.Fprintln(inv.Stderr,"Creating users...")
983985

984-
dialBarrier:=harness.NewBarrier(int(powerUserCount+regularUserCount))
986+
dialBarrier:=new(sync.WaitGroup)
987+
dialBarrier.Add(int(powerUserCount+regularUserCount))
985988

986-
configs:=make([]coderconnect.Config,0,powerUserCount+regularUserCount)
989+
configs:=make([]workspaceupdates.Config,0,powerUserCount+regularUserCount)
987990

988-
fori:=int64(0);i<powerUserCount;i++ {
989-
config:=coderconnect.Config{
990-
User:coderconnect.UserConfig{
991+
forrangepowerUserCount {
992+
config:=workspaceupdates.Config{
993+
User:createusers.Config{
991994
OrganizationID:me.OrganizationIDs[0],
992995
},
993996
Workspace: workspacebuild.Config{
@@ -996,13 +999,12 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
996999
TemplateID:tpl.ID,
9971000
RichParameterValues:richParameters,
9981001
},
999-
NoWaitForAgents:noWaitForAgents,
1002+
NoWaitForAgents:true,
10001003
},
10011004
WorkspaceCount:powerUserWorkspaces,
10021005
WorkspaceUpdatesTimeout:workspaceUpdatesTimeout,
10031006
DialTimeout:dialTimeout,
10041007
Metrics:metrics,
1005-
NoCleanup:noCleanup,
10061008
DialBarrier:dialBarrier,
10071009
}
10081010
iferr:=config.Validate();err!=nil {
@@ -1011,10 +1013,9 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
10111013
configs=append(configs,config)
10121014
}
10131015

1014-
fori:=int64(0);i<regularUserCount;i++ {
1015-
workspaceCount:=1
1016-
config:= coderconnect.Config{
1017-
User: coderconnect.UserConfig{
1016+
forrangeregularUserCount {
1017+
config:= workspaceupdates.Config{
1018+
User: createusers.Config{
10181019
OrganizationID:me.OrganizationIDs[0],
10191020
},
10201021
Workspace: workspacebuild.Config{
@@ -1023,13 +1024,12 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
10231024
TemplateID:tpl.ID,
10241025
RichParameterValues:richParameters,
10251026
},
1026-
NoWaitForAgents:noWaitForAgents,
1027+
NoWaitForAgents:true,
10271028
},
1028-
WorkspaceCount:int64(workspaceCount),
1029+
WorkspaceCount:int64(regularUserWorkspaceCount),
10291030
WorkspaceUpdatesTimeout:workspaceUpdatesTimeout,
10301031
DialTimeout:dialTimeout,
10311032
Metrics:metrics,
1032-
NoCleanup:noCleanup,
10331033
DialBarrier:dialBarrier,
10341034
}
10351035
iferr:=config.Validate();err!=nil {
@@ -1040,16 +1040,9 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
10401040

10411041
th:=harness.NewTestHarness(strategy.toStrategy(),cleanupStrategy.toStrategy())
10421042
fori,config:=rangeconfigs {
1043-
name:=fmt.Sprintf("coderconnect-%dw",config.WorkspaceCount)
1043+
name:=fmt.Sprintf("workspaceupdates-%dw",config.WorkspaceCount)
10441044
id:=strconv.Itoa(i)
1045-
username,email,err:=loadtestutil.GenerateUserIdentifier(id)
1046-
iferr!=nil {
1047-
returnxerrors.Errorf("generate user identifier: %w",err)
1048-
}
1049-
config.User.Username=username
1050-
config.User.Email=email
1051-
1052-
varrunner harness.Runnable=coderconnect.NewRunner(client,config)
1045+
varrunner harness.Runnable=workspaceupdates.NewRunner(client,config)
10531046
iftracingEnabled {
10541047
runner=&runnableTraceWrapper{
10551048
tracer:tracer,
@@ -1061,7 +1054,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
10611054
th.AddRun(name,id,runner)
10621055
}
10631056

1064-
_,_=fmt.Fprintln(inv.Stderr,"RunningCoder Connect scaletest...")
1057+
_,_=fmt.Fprintln(inv.Stderr,"Runningworkspace updates scaletest...")
10651058
testCtx,testCancel:=strategy.toContext(ctx)
10661059
defertestCancel()
10671060
err=th.Run(testCtx)
@@ -1082,12 +1075,14 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
10821075
}
10831076
}
10841077

1085-
_,_=fmt.Fprintln(inv.Stderr,"\nCleaning up...")
1086-
cleanupCtx,cleanupCancel:=cleanupStrategy.toContext(ctx)
1087-
defercleanupCancel()
1088-
err=th.Cleanup(cleanupCtx)
1089-
iferr!=nil {
1090-
returnxerrors.Errorf("cleanup tests: %w",err)
1078+
if!noCleanup {
1079+
_,_=fmt.Fprintln(inv.Stderr,"\nCleaning up...")
1080+
cleanupCtx,cleanupCancel:=cleanupStrategy.toContext(ctx)
1081+
defercleanupCancel()
1082+
err=th.Cleanup(cleanupCtx)
1083+
iferr!=nil {
1084+
returnxerrors.Errorf("cleanup tests: %w",err)
1085+
}
10911086
}
10921087

10931088
ifres.TotalFail>0 {
@@ -1105,6 +1100,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
11051100
Env:"CODER_SCALETEST_WORKSPACE_COUNT",
11061101
Description:"Required: Total number of workspaces to create.",
11071102
Value:serpent.Int64Of(&workspaceCount),
1103+
Required:true,
11081104
},
11091105
{
11101106
Flag:"power-user-workspaces",
@@ -1114,11 +1110,11 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
11141110
Required:true,
11151111
},
11161112
{
1117-
Flag:"power-user-proportion",
1118-
Env:"CODER_SCALETEST_POWER_USER_PROPORTION",
1113+
Flag:"power-user-percentage",
1114+
Env:"CODER_SCALETEST_POWER_USER_PERCENTAGE",
11191115
Default:"50.0",
11201116
Description:"Percentage of total workspaces owned by power-users (0-100).",
1121-
Value:serpent.Float64Of(&powerUserProportion),
1117+
Value:serpent.Float64Of(&powerUserPercentage),
11221118
},
11231119
{
11241120
Flag:"workspace-updates-timeout",
@@ -1131,7 +1127,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
11311127
Flag:"dial-timeout",
11321128
Env:"CODER_SCALETEST_DIAL_TIMEOUT",
11331129
Default:"2m",
1134-
Description:"Timeout for dialing theCoder Connect endpoint.",
1130+
Description:"Timeout for dialing thetailnet endpoint.",
11351131
Value:serpent.DurationOf(&dialTimeout),
11361132
},
11371133
{
@@ -1142,12 +1138,6 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
11421138
Value:serpent.StringOf(&template),
11431139
Required:true,
11441140
},
1145-
{
1146-
Flag:"no-wait-for-agents",
1147-
Env:"CODER_SCALETEST_NO_WAIT_FOR_AGENTS",
1148-
Description:`Do not wait for agents to start before marking the test as succeeded. This can be useful if you are running the test against a template that does not start the agent quickly.`,
1149-
Value:serpent.BoolOf(&noWaitForAgents),
1150-
},
11511141
{
11521142
Flag:"no-cleanup",
11531143
Env:"CODER_SCALETEST_NO_CLEANUP",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp