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

[Filebeat][httpjson] Fix date_cursor validation #21756

Merged
merged 2 commits into from
Oct 15, 2020

Conversation

marc-gr
Copy link
Contributor

@marc-gr marc-gr commented Oct 13, 2020

What does this PR do?

It fixes the httpjson date_cursor config validation by using a fixed date for format validation.

Why is it important?

Before now was used as the date to validate the format against, some formats (like the one used in the tests, which caused a new failing test recently #21748) depending on the current date, would fail or not, causing flaky validation outputs.

Checklist

  • My code follows the style guidelines of this project
  • 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 tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@marc-gr marc-gr added bug Filebeat Filebeat needs_backport PR is waiting to be backported to other branches. flaky-test Unstable or unreliable test cases. labels Oct 13, 2020
@marc-gr marc-gr requested a review from a team October 13, 2020 15:23
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/siem (Team:SIEM)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 13, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 13, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #21756 updated]

  • Start Time: 2020-10-14T07:34:50.668+0000

  • Duration: 66 min 46 sec

Test stats 🧪

Test Results
Failed 0
Passed 1947
Skipped 259
Total 2206


const knownTimestamp = 1602601228 // 2020-10-13T15:00:28+00:00 RFC3339

// if we can't get back the same date from Format than from Parse
Copy link
Member

Choose a reason for hiding this comment

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

Is there a requirement for the format to include seconds? Without seconds in the format this test won't pass, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, and the same applies for any other element of the date since we can't know the intent of the format. I changed it to just check for parse errors instead, just as a sanity check. Since now it is against a known date we can trigger a parse error from the tests.

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM. I think the docs may be missing some of the new cursor options for HTTP JSON.

@marc-gr marc-gr merged commit 471df0b into elastic:master Oct 15, 2020
@marc-gr marc-gr deleted the fix-flaky-httpjson-test branch October 15, 2020 07:53
@marc-gr marc-gr removed the needs_backport PR is waiting to be backported to other branches. label Oct 15, 2020
marc-gr added a commit to marc-gr/beats that referenced this pull request Oct 15, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
marc-gr added a commit to marc-gr/beats that referenced this pull request Oct 15, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
v1v added a commit to v1v/beats that referenced this pull request Oct 15, 2020
* upstream/master: (29 commits)
  [CI] Enable build stage for arm architecture (elastic#21284)
  [BUILD][CI] fetch dependencies with retry (elastic#21614)
  Add proxy metricset (elastic#21751)
  [Filebeat][httpjson] Fix date_cursor validation (elastic#21756)
  Update endpoint-related terminology in Elastic Agent docs (elastic#21458)
  Move s3_daily_storage and s3_request metricsets to use cloudwatch input (elastic#21703)
  [Agent] Remove heartbeat from bundled beats in agent. (elastic#21602)
  [Elastic Agent] Don't perform install until after enroll (elastic#21772)
  [Elastic Agent] Update path from policy change for Kibana connection. (elastic#21804)
  Change cloud.provider from googlecloud to gcp (elastic#21775)
  Fix stress test package list (elastic#21719)
  [Elastic Agent] Remove the service installer scripts from packaging (elastic#21694)
  [CI] Support Windows-2012 in pipeline 2.0 (elastic#21338)
  Fix non-windows fields on system/filesystem (elastic#21758)
  disable TestReceiveEventsAndMetadata/TestSocketCleanup/TestReceiveNewEventsConcurrently in Windows (elastic#21750)
  Use badger code from upstream repository (elastic#21705)
  Disable writes sync in persistent cache (elastic#21754)
  Make API address and Shard ID required in Cloud Foundry settings (elastic#21759)
  [CI] Support skip-ci label (elastic#21377)
  Increase recommended memory when deploying in Cloud foundry (elastic#21755)
  ...
v1v added a commit to v1v/beats that referenced this pull request Oct 15, 2020
* upstream/master: (216 commits)
  [CI] Enable build stage for arm architecture (elastic#21284)
  [BUILD][CI] fetch dependencies with retry (elastic#21614)
  Add proxy metricset (elastic#21751)
  [Filebeat][httpjson] Fix date_cursor validation (elastic#21756)
  Update endpoint-related terminology in Elastic Agent docs (elastic#21458)
  Move s3_daily_storage and s3_request metricsets to use cloudwatch input (elastic#21703)
  [Agent] Remove heartbeat from bundled beats in agent. (elastic#21602)
  [Elastic Agent] Don't perform install until after enroll (elastic#21772)
  [Elastic Agent] Update path from policy change for Kibana connection. (elastic#21804)
  Change cloud.provider from googlecloud to gcp (elastic#21775)
  Fix stress test package list (elastic#21719)
  [Elastic Agent] Remove the service installer scripts from packaging (elastic#21694)
  [CI] Support Windows-2012 in pipeline 2.0 (elastic#21338)
  Fix non-windows fields on system/filesystem (elastic#21758)
  disable TestReceiveEventsAndMetadata/TestSocketCleanup/TestReceiveNewEventsConcurrently in Windows (elastic#21750)
  Use badger code from upstream repository (elastic#21705)
  Disable writes sync in persistent cache (elastic#21754)
  Make API address and Shard ID required in Cloud Foundry settings (elastic#21759)
  [CI] Support skip-ci label (elastic#21377)
  Increase recommended memory when deploying in Cloud foundry (elastic#21755)
  ...
v1v added a commit to v1v/beats that referenced this pull request Oct 15, 2020
* upstream/master: (156 commits)
  [CI] Enable build stage for arm architecture (elastic#21284)
  [BUILD][CI] fetch dependencies with retry (elastic#21614)
  Add proxy metricset (elastic#21751)
  [Filebeat][httpjson] Fix date_cursor validation (elastic#21756)
  Update endpoint-related terminology in Elastic Agent docs (elastic#21458)
  Move s3_daily_storage and s3_request metricsets to use cloudwatch input (elastic#21703)
  [Agent] Remove heartbeat from bundled beats in agent. (elastic#21602)
  [Elastic Agent] Don't perform install until after enroll (elastic#21772)
  [Elastic Agent] Update path from policy change for Kibana connection. (elastic#21804)
  Change cloud.provider from googlecloud to gcp (elastic#21775)
  Fix stress test package list (elastic#21719)
  [Elastic Agent] Remove the service installer scripts from packaging (elastic#21694)
  [CI] Support Windows-2012 in pipeline 2.0 (elastic#21338)
  Fix non-windows fields on system/filesystem (elastic#21758)
  disable TestReceiveEventsAndMetadata/TestSocketCleanup/TestReceiveNewEventsConcurrently in Windows (elastic#21750)
  Use badger code from upstream repository (elastic#21705)
  Disable writes sync in persistent cache (elastic#21754)
  Make API address and Shard ID required in Cloud Foundry settings (elastic#21759)
  [CI] Support skip-ci label (elastic#21377)
  Increase recommended memory when deploying in Cloud foundry (elastic#21755)
  ...
v1v added a commit to v1v/beats that referenced this pull request Oct 15, 2020
* upstream/master: (156 commits)
  [CI] Enable build stage for arm architecture (elastic#21284)
  [BUILD][CI] fetch dependencies with retry (elastic#21614)
  Add proxy metricset (elastic#21751)
  [Filebeat][httpjson] Fix date_cursor validation (elastic#21756)
  Update endpoint-related terminology in Elastic Agent docs (elastic#21458)
  Move s3_daily_storage and s3_request metricsets to use cloudwatch input (elastic#21703)
  [Agent] Remove heartbeat from bundled beats in agent. (elastic#21602)
  [Elastic Agent] Don't perform install until after enroll (elastic#21772)
  [Elastic Agent] Update path from policy change for Kibana connection. (elastic#21804)
  Change cloud.provider from googlecloud to gcp (elastic#21775)
  Fix stress test package list (elastic#21719)
  [Elastic Agent] Remove the service installer scripts from packaging (elastic#21694)
  [CI] Support Windows-2012 in pipeline 2.0 (elastic#21338)
  Fix non-windows fields on system/filesystem (elastic#21758)
  disable TestReceiveEventsAndMetadata/TestSocketCleanup/TestReceiveNewEventsConcurrently in Windows (elastic#21750)
  Use badger code from upstream repository (elastic#21705)
  Disable writes sync in persistent cache (elastic#21754)
  Make API address and Shard ID required in Cloud Foundry settings (elastic#21759)
  [CI] Support skip-ci label (elastic#21377)
  Increase recommended memory when deploying in Cloud foundry (elastic#21755)
  ...
marc-gr added a commit that referenced this pull request Oct 16, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
marc-gr added a commit that referenced this pull request Oct 16, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
@jsoriano
Copy link
Member

Hey @marc-gr, thanks for fixing this. These tests seem to be flaky in 7.9 branch too, could you please backport the change to this branch?

@marc-gr marc-gr added the v7.9.3 label Oct 19, 2020
marc-gr added a commit to marc-gr/beats that referenced this pull request Oct 19, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
marc-gr added a commit that referenced this pull request Oct 19, 2020
* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 471df0b)
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…tic#21982)

* Fix date_cursor validation

* Only check for parse errors

(cherry picked from commit 15251d4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Filebeat Filebeat flaky-test Unstable or unreliable test cases. v7.9.3 v7.10.0 v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test TestConfigOauth2Validation/date_cursor.date_format_will_fail_if_invalid
4 participants