-
Notifications
You must be signed in to change notification settings - Fork 380
Performance improvement for updating or deleting input #247
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -463,6 +463,13 @@ def info(self): | |
response = self.get("/services/server/info") | ||
return _filter_content(_load_atom(response, MATCH_ENTRY_CONTENT)) | ||
|
||
def input(self, path, kind=None): | ||
"""Retrieves an input by path, and optionally kind. | ||
|
||
:return: A :class:`Input` object. | ||
""" | ||
return Input(self, path, kind=kind).refresh() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking Personal Opinion: I like to see these operations broken down atomically because it makes things easier to debug.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair, I'm just following the style I used for |
||
|
||
@property | ||
def inputs(self): | ||
"""Returns the collection of inputs configured on this Splunk instance. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ | |
from __future__ import absolute_import | ||
from __future__ import print_function | ||
|
||
import unittest2 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch |
||
from splunklib.binding import HTTPError | ||
|
||
from tests import testlib | ||
|
@@ -30,6 +28,7 @@ | |
|
||
import splunklib.client as client | ||
|
||
|
||
def highest_port(service, base_port, *kinds): | ||
"""Find the first port >= base_port not in use by any input in kinds.""" | ||
highest_port = base_port | ||
|
@@ -38,6 +37,7 @@ def highest_port(service, base_port, *kinds): | |
highest_port = max(port, highest_port) | ||
return highest_port | ||
|
||
|
||
class TestTcpInputNameHandling(testlib.SDKTestCase): | ||
def setUp(self): | ||
super(TestTcpInputNameHandling, self).setUp() | ||
|
@@ -116,6 +116,7 @@ def test_update_restrictToHost_fails(self): | |
lambda: boris.update(restrictToHost='hilda') | ||
) | ||
|
||
|
||
class TestRead(testlib.SDKTestCase): | ||
def test_read(self): | ||
inputs = self.service.inputs | ||
|
@@ -188,6 +189,7 @@ def test_oneshot_on_nonexistant_file(self): | |
self.assertRaises(HTTPError, | ||
self.service.inputs.oneshot, name) | ||
|
||
|
||
class TestInput(testlib.SDKTestCase): | ||
def setUp(self): | ||
super(TestInput, self).setUp() | ||
|
@@ -243,7 +245,6 @@ def test_lists_modular_inputs(self): | |
input = inputs['abcd', 'test2'] | ||
self.assertEqual(input.field1, 'boris') | ||
|
||
|
||
def test_create(self): | ||
inputs = self.service.inputs | ||
for entity in six.itervalues(self._test_entities): | ||
|
@@ -264,6 +265,13 @@ def test_read(self): | |
self.assertEqual(this_entity.name, read_entity.name) | ||
self.assertEqual(this_entity.host, read_entity.host) | ||
|
||
def test_read_indiviually(self): | ||
tcp_input = self.service.input(self._test_entities['tcp'].path, | ||
self._test_entities['tcp'].kind) | ||
self.assertIsNotNone(tcp_input) | ||
self.assertTrue('tcp', tcp_input.kind) | ||
self.assertTrue(self._test_entities['tcp'].name, tcp_input.name) | ||
|
||
def test_update(self): | ||
inputs = self.service.inputs | ||
for entity in six.itervalues(self._test_entities): | ||
|
@@ -273,7 +281,7 @@ def test_update(self): | |
entity.refresh() | ||
self.assertEqual(entity.host, kwargs['host']) | ||
|
||
@unittest2.skip('flaky') | ||
@unittest.skip('flaky') | ||
def test_delete(self): | ||
inputs = self.service.inputs | ||
remaining = len(self._test_entities)-1 | ||
|
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 a big deal, but should we follow Go style practices of adding a new prefix to the declaration?
Like this
def new_input(self, path, kind=None):
.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 if we want consistency, so I'm going to say let's not do that here