Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix service tests #6720

Merged
merged 3 commits into from
Apr 24, 2023
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
10 changes: 10 additions & 0 deletions test/e2e/logstash/logstash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestLogstashWithCustomService(t *testing.T) {
test.Sequence(nil, test.EmptySteps, logstashBuilder).RunSequential(t)
}

// This test sets a custom port for the Logstash API service
func TestLogstashWithReworkedApiService(t *testing.T) {
name := "test-multiple-custom-logstash"
service := logstashv1alpha1.LogstashService{
Expand All @@ -56,11 +57,16 @@ func TestLogstashWithReworkedApiService(t *testing.T) {
}
logstashBuilder := (logstash.NewBuilder(name).
WithNodeCount(1).
// Change the Logstash API service port
WithConfig(map[string]interface{}{
"api.http.port": 9200,
}).
WithServices(service))

test.Sequence(nil, test.EmptySteps, logstashBuilder).RunSequential(t)
}

// This test adds a new service, and changes the port that the logstash API is served from
func TestLogstashWithCustomServiceAndAmendedApi(t *testing.T) {
name := "test-multiple-custom-logstash"
customService := logstashv1alpha1.LogstashService{
Expand All @@ -87,6 +93,10 @@ func TestLogstashWithCustomServiceAndAmendedApi(t *testing.T) {

logstashBuilder := (logstash.NewBuilder(name).
WithNodeCount(1).
// Change the Logstash API service port
WithConfig(map[string]interface{}{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could we add a comment/godoc on TestLogstashWithReworkedApiService and TestLogstashWithCustomServiceAndAmendedApi? It took me a few minutes to figure out why this change is not needed for TestLogstashWithCustomService.

"api.http.port": 9601,
}).
WithServices(apiService, customService))

test.Sequence(nil, test.EmptySteps, logstashBuilder).RunSequential(t)
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/test/logstash/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ func (b Builder) GetMetricsIndexPattern() string {
return ".monitoring-logstash-8-mb"
}

func (b Builder) WithConfig(config map[string]interface{}) Builder {
b.Logstash.Spec.Config = &commonv1.Config{
Data: config,
}
return b
}

func (b Builder) Name() string {
return b.Logstash.Name
}
Expand Down