mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Additional riak functions
This commit is contained in:
parent
ea57845361
commit
7ceffd4c54
@ -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(',')
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user