Skip to content
Merged
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
14 changes: 10 additions & 4 deletions testing/integration/ess/beat_receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1517,9 +1517,8 @@ func setStrictMapping(client *elasticsearch.Client, index string) error {
defer cancel()

// Build request
req, err := http.NewRequestWithContext(ctx, http.MethodPut,
esEndpoint+"/_index_template/no-dynamic-template",
bytes.NewReader(jsonData))
url := fmt.Sprintf("%s/_index_template/%s", esEndpoint, index)
req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, bytes.NewReader(jsonData))
if err != nil {
return fmt.Errorf("could not create http request to ES server: %v", err)
}
Expand All @@ -1531,8 +1530,15 @@ func setStrictMapping(client *elasticsearch.Client, index string) error {
if err != nil {
return fmt.Errorf("error performing request: %v", err)
}
defer func() {
_ = resp.Body.Close()
}()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("incorrect response code: %v", err)
responseBody, readErr := io.ReadAll(resp.Body)
if readErr != nil {
return fmt.Errorf("unexpected status code: %d, error reading response body: %w", resp.StatusCode, readErr)
}
return fmt.Errorf("unexpected status code: %d, response body: %s", resp.StatusCode, responseBody)
}
return nil
}
Expand Down