Skip to content

Commit 0120719

Browse files
authored
[chore] refactor statustest, fold into status (#13584)
This is just moving an internal package around, as a side effect of #13573
1 parent 4b5e356 commit 0120719

File tree

5 files changed

+12
-23
lines changed

5 files changed

+12
-23
lines changed

service/extensions/extensions.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func New(ctx context.Context, set Settings, cfg Config, options ...Option) (*Ext
203203
extMap: make(map[component.ID]extension.Extension),
204204
instanceIDs: make(map[component.ID]*componentstatus.InstanceID),
205205
extensionIDs: make([]component.ID, 0, len(cfg)),
206-
reporter: &nopReporter{},
206+
reporter: status.NewNopStatusReporter(),
207207
}
208208

209209
for _, opt := range options {
@@ -238,11 +238,3 @@ func New(ctx context.Context, set Settings, cfg Config, options ...Option) (*Ext
238238
exts.extensionIDs = order
239239
return exts, nil
240240
}
241-
242-
type nopReporter struct{}
243-
244-
func (r *nopReporter) Ready() {}
245-
246-
func (r *nopReporter) ReportStatus(*componentstatus.InstanceID, *componentstatus.Event) {}
247-
248-
func (r *nopReporter) ReportOKIfStarting(*componentstatus.InstanceID) {}

service/internal/graph/graph_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"go.opentelemetry.io/collector/receiver/receivertest"
3232
"go.opentelemetry.io/collector/service/internal/builders"
3333
"go.opentelemetry.io/collector/service/internal/status"
34-
"go.opentelemetry.io/collector/service/internal/status/statustest"
3534
"go.opentelemetry.io/collector/service/internal/testcomponents"
3635
"go.opentelemetry.io/collector/service/pipelines"
3736
)
@@ -918,7 +917,7 @@ func testConnectorPipelinesGraph(t *testing.T) {
918917
}
919918

920919
// Shut down the entire component graph
921-
require.NoError(t, pg.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()))
920+
require.NoError(t, pg.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
922921

923922
// Check each pipeline individually, ensuring that all components are stopped.
924923
for pipelineID := range tt.pipelineConfigs {

service/internal/graph/lifecycle_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"go.opentelemetry.io/collector/receiver/receivertest"
2727
"go.opentelemetry.io/collector/service/internal/builders"
2828
"go.opentelemetry.io/collector/service/internal/status"
29-
"go.opentelemetry.io/collector/service/internal/status/statustest"
3029
"go.opentelemetry.io/collector/service/pipelines"
3130
)
3231

@@ -119,7 +118,7 @@ func testGraphStartStop(t *testing.T) {
119118
}
120119

121120
ctx.order = map[component.ID]int{}
122-
require.NoError(t, pg.ShutdownAll(ctx, statustest.NewNopStatusReporter()))
121+
require.NoError(t, pg.ShutdownAll(ctx, status.NewNopStatusReporter()))
123122
for _, edge := range tt.edges {
124123
assert.Less(t, ctx.order[edge[0]], ctx.order[edge[1]])
125124
}
@@ -161,7 +160,7 @@ func testGraphStartStopCycle(t *testing.T) {
161160
err := pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})})
162161
require.ErrorContains(t, err, `topo: no topological ordering: cyclic components`)
163162

164-
err = pg.ShutdownAll(context.Background(), statustest.NewNopStatusReporter())
163+
err = pg.ShutdownAll(context.Background(), status.NewNopStatusReporter())
165164
assert.ErrorContains(t, err, `topo: no topological ordering: cyclic components`)
166165
}
167166

@@ -196,7 +195,7 @@ func testGraphStartStopComponentError(t *testing.T) {
196195
T: e1,
197196
})
198197
require.ErrorIs(t, pg.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}), r1.startErr)
199-
assert.EqualError(t, pg.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()), "bar")
198+
assert.EqualError(t, pg.ShutdownAll(context.Background(), status.NewNopStatusReporter()), "bar")
200199
}
201200

202201
// This includes all tests from the previous implementation, plus a new one
@@ -276,7 +275,7 @@ func testGraphFailToStartAndShutdown(t *testing.T) {
276275
pipelines, err := Build(context.Background(), set)
277276
require.NoError(t, err)
278277
require.Error(t, pipelines.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}))
279-
assert.Error(t, pipelines.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()))
278+
assert.Error(t, pipelines.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
280279
})
281280

282281
t.Run(dt.String()+"/processor", func(t *testing.T) {
@@ -290,7 +289,7 @@ func testGraphFailToStartAndShutdown(t *testing.T) {
290289
pipelines, err := Build(context.Background(), set)
291290
require.NoError(t, err)
292291
require.Error(t, pipelines.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}))
293-
assert.Error(t, pipelines.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()))
292+
assert.Error(t, pipelines.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
294293
})
295294

296295
t.Run(dt.String()+"/exporter", func(t *testing.T) {
@@ -304,7 +303,7 @@ func testGraphFailToStartAndShutdown(t *testing.T) {
304303
pipelines, err := Build(context.Background(), set)
305304
require.NoError(t, err)
306305
require.Error(t, pipelines.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}))
307-
assert.Error(t, pipelines.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()))
306+
assert.Error(t, pipelines.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
308307
})
309308

310309
for _, dt2 := range dataTypes {
@@ -324,7 +323,7 @@ func testGraphFailToStartAndShutdown(t *testing.T) {
324323
pipelines, err := Build(context.Background(), set)
325324
require.NoError(t, err)
326325
require.Error(t, pipelines.StartAll(context.Background(), &Host{Reporter: status.NewReporter(func(*componentstatus.InstanceID, *componentstatus.Event) {}, func(error) {})}))
327-
assert.Error(t, pipelines.ShutdownAll(context.Background(), statustest.NewNopStatusReporter()))
326+
assert.Error(t, pipelines.ShutdownAll(context.Background(), status.NewNopStatusReporter()))
328327
})
329328
}
330329
}

service/internal/status/statustest/statustest.go renamed to service/internal/status/nop.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package statustest // import "go.opentelemetry.io/collector/service/internal/status/statustest"
4+
package status // import "go.opentelemetry.io/collector/service/internal/status"
55

66
import (
77
"go.opentelemetry.io/collector/component/componentstatus"
8-
"go.opentelemetry.io/collector/service/internal/status"
98
)
109

11-
func NewNopStatusReporter() status.Reporter {
10+
func NewNopStatusReporter() Reporter {
1211
return &nopStatusReporter{}
1312
}
1413

service/internal/status/statustest/statustest_test.go renamed to service/internal/status/nop_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package statustest // import "go.opentelemetry.io/collector/service/internal/status/statustest"
4+
package status // import "go.opentelemetry.io/collector/service/internal/status"
55

66
import "testing"
77

0 commit comments

Comments
 (0)