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

Move http_endpoint input to v2 input API #19815

Merged
merged 4 commits into from
Jul 14, 2020

Conversation

urso
Copy link

@urso urso commented Jul 9, 2020

  • Refactoring

What does this PR do?

Update the http_endpoint input to be based on the v2 input API.

This change unexports most symbols and splits the HttpEndpoint into a httpEndpoint (config handling and server run), httpHandler, and a validator type.

The server used to set up a timeout of 10s, based on the period of the Run method gets called. With the v2 API the Run method must block until shutdown or on fatal error. We keep the server alive now.

The json object parsing is local to the handler method only now and not stored in the HTTPEndpoint anymore. This fixes a potential bug with events not getting published or duplicated if multiple clients are served concurrently.

The config validation for the authentication configuration was done in the validation step. This has been moved to config.Validate to stop the initialization process early if an invalid configuration has been provided.

Note: I mostly moved code around. The input still needs more attention (in follow up PRs) regarding testing, and code documentation. All in all the changes should not be user visible.

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.

How to test this PR locally

configure the http_endpoint input and send JSON objects via curl. The objects should be visible in the beats output.

Related issues

@urso urso added review Filebeat Filebeat needs_backport PR is waiting to be backported to other branches. Team:Integrations Label for the Integrations team labels Jul 9, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 9, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 9, 2020

💔 Build Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #19815 updated]

  • Start Time: 2020-07-13T22:44:46.694+0000

  • Duration: 34 min 29 sec

Test stats 🧪

Test Results
Failed 0
Passed 1671
Skipped 384
Total 2055

Steps errors

Expand to view the steps failures

  • Name: Mage update build test
    • Description: mage update build test

    • Duration: 6 min 33 sec

    • Start Time: 2020-07-13T23:07:21.258+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-07-13T23:12:55.824Z] Stashed 2 file(s)
[2020-07-13T23:12:55.834Z] Archiving artifacts
[2020-07-13T23:12:56.439Z] + curl -sSLo codecov https://codecov.io/bash
[2020-07-13T23:12:56.701Z] + FILE=auditbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f auditbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=filebeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f filebeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=heartbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f heartbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=libbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f libbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=metricbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f metricbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=packetbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f packetbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=winlogbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f winlogbeat/build/coverage/full.cov ]
[2020-07-13T23:12:56.701Z] + FILE=journalbeat/build/coverage/full.cov
[2020-07-13T23:12:56.701Z] + [ -f journalbeat/build/coverage/full.cov ]
[2020-07-13T23:12:58.370Z] Failed in branch Filebeat x-pack
[2020-07-13T23:13:28.515Z] >> build: Building filebeat
[2020-07-13T23:15:35.055Z] >> go test: Unit Testing
[2020-07-13T23:17:11.555Z] SUMMARY:
[2020-07-13T23:17:11.555Z]   Fail:     0
[2020-07-13T23:17:11.555Z]   Skip:     7
[2020-07-13T23:17:11.555Z]   Pass:     545
[2020-07-13T23:17:11.555Z]   Packages: 20
[2020-07-13T23:17:11.555Z]   Duration: 1m34.3271817s
[2020-07-13T23:17:11.555Z]   Coverage Report: C:\Users\jenkins\workspace\Beats_beats_PR-19815\src\github.com\elastic\beats\x-pack\filebeat\build\TEST-go-unit.html
[2020-07-13T23:17:11.555Z]   JUnit Report:    C:\Users\jenkins\workspace\Beats_beats_PR-19815\src\github.com\elastic\beats\x-pack\filebeat\build\TEST-go-unit.xml
[2020-07-13T23:17:11.555Z]   Output File:     C:\Users\jenkins\workspace\Beats_beats_PR-19815\src\github.com\elastic\beats\x-pack\filebeat\build\TEST-go-unit.out
[2020-07-13T23:17:11.555Z] >> go test: Unit Test Passed
[2020-07-13T23:17:26.473Z] >> python test: Unit Testing
[2020-07-13T23:17:41.366Z] WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
[2020-07-13T23:17:41.366Z] You should consider upgrading via the 'python -m pip install --upgrade pip' command.
[2020-07-13T23:18:49.082Z] WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
[2020-07-13T23:18:49.083Z] You should consider upgrading via the 'python -m pip install --upgrade pip' command.
[2020-07-13T23:18:49.083Z] .......SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
[2020-07-13T23:18:49.083Z] [success] 19.81% test_http_endpoint.Test.test_http_endpoint_request: 0.8222s
[2020-07-13T23:18:49.083Z] [success] 15.55% test_http_endpoint.Test.test_http_endpoint_empty_body: 0.6455s
[2020-07-13T23:18:49.083Z] [success] 14.95% test_http_endpoint.Test.test_http_endpoint_wrong_content_header: 0.6204s
[2020-07-13T23:18:49.083Z] [success] 14.73% test_http_endpoint.Test.test_http_endpoint_get_request: 0.6113s
[2020-07-13T23:18:49.083Z] [success] 14.64% test_http_endpoint.Test.test_http_endpoint_malformed_json: 0.6077s
[2020-07-13T23:18:49.083Z] [success] 14.23% test_http_endpoint.Test.test_http_endpoint_wrong_auth_value: 0.5903s
[2020-07-13T23:18:49.083Z] [success] 6.08% test_http_endpoint.Test.test_http_endpoint_missing_auth_value: 0.2523s
[2020-07-13T23:18:49.083Z] ----------------------------------------------------------------------
[2020-07-13T23:18:49.083Z] Ran 128 tests in 4.183s
[2020-07-13T23:18:49.083Z] 
[2020-07-13T23:18:49.083Z] OK (SKIP=121)
[2020-07-13T23:18:49.083Z] >> python test: Unit Testing Complete
[2020-07-13T23:18:49.162Z] Recording test results
[2020-07-13T23:18:52.572Z] Stashed 2 file(s)
[2020-07-13T23:18:52.584Z] Archiving artifacts
[2020-07-13T23:18:55.213Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats
[2020-07-13T23:18:55.529Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-07-13T23:18:55.542Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats/Lint
[2020-07-13T23:18:55.640Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats/Filebeat-x-pack-Mac-OS-X
[2020-07-13T23:18:55.730Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats/Filebeat-x-pack
[2020-07-13T23:18:55.820Z] Running in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-07-13T23:18:56.196Z] + cat
[2020-07-13T23:18:56.196Z] + /usr/local/bin/runbld ./runbld-script
[2020-07-13T23:18:56.196Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-07-13T23:19:02.797Z] runbld>>> runbld started
[2020-07-13T23:19:02.797Z] runbld>>> 1.6.12/f45d832f2ba0aa2722ab4ec1fda8ad140f027f8b
[2020-07-13T23:19:04.190Z] runbld>>> The following profiles matched the job 'Beats/beats/PR-19815' in order of occurrence in the config (last value wins).
[2020-07-13T23:19:05.583Z] runbld>>> Debug logging enabled.
[2020-07-13T23:19:05.583Z] runbld>>> Storing result
[2020-07-13T23:19:05.583Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-07-13T23:19:05.583Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200713231905-12BB2F2B
[2020-07-13T23:19:05.583Z] runbld>>> Adding system facts.
[2020-07-13T23:19:06.535Z] runbld>>> Adding vcs info for the latest commit:  80a4fc31aa15820e94e140aea653a51a503c6c45
[2020-07-13T23:19:06.535Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-07-13T23:19:06.535Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-07-13T23:19:06.535Z] + echo 'Processing JUnit reports with runbld...'
[2020-07-13T23:19:06.535Z] Processing JUnit reports with runbld...
[2020-07-13T23:19:06.802Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-07-13T23:19:06.802Z] runbld>>> DURATION: 29ms
[2020-07-13T23:19:06.802Z] runbld>>> STDOUT: 40 bytes
[2020-07-13T23:19:06.802Z] runbld>>> STDERR: 49 bytes
[2020-07-13T23:19:06.802Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-07-13T23:19:06.802Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats
[2020-07-13T23:19:07.757Z] runbld>>> Storing build metadata: 
[2020-07-13T23:19:07.757Z] runbld>>> Adding test report.
[2020-07-13T23:19:07.757Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats_PR-19815/src/github.com/elastic/beats
[2020-07-13T23:19:08.703Z] runbld>>> Found 6 test output files
[2020-07-13T23:19:09.276Z] runbld>>> Test output logs contained: Errors: 0 Failures: 0 Tests: 2055 Skipped: 363
[2020-07-13T23:19:09.276Z] runbld>>> Storing result
[2020-07-13T23:19:09.276Z] runbld>>> FAILURES: 0
[2020-07-13T23:19:09.538Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-07-13T23:19:09.538Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200713231905-12BB2F2B
[2020-07-13T23:19:09.799Z] runbld>>> Email notification disabled by environment variable.
[2020-07-13T23:19:09.799Z] runbld>>> Slack notification disabled by environment variable.
[2020-07-13T23:19:15.370Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats_PR-19815
[2020-07-13T23:19:15.491Z] [INFO] getVaultSecret: Getting secrets
[2020-07-13T23:19:15.580Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-07-13T23:19:16.414Z] + chmod 755 generate-build-data.sh
[2020-07-13T23:19:16.414Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-19815/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-19815/runs/2 FAILURE 2069461
[2020-07-13T23:19:16.414Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-19815/runs/2/steps/?limit=10000 -o steps-info.json
[2020-07-13T23:19:16.965Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-19815/runs/2/tests/?status=FAILED -o tests-errors.json
[2020-07-13T23:19:16.965Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats/PR-19815/runs/2/log/ -o pipeline-log.txt

@urso urso merged commit 542a4af into elastic:master Jul 14, 2020
@urso urso deleted the filebeat-httpendpoint-v2 branch July 14, 2020 13:26
@urso urso added v7.9.0 and removed needs_backport PR is waiting to be backported to other branches. labels Jul 14, 2020
urso pushed a commit to urso/beats that referenced this pull request Jul 14, 2020
@urso urso added the test-plan Add this PR to be manual test plan label Jul 14, 2020
@andresrc andresrc added the test-plan-added This PR has been added to the test plan label Jul 21, 2020
melchiormoulin pushed a commit to melchiormoulin/beats that referenced this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Filebeat Filebeat review Team:Integrations Label for the Integrations team test-plan Add this PR to be manual test plan test-plan-added This PR has been added to the test plan v7.9.0 [zube]: Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants