@@ -33,14 +33,15 @@ import (
33
33
"github.com/coder/coder/v2/codersdk"
34
34
"github.com/coder/coder/v2/codersdk/workspacesdk"
35
35
"github.com/coder/coder/v2/scaletest/agentconn"
36
- "github.com/coder/coder/v2/scaletest/coderconnect "
36
+ "github.com/coder/coder/v2/scaletest/createusers "
37
37
"github.com/coder/coder/v2/scaletest/createworkspaces"
38
38
"github.com/coder/coder/v2/scaletest/dashboard"
39
39
"github.com/coder/coder/v2/scaletest/harness"
40
40
"github.com/coder/coder/v2/scaletest/loadtestutil"
41
41
"github.com/coder/coder/v2/scaletest/reconnectingpty"
42
42
"github.com/coder/coder/v2/scaletest/workspacebuild"
43
43
"github.com/coder/coder/v2/scaletest/workspacetraffic"
44
+ "github.com/coder/coder/v2/scaletest/workspaceupdates"
44
45
"github.com/coder/serpent"
45
46
)
46
47
@@ -57,7 +58,7 @@ func (r *RootCmd) scaletestCmd() *serpent.Command {
57
58
r .scaletestCleanup (),
58
59
r .scaletestDashboard (),
59
60
r .scaletestCreateWorkspaces (),
60
- r .scaletestCoderConnect (),
61
+ r .scaletestWorkspaceUpdates (),
61
62
r .scaletestWorkspaceTraffic (),
62
63
},
63
64
}
@@ -856,7 +857,7 @@ func (r *RootCmd) scaletestCreateWorkspaces() *serpent.Command {
856
857
return cmd
857
858
}
858
859
859
- func (r * RootCmd )scaletestCoderConnect ()* serpent.Command {
860
+ func (r * RootCmd )scaletestWorkspaceUpdates ()* serpent.Command {
860
861
var (
861
862
workspaceCount int64
862
863
powerUserWorkspaces int64
@@ -865,7 +866,6 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
865
866
dialTimeout time.Duration
866
867
template string
867
868
noCleanup bool
868
- noWaitForAgents bool
869
869
870
870
parameterFlags workspaceParameterFlags
871
871
tracingFlags = & scaletestTracingFlags {}
@@ -877,8 +877,8 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
877
877
)
878
878
879
879
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 " ,
882
882
Handler :func (inv * serpent.Invocation )error {
883
883
ctx := inv .Context ()
884
884
client ,err := r .TryInitClient (inv )
@@ -951,7 +951,6 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
951
951
RichParameterFile :parameterFlags .richParameterFile ,
952
952
RichParameters :cliRichParameters ,
953
953
})
954
- _ = richParameters
955
954
if err != nil {
956
955
return xerrors .Errorf ("prepare build: %w" ,err )
957
956
}
@@ -963,7 +962,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
963
962
tracer := tracerProvider .Tracer (scaletestTracerName )
964
963
965
964
reg := prometheus .NewRegistry ()
966
- metrics := coderconnect .NewMetrics (reg )
965
+ metrics := workspaceupdates .NewMetrics (reg )
967
966
968
967
logger := inv .Logger
969
968
prometheusSrvClose := ServeHandler (ctx ,logger ,promhttp .HandlerFor (reg , promhttp.HandlerOpts {}),prometheusFlags .Address ,"prometheus" )
@@ -981,13 +980,14 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
981
980
982
981
_ ,_ = fmt .Fprintln (inv .Stderr ,"Creating users..." )
983
982
984
- dialBarrier := harness .NewBarrier (int (powerUserCount + regularUserCount ))
983
+ dialBarrier := new (sync.WaitGroup )
984
+ dialBarrier .Add (int (powerUserCount + regularUserCount ))
985
985
986
- configs := make ([]coderconnect .Config ,0 ,powerUserCount + regularUserCount )
986
+ configs := make ([]workspaceupdates .Config ,0 ,powerUserCount + regularUserCount )
987
987
988
- for i := int64 ( 0 ); i < powerUserCount ; i ++ {
989
- config := coderconnect .Config {
990
- User :coderconnect. UserConfig {
988
+ for range powerUserCount {
989
+ config := workspaceupdates .Config {
990
+ User :createusers. Config {
991
991
OrganizationID :me .OrganizationIDs [0 ],
992
992
},
993
993
Workspace : workspacebuild.Config {
@@ -996,13 +996,12 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
996
996
TemplateID :tpl .ID ,
997
997
RichParameterValues :richParameters ,
998
998
},
999
- NoWaitForAgents :noWaitForAgents ,
999
+ NoWaitForAgents :true ,
1000
1000
},
1001
1001
WorkspaceCount :powerUserWorkspaces ,
1002
1002
WorkspaceUpdatesTimeout :workspaceUpdatesTimeout ,
1003
1003
DialTimeout :dialTimeout ,
1004
1004
Metrics :metrics ,
1005
- NoCleanup :noCleanup ,
1006
1005
DialBarrier :dialBarrier ,
1007
1006
}
1008
1007
if err := config .Validate ();err != nil {
@@ -1011,10 +1010,10 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1011
1010
configs = append (configs ,config )
1012
1011
}
1013
1012
1014
- for i := int64 ( 0 ); i < regularUserCount ; i ++ {
1013
+ for range regularUserCount {
1015
1014
workspaceCount := 1
1016
- config := coderconnect .Config {
1017
- User :coderconnect. UserConfig {
1015
+ config := workspaceupdates .Config {
1016
+ User :createusers. Config {
1018
1017
OrganizationID :me .OrganizationIDs [0 ],
1019
1018
},
1020
1019
Workspace : workspacebuild.Config {
@@ -1023,13 +1022,12 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1023
1022
TemplateID :tpl .ID ,
1024
1023
RichParameterValues :richParameters ,
1025
1024
},
1026
- NoWaitForAgents :noWaitForAgents ,
1025
+ NoWaitForAgents :true ,
1027
1026
},
1028
1027
WorkspaceCount :int64 (workspaceCount ),
1029
1028
WorkspaceUpdatesTimeout :workspaceUpdatesTimeout ,
1030
1029
DialTimeout :dialTimeout ,
1031
1030
Metrics :metrics ,
1032
- NoCleanup :noCleanup ,
1033
1031
DialBarrier :dialBarrier ,
1034
1032
}
1035
1033
if err := config .Validate ();err != nil {
@@ -1040,16 +1038,9 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1040
1038
1041
1039
th := harness .NewTestHarness (strategy .toStrategy (),cleanupStrategy .toStrategy ())
1042
1040
for i ,config := range configs {
1043
- name := fmt .Sprintf ("coderconnect -%dw" ,config .WorkspaceCount )
1041
+ name := fmt .Sprintf ("workspaceupdates -%dw" ,config .WorkspaceCount )
1044
1042
id := strconv .Itoa (i )
1045
- username ,email ,err := loadtestutil .GenerateUserIdentifier (id )
1046
- if err != nil {
1047
- return xerrors .Errorf ("generate user identifier: %w" ,err )
1048
- }
1049
- config .User .Username = username
1050
- config .User .Email = email
1051
-
1052
- var runner harness.Runnable = coderconnect .NewRunner (client ,config )
1043
+ var runner harness.Runnable = workspaceupdates .NewRunner (client ,config )
1053
1044
if tracingEnabled {
1054
1045
runner = & runnableTraceWrapper {
1055
1046
tracer :tracer ,
@@ -1061,7 +1052,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1061
1052
th .AddRun (name ,id ,runner )
1062
1053
}
1063
1054
1064
- _ ,_ = fmt .Fprintln (inv .Stderr ,"RunningCoder Connect scaletest..." )
1055
+ _ ,_ = fmt .Fprintln (inv .Stderr ,"Runningworkspace updates scaletest..." )
1065
1056
testCtx ,testCancel := strategy .toContext (ctx )
1066
1057
defer testCancel ()
1067
1058
err = th .Run (testCtx )
@@ -1082,12 +1073,14 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1082
1073
}
1083
1074
}
1084
1075
1085
- _ ,_ = fmt .Fprintln (inv .Stderr ,"\n Cleaning up..." )
1086
- cleanupCtx ,cleanupCancel := cleanupStrategy .toContext (ctx )
1087
- defer cleanupCancel ()
1088
- err = th .Cleanup (cleanupCtx )
1089
- if err != nil {
1090
- return xerrors .Errorf ("cleanup tests: %w" ,err )
1076
+ if ! noCleanup {
1077
+ _ ,_ = fmt .Fprintln (inv .Stderr ,"\n Cleaning up..." )
1078
+ cleanupCtx ,cleanupCancel := cleanupStrategy .toContext (ctx )
1079
+ defer cleanupCancel ()
1080
+ err = th .Cleanup (cleanupCtx )
1081
+ if err != nil {
1082
+ return xerrors .Errorf ("cleanup tests: %w" ,err )
1083
+ }
1091
1084
}
1092
1085
1093
1086
if res .TotalFail > 0 {
@@ -1105,6 +1098,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1105
1098
Env :"CODER_SCALETEST_WORKSPACE_COUNT" ,
1106
1099
Description :"Required: Total number of workspaces to create." ,
1107
1100
Value :serpent .Int64Of (& workspaceCount ),
1101
+ Required :true ,
1108
1102
},
1109
1103
{
1110
1104
Flag :"power-user-workspaces" ,
@@ -1131,7 +1125,7 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1131
1125
Flag :"dial-timeout" ,
1132
1126
Env :"CODER_SCALETEST_DIAL_TIMEOUT" ,
1133
1127
Default :"2m" ,
1134
- Description :"Timeout for dialing theCoder Connect endpoint." ,
1128
+ Description :"Timeout for dialing thetailnet endpoint." ,
1135
1129
Value :serpent .DurationOf (& dialTimeout ),
1136
1130
},
1137
1131
{
@@ -1142,12 +1136,6 @@ func (r *RootCmd) scaletestCoderConnect() *serpent.Command {
1142
1136
Value :serpent .StringOf (& template ),
1143
1137
Required :true ,
1144
1138
},
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
- },
1151
1139
{
1152
1140
Flag :"no-cleanup" ,
1153
1141
Env :"CODER_SCALETEST_NO_CLEANUP" ,