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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions testing/integration/k8s/journald_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,84 @@ func TestKubernetesJournaldInput(t *testing.T) {
"journald")
}

<<<<<<< HEAD
=======
func TestKubernetesJournaldInputOtel(t *testing.T) {
info := define.Require(t, define.Requirements{
Stack: &define.Stack{},
Local: false,
Sudo: false,
OS: []define.OS{
{Type: define.Kubernetes, DockerVariant: "elastic-otel-collector"},
},
Group: define.Kubernetes,
})

otelConfigYAML, err := os.ReadFile(filepath.Join("testdata", "journald-otel.yml"))
require.NoError(t, err, "failed to read journald input template")

kCtx := k8sGetContext(t, info)
namespace := kCtx.getNamespace(t)
hostPathType := corev1.HostPathDirectory

steps := []k8sTestStep{
k8sStepCreateNamespace(),
k8sStepDeployKustomize(
"elastic-agent-standalone",
k8sKustomizeOverrides{
agentContainerArgs: []string{"--config", "/etc/elastic-agent/agent.yml"},
agentContainerExtraEnv: []corev1.EnvVar{
{
Name: "EA_POLICY_NAMESPACE",
Value: namespace,
},
{
Name: "ES_API_KEY_ENCODED",
Value: kCtx.esEncodedAPIKey,
},
},
agentContainerVolumeMounts: []corev1.VolumeMount{
{
Name: "journald-mount",
MountPath: "/opt/journal",
ReadOnly: true,
},
},
agentPodVolumes: []corev1.Volume{
{
Name: "journald-mount",
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/run/log/journal",
Type: &hostPathType,
},
},
},
},
},
func(obj k8s.Object) {
// update the configmap to use the journald input
switch objWithType := obj.(type) {
case *corev1.ConfigMap:
_, ok := objWithType.Data["agent.yml"]
if ok {
objWithType.Data["agent.yml"] = string(otelConfigYAML)
}
}
}),
}

journaldTest(
t,
info.ESClient,
kCtx,
steps,
namespace,
"Body.input.type",
"journald")
}

>>>>>>> efafc2a65 (Use unique index for TestKubernetesJournaldInputOtel (#11316))
func journaldTest(
t *testing.T,
esClient *elasticsearch.Client,
Expand Down
3 changes: 3 additions & 0 deletions testing/integration/k8s/testdata/journald-otel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ processors:

exporters:
elasticsearch:
logs_index: "${EA_POLICY_NAMESPACE}"
endpoint: "${ES_HOST}"
api_key: "${ES_API_KEY_ENCODED}"
mapping:
mode: none

service:
pipelines:
Expand Down
Loading