Skip to content

Commit

Permalink
Fix Otel API change and update system test golden files to 2025 (#42199)
Browse files Browse the repository at this point in the history
* Fix Otel API change

* Update test files with new date/year

(cherry picked from commit 1430cfd)

# Conflicts:
#	x-pack/filebeat/fbreceiver/receiver_test.go
#	x-pack/filebeat/module/cisco/asa/test/non-canonical.log-expected.json
  • Loading branch information
belimawr authored and mergify[bot] committed Jan 3, 2025
1 parent 199abb9 commit 4a09a9a
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 33 deletions.
136 changes: 136 additions & 0 deletions x-pack/filebeat/fbreceiver/receiver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package fbreceiver

import (
"bytes"
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/pdata/plog"
"go.opentelemetry.io/collector/receiver"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

func TestNewReceiver(t *testing.T) {
config := Config{

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

View workflow job for this annotation

GitHub Actions / lint (windows)

undefined: Config (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (linux)

undefined: Config (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (darwin)

undefined: Config (typecheck)
Beatconfig: map[string]interface{}{
"filebeat": map[string]interface{}{
"inputs": []map[string]interface{}{
{
"type": "benchmark",
"enabled": true,
"message": "test",
"count": 1,
},
},
},
"output": map[string]interface{}{
"otelconsumer": map[string]interface{}{},
},
"logging": map[string]interface{}{
"level": "debug",
"selectors": []string{
"*",
},
},
"path.home": t.TempDir(),
},
}

var zapLogs bytes.Buffer
core := zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(&zapLogs),
zapcore.DebugLevel)

receiverSettings := receiver.Settings{}
receiverSettings.Logger = zap.New(core)

var countLogs int
logConsumer, err := consumer.NewLogs(func(ctx context.Context, ld plog.Logs) error {
countLogs = countLogs + ld.LogRecordCount()
return nil
})
assert.NoError(t, err, "Error creating log consumer")

r, err := createReceiver(context.Background(), receiverSettings, &config, logConsumer)

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

View workflow job for this annotation

GitHub Actions / lint (windows)

undefined: createReceiver (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (linux)

undefined: createReceiver (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (darwin)

undefined: createReceiver (typecheck)
assert.NoErrorf(t, err, "Error creating receiver. Logs:\n %s", zapLogs.String())
err = r.Start(context.Background(), nil)
assert.NoError(t, err, "Error starting filebeatreceiver")

ch := make(chan bool, 1)
timer := time.NewTimer(120 * time.Second)
defer timer.Stop()
ticker := time.NewTicker(1 * time.Second)
defer ticker.Stop()

for tick := ticker.C; ; {
select {
case <-timer.C:
t.Fatalf("consumed logs didn't increase\nCount: %d\nLogs: %s\n", countLogs, zapLogs.String())
case <-tick:
tick = nil
go func() { ch <- countLogs > 0 }()
case v := <-ch:
if v {
goto found
}
tick = ticker.C
}
}
found:
err = r.Shutdown(context.Background())
assert.NoError(t, err, "Error shutting down filebeatreceiver")
}

func BenchmarkFactory(b *testing.B) {
tmpDir := b.TempDir()

cfg := &Config{

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

View workflow job for this annotation

GitHub Actions / lint (windows)

undefined: Config (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (linux)

undefined: Config (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (darwin)

undefined: Config (typecheck)
Beatconfig: map[string]interface{}{
"filebeat": map[string]interface{}{
"inputs": []map[string]interface{}{
{
"type": "benchmark",
"enabled": true,
"message": "test",
"count": 10,
},
},
},
"output": map[string]interface{}{
"otelconsumer": map[string]interface{}{},
},
"logging": map[string]interface{}{
"level": "debug",
"selectors": []string{
"*",
},
},
"path.home": tmpDir,
},
}

var zapLogs bytes.Buffer
core := zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(&zapLogs),
zapcore.DebugLevel)

receiverSettings := receiver.Settings{}
receiverSettings.Logger = zap.New(core)

b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := NewFactory().CreateLogs(context.Background(), receiverSettings, cfg, nil)

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

View workflow job for this annotation

GitHub Actions / lint (windows)

undefined: NewFactory (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (linux)

undefined: NewFactory (typecheck)

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

View workflow job for this annotation

GitHub Actions / lint (darwin)

undefined: NewFactory (typecheck)
require.NoError(b, err)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@
"event.code": 609002,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T17:51:17.000-02:00",
"event.end": "2025-05-05T17:51:17.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%FTD-7-609002: Teardown local-host net:192.168.2.2 duration 0:00:00",
"event.severity": 7,
"event.start": "2024-05-05T19:51:17.000Z",
"event.start": "2025-05-05T19:51:17.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -701,12 +701,12 @@
"event.code": 609002,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T18:24:31.000-02:00",
"event.end": "2025-05-05T18:24:31.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-7-609002: Teardown local-host identity:10.10.10.10 duration 0:00:00",
"event.severity": 7,
"event.start": "2024-05-05T20:24:31.000Z",
"event.start": "2025-05-05T20:24:31.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -849,13 +849,13 @@
"event.code": 302014,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T18:29:32.000-02:00",
"event.end": "2025-05-05T18:29:32.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-302014: Teardown TCP connection 2960892904 for out111:10.10.10.10/443 to fw111:192.168.2.2/55225 duration 0:00:00 bytes 0 TCP Reset-I",
"event.reason": "TCP Reset-I",
"event.severity": 6,
"event.start": "2024-05-05T20:29:32.000Z",
"event.start": "2025-05-05T20:29:32.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -966,12 +966,12 @@
"event.code": 305012,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T18:29:32.000-02:00",
"event.end": "2025-05-05T18:29:32.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-305012: Teardown dynamic UDP translation from fw111:10.10.10.10/54230 to out111:192.168.2.2/54230 duration 0:00:00",
"event.severity": 6,
"event.start": "2024-05-05T20:29:32.000Z",
"event.start": "2025-05-05T20:29:32.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -1185,12 +1185,12 @@
"event.code": 302016,
"event.dataset": "cisco.asa",
"event.duration": 124000000000,
"event.end": "2024-05-05T18:40:50.000-02:00",
"event.end": "2025-05-05T18:40:50.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-2-302016: Teardown UDP connection 1671727 for intfacename:10.10.10.10/161 to net:192.186.2.2/53356 duration 0:02:04 bytes 64585",
"event.severity": 2,
"event.start": "2024-05-05T20:38:46.000Z",
"event.start": "2025-05-05T20:38:46.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -1822,13 +1822,13 @@
"event.code": 302023,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T19:02:58.000-02:00",
"event.end": "2025-05-05T19:02:58.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-302023: Teardown stub TCP connection for fw111:10.10.10.10/39210 to net:192.168.2.2/10051 duration 0:00:00 forwarded bytes 0 Cluster flow with CLU closed on owner",
"event.reason": "Cluster flow with CLU closed on owner",
"event.severity": 6,
"event.start": "2024-05-05T21:02:58.000Z",
"event.start": "2025-05-05T21:02:58.000Z",
"event.timezone": "-02:00",
"event.type": [
"info"
Expand Down Expand Up @@ -1878,13 +1878,13 @@
"event.code": 302023,
"event.dataset": "cisco.asa",
"event.duration": 0,
"event.end": "2024-05-05T19:02:58.000-02:00",
"event.end": "2025-05-05T19:02:58.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-302023: Teardown stub TCP connection for net:10.10.10.10/10051 to unknown:192.168.2.2/39222 duration 0:00:00 forwarded bytes 0 Forwarding or redirect flow removed to create director or backup flow",
"event.reason": "Forwarding or redirect flow removed to create director or backup flow",
"event.severity": 6,
"event.start": "2024-05-05T21:02:58.000Z",
"event.start": "2025-05-05T21:02:58.000Z",
"event.timezone": "-02:00",
"event.type": [
"info"
Expand Down Expand Up @@ -2701,13 +2701,13 @@
"event.code": 302304,
"event.dataset": "cisco.asa",
"event.duration": 3602000000000,
"event.end": "2024-04-27T04:12:23.000-02:00",
"event.end": "2025-04-27T04:12:23.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-302304: Teardown TCP state-bypass connection 2751765169 from server.deflan:1.2.3.4/54242 to server.deflan:2.3.4.5/9101 duration 1:00:02 bytes 245 Connection timeout",
"event.reason": "Connection timeout",
"event.severity": 6,
"event.start": "2024-04-27T05:12:21.000Z",
"event.start": "2025-04-27T05:12:21.000Z",
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -3256,13 +3256,13 @@
"event.code": 113019,
"event.dataset": "cisco.asa",
"event.duration": 1936000000000,
"event.end": "2024-04-27T02:03:03.000-02:00",
"event.end": "2025-04-27T02:03:03.000-02:00",
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-4-113019: Group = 91.240.17.178, Username = 91.240.17.178, IP = 91.240.17.178, Session disconnected. Session Type: LAN-to-LAN, Duration: 0h:32m:16s, Bytes xmt: 297103, Bytes rcv: 1216163, Reason: User Requested",
"event.reason": "User Requested",
"event.severity": 4,
"event.start": "2024-04-27T03:30:47.000Z",
"event.start": "2025-04-27T03:30:47.000Z",
"event.timezone": "-02:00",
"event.type": [
"info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,20 @@
"event.code": 305012,
"event.dataset": "cisco.asa",
"event.duration": 41000000000,
<<<<<<< HEAD
"event.end": "2023-07-15T13:38:47.000-02:00",
=======
"event.end": "2025-07-15T13:38:47.000-02:00",
>>>>>>> 1430cfda7 (Fix Otel API change and update system test golden files to 2025 (#42199))
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-305012: Teardown dynamic UDP translation from SERVERS:exp-wait/62409 to outside:81.2.69.142/62409 duration 0:00:41",
"event.severity": 6,
<<<<<<< HEAD
"event.start": "2023-07-15T15:38:06.000Z",
=======
"event.start": "2025-07-15T15:38:06.000Z",
>>>>>>> 1430cfda7 (Fix Otel API change and update system test golden files to 2025 (#42199))
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down Expand Up @@ -423,12 +431,20 @@
"event.code": 305012,
"event.dataset": "cisco.asa",
"event.duration": 30000000000,
<<<<<<< HEAD
"event.end": "2023-07-15T13:37:33.000-02:00",
=======
"event.end": "2025-07-15T13:37:33.000-02:00",
>>>>>>> 1430cfda7 (Fix Otel API change and update system test golden files to 2025 (#42199))
"event.kind": "event",
"event.module": "cisco",
"event.original": "%ASA-6-305012: Teardown dynamic UDP translation from SERVERS:exp-wait/56421 to outside:81.2.69.142/56421 duration 0:00:30",
"event.severity": 6,
<<<<<<< HEAD
"event.start": "2023-07-15T15:37:03.000Z",
=======
"event.start": "2025-07-15T15:37:03.000Z",
>>>>>>> 1430cfda7 (Fix Otel API change and update system test golden files to 2025 (#42199))
"event.timezone": "-02:00",
"event.type": [
"connection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T03:00:20.000-02:00",
"@timestamp": "2025-03-08T03:00:20.000-02:00",
"cyberarkpas.audit.action": "Auto Clear Users History start",
"cyberarkpas.audit.desc": "Auto Clear Users History start",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T03:00:20.000-02:00",
"@timestamp": "2025-03-08T03:00:20.000-02:00",
"cyberarkpas.audit.action": "Auto Clear Users History end",
"cyberarkpas.audit.desc": "Auto Clear Users History end",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T02:48:07.000-02:00",
"@timestamp": "2025-03-08T02:48:07.000-02:00",
"cyberarkpas.audit.action": "Monitor DR Replication start",
"cyberarkpas.audit.desc": "Monitor DR Replication start",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T02:48:07.000-02:00",
"@timestamp": "2025-03-08T02:48:07.000-02:00",
"cyberarkpas.audit.action": "Monitor DR Replication end",
"cyberarkpas.audit.desc": "Monitor DR Replication end",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T02:32:56.000-02:00",
"@timestamp": "2025-03-08T02:32:56.000-02:00",
"cyberarkpas.audit.action": "Monitor FW rules start",
"cyberarkpas.audit.desc": "Monitor FW rules start",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
{
"@timestamp": "2024-03-08T02:32:56.000-02:00",
"@timestamp": "2025-03-08T02:32:56.000-02:00",
"cyberarkpas.audit.action": "Monitor FW Rules end",
"cyberarkpas.audit.desc": "Monitor FW Rules end",
"cyberarkpas.audit.issuer": "Batch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
]
},
{
"@timestamp": "2024-03-08T07:46:54.000-02:00",
"@timestamp": "2025-03-08T07:46:54.000-02:00",
"cyberarkpas.audit.action": "Security warning - The Signature Hash Algorithm of the Vault certificate is SHA1.",
"cyberarkpas.audit.desc": "Security warning - The Signature Hash Algorithm of the Vault certificate is SHA1.",
"cyberarkpas.audit.issuer": "Builtin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
]
},
{
"@timestamp": "2024-03-08T03:10:31.000-02:00",
"@timestamp": "2025-03-08T03:10:31.000-02:00",
"cyberarkpas.audit.action": "Clear Safe History",
"cyberarkpas.audit.desc": "Clear Safe History",
"cyberarkpas.audit.issuer": "PasswordManager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
]
},
{
"@timestamp": "2024-03-08T02:54:46.000-02:00",
"@timestamp": "2025-03-08T02:54:46.000-02:00",
"cyberarkpas.audit.action": "Set Password",
"cyberarkpas.audit.desc": "Set Password",
"cyberarkpas.audit.issuer": "PVWAGWUser",
Expand Down
Loading

0 comments on commit 4a09a9a

Please sign in to comment.