Skip to content

Commit 52d231c

Browse files
committed
remove test
1 parent f90bed2 commit 52d231c

File tree

3 files changed

+0
-113
lines changed

3 files changed

+0
-113
lines changed

coderd/agentapi/api.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ func New(opts Options) *API {
120120
Log: opts.Log,
121121
StatsReporter: opts.StatsReporter,
122122
AgentStatsRefreshInterval: opts.AgentStatsRefreshInterval,
123-
Experiments: opts.Experiments,
124123
}
125124

126125
api.LifecycleAPI = &LifecycleAPI{

coderd/agentapi/stats.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/coder/coder/v2/coderd/database"
1313
"github.com/coder/coder/v2/coderd/database/dbtime"
1414
"github.com/coder/coder/v2/coderd/workspacestats"
15-
"github.com/coder/coder/v2/codersdk"
1615
)
1716

1817
type StatsAPI struct {
@@ -21,7 +20,6 @@ type StatsAPI struct {
2120
Log slog.Logger
2221
StatsReporter *workspacestats.Reporter
2322
AgentStatsRefreshInterval time.Duration
24-
Experiments codersdk.Experiments
2523

2624
TimeNowFn func() time.Time // defaults to dbtime.Now()
2725
}
@@ -57,17 +55,6 @@ func (a *StatsAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateStatsR
5755
slog.F("payload", req),
5856
)
5957

60-
if a.Experiments.Enabled(codersdk.ExperimentWorkspaceUsage) {
61-
// Certain session agent stats are being handled by postWorkspaceUsage route when this
62-
// experiment is enabled. We still want most of the stats data but will zero
63-
// out the ones being written elsewhere.
64-
req.Stats.SessionCountSsh = 0
65-
// TODO: More session types will be enabled as we migrate over.
66-
// req.Stats.SessionCountVscode = 0
67-
// req.Stats.SessionCountJetbrains = 0
68-
// req.Stats.SessionCountReconnectingPty = 0
69-
}
70-
7158
err = a.StatsReporter.ReportAgentStats(
7259
ctx,
7360
a.now(),

coderd/agentapi/stats_test.go

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -379,105 +379,6 @@ func TestUpdateStates(t *testing.T) {
379379

380380
require.True(t, updateAgentMetricsFnCalled)
381381
})
382-
383-
t.Run("WorkspaceUsageExperiment", func(t *testing.T) {
384-
t.Parallel()
385-
386-
var (
387-
now = dbtime.Now()
388-
dbM = dbmock.NewMockStore(gomock.NewController(t))
389-
ps = pubsub.NewInMemory()
390-
391-
templateScheduleStore = schedule.MockTemplateScheduleStore{
392-
GetFn: func(context.Context, database.Store, uuid.UUID) (schedule.TemplateScheduleOptions, error) {
393-
panic("should not be called")
394-
},
395-
SetFn: func(context.Context, database.Store, database.Template, schedule.TemplateScheduleOptions) (database.Template, error) {
396-
panic("not implemented")
397-
},
398-
}
399-
batcher = &wstest.StatsBatcher{}
400-
401-
req = &agentproto.UpdateStatsRequest{
402-
Stats: &agentproto.Stats{
403-
ConnectionsByProto: map[string]int64{
404-
"tcp": 1,
405-
"dean": 2,
406-
},
407-
ConnectionCount: 3,
408-
ConnectionMedianLatencyMs: 23,
409-
RxPackets: 120,
410-
RxBytes: 1000,
411-
TxPackets: 130,
412-
TxBytes: 2000,
413-
SessionCountVscode: 1,
414-
SessionCountJetbrains: 2,
415-
SessionCountReconnectingPty: 3,
416-
SessionCountSsh: 4,
417-
Metrics: []*agentproto.Stats_Metric{
418-
{
419-
Name: "awesome metric",
420-
Value: 42,
421-
},
422-
{
423-
Name: "uncool metric",
424-
Value: 0,
425-
},
426-
},
427-
},
428-
}
429-
)
430-
api := agentapi.StatsAPI{
431-
AgentFn: func(context.Context) (database.WorkspaceAgent, error) {
432-
return agent, nil
433-
},
434-
Database: dbM,
435-
StatsReporter: workspacestats.NewReporter(workspacestats.ReporterOptions{
436-
Database: dbM,
437-
Pubsub: ps,
438-
StatsBatcher: batcher,
439-
TemplateScheduleStore: templateScheduleStorePtr(templateScheduleStore),
440-
}),
441-
AgentStatsRefreshInterval: 10 * time.Second,
442-
TimeNowFn: func() time.Time {
443-
return now
444-
},
445-
Experiments: []codersdk.Experiment{codersdk.ExperimentWorkspaceUsage},
446-
}
447-
448-
// Workspace gets fetched.
449-
dbM.EXPECT().GetWorkspaceByAgentID(gomock.Any(), agent.ID).Return(database.GetWorkspaceByAgentIDRow{
450-
Workspace: workspace,
451-
TemplateName: template.Name,
452-
}, nil)
453-
454-
// We expect an activity bump because ConnectionCount > 0.
455-
dbM.EXPECT().ActivityBumpWorkspace(gomock.Any(), database.ActivityBumpWorkspaceParams{
456-
WorkspaceID: workspace.ID,
457-
NextAutostart: time.Time{}.UTC(),
458-
}).Return(nil)
459-
460-
// Workspace last used at gets bumped.
461-
dbM.EXPECT().UpdateWorkspaceLastUsedAt(gomock.Any(), database.UpdateWorkspaceLastUsedAtParams{
462-
ID: workspace.ID,
463-
LastUsedAt: now,
464-
}).Return(nil)
465-
466-
resp, err := api.UpdateStats(context.Background(), req)
467-
require.NoError(t, err)
468-
require.Equal(t, &agentproto.UpdateStatsResponse{
469-
ReportInterval: durationpb.New(10 * time.Second),
470-
}, resp)
471-
472-
batcher.Mu.Lock()
473-
defer batcher.Mu.Unlock()
474-
require.EqualValues(t, 1, batcher.Called)
475-
require.EqualValues(t, 0, batcher.LastStats.SessionCountSsh)
476-
// TODO: other session values will come as they are migrated over
477-
// require.EqualValues(t, batcher.lastStats.SessionCountVscode, 0)
478-
// require.EqualValues(t, batcher.lastStats.SessionCountJetbrains, 0)
479-
// require.EqualValues(t, batcher.lastStats.SessionCountReconnectingPty, 0)
480-
})
481382
}
482383

483384
func templateScheduleStorePtr(store schedule.TemplateScheduleStore) *atomic.Pointer[schedule.TemplateScheduleStore] {

0 commit comments

Comments
 (0)