Skip to content

Commit 9d0d78d

Browse files
author
David Noble
committed
testlib.SDKTestCase.teardown now ignores complaints about not being able to delete apps because these are likely spurious errors on Windows.
I've never hit this issue on Linux or OS X and this change eliminates numerous false alarms on Windows.
1 parent 567ef17 commit 9d0d78d

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

examples/searchcommands_app/setup.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,17 @@ def run(self):
207207
commands_conf = os.path.join(self.build_dir, 'default', 'commands.conf')
208208
source = os.path.join(self.build_dir, 'default', 'commands-scpv{}.conf'.format(self.scp_version))
209209

210-
if os.path.exists(commands_conf) or os.path.islink(commands_conf):
210+
if os.path.exists(commands_conf) and os.path.islink(commands_conf):
211211
os.remove(commands_conf)
212+
else:
213+
try:
214+
os.path.islink(commands_conf)
215+
except OSError:
216+
pass
217+
else:
218+
os.remove(commands_conf)
212219

213220
os.symlink(source, commands_conf)
214-
215221
self._make_archive()
216222
return
217223

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Traceback (most recent call last):
2+
File "custom_search/bin/usercount.py", line 182, in <module>
3+
main(sys.argv)
4+
File "custom_search/bin/usercount.py", line 149, in main
5+
buf, settings = read_input(stdin_wrapper, has_header = True)
6+
File "custom_search/bin/usercount.py", line 109, in read_input
7+
line = buf.readline()
8+
File "custom_search/bin/usercount.py", line 58, in readline
9+
raise StopIteration
10+
StopIteration
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2015-09-21 17:55:28,246, Level=ERROR, Pid=1768, File=search_command.py, Line=962, RuntimeError at "../splunklib\searchcommands\search_command.py", line 601 : Command test appears to be statically configured for search command protocol version 1 and static configuration is unsupported by splunklib.searchcommands. Please ensure that default/commands.conf contains this stanza:
2+
[test]
3+
filename = test.py
4+
enableheader = true
5+
outputheader = true
6+
requires_srinfo = true
7+
supports_getinfo = true
8+
supports_multivalues = true
9+
supports_rawargs = true
10+
Traceback:
11+
File "../splunklib\searchcommands\search_command.py", line 601, in _process_protocol_v1
12+
raise RuntimeError(message)
13+
14+
2015-09-21 17:55:28,253, Level=ERROR, Pid=1768, File=search_command.py, Line=962, RuntimeError at "C:\Users\Administrator\Workspace.private\splunk-sdks\splunk-sdk-python\tests\searchcommands\test_search_command.py", line 87 : Testing
15+
Traceback:
16+
File "../splunklib\searchcommands\search_command.py", line 586, in _process_protocol_v1
17+
self._execute(ifile, None)
18+
File "../splunklib\searchcommands\streaming_command.py", line 54, in _execute
19+
SearchCommand._execute(self, ifile, self.stream)
20+
File "../splunklib\searchcommands\search_command.py", line 830, in _execute
21+
self._record_writer.write_records(process(self._records(ifile)))
22+
File "../splunklib\searchcommands\internals.py", line 515, in write_records
23+
for record in records:
24+
File "C:\Users\Administrator\Workspace.private\splunk-sdks\splunk-sdk-python\tests\searchcommands\test_search_command.py", line 87, in stream
25+
raise RuntimeError('Testing')
26+
27+
2015-09-21 17:55:28,256, Level=ERROR, Pid=1768, File=search_command.py, Line=962, RuntimeError at "../splunklib\searchcommands\search_command.py", line 864 : Failed to parse metadata of length 1382: Invalid \escape: line 1 column 186 (char 185)
28+
Traceback:
29+
File "../splunklib\searchcommands\search_command.py", line 641, in _process_protocol_v2
30+
metadata, body = self._read_chunk(ifile)
31+
File "../splunklib\searchcommands\search_command.py", line 864, in _read_chunk
32+
raise RuntimeError('Failed to parse metadata of length {}: {}'.format(metadata_length, error))
33+

tests/testlib.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def setUp(self):
246246
logging.debug("Connected to splunkd version %s", '.'.join(str(x) for x in self.service.splunk_version))
247247

248248
def tearDown(self):
249-
from urllib2 import HTTPError
249+
from splunklib.binding import HTTPError
250250

251251
if self.service.restart_required:
252252
self.fail("Test left Splunk in a state requiring a restart.")
@@ -255,10 +255,10 @@ def tearDown(self):
255255
if appName in self.service.apps:
256256
try:
257257
self.service.apps.delete(appName)
258+
wait(lambda: appName not in self.service.apps)
258259
except HTTPError as error:
259-
print error
260-
pass
261-
wait(lambda: appName not in self.service.apps)
262-
260+
if error.status != 500:
261+
raise
262+
print 'Ignoring teardown error because it is likely spurious: {}'.format(error)
263263
if self.service.restart_required:
264264
self.clear_restart_message()

0 commit comments

Comments
 (0)