From 95693824fb0e359fa8e334ca290c807a41a05bf6 Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 10 Sep 2021 15:22:00 +0200 Subject: [PATCH 1/9] [Elastic Agent] Golden files for program tests 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. --- .../pkg/agent/program/program_test.go | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 5ca35de01362..7031c10d00c8 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -5,6 +5,8 @@ package program import ( + "flag" + "fmt" "io/ioutil" "os" "path/filepath" @@ -21,6 +23,10 @@ import ( "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" ) +var ( + generateFlag = flag.Bool("generate", false, "Write golden files") +) + func TestGroupBy(t *testing.T) { t.Run("only named output", func(t *testing.T) { sConfig := map[string]interface{}{ @@ -465,20 +471,35 @@ func TestConfiguration(t *testing.T) { require.True(t, ok) require.Equal(t, test.expected, len(defPrograms)) + if *generateFlag { + + } + + // TODO: If generate, remove all generated files first for _, program := range defPrograms { - programConfig, err := ioutil.ReadFile(filepath.Join( + generatedPath := filepath.Join( "testdata", - name+"-"+strings.ToLower(program.Spec.Cmd)+".yml", - )) + name+"-"+strings.ToLower(program.Spec.Cmd)+".generated.yml", + ) + + compareMap := &transpiler.MapVisitor{} + program.Config.Accept(compareMap) + + if *generateFlag { + d, _ := yaml.Marshal(&compareMap.Content) + fmt.Println(string(d)) + ioutil.WriteFile(generatedPath, d, 0644) + // TODO: Close writing file / flush + } + + programConfig, err := ioutil.ReadFile(generatedPath) require.NoError(t, err) var m map[string]interface{} err = yamltest.FromYAML(programConfig, &m) require.NoError(t, errors.Wrap(err, program.Cmd())) - compareMap := &transpiler.MapVisitor{} - program.Config.Accept(compareMap) - + fmt.Println(compareMap.Content) if !assert.True(t, cmp.Equal(m, compareMap.Content)) { diff := cmp.Diff(m, compareMap.Content) if diff != "" { @@ -487,10 +508,11 @@ func TestConfiguration(t *testing.T) { } } }) + } } -type fakeAgentInfo struct{} +type fakeAgentInfo struct {} func (*fakeAgentInfo) AgentID() string { return "agent-id" From 1f44a45efd2c597cc5a8813ff878620f85da19e3 Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 10 Sep 2021 15:59:11 +0200 Subject: [PATCH 2/9] add more changes, delete old files, enable cleanup --- .../pkg/agent/program/program_test.go | 24 ++-- .../testdata/enabled_output_true-filebeat.yml | 38 ------ .../testdata/enabled_true-filebeat.yml | 38 ------ .../endpoint_basic-endpoint-security.yml | 113 ----------------- .../testdata/fleet_server-fleet-server.yml | 33 ----- .../testdata/namespace-endpoint-security.yml | 114 ----------------- .../program/testdata/namespace-filebeat.yml | 71 ----------- .../testdata/namespace-fleet-server.yml | 18 --- .../program/testdata/namespace-heartbeat.yml | 30 ----- .../program/testdata/namespace-metricbeat.yml | 91 -------------- .../program/testdata/namespace-packetbeat.yml | 35 ------ .../single_config-endpoint-security.yml | 115 ------------------ .../testdata/single_config-filebeat.yml | 71 ----------- .../testdata/single_config-fleet-server.yml | 18 --- .../testdata/single_config-heartbeat.yml | 31 ----- .../testdata/single_config-metricbeat.yml | 91 -------------- .../testdata/single_config-packetbeat.yml | 36 ------ .../testdata/synthetics_config-heartbeat.yml | 66 ---------- 18 files changed, 15 insertions(+), 1018 deletions(-) delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 7031c10d00c8..969b4fb6c851 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -442,6 +442,16 @@ func TestConfiguration(t *testing.T) { }, } + // Cleanup all generated files to make sure not having any left overs + if *generateFlag { + generatedFiles, err := filepath.Glob(filepath.Join("testdata", "*.generated.yml")) + require.NoError(t, err) + + for _, file := range generatedFiles { + fmt.Println(file) + } + } + for name, test := range testcases { t.Run(name, func(t *testing.T) { singleConfig, err := ioutil.ReadFile(filepath.Join("testdata", name+".yml")) @@ -471,10 +481,6 @@ func TestConfiguration(t *testing.T) { require.True(t, ok) require.Equal(t, test.expected, len(defPrograms)) - if *generateFlag { - - } - // TODO: If generate, remove all generated files first for _, program := range defPrograms { generatedPath := filepath.Join( @@ -485,21 +491,21 @@ func TestConfiguration(t *testing.T) { compareMap := &transpiler.MapVisitor{} program.Config.Accept(compareMap) + // Generate new file file for programm if *generateFlag { d, _ := yaml.Marshal(&compareMap.Content) fmt.Println(string(d)) - ioutil.WriteFile(generatedPath, d, 0644) - // TODO: Close writing file / flush + err := ioutil.WriteFile(generatedPath, d, 0644) + require.NoError(t, err) } programConfig, err := ioutil.ReadFile(generatedPath) - require.NoError(t, err) + var m map[string]interface{} err = yamltest.FromYAML(programConfig, &m) require.NoError(t, errors.Wrap(err, program.Cmd())) - fmt.Println(compareMap.Content) if !assert.True(t, cmp.Equal(m, compareMap.Content)) { diff := cmp.Diff(m, compareMap.Content) if diff != "" { @@ -512,7 +518,7 @@ func TestConfiguration(t *testing.T) { } } -type fakeAgentInfo struct {} +type fakeAgentInfo struct{} func (*fakeAgentInfo) AgentID() string { return "agent-id" diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml deleted file mode 100644 index d9b4dc079f50..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml +++ /dev/null @@ -1,38 +0,0 @@ -filebeat: - inputs: - - type: log - paths: - - /var/log/hello1.log - - /var/log/hello2.log - index: logs-generic-default - processors: - - add_fields: - target: "data_stream" - fields: - type: logs - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - enabled: true - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - headers: - h1: test-header - username: elastic - password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml deleted file mode 100644 index f579dcba416c..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml +++ /dev/null @@ -1,38 +0,0 @@ -filebeat: - inputs: - - type: log - enabled: true - paths: - - /var/log/hello1.log - - /var/log/hello2.log - index: logs-generic-default - processors: - - add_fields: - target: "data_stream" - fields: - type: logs - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - headers: - h1: test-header - username: elastic - password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml deleted file mode 100644 index dfbec8016ba0..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml +++ /dev/null @@ -1,113 +0,0 @@ -revision: 5 -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 - -output: - 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml deleted file mode 100644 index 7a0fad5c9df6..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml +++ /dev/null @@ -1,33 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id - -output: - elasticsearch: - hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] - headers: - h1: test-header - username: fleet - password: fleetpassword - -inputs: - - id: fleet-server-id - type: fleet-server - name: fleet_server-1 - revision: 6 - server: - host: 0.0.0.0 - port: 8220 - ssl: - verification_mode: none - limits: - max_connections: 40 - runtime: - gc_percent: 50 - timeouts: - read: 5m - policy: - id: copy-policy-id diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml deleted file mode 100644 index 7e9f04dc4119..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml +++ /dev/null @@ -1,114 +0,0 @@ -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 - -output: - elasticsearch: - hosts: - - "127.0.0.1:9200" - - "127.0.0.1:9300" - namespace: test_namespace - 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml deleted file mode 100644 index eafedb688c99..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml +++ /dev/null @@ -1,71 +0,0 @@ -filebeat: - inputs: - - type: log - paths: - - /var/log/hello1.log - - /var/log/hello2.log - index: logs-generic-default - vars: - var: value - processors: - - add_fields: - target: "data_stream" - fields: - type: logs - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - type: log - paths: - - /var/log/hello3.log - - /var/log/hello4.log - index: testtype-generic-default - vars: - var: value - processors: - - add_fields: - target: "data_stream" - fields: - type: testtype - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - headers: - h1: test-header - - namespace: test_namespace - username: elastic - password: changeme - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml deleted file mode 100644 index b306cf402773..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml +++ /dev/null @@ -1,18 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id - -output: - elasticsearch: - hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] - headers: - h1: test-header - username: fleet - password: fleetpassword - -inputs: - - id: fleet-server-id - type: fleet-server diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml deleted file mode 100644 index f34b204f5fae..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml +++ /dev/null @@ -1,30 +0,0 @@ -inputs: -- type: synthetics/http - id: unique-http-id - name: my-http - schedule: '*/5 * * * * * *' - host: "http://localhost:80/service/status" - timeout: 16s - wait: 1s - data_stream.namespace: default - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - username: elastic - password: changeme - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml deleted file mode 100644 index d0d4c24f0586..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml +++ /dev/null @@ -1,91 +0,0 @@ -metricbeat: - modules: - - module: docker - metricsets: [status] - index: metrics-docker.status-default - hosts: ["http://127.0.0.1:8080"] - processors: - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: docker.status - namespace: default - - add_fields: - target: "event" - fields: - dataset: docker.status - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - module: docker - metricsets: [info] - index: metrics-generic-default - hosts: ["http://127.0.0.1:8080"] - processors: - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - module: apache - metricsets: [info] - index: metrics-generic-testing - hosts: ["http://apache.remote"] - processors: - - add_fields: - fields: - should_be: first - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: generic - namespace: testing - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - hosts: [127.0.0.1:9200, 127.0.0.1:9300] - headers: - h1: test-header - - namespace: test_namespace - username: elastic - password: changeme - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml deleted file mode 100644 index d71499bdef4d..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml +++ /dev/null @@ -1,35 +0,0 @@ -inputs: -- type: packet - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id - streams: - - type: flow - timeout: 10s - period: 10s - keep_null: false - data_stream: - dataset: packet.flow - type: logs - - type: icmp - data_stream: - dataset: packet.icmp - type: logs -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - username: elastic - password: changeme - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml deleted file mode 100644 index f7bcdb284c4d..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml +++ /dev/null @@ -1,115 +0,0 @@ -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 - -output: - elasticsearch: - hosts: - - "127.0.0.1:9200" - - "127.0.0.1:9300" - bulk_max_size: 23 - worker: 10 - 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml deleted file mode 100644 index e628cd2c098e..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml +++ /dev/null @@ -1,71 +0,0 @@ -filebeat: - inputs: - - type: log - paths: - - /var/log/hello1.log - - /var/log/hello2.log - index: logs-generic-default - vars: - var: value - processors: - - add_fields: - target: "data_stream" - fields: - type: logs - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - type: log - paths: - - /var/log/hello3.log - - /var/log/hello4.log - index: testtype-generic-default - vars: - var: value - processors: - - add_fields: - target: "data_stream" - fields: - type: testtype - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - headers: - h1: test-header - username: elastic - password: changeme - bulk_max_size: 23 - worker: 10 - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml deleted file mode 100644 index b306cf402773..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml +++ /dev/null @@ -1,18 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id - -output: - elasticsearch: - hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] - headers: - h1: test-header - username: fleet - password: fleetpassword - -inputs: - - id: fleet-server-id - type: fleet-server diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml deleted file mode 100644 index 800f4100382c..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml +++ /dev/null @@ -1,31 +0,0 @@ -inputs: -- type: synthetics/http - id: unique-http-id - name: my-http - schedule: '*/5 * * * * * *' - host: "http://localhost:80/service/status" - timeout: 16s - wait: 1s - data_stream.namespace: default - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - bulk_max_size: 23 - worker: 10 - username: elastic - password: changeme - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml deleted file mode 100644 index a2c36b151f00..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml +++ /dev/null @@ -1,91 +0,0 @@ -metricbeat: - modules: - - module: docker - metricsets: [status] - index: metrics-docker.status-default - hosts: ["http://127.0.0.1:8080"] - processors: - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: docker.status - namespace: default - - add_fields: - target: "event" - fields: - dataset: docker.status - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - module: docker - metricsets: [info] - index: metrics-generic-default - hosts: ["http://127.0.0.1:8080"] - processors: - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: generic - namespace: default - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id - - module: apache - metricsets: [info] - index: metrics-generic-testing - hosts: ["http://apache.remote"] - processors: - - add_fields: - fields: - should_be: first - - add_fields: - target: "data_stream" - fields: - type: metrics - dataset: generic - namespace: testing - - add_fields: - target: "event" - fields: - dataset: generic - - add_fields: - target: "elastic_agent" - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: "agent" - fields: - id: agent-id -output: - elasticsearch: - hosts: [127.0.0.1:9200, 127.0.0.1:9300] - headers: - h1: test-header - username: elastic - password: changeme - bulk_max_size: 23 - worker: 10 - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml deleted file mode 100644 index f800d0bd2a09..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml +++ /dev/null @@ -1,36 +0,0 @@ -inputs: -- type: packet - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id - streams: - - type: flow - timeout: 10s - period: 10s - keep_null: false - data_stream: - dataset: packet.flow - type: logs - - type: icmp - data_stream: - dataset: packet.icmp - type: logs -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - username: elastic - password: changeme - bulk_max_size: 23 - worker: 10 - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml deleted file mode 100644 index 284d391f78b8..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml +++ /dev/null @@ -1,66 +0,0 @@ -inputs: -- type: synthetics/http - id: unique-http-id - name: my-http - schedule: '*/5 * * * * * *' - host: "http://localhost:80/service/status" - timeout: 16s - wait: 1s - data_stream.namespace: default - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id -- type: synthetics/tcp - id: unique-tcp-id - name: my-tcp - schedule: '*/5 * * * * * *' - host: "localhost:777" - timeout: 16s - wait: 1s - data_stream.namespace: default - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id -- type: synthetics/icmp - id: unique-icmp-id - name: my-icmp - schedule: '@every 5s' - host: "localhost" - ipv4: true - ipv6: true - mode: any - timeout: 16s - wait: 1s - data_stream.namespace: default - processors: - - add_fields: - target: 'elastic_agent' - fields: - id: agent-id - version: 8.0.0 - snapshot: false - - add_fields: - target: 'agent' - fields: - id: agent-id -output: - elasticsearch: - hosts: [127.0.0.1:9200, 127.0.0.1:9300] - username: elastic - password: changeme From 134d7852f3f44b1c448c6ae55a57ee324931ae77 Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 10 Sep 2021 16:11:28 +0200 Subject: [PATCH 3/9] add generated files --- ...enabled_output_true-filebeat.generated.yml | 38 ++++++ .../enabled_true-filebeat.generated.yml | 38 ++++++ ...oint_basic-endpoint-security.generated.yml | 112 +++++++++++++++++ .../fleet_server-fleet-server.generated.yml | 33 +++++ .../namespace-endpoint-security.generated.yml | 113 +++++++++++++++++ .../testdata/namespace-filebeat.generated.yml | 70 +++++++++++ .../namespace-fleet-server.generated.yml | 18 +++ .../namespace-heartbeat.generated.yml | 30 +++++ .../namespace-metricbeat.generated.yml | 98 +++++++++++++++ .../namespace-packetbeat.generated.yml | 35 ++++++ ...gle_config-endpoint-security.generated.yml | 114 ++++++++++++++++++ .../single_config-filebeat.generated.yml | 71 +++++++++++ .../single_config-fleet-server.generated.yml | 18 +++ .../single_config-heartbeat.generated.yml | 31 +++++ .../single_config-metricbeat.generated.yml | 99 +++++++++++++++ .../single_config-packetbeat.generated.yml | 36 ++++++ .../synthetics_config-heartbeat.generated.yml | 68 +++++++++++ 17 files changed, 1022 insertions(+) create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml new file mode 100644 index 000000000000..6b898a6128a3 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml new file mode 100644 index 000000000000..197bf2f62321 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml new file mode 100644 index 000000000000..6359f9185b8d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml @@ -0,0 +1,112 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic +revision: 5 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml new file mode 100644 index 000000000000..01dc3bd3c89c --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml @@ -0,0 +1,33 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + name: fleet_server-1 + policy: + id: copy-policy-id + revision: 6 + server: + host: 0.0.0.0 + limits: + max_connections: 40 + port: 8220 + runtime: + gc_percent: 50 + ssl: + verification_mode: none + timeouts: + read: 5m + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml new file mode 100644 index 000000000000..7c8b033c4e62 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml @@ -0,0 +1,113 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + enabled: true + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml new file mode 100644 index 000000000000..2def5f274dea --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml @@ -0,0 +1,70 @@ +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 + vars: + var: value + - index: testtype-generic-default + paths: + - /var/log/hello3.log + - /var/log/hello4.log + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: testtype + 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 + vars: + var: value +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml new file mode 100644 index 000000000000..ab7499a4f112 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml new file mode 100644 index 000000000000..c18573ee7803 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml @@ -0,0 +1,30 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml new file mode 100644 index 000000000000..3232297227a0 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml @@ -0,0 +1,98 @@ +metricbeat: + modules: + - hosts: + - http://127.0.0.1:8080 + index: metrics-docker.status-default + metricsets: + - status + module: docker + processors: + - add_fields: + fields: + dataset: docker.status + namespace: default + type: metrics + target: data_stream + - add_fields: + fields: + dataset: docker.status + 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 + - hosts: + - http://127.0.0.1:8080 + index: metrics-generic-default + metricsets: + - info + module: docker + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: metrics + 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 + - hosts: + - http://apache.remote + index: metrics-generic-testing + metricsets: + - info + module: apache + processors: + - add_fields: + fields: + should_be: first + - add_fields: + fields: + dataset: generic + namespace: testing + type: metrics + 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 +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml new file mode 100644 index 000000000000..cc38887ff8e2 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml @@ -0,0 +1,35 @@ +inputs: +- processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + streams: + - data_stream: + dataset: packet.flow + type: logs + keep_null: false + period: 10s + timeout: 10s + type: flow + - data_stream: + dataset: packet.icmp + type: logs + type: icmp + type: packet +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml new file mode 100644 index 000000000000..552e169bbac2 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml @@ -0,0 +1,114 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + enabled: true + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml new file mode 100644 index 000000000000..da16ff8200d9 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml @@ -0,0 +1,71 @@ +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 + vars: + var: value + - index: testtype-generic-default + paths: + - /var/log/hello3.log + - /var/log/hello4.log + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: testtype + 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 + vars: + var: value +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml new file mode 100644 index 000000000000..ab7499a4f112 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml new file mode 100644 index 000000000000..f4c5827603a8 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml @@ -0,0 +1,31 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml new file mode 100644 index 000000000000..aca140556350 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml @@ -0,0 +1,99 @@ +metricbeat: + modules: + - hosts: + - http://127.0.0.1:8080 + index: metrics-docker.status-default + metricsets: + - status + module: docker + processors: + - add_fields: + fields: + dataset: docker.status + namespace: default + type: metrics + target: data_stream + - add_fields: + fields: + dataset: docker.status + 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 + - hosts: + - http://127.0.0.1:8080 + index: metrics-generic-default + metricsets: + - info + module: docker + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: metrics + 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 + - hosts: + - http://apache.remote + index: metrics-generic-testing + metricsets: + - info + module: apache + processors: + - add_fields: + fields: + should_be: first + - add_fields: + fields: + dataset: generic + namespace: testing + type: metrics + 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 +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml new file mode 100644 index 000000000000..e7f13deb0a20 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml @@ -0,0 +1,36 @@ +inputs: +- processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + streams: + - data_stream: + dataset: packet.flow + type: logs + keep_null: false + period: 10s + timeout: 10s + type: flow + - data_stream: + dataset: packet.icmp + type: logs + type: icmp + type: packet +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml new file mode 100644 index 000000000000..870a0070f4eb --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml @@ -0,0 +1,68 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +- data_stream.namespace: default + host: localhost:777 + id: unique-tcp-id + name: my-tcp + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/tcp + wait: 1s +- data_stream.namespace: default + host: localhost + id: unique-icmp-id + ipv4: true + ipv6: true + mode: any + name: my-icmp + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '@every 5s' + timeout: 16s + type: synthetics/icmp + wait: 1s +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic From 0d07e58fa159574db8a4ae2d9d77406907ad667a Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 10 Sep 2021 16:19:46 +0200 Subject: [PATCH 4/9] move generated files --- .../pkg/agent/program/program_test.go | 13 +- ...enabled_output_true-filebeat.generated.yml | 38 ------ .../enabled_true-filebeat.generated.yml | 38 ------ ...oint_basic-endpoint-security.generated.yml | 112 ----------------- .../fleet_server-fleet-server.generated.yml | 33 ----- .../namespace-endpoint-security.generated.yml | 113 ----------------- .../testdata/namespace-filebeat.generated.yml | 70 ----------- .../namespace-fleet-server.generated.yml | 18 --- .../namespace-heartbeat.generated.yml | 30 ----- .../namespace-metricbeat.generated.yml | 98 --------------- .../namespace-packetbeat.generated.yml | 35 ------ ...gle_config-endpoint-security.generated.yml | 114 ------------------ .../single_config-filebeat.generated.yml | 71 ----------- .../single_config-fleet-server.generated.yml | 18 --- .../single_config-heartbeat.generated.yml | 31 ----- .../single_config-metricbeat.generated.yml | 99 --------------- .../single_config-packetbeat.generated.yml | 36 ------ .../synthetics_config-heartbeat.generated.yml | 68 ----------- 18 files changed, 7 insertions(+), 1028 deletions(-) delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml delete mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 969b4fb6c851..31b9160ba449 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -442,14 +442,13 @@ func TestConfiguration(t *testing.T) { }, } + generatedFilesDir := filepath.Join("testdata", "generated") + // Cleanup all generated files to make sure not having any left overs if *generateFlag { - generatedFiles, err := filepath.Glob(filepath.Join("testdata", "*.generated.yml")) - require.NoError(t, err) - for _, file := range generatedFiles { - fmt.Println(file) - } + err := os.RemoveAll(generatedFilesDir) + require.NoError(t, err) } for name, test := range testcases { @@ -484,7 +483,7 @@ func TestConfiguration(t *testing.T) { // TODO: If generate, remove all generated files first for _, program := range defPrograms { generatedPath := filepath.Join( - "testdata", + "testdata", "generated", name+"-"+strings.ToLower(program.Spec.Cmd)+".generated.yml", ) @@ -495,6 +494,8 @@ func TestConfiguration(t *testing.T) { if *generateFlag { d, _ := yaml.Marshal(&compareMap.Content) fmt.Println(string(d)) + + os.MkdirAll(generatedFilesDir, 0755) err := ioutil.WriteFile(generatedPath, d, 0644) require.NoError(t, err) } diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml deleted file mode 100644 index 6b898a6128a3..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.generated.yml +++ /dev/null @@ -1,38 +0,0 @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml deleted file mode 100644 index 197bf2f62321..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.generated.yml +++ /dev/null @@ -1,38 +0,0 @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml deleted file mode 100644 index 6359f9185b8d..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.generated.yml +++ /dev/null @@ -1,112 +0,0 @@ -fleet: - access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id - hosts: - - localhost:5601 - protocol: https - timeout: 30s -inputs: -- artifact_manifest: - 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 - manifest_version: v21 - schema_version: v22 - data_stream: - namespace: default - enabled: true - id: endpoint-id - name: endpoint-1 - package: - name: endpoint - version: 0.3.0 - policy: - linux: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - mac: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - alerts: logs-endpoint.alerts-default - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - windows: - advanced: - free-form: free-form-value - events: - dll_and_driver_load: false - dns: false - file: true - network: true - process: true - registry: true - security: true - indices: - alerts: logs-endpoint.alerts-default - driver: logs-endpoint.events.driver-default - file: logs-endpoint.events.file-default - library: logs-endpoint.events.library-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - registry: logs-endpoint.events.registry-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - type: endpoint -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic -revision: 5 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml deleted file mode 100644 index 01dc3bd3c89c..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.generated.yml +++ /dev/null @@ -1,33 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id -inputs: -- id: fleet-server-id - name: fleet_server-1 - policy: - id: copy-policy-id - revision: 6 - server: - host: 0.0.0.0 - limits: - max_connections: 40 - port: 8220 - runtime: - gc_percent: 50 - ssl: - verification_mode: none - timeouts: - read: 5m - type: fleet-server -output: - elasticsearch: - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: fleetpassword - username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml deleted file mode 100644 index 7c8b033c4e62..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.generated.yml +++ /dev/null @@ -1,113 +0,0 @@ -fleet: - access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw - agent: - id: fleet-agent-id - logging.level: error - enabled: true - host: - id: host-agent-id - hosts: - - localhost:5601 - protocol: https - timeout: 30s -inputs: -- artifact_manifest: - 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 - manifest_version: v21 - schema_version: v22 - data_stream: - namespace: default - enabled: true - id: endpoint-id - name: endpoint-1 - package: - name: endpoint - version: 0.3.0 - policy: - linux: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - mac: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - alerts: logs-endpoint.alerts-default - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - windows: - advanced: - free-form: free-form-value - events: - dll_and_driver_load: false - dns: false - file: true - network: true - process: true - registry: true - security: true - indices: - alerts: logs-endpoint.alerts-default - driver: logs-endpoint.events.driver-default - file: logs-endpoint.events.file-default - library: logs-endpoint.events.library-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - registry: logs-endpoint.events.registry-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - type: endpoint -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - password: changeme - username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml deleted file mode 100644 index 2def5f274dea..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.generated.yml +++ /dev/null @@ -1,70 +0,0 @@ -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 - vars: - var: value - - index: testtype-generic-default - paths: - - /var/log/hello3.log - - /var/log/hello4.log - processors: - - add_fields: - fields: - dataset: generic - namespace: default - type: testtype - 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 - vars: - var: value -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - password: changeme - username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml deleted file mode 100644 index ab7499a4f112..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.generated.yml +++ /dev/null @@ -1,18 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id -inputs: -- id: fleet-server-id - type: fleet-server -output: - elasticsearch: - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: fleetpassword - username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml deleted file mode 100644 index c18573ee7803..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.generated.yml +++ /dev/null @@ -1,30 +0,0 @@ -inputs: -- data_stream.namespace: default - host: http://localhost:80/service/status - id: unique-http-id - name: my-http - processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - schedule: '*/5 * * * * * *' - timeout: 16s - type: synthetics/http - wait: 1s -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - password: changeme - username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml deleted file mode 100644 index 3232297227a0..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.generated.yml +++ /dev/null @@ -1,98 +0,0 @@ -metricbeat: - modules: - - hosts: - - http://127.0.0.1:8080 - index: metrics-docker.status-default - metricsets: - - status - module: docker - processors: - - add_fields: - fields: - dataset: docker.status - namespace: default - type: metrics - target: data_stream - - add_fields: - fields: - dataset: docker.status - 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 - - hosts: - - http://127.0.0.1:8080 - index: metrics-generic-default - metricsets: - - info - module: docker - processors: - - add_fields: - fields: - dataset: generic - namespace: default - type: metrics - 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 - - hosts: - - http://apache.remote - index: metrics-generic-testing - metricsets: - - info - module: apache - processors: - - add_fields: - fields: - should_be: first - - add_fields: - fields: - dataset: generic - namespace: testing - type: metrics - 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 -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - password: changeme - username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml deleted file mode 100644 index cc38887ff8e2..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.generated.yml +++ /dev/null @@ -1,35 +0,0 @@ -inputs: -- processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - streams: - - data_stream: - dataset: packet.flow - type: logs - keep_null: false - period: 10s - timeout: 10s - type: flow - - data_stream: - dataset: packet.icmp - type: logs - type: icmp - type: packet -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - namespace: test_namespace - password: changeme - username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml deleted file mode 100644 index 552e169bbac2..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.generated.yml +++ /dev/null @@ -1,114 +0,0 @@ -fleet: - access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw - agent: - id: fleet-agent-id - logging.level: error - enabled: true - host: - id: host-agent-id - hosts: - - localhost:5601 - protocol: https - timeout: 30s -inputs: -- artifact_manifest: - 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 - manifest_version: v21 - schema_version: v22 - data_stream: - namespace: default - enabled: true - id: endpoint-id - name: endpoint-1 - package: - name: endpoint - version: 0.3.0 - policy: - linux: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - mac: - advanced: - free-form: free-form-value - events: - file: true - network: true - process: true - indices: - alerts: logs-endpoint.alerts-default - file: logs-endpoint.events.file-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - windows: - advanced: - free-form: free-form-value - events: - dll_and_driver_load: false - dns: false - file: true - network: true - process: true - registry: true - security: true - indices: - alerts: logs-endpoint.alerts-default - driver: logs-endpoint.events.driver-default - file: logs-endpoint.events.file-default - library: logs-endpoint.events.library-default - metadata: metrics-endpoint.metadata-default - network: logs-endpoint.events.network-default - policy: metrics-endpoint.policy-default - process: logs-endpoint.events.process-default - registry: logs-endpoint.events.registry-default - telemetry: metrics-endpoint.telemetry-default - logging: - file: info - stdout: debug - malware: - mode: prevent - type: endpoint -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - bulk_max_size: 23 - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic - worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml deleted file mode 100644 index da16ff8200d9..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.generated.yml +++ /dev/null @@ -1,71 +0,0 @@ -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 - vars: - var: value - - index: testtype-generic-default - paths: - - /var/log/hello3.log - - /var/log/hello4.log - processors: - - add_fields: - fields: - dataset: generic - namespace: default - type: testtype - 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 - vars: - var: value -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - bulk_max_size: 23 - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic - worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml deleted file mode 100644 index ab7499a4f112..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.generated.yml +++ /dev/null @@ -1,18 +0,0 @@ -fleet: - agent: - id: fleet-agent-id - logging.level: error - host: - id: host-agent-id -inputs: -- id: fleet-server-id - type: fleet-server -output: - elasticsearch: - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: fleetpassword - username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml deleted file mode 100644 index f4c5827603a8..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.generated.yml +++ /dev/null @@ -1,31 +0,0 @@ -inputs: -- data_stream.namespace: default - host: http://localhost:80/service/status - id: unique-http-id - name: my-http - processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - schedule: '*/5 * * * * * *' - timeout: 16s - type: synthetics/http - wait: 1s -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - bulk_max_size: 23 - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic - worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml deleted file mode 100644 index aca140556350..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.generated.yml +++ /dev/null @@ -1,99 +0,0 @@ -metricbeat: - modules: - - hosts: - - http://127.0.0.1:8080 - index: metrics-docker.status-default - metricsets: - - status - module: docker - processors: - - add_fields: - fields: - dataset: docker.status - namespace: default - type: metrics - target: data_stream - - add_fields: - fields: - dataset: docker.status - 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 - - hosts: - - http://127.0.0.1:8080 - index: metrics-generic-default - metricsets: - - info - module: docker - processors: - - add_fields: - fields: - dataset: generic - namespace: default - type: metrics - 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 - - hosts: - - http://apache.remote - index: metrics-generic-testing - metricsets: - - info - module: apache - processors: - - add_fields: - fields: - should_be: first - - add_fields: - fields: - dataset: generic - namespace: testing - type: metrics - 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 -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - bulk_max_size: 23 - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - headers: - h1: test-header - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic - worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml deleted file mode 100644 index e7f13deb0a20..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.generated.yml +++ /dev/null @@ -1,36 +0,0 @@ -inputs: -- processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - streams: - - data_stream: - dataset: packet.flow - type: logs - keep_null: false - period: 10s - timeout: 10s - type: flow - - data_stream: - dataset: packet.icmp - type: logs - type: icmp - type: packet -output: - elasticsearch: - api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA - bulk_max_size: 23 - ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic - worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml deleted file mode 100644 index 870a0070f4eb..000000000000 --- a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.generated.yml +++ /dev/null @@ -1,68 +0,0 @@ -inputs: -- data_stream.namespace: default - host: http://localhost:80/service/status - id: unique-http-id - name: my-http - processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - schedule: '*/5 * * * * * *' - timeout: 16s - type: synthetics/http - wait: 1s -- data_stream.namespace: default - host: localhost:777 - id: unique-tcp-id - name: my-tcp - processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - schedule: '*/5 * * * * * *' - timeout: 16s - type: synthetics/tcp - wait: 1s -- data_stream.namespace: default - host: localhost - id: unique-icmp-id - ipv4: true - ipv6: true - mode: any - name: my-icmp - processors: - - add_fields: - fields: - id: agent-id - snapshot: false - version: 8.0.0 - target: elastic_agent - - add_fields: - fields: - id: agent-id - target: agent - schedule: '@every 5s' - timeout: 16s - type: synthetics/icmp - wait: 1s -output: - elasticsearch: - hosts: - - 127.0.0.1:9200 - - 127.0.0.1:9300 - password: changeme - username: elastic From 8832b108aae92e2828d7785a3b1316b9bb66d42a Mon Sep 17 00:00:00 2001 From: ruflin Date: Fri, 10 Sep 2021 16:20:06 +0200 Subject: [PATCH 5/9] add generated files --- ...enabled_output_true-filebeat.generated.yml | 38 ++++++ .../enabled_true-filebeat.generated.yml | 38 ++++++ ...oint_basic-endpoint-security.generated.yml | 112 +++++++++++++++++ .../fleet_server-fleet-server.generated.yml | 33 +++++ .../namespace-endpoint-security.generated.yml | 113 +++++++++++++++++ .../namespace-filebeat.generated.yml | 70 +++++++++++ .../namespace-fleet-server.generated.yml | 18 +++ .../namespace-heartbeat.generated.yml | 30 +++++ .../namespace-metricbeat.generated.yml | 98 +++++++++++++++ .../namespace-packetbeat.generated.yml | 35 ++++++ ...gle_config-endpoint-security.generated.yml | 114 ++++++++++++++++++ .../single_config-filebeat.generated.yml | 71 +++++++++++ .../single_config-fleet-server.generated.yml | 18 +++ .../single_config-heartbeat.generated.yml | 31 +++++ .../single_config-metricbeat.generated.yml | 99 +++++++++++++++ .../single_config-packetbeat.generated.yml | 36 ++++++ .../synthetics_config-heartbeat.generated.yml | 68 +++++++++++ 17 files changed, 1022 insertions(+) create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml new file mode 100644 index 000000000000..6b898a6128a3 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml new file mode 100644 index 000000000000..197bf2f62321 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml new file mode 100644 index 000000000000..6359f9185b8d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml @@ -0,0 +1,112 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic +revision: 5 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml new file mode 100644 index 000000000000..01dc3bd3c89c --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml @@ -0,0 +1,33 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + name: fleet_server-1 + policy: + id: copy-policy-id + revision: 6 + server: + host: 0.0.0.0 + limits: + max_connections: 40 + port: 8220 + runtime: + gc_percent: 50 + ssl: + verification_mode: none + timeouts: + read: 5m + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml new file mode 100644 index 000000000000..7c8b033c4e62 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml @@ -0,0 +1,113 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + enabled: true + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml new file mode 100644 index 000000000000..2def5f274dea --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml @@ -0,0 +1,70 @@ +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 + vars: + var: value + - index: testtype-generic-default + paths: + - /var/log/hello3.log + - /var/log/hello4.log + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: testtype + 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 + vars: + var: value +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml new file mode 100644 index 000000000000..ab7499a4f112 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml new file mode 100644 index 000000000000..c18573ee7803 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml @@ -0,0 +1,30 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml new file mode 100644 index 000000000000..3232297227a0 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml @@ -0,0 +1,98 @@ +metricbeat: + modules: + - hosts: + - http://127.0.0.1:8080 + index: metrics-docker.status-default + metricsets: + - status + module: docker + processors: + - add_fields: + fields: + dataset: docker.status + namespace: default + type: metrics + target: data_stream + - add_fields: + fields: + dataset: docker.status + 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 + - hosts: + - http://127.0.0.1:8080 + index: metrics-generic-default + metricsets: + - info + module: docker + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: metrics + 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 + - hosts: + - http://apache.remote + index: metrics-generic-testing + metricsets: + - info + module: apache + processors: + - add_fields: + fields: + should_be: first + - add_fields: + fields: + dataset: generic + namespace: testing + type: metrics + 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 +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml new file mode 100644 index 000000000000..cc38887ff8e2 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml @@ -0,0 +1,35 @@ +inputs: +- processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + streams: + - data_stream: + dataset: packet.flow + type: logs + keep_null: false + period: 10s + timeout: 10s + type: flow + - data_stream: + dataset: packet.icmp + type: logs + type: icmp + type: packet +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + password: changeme + username: elastic diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml new file mode 100644 index 000000000000..552e169bbac2 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml @@ -0,0 +1,114 @@ +fleet: + access_api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + agent: + id: fleet-agent-id + logging.level: error + enabled: true + host: + id: host-agent-id + hosts: + - localhost:5601 + protocol: https + timeout: 30s +inputs: +- artifact_manifest: + 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 + manifest_version: v21 + schema_version: v22 + data_stream: + namespace: default + enabled: true + id: endpoint-id + name: endpoint-1 + package: + name: endpoint + version: 0.3.0 + policy: + linux: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + mac: + advanced: + free-form: free-form-value + events: + file: true + network: true + process: true + indices: + alerts: logs-endpoint.alerts-default + file: logs-endpoint.events.file-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + windows: + advanced: + free-form: free-form-value + events: + dll_and_driver_load: false + dns: false + file: true + network: true + process: true + registry: true + security: true + indices: + alerts: logs-endpoint.alerts-default + driver: logs-endpoint.events.driver-default + file: logs-endpoint.events.file-default + library: logs-endpoint.events.library-default + metadata: metrics-endpoint.metadata-default + network: logs-endpoint.events.network-default + policy: metrics-endpoint.policy-default + process: logs-endpoint.events.process-default + registry: logs-endpoint.events.registry-default + telemetry: metrics-endpoint.telemetry-default + logging: + file: info + stdout: debug + malware: + mode: prevent + type: endpoint +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml new file mode 100644 index 000000000000..da16ff8200d9 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml @@ -0,0 +1,71 @@ +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 + vars: + var: value + - index: testtype-generic-default + paths: + - /var/log/hello3.log + - /var/log/hello4.log + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: testtype + 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 + vars: + var: value +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml new file mode 100644 index 000000000000..ab7499a4f112 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id +inputs: +- id: fleet-server-id + type: fleet-server +output: + elasticsearch: + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: fleetpassword + username: fleet diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml new file mode 100644 index 000000000000..f4c5827603a8 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml @@ -0,0 +1,31 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml new file mode 100644 index 000000000000..aca140556350 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml @@ -0,0 +1,99 @@ +metricbeat: + modules: + - hosts: + - http://127.0.0.1:8080 + index: metrics-docker.status-default + metricsets: + - status + module: docker + processors: + - add_fields: + fields: + dataset: docker.status + namespace: default + type: metrics + target: data_stream + - add_fields: + fields: + dataset: docker.status + 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 + - hosts: + - http://127.0.0.1:8080 + index: metrics-generic-default + metricsets: + - info + module: docker + processors: + - add_fields: + fields: + dataset: generic + namespace: default + type: metrics + 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 + - hosts: + - http://apache.remote + index: metrics-generic-testing + metricsets: + - info + module: apache + processors: + - add_fields: + fields: + should_be: first + - add_fields: + fields: + dataset: generic + namespace: testing + type: metrics + 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 +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + headers: + h1: test-header + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml new file mode 100644 index 000000000000..e7f13deb0a20 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml @@ -0,0 +1,36 @@ +inputs: +- processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + streams: + - data_stream: + dataset: packet.flow + type: logs + keep_null: false + period: 10s + timeout: 10s + type: flow + - data_stream: + dataset: packet.icmp + type: logs + type: icmp + type: packet +output: + elasticsearch: + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + bulk_max_size: 23 + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic + worker: 10 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml new file mode 100644 index 000000000000..870a0070f4eb --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml @@ -0,0 +1,68 @@ +inputs: +- data_stream.namespace: default + host: http://localhost:80/service/status + id: unique-http-id + name: my-http + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/http + wait: 1s +- data_stream.namespace: default + host: localhost:777 + id: unique-tcp-id + name: my-tcp + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '*/5 * * * * * *' + timeout: 16s + type: synthetics/tcp + wait: 1s +- data_stream.namespace: default + host: localhost + id: unique-icmp-id + ipv4: true + ipv6: true + mode: any + name: my-icmp + processors: + - add_fields: + fields: + id: agent-id + snapshot: false + version: 8.0.0 + target: elastic_agent + - add_fields: + fields: + id: agent-id + target: agent + schedule: '@every 5s' + timeout: 16s + type: synthetics/icmp + wait: 1s +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + password: changeme + username: elastic From 4cf76a193878ed380d02493110208eafa47d5772 Mon Sep 17 00:00:00 2001 From: ruflin Date: Mon, 13 Sep 2021 08:31:17 +0200 Subject: [PATCH 6/9] add golden files --- .../pkg/agent/program/program_test.go | 77 ++++++++++++++++++- .../{ => usecases}/enabled_output_true.yml | 0 .../testdata/{ => usecases}/enabled_true.yml | 0 .../{ => usecases}/endpoint_basic.yml | 0 .../testdata/{ => usecases}/fleet_server.yml | 0 .../enabled_output_true.filebeat.golden.yml} | 0 .../enabled_true.filebeat.golden.yml} | 0 ...dpoint_basic.endpoint-security.golden.yml} | 0 .../fleet_server.fleet-server.golden.yml} | 0 .../namespace.endpoint-security.golden.yml} | 0 .../generated/namespace.filebeat.golden.yml} | 0 .../namespace.fleet-server.golden.yml} | 0 .../generated/namespace.heartbeat.golden.yml} | 0 .../namespace.metricbeat.golden.yml} | 0 .../namespace.packetbeat.golden.yml} | 0 ...ingle_config.endpoint-security.golden.yml} | 0 .../single_config.filebeat.golden.yml} | 0 .../single_config.fleet-server.golden.yml} | 0 .../single_config.heartbeat.golden.yml} | 0 .../single_config.metricbeat.golden.yml} | 0 .../single_config.packetbeat.golden.yml} | 0 .../synthetics_config.heartbeat.golden.yml} | 0 .../testdata/{ => usecases}/namespace.yml | 0 .../testdata/{ => usecases}/single_config.yml | 0 .../{ => usecases}/synthetics_config.yml | 0 25 files changed, 76 insertions(+), 1 deletion(-) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/enabled_output_true.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/enabled_true.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/endpoint_basic.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/fleet_server.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/enabled_output_true-filebeat.generated.yml => usecases/generated/enabled_output_true.filebeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/enabled_true-filebeat.generated.yml => usecases/generated/enabled_true.filebeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/endpoint_basic-endpoint-security.generated.yml => usecases/generated/endpoint_basic.endpoint-security.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/fleet_server-fleet-server.generated.yml => usecases/generated/fleet_server.fleet-server.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-endpoint-security.generated.yml => usecases/generated/namespace.endpoint-security.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-filebeat.generated.yml => usecases/generated/namespace.filebeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-fleet-server.generated.yml => usecases/generated/namespace.fleet-server.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-heartbeat.generated.yml => usecases/generated/namespace.heartbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-metricbeat.generated.yml => usecases/generated/namespace.metricbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/namespace-packetbeat.generated.yml => usecases/generated/namespace.packetbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-endpoint-security.generated.yml => usecases/generated/single_config.endpoint-security.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-filebeat.generated.yml => usecases/generated/single_config.filebeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-fleet-server.generated.yml => usecases/generated/single_config.fleet-server.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-heartbeat.generated.yml => usecases/generated/single_config.heartbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-metricbeat.generated.yml => usecases/generated/single_config.metricbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/single_config-packetbeat.generated.yml => usecases/generated/single_config.packetbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{generated/synthetics_config-heartbeat.generated.yml => usecases/generated/synthetics_config.heartbeat.golden.yml} (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/namespace.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/single_config.yml (100%) rename x-pack/elastic-agent/pkg/agent/program/testdata/{ => usecases}/synthetics_config.yml (100%) diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 31b9160ba449..9dc653bbf1fd 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -380,7 +380,7 @@ func TestGroupBy(t *testing.T) { }) } -func TestConfiguration(t *testing.T) { +/*func TestConfiguration(t *testing.T) { defer os.Remove("fleet.yml") testcases := map[string]struct { @@ -516,6 +516,81 @@ func TestConfiguration(t *testing.T) { } }) + } +}*/ + +func TestUseCases(t *testing.T) { + defer os.Remove("fleet.yml") + + useCasesPath := filepath.Join("testdata", "usecases") + useCases, err := filepath.Glob(filepath.Join(useCasesPath, "*.yml")) + require.NoError(t, err) + + generatedFilesDir := filepath.Join(useCasesPath, "generated") + + // Cleanup all generated files to make sure not having any left overs + if *generateFlag { + err := os.RemoveAll(generatedFilesDir) + require.NoError(t, err) + } + + for _, usecase := range useCases { + t.Run(usecase, func(t *testing.T) { + + useCaseName := strings.TrimSuffix(filepath.Base(usecase), ".yml") + singleConfig, err := ioutil.ReadFile(usecase) + require.NoError(t, err) + + var m map[string]interface{} + err = yaml.Unmarshal(singleConfig, &m) + require.NoError(t, err) + + ast, err := transpiler.NewAST(m) + require.NoError(t, err) + + programs, err := Programs(&fakeAgentInfo{}, ast) + require.NoError(t, err) + + require.Equal(t, 1, len(programs)) + + defPrograms, ok := programs["default"] + require.True(t, ok) + + for _, program := range defPrograms { + generatedPath := filepath.Join( + useCasesPath, "generated", + useCaseName+"."+strings.ToLower(program.Spec.Cmd)+".golden.yml", + ) + + compareMap := &transpiler.MapVisitor{} + program.Config.Accept(compareMap) + + // Generate new file file for programm + if *generateFlag { + d, _ := yaml.Marshal(&compareMap.Content) + fmt.Println(string(d)) + + os.MkdirAll(generatedFilesDir, 0755) + err := ioutil.WriteFile(generatedPath, d, 0644) + require.NoError(t, err) + } + + programConfig, err := ioutil.ReadFile(generatedPath) + require.NoError(t, err) + + var m map[string]interface{} + err = yamltest.FromYAML(programConfig, &m) + require.NoError(t, errors.Wrap(err, program.Cmd())) + + if !assert.True(t, cmp.Equal(m, compareMap.Content)) { + diff := cmp.Diff(m, compareMap.Content) + if diff != "" { + t.Errorf("%s-%s mismatch (-want +got):\n%s", usecase, program.Spec.Name, diff) + } + } + } + }) + } } diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_output_true.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_output_true.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_true.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/enabled_true.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/endpoint_basic.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/endpoint_basic.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/fleet_server.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/fleet_server.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/enabled_output_true.filebeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_output_true-filebeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/enabled_output_true.filebeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/enabled_true.filebeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/enabled_true-filebeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/enabled_true.filebeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/endpoint_basic.endpoint-security.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/endpoint_basic-endpoint-security.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/endpoint_basic.endpoint-security.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/fleet_server.fleet-server.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/fleet_server-fleet-server.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/fleet_server.fleet-server.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.endpoint-security.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-endpoint-security.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.endpoint-security.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.filebeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-filebeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.filebeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.fleet-server.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-fleet-server.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.fleet-server.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.heartbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-heartbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.heartbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.metricbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-metricbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.metricbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.packetbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/namespace-packetbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/namespace.packetbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.endpoint-security.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-endpoint-security.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.endpoint-security.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.filebeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-filebeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.filebeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.fleet-server.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-fleet-server.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.fleet-server.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.heartbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-heartbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.heartbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.metricbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-metricbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.metricbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.packetbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/single_config-packetbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/single_config.packetbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/synthetics_config.heartbeat.golden.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/generated/synthetics_config-heartbeat.generated.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/generated/synthetics_config.heartbeat.golden.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/namespace.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/namespace.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/single_config.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/single_config.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/usecases/synthetics_config.yml similarity index 100% rename from x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/usecases/synthetics_config.yml From 89670975bd351b79379b0ce848d6b625a32c8cbf Mon Sep 17 00:00:00 2001 From: ruflin Date: Mon, 13 Sep 2021 08:33:05 +0200 Subject: [PATCH 7/9] add golden files --- .../pkg/agent/program/program_test.go | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 9dc653bbf1fd..24eba40353d7 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -6,7 +6,6 @@ package program import ( "flag" - "fmt" "io/ioutil" "os" "path/filepath" @@ -380,7 +379,7 @@ func TestGroupBy(t *testing.T) { }) } -/*func TestConfiguration(t *testing.T) { +func TestConfiguration(t *testing.T) { defer os.Remove("fleet.yml") testcases := map[string]struct { @@ -442,15 +441,6 @@ func TestGroupBy(t *testing.T) { }, } - generatedFilesDir := filepath.Join("testdata", "generated") - - // Cleanup all generated files to make sure not having any left overs - if *generateFlag { - - err := os.RemoveAll(generatedFilesDir) - require.NoError(t, err) - } - for name, test := range testcases { t.Run(name, func(t *testing.T) { singleConfig, err := ioutil.ReadFile(filepath.Join("testdata", name+".yml")) @@ -480,33 +470,20 @@ func TestGroupBy(t *testing.T) { require.True(t, ok) require.Equal(t, test.expected, len(defPrograms)) - // TODO: If generate, remove all generated files first for _, program := range defPrograms { - generatedPath := filepath.Join( - "testdata", "generated", - name+"-"+strings.ToLower(program.Spec.Cmd)+".generated.yml", - ) - - compareMap := &transpiler.MapVisitor{} - program.Config.Accept(compareMap) - - // Generate new file file for programm - if *generateFlag { - d, _ := yaml.Marshal(&compareMap.Content) - fmt.Println(string(d)) - - os.MkdirAll(generatedFilesDir, 0755) - err := ioutil.WriteFile(generatedPath, d, 0644) - require.NoError(t, err) - } + programConfig, err := ioutil.ReadFile(filepath.Join( + "testdata", + name+"-"+strings.ToLower(program.Spec.Cmd)+".yml", + )) - programConfig, err := ioutil.ReadFile(generatedPath) require.NoError(t, err) - var m map[string]interface{} err = yamltest.FromYAML(programConfig, &m) require.NoError(t, errors.Wrap(err, program.Cmd())) + compareMap := &transpiler.MapVisitor{} + program.Config.Accept(compareMap) + if !assert.True(t, cmp.Equal(m, compareMap.Content)) { diff := cmp.Diff(m, compareMap.Content) if diff != "" { @@ -515,9 +492,8 @@ func TestGroupBy(t *testing.T) { } } }) - } -}*/ +} func TestUseCases(t *testing.T) { defer os.Remove("fleet.yml") @@ -565,13 +541,14 @@ func TestUseCases(t *testing.T) { compareMap := &transpiler.MapVisitor{} program.Config.Accept(compareMap) - // Generate new file file for programm + // Generate new golden file for programm if *generateFlag { - d, _ := yaml.Marshal(&compareMap.Content) - fmt.Println(string(d)) + d, err := yaml.Marshal(&compareMap.Content) + require.NoError(t, err) - os.MkdirAll(generatedFilesDir, 0755) - err := ioutil.WriteFile(generatedPath, d, 0644) + err := os.MkdirAll(generatedFilesDir, 0755) + require.NoError(t, err) + err = ioutil.WriteFile(generatedPath, d, 0644) require.NoError(t, err) } @@ -590,7 +567,6 @@ func TestUseCases(t *testing.T) { } } }) - } } From 8eec37515d4cbafd5ff2aeaf511a36945e9bcee8 Mon Sep 17 00:00:00 2001 From: ruflin Date: Mon, 13 Sep 2021 08:34:51 +0200 Subject: [PATCH 8/9] add test files --- .../pkg/agent/program/program_test.go | 2 +- .../program/testdata/enabled_output_true.yml | 17 ++ .../agent/program/testdata/enabled_true.yml | 22 ++ .../agent/program/testdata/endpoint_basic.yml | 115 ++++++++++ .../agent/program/testdata/fleet_server.yml | 51 +++++ .../pkg/agent/program/testdata/namespace.yml | 201 +++++++++++++++++ .../agent/program/testdata/single_config.yml | 202 ++++++++++++++++++ .../program/testdata/synthetics_config.yml | 31 +++ 8 files changed, 640 insertions(+), 1 deletion(-) create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go index 24eba40353d7..04c3519af65d 100644 --- a/x-pack/elastic-agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -546,7 +546,7 @@ func TestUseCases(t *testing.T) { d, err := yaml.Marshal(&compareMap.Content) require.NoError(t, err) - err := os.MkdirAll(generatedFilesDir, 0755) + err = os.MkdirAll(generatedFilesDir, 0755) require.NoError(t, err) err = ioutil.WriteFile(generatedPath, d, 0644) require.NoError(t, err) diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml new file mode 100644 index 000000000000..9601388c536d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml new file mode 100644 index 000000000000..6afc7f37ab15 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml new file mode 100644 index 000000000000..9f438cd46fdc --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml new file mode 100644 index 000000000000..a816197917e7 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server.yml @@ -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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml new file mode 100644 index 000000000000..c2f83a9abf08 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace.yml @@ -0,0 +1,201 @@ +name: Production Website DB Servers +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: + output: + elasticsearch: + hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + username: fleet + password: fleetpassword + +outputs: + default: + type: elasticsearch + namespace: test_namespace + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + + monitoring: + type: elasticsearch + api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + hosts: ["monitoring:9200"] + ca_sha256: "7lHLiyp4J8m9kw38SJ7SURJP4bXRZv/BNxyyXkCcE/M=" + +inputs: +- id: fleet-server-id + type: fleet-server + use_output: default + data_stream: + type: default +- type: docker/metrics + use_output: default + streams: + - metricset: status + processors: + - null + data_stream: + dataset: docker.status + - metricset: info + data_stream: + dataset: "" + hosts: ["http://127.0.0.1:8080"] +- type: logfile + use_output: default + streams: + - paths: + - /var/log/hello1.log + - /var/log/hello2.log + vars: + var: value +- type: logfile + data_stream: + type: testtype + use_output: default + streams: + - paths: + - /var/log/hello3.log + - /var/log/hello4.log + vars: + var: value +- id: apache-metrics-id + type: apache/metrics + data_stream: + namespace: testing + use_output: default + processors: + - add_fields: + fields: + should_be: first + streams: + - enabled: true + metricset: info + hosts: ["http://apache.remote"] + hosts: ["http://apache.local"] +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s +- type: packet + streams: + - type: flow + timeout: 10s + period: 10s + keep_null: false + data_stream: + dataset: packet.flow + type: logs + - type: icmp + data_stream: + dataset: packet.icmp + type: logs +- 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 + +agent.monitoring: + use_output: monitoring + +agent: + reload: 123 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml new file mode 100644 index 000000000000..16a03f9a77da --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml @@ -0,0 +1,202 @@ +name: Production Website DB Servers +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: + 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] + bulk_max_size: 23 + worker: 10 + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= + + monitoring: + type: elasticsearch + api_key: VuaCfGcBCdbkQm-e5aOx:ui2lp2axTNmsyakw9tvNnw + hosts: ["monitoring:9200"] + ca_sha256: "7lHLiyp4J8m9kw38SJ7SURJP4bXRZv/BNxyyXkCcE/M=" + +inputs: +- id: fleet-server-id + type: fleet-server + use_output: default + data_stream: + type: default +- type: docker/metrics + use_output: default + streams: + - metricset: status + processors: + - null + data_stream: + dataset: docker.status + - metricset: info + data_stream: + dataset: "" + hosts: ["http://127.0.0.1:8080"] +- type: logfile + use_output: default + streams: + - paths: + - /var/log/hello1.log + - /var/log/hello2.log + vars: + var: value +- type: logfile + data_stream: + type: testtype + use_output: default + streams: + - paths: + - /var/log/hello3.log + - /var/log/hello4.log + vars: + var: value +- id: apache-metrics-id + type: apache/metrics + data_stream: + namespace: testing + use_output: default + processors: + - add_fields: + fields: + should_be: first + streams: + - enabled: true + metricset: info + hosts: ["http://apache.remote"] + hosts: ["http://apache.local"] +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s +- type: packet + streams: + - type: flow + timeout: 10s + period: 10s + keep_null: false + data_stream: + dataset: packet.flow + type: logs + - type: icmp + data_stream: + dataset: packet.icmp + type: logs +- 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 + +agent.monitoring: + use_output: monitoring + +agent: + reload: 123 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml new file mode 100644 index 000000000000..74aa9916a658 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config.yml @@ -0,0 +1,31 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s +- type: synthetics/tcp + id: unique-tcp-id + name: my-tcp + schedule: '*/5 * * * * * *' + host: "localhost:777" + timeout: 16s + wait: 1s +- type: synthetics/icmp + id: unique-icmp-id + name: my-icmp + schedule: '@every 5s' + host: "localhost" + ipv4: true + ipv6: true + mode: any + timeout: 16s + wait: 1s +outputs: + default: + type: elasticsearch + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + username: elastic + password: changeme From ae92c5461e99fb1d74023b11dbc64239e5caf53e Mon Sep 17 00:00:00 2001 From: ruflin Date: Mon, 13 Sep 2021 08:36:04 +0200 Subject: [PATCH 9/9] readd old test files --- .../testdata/enabled_output_true-filebeat.yml | 38 ++++++ .../testdata/enabled_true-filebeat.yml | 38 ++++++ .../endpoint_basic-endpoint-security.yml | 113 +++++++++++++++++ .../testdata/fleet_server-fleet-server.yml | 33 +++++ .../testdata/namespace-endpoint-security.yml | 114 +++++++++++++++++ .../program/testdata/namespace-filebeat.yml | 71 +++++++++++ .../testdata/namespace-fleet-server.yml | 18 +++ .../program/testdata/namespace-heartbeat.yml | 30 +++++ .../program/testdata/namespace-metricbeat.yml | 91 ++++++++++++++ .../program/testdata/namespace-packetbeat.yml | 35 ++++++ .../single_config-endpoint-security.yml | 115 ++++++++++++++++++ .../testdata/single_config-filebeat.yml | 71 +++++++++++ .../testdata/single_config-fleet-server.yml | 18 +++ .../testdata/single_config-heartbeat.yml | 31 +++++ .../testdata/single_config-metricbeat.yml | 91 ++++++++++++++ .../testdata/single_config-packetbeat.yml | 36 ++++++ .../testdata/synthetics_config-heartbeat.yml | 66 ++++++++++ 17 files changed, 1009 insertions(+) create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml create mode 100644 x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml new file mode 100644 index 000000000000..d9b4dc079f50 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml @@ -0,0 +1,38 @@ +filebeat: + inputs: + - type: log + paths: + - /var/log/hello1.log + - /var/log/hello2.log + index: logs-generic-default + processors: + - add_fields: + target: "data_stream" + fields: + type: logs + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + enabled: true + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + headers: + h1: test-header + username: elastic + password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml new file mode 100644 index 000000000000..f579dcba416c --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml @@ -0,0 +1,38 @@ +filebeat: + inputs: + - type: log + enabled: true + paths: + - /var/log/hello1.log + - /var/log/hello2.log + index: logs-generic-default + processors: + - add_fields: + target: "data_stream" + fields: + type: logs + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + headers: + h1: test-header + username: elastic + password: changeme diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml new file mode 100644 index 000000000000..dfbec8016ba0 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/endpoint_basic-endpoint-security.yml @@ -0,0 +1,113 @@ +revision: 5 +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 + +output: + 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml new file mode 100644 index 000000000000..7a0fad5c9df6 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/fleet_server-fleet-server.yml @@ -0,0 +1,33 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id + +output: + elasticsearch: + hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header + username: fleet + password: fleetpassword + +inputs: + - id: fleet-server-id + type: fleet-server + name: fleet_server-1 + revision: 6 + server: + host: 0.0.0.0 + port: 8220 + ssl: + verification_mode: none + limits: + max_connections: 40 + runtime: + gc_percent: 50 + timeouts: + read: 5m + policy: + id: copy-policy-id diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml new file mode 100644 index 000000000000..7e9f04dc4119 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-endpoint-security.yml @@ -0,0 +1,114 @@ +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 + +output: + elasticsearch: + hosts: + - "127.0.0.1:9200" + - "127.0.0.1:9300" + namespace: test_namespace + 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml new file mode 100644 index 000000000000..eafedb688c99 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-filebeat.yml @@ -0,0 +1,71 @@ +filebeat: + inputs: + - type: log + paths: + - /var/log/hello1.log + - /var/log/hello2.log + index: logs-generic-default + vars: + var: value + processors: + - add_fields: + target: "data_stream" + fields: + type: logs + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - type: log + paths: + - /var/log/hello3.log + - /var/log/hello4.log + index: testtype-generic-default + vars: + var: value + processors: + - add_fields: + target: "data_stream" + fields: + type: testtype + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + headers: + h1: test-header + + namespace: test_namespace + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml new file mode 100644 index 000000000000..b306cf402773 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-fleet-server.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id + +output: + elasticsearch: + hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header + username: fleet + password: fleetpassword + +inputs: + - id: fleet-server-id + type: fleet-server diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml new file mode 100644 index 000000000000..f34b204f5fae --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-heartbeat.yml @@ -0,0 +1,30 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s + data_stream.namespace: default + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml new file mode 100644 index 000000000000..d0d4c24f0586 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-metricbeat.yml @@ -0,0 +1,91 @@ +metricbeat: + modules: + - module: docker + metricsets: [status] + index: metrics-docker.status-default + hosts: ["http://127.0.0.1:8080"] + processors: + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: docker.status + namespace: default + - add_fields: + target: "event" + fields: + dataset: docker.status + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - module: docker + metricsets: [info] + index: metrics-generic-default + hosts: ["http://127.0.0.1:8080"] + processors: + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - module: apache + metricsets: [info] + index: metrics-generic-testing + hosts: ["http://apache.remote"] + processors: + - add_fields: + fields: + should_be: first + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: generic + namespace: testing + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + headers: + h1: test-header + + namespace: test_namespace + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml new file mode 100644 index 000000000000..d71499bdef4d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/namespace-packetbeat.yml @@ -0,0 +1,35 @@ +inputs: +- type: packet + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id + streams: + - type: flow + timeout: 10s + period: 10s + keep_null: false + data_stream: + dataset: packet.flow + type: logs + - type: icmp + data_stream: + dataset: packet.icmp + type: logs +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + namespace: test_namespace + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml new file mode 100644 index 000000000000..f7bcdb284c4d --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-endpoint-security.yml @@ -0,0 +1,115 @@ +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 + +output: + elasticsearch: + hosts: + - "127.0.0.1:9200" + - "127.0.0.1:9300" + bulk_max_size: 23 + worker: 10 + 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 diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml new file mode 100644 index 000000000000..e628cd2c098e --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml @@ -0,0 +1,71 @@ +filebeat: + inputs: + - type: log + paths: + - /var/log/hello1.log + - /var/log/hello2.log + index: logs-generic-default + vars: + var: value + processors: + - add_fields: + target: "data_stream" + fields: + type: logs + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - type: log + paths: + - /var/log/hello3.log + - /var/log/hello4.log + index: testtype-generic-default + vars: + var: value + processors: + - add_fields: + target: "data_stream" + fields: + type: testtype + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + headers: + h1: test-header + username: elastic + password: changeme + bulk_max_size: 23 + worker: 10 + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml new file mode 100644 index 000000000000..b306cf402773 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-fleet-server.yml @@ -0,0 +1,18 @@ +fleet: + agent: + id: fleet-agent-id + logging.level: error + host: + id: host-agent-id + +output: + elasticsearch: + hosts: [ 127.0.0.1:9200, 127.0.0.1:9300 ] + headers: + h1: test-header + username: fleet + password: fleetpassword + +inputs: + - id: fleet-server-id + type: fleet-server diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml new file mode 100644 index 000000000000..800f4100382c --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-heartbeat.yml @@ -0,0 +1,31 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s + data_stream.namespace: default + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + bulk_max_size: 23 + worker: 10 + username: elastic + password: changeme + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml new file mode 100644 index 000000000000..a2c36b151f00 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml @@ -0,0 +1,91 @@ +metricbeat: + modules: + - module: docker + metricsets: [status] + index: metrics-docker.status-default + hosts: ["http://127.0.0.1:8080"] + processors: + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: docker.status + namespace: default + - add_fields: + target: "event" + fields: + dataset: docker.status + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - module: docker + metricsets: [info] + index: metrics-generic-default + hosts: ["http://127.0.0.1:8080"] + processors: + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: generic + namespace: default + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id + - module: apache + metricsets: [info] + index: metrics-generic-testing + hosts: ["http://apache.remote"] + processors: + - add_fields: + fields: + should_be: first + - add_fields: + target: "data_stream" + fields: + type: metrics + dataset: generic + namespace: testing + - add_fields: + target: "event" + fields: + dataset: generic + - add_fields: + target: "elastic_agent" + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: "agent" + fields: + id: agent-id +output: + elasticsearch: + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + headers: + h1: test-header + username: elastic + password: changeme + bulk_max_size: 23 + worker: 10 + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml new file mode 100644 index 000000000000..f800d0bd2a09 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-packetbeat.yml @@ -0,0 +1,36 @@ +inputs: +- type: packet + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id + streams: + - type: flow + timeout: 10s + period: 10s + keep_null: false + data_stream: + dataset: packet.flow + type: logs + - type: icmp + data_stream: + dataset: packet.icmp + type: logs +output: + elasticsearch: + hosts: + - 127.0.0.1:9200 + - 127.0.0.1:9300 + username: elastic + password: changeme + bulk_max_size: 23 + worker: 10 + api_key: TiNAGG4BaaMdaH1tRfuU:KnR6yE41RrSowb0kQ0HWoA + ca_sha256: 7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y= diff --git a/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml new file mode 100644 index 000000000000..284d391f78b8 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/synthetics_config-heartbeat.yml @@ -0,0 +1,66 @@ +inputs: +- type: synthetics/http + id: unique-http-id + name: my-http + schedule: '*/5 * * * * * *' + host: "http://localhost:80/service/status" + timeout: 16s + wait: 1s + data_stream.namespace: default + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id +- type: synthetics/tcp + id: unique-tcp-id + name: my-tcp + schedule: '*/5 * * * * * *' + host: "localhost:777" + timeout: 16s + wait: 1s + data_stream.namespace: default + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id +- type: synthetics/icmp + id: unique-icmp-id + name: my-icmp + schedule: '@every 5s' + host: "localhost" + ipv4: true + ipv6: true + mode: any + timeout: 16s + wait: 1s + data_stream.namespace: default + processors: + - add_fields: + target: 'elastic_agent' + fields: + id: agent-id + version: 8.0.0 + snapshot: false + - add_fields: + target: 'agent' + fields: + id: agent-id +output: + elasticsearch: + hosts: [127.0.0.1:9200, 127.0.0.1:9300] + username: elastic + password: changeme