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

Cherry-pick #19815 to 7.x: Move http_endpoint input to v2 input API #19891

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

urso
Copy link

@urso urso commented Jul 14, 2020

Cherry-pick of PR #19815 to 7.x branch. Original message:

  • 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 [zube]: In Review backport Team:Services (Deprecated) Label for the former Integrations-Services team labels Jul 14, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@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 14, 2020
@@ -193,7 +184,7 @@ def test_http_endpoint_get_request(self):
payload = {self.prefix: message}
headers = {"Content-Type": "application/json", "Accept": "application/json"}
r = requests.get(self.url, headers=headers, data=json.dumps(payload))

print("response:", r.status_code, r.text)
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is just a debug print which does not belong here. Do you mind removing it from master as well?

Copy link
Author

Choose a reason for hiding this comment

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

it belongs here. nosetest supresses output by default, but if the test fails (or if you enable verbose mode) then everything you printed will be displayed in the context of the test. The 'log' is here to give you a hint why the assert did fail. using assert in python tests just tells you where it did fail, not why.

Copy link
Contributor

@kvch kvch left a comment

Choose a reason for hiding this comment

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

Minor comment, otherwise fine. I approve this PR so you can merge it whenever you are ready.

@urso urso merged commit e2924ae into elastic:7.x Jul 14, 2020
@urso urso deleted the backport_19815_7.x branch July 14, 2020 16:21
@zube zube bot added [zube]: Done and removed [zube]: Inbox labels Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Services (Deprecated) Label for the former Integrations-Services team [zube]: Done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants