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

Commit987b7ca

Browse files
committed
feat(scaletest): add runner for coder connect load gen
1 parent297b92f commit987b7ca

File tree

4 files changed

+571
-0
lines changed

4 files changed

+571
-0
lines changed

‎scaletest/coderconnect/config.go‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package coderconnect
2+
3+
import (
4+
"time"
5+
6+
"github.com/google/uuid"
7+
"golang.org/x/xerrors"
8+
9+
"github.com/coder/coder/v2/codersdk"
10+
"github.com/coder/coder/v2/scaletest/harness"
11+
"github.com/coder/coder/v2/scaletest/workspacebuild"
12+
)
13+
14+
typeUserConfigstruct {
15+
// OrganizationID is the ID of the organization to add the user to.
16+
OrganizationID uuid.UUID`json:"organization_id"`
17+
// Username is the username of the new user.
18+
Usernamestring`json:"username"`
19+
// Email is the email of the new user.
20+
Emailstring`json:"email"`
21+
// SessionToken is the session token of an already existing user. If set, no
22+
// user will be created.
23+
SessionTokenstring`json:"session_token"`
24+
}
25+
26+
func (cUserConfig)Validate()error {
27+
ifc.OrganizationID==uuid.Nil {
28+
returnxerrors.New("organization_id must not be a nil UUID")
29+
}
30+
ifc.SessionToken!="" {
31+
ifc.Username!="" {
32+
returnxerrors.New("username must be empty when session_token is set")
33+
}
34+
ifc.Email!="" {
35+
returnxerrors.New("email must be empty when session_token is set")
36+
}
37+
}
38+
39+
returnnil
40+
}
41+
42+
typeConfigstruct {
43+
// User is the configuration for the user to create or use.
44+
UserUserConfig`json:"user"`
45+
46+
// Workspace is the configuration for the workspace to create. The workspace
47+
// will be built using the new user.
48+
//
49+
// OrganizationID is ignored and set to the new user's organization ID.
50+
Workspace workspacebuild.Config`json:"workspace"`
51+
52+
// WorkspaceCount is the number of workspaces to create.
53+
WorkspaceCountint64`json:"power_user_workspaces"`
54+
55+
// WorkspaceUpdatesTimeout is how long to wait for all expected workspace updates.
56+
WorkspaceUpdatesTimeout time.Duration`json:"workspace_updates_timeout"`
57+
58+
// DialTimeout is how long to wait for the Coder Connect endpoint to be
59+
// reachable.
60+
DialTimeout time.Duration`json:"dial_timeout"`
61+
62+
// NoCleanup determines whether users and workspaces should be left after the test.
63+
NoCleanupbool`json:"no_cleanup"`
64+
65+
Metrics*Metrics`json:"-"`
66+
67+
MetricLabelValues []string`json:"metric_label_values"`
68+
69+
// DialBarrier is used to ensure all runners have dialed the Coder Connect
70+
// endpoint before creating their workspace(s).
71+
DialBarrier*harness.Barrier`json:"-"`
72+
}
73+
74+
func (cConfig)Validate()error {
75+
iferr:=c.User.Validate();err!=nil {
76+
returnxerrors.Errorf("user config: %w",err)
77+
}
78+
c.Workspace.OrganizationID=c.User.OrganizationID
79+
// This value will be overwritten during the test.
80+
c.Workspace.UserID=codersdk.Me
81+
iferr:=c.Workspace.Validate();err!=nil {
82+
returnxerrors.Errorf("workspace config: %w",err)
83+
}
84+
85+
ifc.DialBarrier==nil {
86+
returnxerrors.New("dial barrier must be set")
87+
}
88+
89+
ifc.WorkspaceUpdatesTimeout<=0 {
90+
returnxerrors.New("workspace_updates_timeout must be greater than 0")
91+
}
92+
93+
ifc.DialTimeout<=0 {
94+
returnxerrors.New("dial_timeout must be greater than 0")
95+
}
96+
97+
ifc.Metrics==nil {
98+
returnxerrors.New("metrics must be set")
99+
}
100+
101+
returnnil
102+
}

‎scaletest/coderconnect/metrics.go‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package coderconnect
2+
3+
import (
4+
"sync/atomic"
5+
"time"
6+
7+
"github.com/prometheus/client_golang/prometheus"
8+
)
9+
10+
typeMetricsstruct {
11+
WorkspaceUpdatesLatencySeconds prometheus.HistogramVec
12+
WorkspaceUpdatesErrorsTotal prometheus.CounterVec
13+
14+
numErrors atomic.Int64
15+
completionDuration time.Duration
16+
}
17+
18+
funcNewMetrics(reg prometheus.Registerer,labelNames...string)*Metrics {
19+
m:=&Metrics{
20+
WorkspaceUpdatesLatencySeconds:*prometheus.NewHistogramVec(prometheus.HistogramOpts{
21+
Namespace:"coderd",
22+
Subsystem:"scaletest",
23+
Name:"workspace_updates_latency_seconds",
24+
Help:"Time until all expected workspaces and agents are seen via workspace updates",
25+
},labelNames),
26+
WorkspaceUpdatesErrorsTotal:*prometheus.NewCounterVec(prometheus.CounterOpts{
27+
Namespace:"coderd",
28+
Subsystem:"scaletest",
29+
Name:"workspace_updates_errors_total",
30+
Help:"Total number of workspace updates errors",
31+
},append(labelNames,"action")),
32+
}
33+
34+
reg.MustRegister(m.WorkspaceUpdatesLatencySeconds)
35+
reg.MustRegister(m.WorkspaceUpdatesErrorsTotal)
36+
returnm
37+
}
38+
39+
func (m*Metrics)AddError(labelValues...string) {
40+
m.numErrors.Add(1)
41+
m.WorkspaceUpdatesErrorsTotal.WithLabelValues(labelValues...).Inc()
42+
}
43+
44+
func (m*Metrics)RecordCompletion(elapsed time.Duration,labelValues...string) {
45+
m.completionDuration=elapsed
46+
m.WorkspaceUpdatesLatencySeconds.WithLabelValues(labelValues...).Observe(elapsed.Seconds())
47+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp