@@ -78,7 +78,7 @@ func TestGetAllComponentState(t *testing.T) {
7878 },
7979 },
8080 },
81- expectedErr : fmt .Errorf ("pipeline status id %s is not a pipeline " , fmt .Sprintf ("logs/%sfilestream-default" , OtelNamePrefix )),
81+ expectedErr : fmt .Errorf ("couldn't parse otel status id: %s" , fmt .Sprintf ("logs/%sfilestream-default" , OtelNamePrefix )),
8282 },
8383 {
8484 name : "one otel component, one process component" ,
@@ -213,7 +213,20 @@ func TestDropComponentStateFromOtelStatus(t *testing.T) {
213213 s , err := DropComponentStateFromOtelStatus (otelStatus )
214214 require .Error (t , err )
215215 require .Nil (t , s )
216- assert .Equal (t , "pipeline status id logs is not a pipeline" , err .Error ())
216+ assert .Equal (t , "couldn't parse otel status id: logs" , err .Error ())
217+ })
218+
219+ t .Run ("ignore extensions" , func (t * testing.T ) {
220+ otelStatus := & status.AggregateStatus {
221+ ComponentStatusMap : map [string ]* status.AggregateStatus {
222+ "extensions" : {
223+ Event : componentstatus .NewEvent (componentstatus .StatusOK ),
224+ },
225+ },
226+ }
227+ s , err := DropComponentStateFromOtelStatus (otelStatus )
228+ require .NoError (t , err )
229+ assert .Equal (t , otelStatus , s )
217230 })
218231}
219232
@@ -262,7 +275,19 @@ func TestGetOtelRuntimePipelineStatuses(t *testing.T) {
262275 },
263276 },
264277 expected : nil ,
265- err : "pipeline status id invalid-format is not a pipeline" ,
278+ err : "couldn't parse otel status id: invalid-format" ,
279+ },
280+ {
281+ name : "extensions are ignored" ,
282+ status : & status.AggregateStatus {
283+ Event : componentstatus .NewEvent (componentstatus .StatusOK ),
284+ ComponentStatusMap : map [string ]* status.AggregateStatus {
285+ "extensions" : {
286+ Event : componentstatus .NewEvent (componentstatus .StatusOK ),
287+ },
288+ },
289+ },
290+ expected : map [string ]* status.AggregateStatus {},
266291 },
267292 }
268293
@@ -487,16 +512,20 @@ func TestParseEntityStatusId(t *testing.T) {
487512 id string
488513 expectedKind string
489514 expectedEntityID string
515+ expectedErr error
490516 }{
491- {"pipeline:logs" , "pipeline" , "logs" },
492- {"pipeline:logs/filestream-monitoring" , "pipeline" , "logs/filestream-monitoring" },
493- {"receiver:filebeat/filestream-monitoring" , "receiver" , "filebeat/filestream-monitoring" },
494- {"exporter:elasticsearch/default" , "exporter" , "elasticsearch/default" },
495- {"invalid" , "" , "" },
517+ {"pipeline:logs" , "pipeline" , "logs" , nil },
518+ {"pipeline:logs/filestream-monitoring" , "pipeline" , "logs/filestream-monitoring" , nil },
519+ {"receiver:filebeat/filestream-monitoring" , "receiver" , "filebeat/filestream-monitoring" , nil },
520+ {"exporter:elasticsearch/default" , "exporter" , "elasticsearch/default" , nil },
521+ {"invalid" , "" , "" , fmt .Errorf ("couldn't parse otel status id: %s" , "invalid" )},
522+ {"" , "" , "" , fmt .Errorf ("couldn't parse otel status id: %s" , "" )},
523+ {"extensions" , "extensions" , "" , nil },
496524 }
497525
498526 for _ , test := range tests {
499- componentKind , pipelineId := parseEntityStatusId (test .id )
527+ componentKind , pipelineId , err := parseEntityStatusId (test .id )
528+ assert .Equal (t , test .expectedErr , err )
500529 assert .Equal (t , test .expectedKind , componentKind , "component kind" )
501530 assert .Equal (t , test .expectedEntityID , pipelineId , "pipeline id" )
502531 }
0 commit comments