Additional riak functions

This commit is contained in:
Damian Myerscough 2015-06-10 22:14:03 -07:00
parent ea57845361
commit 7ceffd4c54
2 changed files with 60 additions and 0 deletions

View File

@ -245,3 +245,45 @@ def status():
ret[name.strip()] = val.strip()
return ret
def test():
'''
Runs a test of a few standard Riak operations
.. versionadded:: Beryllium
CLI Example:
.. code-block:: bash
salt '*' riak.test
'''
ret = {'comment': '', 'success': False}
cmd = __execute_cmd('riak-admin', 'test')
if cmd['retcode'] != 0:
ret['comment'] = cmd['stdout']
else:
ret['comment'] = cmd['stdout']
ret['success'] = True
return ret
def services():
'''
List available services on a node
.. versionadded:: Beryllium
CLI Example:
.. code-block:: bash
salt '*' riak.services
'''
cmd = __execute_cmd('riak-admin', 'services')
return cmd['stdout'][1:-1].split(',')

View File

@ -103,6 +103,24 @@ class RiakTestCase(TestCase):
riak.status(), {'vnode_map_update_time_95': '0', 'vnode_map_update_time_99': '0'}
)
def test_test(self):
'''
Test the Riak test
'''
with patch.object(riak, '__execute_cmd', return_value={'retcode': 0, 'stdout': 'success'}):
self.assertEqual(
riak.test(), {'success': True, 'comment': 'success'}
)
def test_services(self):
'''
Test Riak Service List
'''
with patch.object(riak, '__execute_cmd', return_value={'stdout': '[a,b,c]'}):
self.assertEqual(
riak.services(), ['a','b','c']
)
if __name__ == '__main__':
from integration import run_tests
run_tests(RiakTestCase, needs_daemon=False)