-
Notifications
You must be signed in to change notification settings - Fork 4.9k
metricbeat: add integration TestIndexTotalFieldsLimitNotReached #41698
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
metricbeat: add integration TestIndexTotalFieldsLimitNotReached #41698
Conversation
779abce
to
b9722e4
Compare
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
b9722e4
to
5fa28a7
Compare
The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested.
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
5fa28a7
to
df48d3b
Compare
"-E", "output.file.enabled=false") | ||
procState, err := metricbeat.Process.Wait() | ||
require.NoError(t, err, "metricbeat setup failed") | ||
require.Equal(t, 0, procState.ExitCode(), "metircbeat setup failed: incorrect exit code") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Equal(t, 0, procState.ExitCode(), "metircbeat setup failed: incorrect exit code") | |
require.Equal(t, 0, procState.ExitCode(), "metricbeat setup failed: incorrect exit code") |
require.NoError(t, err, "could not send request to send event to ES") | ||
defer resp.Body.Close() | ||
|
||
failuremsg := fmt.Sprintf("filed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the envent was not ingested", totalFields, index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failuremsg := fmt.Sprintf("filed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the envent was not ingested", totalFields, index) | |
failuremsg := fmt.Sprintf("failed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the event was not ingested", totalFields, index) |
defer resp.Body.Close() | ||
|
||
failuremsg := fmt.Sprintf("filed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the envent was not ingested", totalFields, index) | ||
if !assert.Equal(t, http.StatusCreated, resp.StatusCode, failuremsg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use assert.NotEqual here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really. I want to assert it's equal, if the assertion fails, then the extra code runs to help to explain what went wrong
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
defer cancel() | ||
|
||
r, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint, bytes.NewBuffer(event)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall seeing tests that need to interact with Elasticsearch that use the libbeat es client. I think this is preferable to avoid code duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Left some comments, but overall the test seems correct to me.
The linter error seems to be the same one that Lee faced this week, caused by an old version of golangci-lint.
_, _, err = integration.HttpDo(t, http.MethodDelete, templateURL) | ||
require.NoErrorf(t, err, "cleanup failed: could not remove index template %s", index) | ||
_, _, err = integration.HttpDo(t, http.MethodDelete, policyURL) | ||
require.NoErrorf(t, err, "cleanup failed: could not ilm policy %s", index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
require.NoErrorf(t, err, "cleanup failed: could not ilm policy %s", index) | |
require.NoErrorf(t, err, "cleanup failed: could not remove ilm policy %s", index) |
// ensure datastream/index template/ ilm policy is set before running the test | ||
cleanUpES() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
You're removing them all, however you wrote about ensuring they're set... I'm confused on what you're trying to accomplish here.
"-E", "setup.kibana.port="+kURL.Port(), | ||
"-E", "output.elasticsearch.protocol=http", | ||
"-E", "output.elasticsearch.hosts=['"+esURL.String()+"']", | ||
"-E", "output.file.enabled=false") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to set the file output to false?
"-E", "output.file.enabled=false") |
"-E", "output.file.enabled=false") | ||
procState, err := metricbeat.Process.Wait() | ||
require.NoError(t, err, "metricbeat setup failed") | ||
require.Equal(t, 0, procState.ExitCode(), "metricbeat setup failed: incorrect exit code") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion]
Add the exit code to the error message.
require.Equal(t, 0, procState.ExitCode(), "metricbeat setup failed: incorrect exit code") | |
require.Equalf(t, 0, procState.ExitCode(), "metricbeat setup failed: incorrect exit code: %d", procState.ExitCode()) |
Just to confirm, if you revert #41640 this test fails immediately? |
require.NoError(t, err, "could not send request to send event to ES") | ||
defer resp.Body.Close() | ||
|
||
failuremsg := fmt.Sprintf("failed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the event was not ingested", totalFields, index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failuremsg := fmt.Sprintf("failed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to be reached. Check the logs to see why the event was not ingested", totalFields, index) | |
failuremsg := fmt.Sprintf("failed to ingest events with %d new fields. If this test fails it likely means the current `index.mapping.total_fields.limit` for metricbeat index (%s) is close to being reached. Check the logs to see why the event was not ingested", totalFields, index) |
The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a)
The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a)
The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a)
"github.com/elastic/beats/v7/libbeat/version" | ||
) | ||
|
||
func TestIndexTotalFieldsLimitNotReached(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add some explicit documentation for why this test exists and that it is a regression test for #41614 specifically.
This test is likely to fail for seemingly unrelated changes so let's go overboard with documenting the problem it is detecting.
I see this was answered in the description reading it again 👍 |
The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a)
…tic#41698) The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested.
…) (#41757) The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a) Co-authored-by: Anderson Queiroz <[email protected]>
…) (#41758) The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a) Co-authored-by: Anderson Queiroz <[email protected]>
…) (#41759) The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a) Co-authored-by: Anderson Queiroz <[email protected]>
…) (#41768) The new integration test TestIndexTotalFieldsLimitNotReached ensures events with at least 500 new dynamically mapped fields can be ingested. (cherry picked from commit 8a2724a) Co-authored-by: Anderson Queiroz <[email protected]>
Proposed commit message
This new test will start failing when the metricbeat mapping has increased to the point it isn't possible to add a new event with 500 dynamically mapped fields. It should act as a safe guard to prevent us from releasing a version where the static mapping is too close to the total fields limit.
Checklist
[ ] I have commented my code, particularly in hard-to-understand areas[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry inCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
How to test this PR locally
x-pack/metricbeat
cd x-pack/metricbeat
go build .
metricbeat.yml
to point to your stack and make sure to includesetup.kibana.host
./metricbeat setup
index.mapping.total_fields.limit
for the metricbeat index template:your-kibna/app/management/data/index_management/templates/metricbeat-9.0.0
metricbeat-9.0.0
> Manage > Edit > 3 Index settingsindex.mapping.total_fields.limit
to 10000:Related issues