Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions libbeat/otelbeat/oteltest/oteltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,35 @@

// Ensure the logger fields from the otel collector are present
for _, zl := range zapLogs.All() {
require.Contains(t, zl.ContextMap(), "otelcol.component.kind")
require.Equal(t, "receiver", zl.ContextMap()["otelcol.component.kind"])
require.Contains(t, zl.ContextMap(), "otelcol.signal")
require.Equal(t, "logs", zl.ContextMap()["otelcol.signal"])
require.Contains(t, zl.ContextMap(), "otelcol.component.id")
require.Contains(ct, zl.ContextMap(), "otelcol.component.kind")
require.Equal(ct, "receiver", zl.ContextMap()["otelcol.component.kind"])
require.Contains(ct, zl.ContextMap(), "otelcol.signal")
require.Equal(ct, "logs", zl.ContextMap()["otelcol.signal"])
require.Contains(ct, zl.ContextMap(), "otelcol.component.id")
compID, ok := zl.ContextMap()["otelcol.component.id"].(string)
require.True(t, ok, "otelcol.component.id should be a string")
require.Contains(t, zl.ContextMap(), "service.name")
require.Equal(t, beatForCompID(compID), zl.ContextMap()["service.name"])
require.True(ct, ok, "otelcol.component.id should be a string")
require.Contains(ct, zl.ContextMap(), "service.name")
require.Equal(ct, beatForCompID(compID), zl.ContextMap()["service.name"])
break
}
<<<<<<< HEAD

Check failure on line 165 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected statement, found '<<' (typecheck)

Check failure on line 165 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

syntax error: unexpected <<, expected }

params.AssertFunc(ct, logs, zapLogs)
=======

Check failure on line 168 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

syntax error: unexpected ==, expected }
require.NotNil(ct, host.Evt, "expected not nil, got nil")

if params.Status.Error == "" {
require.Equalf(ct, host.Evt.Status(), componentstatus.StatusOK, "expected %v, got %v", params.Status.Status, host.Evt.Status())
require.Nilf(ct, host.Evt.Err(), "expected nil, got %v", host.Evt.Err())
} else {
require.Equalf(ct, host.Evt.Status(), params.Status.Status, "expected %v, got %v", params.Status.Status, host.Evt.Status())
require.ErrorContainsf(ct, host.Evt.Err(), params.Status.Error, "expected error to contain '%v': %v", params.Status.Error, host.Evt.Err())
}

if params.AssertFunc != nil {
params.AssertFunc(ct, logs, zapLogs)
}
>>>>>>> dd5cbacf4 ([oteltest][fbreceiver] Fix flaky test (#45127))

Check failure on line 182 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected statement, found '>>' (typecheck)

Check failure on line 182 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

invalid character U+0023 '#' (typecheck)
}, 2*time.Minute, 100*time.Millisecond,
"timeout waiting for logger fields from the OTel collector are present in the logs and other assertions to be met")
}

Check failure on line 185 in libbeat/otelbeat/oteltest/oteltest.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected '}', found 'EOF' (typecheck)
77 changes: 77 additions & 0 deletions x-pack/filebeat/fbreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,83 @@
})
}

<<<<<<< HEAD

Check failure on line 250 in x-pack/filebeat/fbreceiver/receiver_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected declaration, found '<<' (typecheck)
=======
func TestReceiverDegraded(t *testing.T) {
testCases := []struct {
name string
status oteltest.ExpectedStatus
benchmarkStatus string
}{
{
name: "failed input",
status: oteltest.ExpectedStatus{
Status: componentstatus.StatusPermanentError,
Error: "benchmark input failed",
},
benchmarkStatus: "failed",
},
{
name: "degraded input",
status: oteltest.ExpectedStatus{
Status: componentstatus.StatusRecoverableError,
Error: "benchmark input degraded",
},
benchmarkStatus: "degraded",
},
{
name: "running input",
status: oteltest.ExpectedStatus{
Status: componentstatus.StatusOK,
Error: "",
},
},
}

for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
config := Config{
Beatconfig: map[string]any{
"filebeat": map[string]any{
"inputs": []map[string]any{
{
"type": "benchmark",
"enabled": true,
"message": "test",
"count": 1,
"status": test.benchmarkStatus,
},
},
},
"output": map[string]any{
"otelconsumer": map[string]any{},
},
"logging": map[string]any{
"level": "debug",
"selectors": []string{
"*",
},
},
"path.home": t.TempDir(),
},
}
oteltest.CheckReceivers(oteltest.CheckReceiversParams{
T: t,
Receivers: []oteltest.ReceiverConfig{
{
Name: "r1",
Beat: "filebeat",
Config: &config,
Factory: NewFactory(),
},
},
Status: test.status,
})
})
}
}

>>>>>>> dd5cbacf4 ([oteltest][fbreceiver] Fix flaky test (#45127))

Check failure on line 326 in x-pack/filebeat/fbreceiver/receiver_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

illegal character U+0023 '#' (typecheck)
func genSocketPath() string {
randData := make([]byte, 16)
for i := range len(randData) {
Expand Down Expand Up @@ -302,7 +379,7 @@

if endpoint == "inputs" {
var data []any
if err := json.Unmarshal(body, &data); err != nil {

Check failure on line 382 in x-pack/filebeat/fbreceiver/receiver_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected declaration, found 'if' (typecheck)
sb.Reset()
fmt.Fprintf(sb, "json unmarshal of body failed: %s\n", err)
fmt.Fprintf(sb, "body was %v\n", body)
Expand All @@ -316,7 +393,7 @@
}
} else {
var data map[string]any
if err := json.Unmarshal(body, &data); err != nil {

Check failure on line 396 in x-pack/filebeat/fbreceiver/receiver_test.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

expected declaration, found 'if' (typecheck)
sb.Reset()
fmt.Fprintf(sb, "json unmarshal of body failed: %s\n", err)
fmt.Fprintf(sb, "body was %v\n", body)
Expand Down
Loading