Skip to content

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Feb 25, 2025

Closes #2378

This PR includes new system test settings to allow for different conditions when waiting for the required/needed documents to be ingested into the data stream.

Three new settings have been added:

  • assert.min_count: minimum number of documents to be ingested in the data stream.
    • this could be useful in packages that send metrics from a service and there is no upper limit of docs to be ingested.
  • assert.fields_present: list of fields that must be present in any document of the given data stream.
    • this could be useful for debugging to wait for a specific field that could be sent at the end.
  • assert.ingestion_idle_time: minimum period of time that the data stream should not have any new document ingested.

Examples of the elastic-package output when these settings are defined:

  • assert.ingestion_idle_time: 20s:
2025/02/25 13:31:34 DEBUG found 0 hits in logs-system_test_assert_conditions.test-26419 data stream 2025/02/25 13:31:35 DEBUG found 100 hits in logs-system_test_assert_conditions.test-26419 data stream ... 2025/02/25 13:31:56 DEBUG found 100 hits in logs-system_test_assert_conditions.test-26419 data stream 2025/02/25 13:31:56 DEBUG No new documents ingested in 20s 
  • assert.fields_present: [target.file, target.expected, target.finish]:
2025/02/25 13:33:34 DEBUG found 0 hits in logs-system_test_assert_conditions.test-50949 data stream 2025/02/25 13:33:35 DEBUG found 450 hits in logs-system_test_assert_conditions.test-50949 data stream 2025/02/25 13:33:35 DEBUG > Found field "target.file" in hits 2025/02/25 13:33:35 DEBUG > Found field "target.expected" in hits 2025/02/25 13:33:35 DEBUG Not found field "target.finish" in hits 2025/02/25 13:33:36 DEBUG found 492 hits in logs-system_test_assert_conditions.test-50949 data stream 2025/02/25 13:33:36 DEBUG > Found field "target.finish" in hits 
  • assert.min_count: 50:
2025/02/25 13:32:42 DEBUG checking for expected data in data stream (10m0s)... 2025/02/25 13:32:42 DEBUG found 0 hits in logs-system_test_assert_conditions.test-82487 data stream 2025/02/25 13:32:43 DEBUG found 0 hits in logs-system_test_assert_conditions.test-82487 data stream 2025/02/25 13:32:44 DEBUG found 0 hits in logs-system_test_assert_conditions.test-82487 data stream 2025/02/25 13:32:45 DEBUG found 100 hits in logs-system_test_assert_conditions.test-82487 data stream 2025/02/25 13:32:45 DEBUG Found 0 deprecation warnings for data stream logs-system_test_assert_conditions 

Moreover, these settings can be defined simultaneously. For instance:

assert: min_count: 50 fields_present: - field.expected - field.foo

In that example, the validation performed by the system test will only run after at least 50 documents have been ingested into the specified data stream, and the two designated fields are prsent in any of the ingested documents.

Author's checklist

  • Add test package
  • Add documentation

How to test this PR locally

elastic-package stack up -v -d cd test/packages/other/system_test_assert_conditions # Update system test configuration files as needed: # - "data_stream/test/_dev/test/system/test-fields_present-config.yml" # - "data_stream/test/_dev/test/system/test-min_count-config.yml" elastic-package test system -v elastic-package stack down -v
@mrodm mrodm self-assigned this Feb 25, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to keep this package under the other folder? or should we move it to the parallel folder?
At least, this package requires to spin up an Elastic Agent to read the logs. Should we just add packages that their tests are run fast in other?

@mrodm mrodm changed the title [system tests] Add new settings to wait for documents being ingested - WIP [system tests] Add new settings to wait for documents being ingested Feb 25, 2025
@mrodm mrodm marked this pull request as ready for review February 25, 2025 18:06
@mrodm
Copy link
Contributor Author

mrodm commented Feb 26, 2025

Depends on #2433

@mrodm
Copy link
Contributor Author

mrodm commented Feb 26, 2025

test integrations

@elastic-vault-github-plugin-prod

Created or updated PR in integrations repository to test this version. Check elastic/integrations#12900

@mrodm mrodm requested a review from jsoriano February 26, 2025 15:50
@mrodm
Copy link
Contributor Author

mrodm commented Feb 26, 2025

/test

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Nice! Added some small suggestions, but feel free to merge.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit 06f0778 into elastic:main Feb 27, 2025
3 checks passed
@mrodm mrodm deleted the add-min-count-config-system-tests branch February 27, 2025 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants