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

Method scaletestDynamicParameters

cli/exp_scaletest_dynamicparameters.go:25–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func (r *RootCmd) scaletestDynamicParameters() *serpent.Command {
26 var (
27 templateName string
28 provisionerTags []string
29 numEvals int64
30 tracingFlags = &scaletestTracingFlags{}
31 prometheusFlags = &scaletestPrometheusFlags{}
32 // This test requires unlimited concurrency
33 timeoutStrategy = &timeoutFlags{}
34 )
35 orgContext := NewOrganizationContext()
36 output := &scaletestOutputFlags{}
37
38 cmd := &serpent.Command{
39 Use: "dynamic-parameters",
40 Short: "Generates load on the Coder server evaluating dynamic parameters",
41 Long: `It is recommended that all rate limits are disabled on the server before running this scaletest. This test generates many login events which will be rate limited against the (most likely single) IP.`,
42 Handler: func(inv *serpent.Invocation) error {
43 ctx := inv.Context()
44
45 outputs, err := output.parse()
46 if err != nil {
47 return xerrors.Errorf("could not parse --output flags")
48 }
49
50 client, err := r.InitClient(inv)
51 if err != nil {
52 return err
53 }
54 if templateName == "" {
55 return xerrors.Errorf("template cannot be empty")
56 }
57
58 tags, err := ParseProvisionerTags(provisionerTags)
59 if err != nil {
60 return err
61 }
62
63 org, err := orgContext.Selected(inv, client)
64 if err != nil {
65 return err
66 }
67
68 _, err = RequireAdmin(ctx, client)
69 if err != nil {
70 return err
71 }
72
73 reg := prometheus.NewRegistry()
74 metrics := dynamicparameters.NewMetrics(reg, "concurrent_evaluations")
75
76 logger := slog.Make(sloghuman.Sink(inv.Stdout)).Leveled(slog.LevelDebug)
77 prometheusSrvClose := ServeHandler(ctx, logger, promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), prometheusFlags.Address, "prometheus")
78 defer prometheusSrvClose()
79
80 tracerProvider, closeTracing, tracingEnabled, err := tracingFlags.provider(ctx)
81 if err != nil {
82 return xerrors.Errorf("create tracer provider: %w", err)

Callers 1

scaletestCmdMethod · 0.95

Calls 15

parseMethod · 0.95
InitClientMethod · 0.95
SelectedMethod · 0.95
AddRunMethod · 0.95
RunMethod · 0.95
ResultsMethod · 0.95
AttachOptionsMethod · 0.95
attachMethod · 0.95
NewMetricsFunction · 0.92
SetupPartitionsFunction · 0.92
NewTestHarnessFunction · 0.92
DupClientCopyingHeadersFunction · 0.92

Tested by

no test coverage detected