-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Elastic Agent] Golden files for program tests (#27862)
Currently it seems the expected config files for each program were manually generated. This makes adding a new test cumbersome and in case of small changes it means adjusting many files. This changes the test that it is possible to run with `go test . -generate` and new golden files are generated. Ideally it also means most of the additional tests become obsolete like how many program files should be generated. To make sure no left over files exist, on -generate all the generated files are first cleaned up.
- Loading branch information
Showing
25 changed files
with
1,741 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_output_true.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
inputs: | ||
- type: event/file | ||
streams: | ||
- paths: | ||
- /var/log/hello1.log | ||
- /var/log/hello2.log | ||
management: | ||
host: "localhost" | ||
config: | ||
reload: 123 | ||
outputs: | ||
default: | ||
type: elasticsearch | ||
enabled: true | ||
hosts: [127.0.0.1:9200, 127.0.0.1:9300] | ||
username: elastic | ||
password: changeme |
22 changes: 22 additions & 0 deletions
22
x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_true.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Production Website DB Servers | ||
fleet: | ||
kibana_url: https://kibana.mydomain.com:5601 | ||
ca_hash: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= | ||
checkin_interval: 5m | ||
inputs: | ||
- type: event/file | ||
streams: | ||
- enabled: true | ||
paths: | ||
- /var/log/hello1.log | ||
- /var/log/hello2.log | ||
management: | ||
host: "localhost" | ||
config: | ||
reload: 123 | ||
outputs: | ||
default: | ||
type: elasticsearch | ||
hosts: [127.0.0.1:9200, 127.0.0.1:9300] | ||
username: elastic | ||
password: changeme |
115 changes: 115 additions & 0 deletions
115
x-pack/elastic-agent/pkg/agent/program/testdata/usecases/endpoint_basic.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
revision: 5 | ||
name: Endpoint Host | ||
fleet: | ||
access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw | ||
protocol: https | ||
hosts: [ localhost:5601 ] | ||
timeout: 30s | ||
agent: | ||
id: fleet-agent-id | ||
logging.level: error | ||
host: | ||
id: host-agent-id | ||
|
||
outputs: | ||
default: | ||
type: elasticsearch | ||
hosts: [127.0.0.1:9200, 127.0.0.1:9300] | ||
username: elastic | ||
password: changeme | ||
api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA | ||
ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= | ||
|
||
inputs: | ||
- id: endpoint-id | ||
type: endpoint | ||
name: endpoint-1 | ||
enabled: true | ||
package: | ||
name: endpoint | ||
version: 0.3.0 | ||
data_stream: | ||
namespace: default | ||
artifact_manifest: | ||
schema_version: v22 | ||
manifest_version: v21 | ||
artifacts: | ||
- endpoint-allowlist-windows: | ||
sha256: 1234 | ||
size: 2 | ||
url: /relative/path/to/endpoint-allowlist-windows | ||
- endpoint-allowlist-macos: | ||
sha256: 1234 | ||
size: 2 | ||
url: /relative/path/to/endpoint-allowlist-macos | ||
- endpoint-allowlist-linux: | ||
sha256: 1234 | ||
size: 2 | ||
url: /relative/path/to/endpoint-allowlist-linux | ||
policy: | ||
linux: | ||
advanced: | ||
free-form: free-form-value | ||
indices: | ||
network: logs-endpoint.events.network-default | ||
file: logs-endpoint.events.file-default | ||
process: logs-endpoint.events.process-default | ||
metadata: metrics-endpoint.metadata-default | ||
policy: metrics-endpoint.policy-default | ||
telemetry: metrics-endpoint.telemetry-default | ||
logging: | ||
file: info | ||
stdout: debug | ||
events: | ||
process: true | ||
file: true | ||
network: true | ||
windows: | ||
malware: | ||
mode: prevent | ||
advanced: | ||
free-form: free-form-value | ||
indices: | ||
network: logs-endpoint.events.network-default | ||
file: logs-endpoint.events.file-default | ||
registry: logs-endpoint.events.registry-default | ||
process: logs-endpoint.events.process-default | ||
driver: logs-endpoint.events.driver-default | ||
library: logs-endpoint.events.library-default | ||
alerts: logs-endpoint.alerts-default | ||
metadata: metrics-endpoint.metadata-default | ||
policy: metrics-endpoint.policy-default | ||
telemetry: metrics-endpoint.telemetry-default | ||
logging: | ||
file: info | ||
stdout: debug | ||
events: | ||
registry: true | ||
process: true | ||
security: true | ||
file: true | ||
dns: false | ||
dll_and_driver_load: false | ||
network: true | ||
mac: | ||
malware: | ||
mode: prevent | ||
advanced: | ||
free-form: free-form-value | ||
indices: | ||
network: logs-endpoint.events.network-default | ||
file: logs-endpoint.events.file-default | ||
process: logs-endpoint.events.process-default | ||
alerts: logs-endpoint.alerts-default | ||
metadata: metrics-endpoint.metadata-default | ||
policy: metrics-endpoint.policy-default | ||
telemetry: metrics-endpoint.telemetry-default | ||
logging: | ||
file: info | ||
stdout: debug | ||
events: | ||
process: true | ||
file: true | ||
network: true | ||
runtime: | ||
arch: x86_64 |
51 changes: 51 additions & 0 deletions
51
x-pack/elastic-agent/pkg/agent/program/testdata/usecases/fleet_server.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Fleet Server Only | ||
fleet: | ||
enabled: true | ||
access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw | ||
protocol: https | ||
hosts: [ localhost:5601 ] | ||
timeout: 30s | ||
agent: | ||
id: fleet-agent-id | ||
logging.level: error | ||
host: | ||
id: host-agent-id | ||
server: | ||
host: 127.0.0.1 | ||
port: 8822 | ||
ssl: | ||
verification_mode: none | ||
policy: | ||
id: copy-policy-id | ||
output: | ||
elasticsearch: | ||
hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] | ||
username: fleet | ||
password: fleetpassword | ||
|
||
outputs: | ||
default: | ||
type: elasticsearch | ||
hosts: [127.0.0.1:9200, 127.0.0.1:9300] | ||
username: elastic | ||
password: changeme | ||
api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA | ||
ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= | ||
|
||
inputs: | ||
- id: fleet-server-id | ||
type: fleet-server | ||
use_output: default | ||
data_stream: | ||
namespace: default | ||
name: fleet_server-1 | ||
revision: 6 | ||
server: | ||
host: 0.0.0.0 | ||
port: 8220 | ||
limits: | ||
max_connections: 40 | ||
runtime: | ||
gc_percent: 50 | ||
timeouts: | ||
read: 5m |
38 changes: 38 additions & 0 deletions
38
...ent/pkg/agent/program/testdata/usecases/generated/enabled_output_true.filebeat.golden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
filebeat: | ||
inputs: | ||
- index: logs-generic-default | ||
paths: | ||
- /var/log/hello1.log | ||
- /var/log/hello2.log | ||
processors: | ||
- add_fields: | ||
fields: | ||
dataset: generic | ||
namespace: default | ||
type: logs | ||
target: data_stream | ||
- add_fields: | ||
fields: | ||
dataset: generic | ||
target: event | ||
- add_fields: | ||
fields: | ||
id: agent-id | ||
snapshot: false | ||
version: 8.0.0 | ||
target: elastic_agent | ||
- add_fields: | ||
fields: | ||
id: agent-id | ||
target: agent | ||
type: log | ||
output: | ||
elasticsearch: | ||
enabled: true | ||
headers: | ||
h1: test-header | ||
hosts: | ||
- 127.0.0.1:9200 | ||
- 127.0.0.1:9300 | ||
password: changeme | ||
username: elastic |
38 changes: 38 additions & 0 deletions
38
...stic-agent/pkg/agent/program/testdata/usecases/generated/enabled_true.filebeat.golden.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
filebeat: | ||
inputs: | ||
- enabled: true | ||
index: logs-generic-default | ||
paths: | ||
- /var/log/hello1.log | ||
- /var/log/hello2.log | ||
processors: | ||
- add_fields: | ||
fields: | ||
dataset: generic | ||
namespace: default | ||
type: logs | ||
target: data_stream | ||
- add_fields: | ||
fields: | ||
dataset: generic | ||
target: event | ||
- add_fields: | ||
fields: | ||
id: agent-id | ||
snapshot: false | ||
version: 8.0.0 | ||
target: elastic_agent | ||
- add_fields: | ||
fields: | ||
id: agent-id | ||
target: agent | ||
type: log | ||
output: | ||
elasticsearch: | ||
headers: | ||
h1: test-header | ||
hosts: | ||
- 127.0.0.1:9200 | ||
- 127.0.0.1:9300 | ||
password: changeme | ||
username: elastic |
Oops, something went wrong.