Skip to content
Merged
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
2 changes: 1 addition & 1 deletion config/samples/logstash/logstash_svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
api.http.port: 9601
queue.type: memory
pipelines:
- pipeline.id: one
- pipeline.id: main
pipeline.workers: 2
config.string: "input { beats { port => 5044 }} output { stdout {}}"
services:
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/logstash/stack_monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func TestLogstashStackMonitoring(t *testing.T) {
WithESMasterDataNodes(2, elasticsearch.DefaultResources)
monitored := logstash.NewBuilder("test-ls-mon-a").
WithNodeCount(1).
WithMonitoring(metrics.Ref(), logs.Ref())
WithMetricsMonitoring(metrics.Ref()).
WithLogsMonitoring(logs.Ref())

// checks that the sidecar beats have sent data in the monitoring clusters
steps := func(k *test.K8sClient) test.StepList {
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,20 @@ func createBuilders(t *testing.T, decoder *helper.YAMLDecoder, sampleFile, testN
ClusterName: ref.ClusterName,
})
}
metricsRefs := make([]commonv1.ObjectSelector, 0, len(b.Logstash.Spec.Monitoring.Metrics.ElasticsearchRefs))
for _, ref := range b.Logstash.Spec.Monitoring.Metrics.ElasticsearchRefs {
metricsRefs = append(metricsRefs, tweakServiceRef(ref, suffix))
}
logRefs := make([]commonv1.ObjectSelector, 0, len(b.Logstash.Spec.Monitoring.Logs.ElasticsearchRefs))
for _, ref := range b.Logstash.Spec.Monitoring.Logs.ElasticsearchRefs {
logRefs = append(logRefs, tweakServiceRef(ref, suffix))
}

return b.WithNamespace(namespace).
WithSuffix(suffix).
WithElasticsearchRefs(esRefs...).
WithMetricsMonitoring(metricsRefs...).
WithLogsMonitoring(logRefs...).
WithRestrictedSecurityContext().
WithLabel(run.TestNameLabel, fullTestName).
WithPodLabel(run.TestNameLabel, fullTestName)
Expand Down
10 changes: 7 additions & 3 deletions test/e2e/test/logstash/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ func (b Builder) WithElasticsearchRefs(refs ...logstashv1alpha1.ElasticsearchClu
return b
}

func (b Builder) WithMonitoring(metricsESRef commonv1.ObjectSelector, logsESRef commonv1.ObjectSelector) Builder {
b.Logstash.Spec.Monitoring.Metrics.ElasticsearchRefs = []commonv1.ObjectSelector{metricsESRef}
b.Logstash.Spec.Monitoring.Logs.ElasticsearchRefs = []commonv1.ObjectSelector{logsESRef}
func (b Builder) WithMetricsMonitoring(metricsESRef ...commonv1.ObjectSelector) Builder {
b.Logstash.Spec.Monitoring.Metrics.ElasticsearchRefs = metricsESRef
return b
}

func (b Builder) WithLogsMonitoring(logsESRef ...commonv1.ObjectSelector) Builder {
b.Logstash.Spec.Monitoring.Logs.ElasticsearchRefs = logsESRef
return b
}

Expand Down
12 changes: 11 additions & 1 deletion test/e2e/test/logstash/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func CheckStatus(b Builder, k *test.K8sClient) test.Step {
return fmt.Errorf("expected status %+v but got %+v", expected, logstash.Status)
}

expectedMonitoringInStatus := uniqueAssociationCount(logstash.Spec.Monitoring.Metrics.ElasticsearchRefs, logstash.Spec.Monitoring.Logs.ElasticsearchRefs)
// monitoring status
expectedMonitoringInStatus := len(logstash.Spec.Monitoring.Metrics.ElasticsearchRefs) + len(logstash.Spec.Monitoring.Metrics.ElasticsearchRefs)
actualMonitoringInStatus := len(logstash.Status.MonitoringAssociationStatus)
if expectedMonitoringInStatus != actualMonitoringInStatus {
return fmt.Errorf("expected %d monitoring associations in status but got %d", expectedMonitoringInStatus, actualMonitoringInStatus)
Expand Down Expand Up @@ -143,6 +143,16 @@ func CheckStatus(b Builder, k *test.K8sClient) test.Step {
}
}

func uniqueAssociationCount(refsList ...[]v1.ObjectSelector) int {
uniqueAssociations := make(map[v1.ObjectSelector]struct{})
for _, refs := range refsList {
for _, val := range refs {
uniqueAssociations[val] = struct{}{}
}
}
return len(uniqueAssociations)
}

func (b Builder) CheckStackTestSteps(k *test.K8sClient) test.StepList {
return test.StepList{
b.CheckMetricsRequest(k,
Expand Down