def test_list(self, cell_state_cls_mock): """Tests for treadmill.api.state.list()""" cell_state_cls_mock.return_value = self.cell_state state_api = state.API() self.assertEqual(state_api.list(), [{ 'host': 'baz1', 'state': 'running', 'name': 'foo.bar#0000000001', 'expires': 1234567890.1 }]) self.assertEqual(state_api.list('foo.bar#000000000[12]', True), [{ 'host': 'baz1', 'state': 'running', 'name': 'foo.bar#0000000001', 'expires': 1234567890.1 }, { 'host': 'baz1', 'name': 'foo.bar#0000000002', 'oom': False, 'when': '123456789.2', 'state': 'finished', 'exitcode': 0 }])
def test_list_partition(self, cell_state_cls_mock): """Tests for treadmill.api.state.list() with partition""" cell_state_cls_mock.return_value = self.cell_state state_api = state.API() self.assertEqual( state_api.list('foo.bar#000000000[1234567]', True, 'part1'), [{ 'host': 'baz1', 'state': 'running', 'name': 'foo.bar#0000000001', 'expires': 1234567890.1 }, { 'host': 'baz1', 'name': 'foo.bar#0000000002', 'oom': False, 'when': '123456789.2', 'state': 'finished', 'exitcode': 0 }, { 'host': 'baz1', 'name': 'foo.bar#0000000003', 'oom': False, 'when': '123456789.3', 'state': 'finished', 'exitcode': 255 }, { 'host': 'baz1', 'name': 'foo.bar#0000000004', 'oom': False, 'signal': 11, 'when': '1234567890.4', 'state': 'finished' }])
def test_get(self, cell_state_cls_mock): """Tests for treadmill.api.state.get()""" cell_state_cls_mock.return_value = self.cell_state state_api = state.API() self.assertEqual( state_api.get('foo.bar#0000000001'), { 'host': 'baz1', 'state': 'running', 'expires': 1234567890.1, 'name': 'foo.bar#0000000001' }) self.assertEqual( state_api.get('foo.bar#0000000002'), { 'host': 'baz1', 'name': 'foo.bar#0000000002', 'oom': False, 'when': '123456789.2', 'state': 'finished', 'exitcode': 0 }) self.assertEqual( state_api.get('foo.bar#0000000003'), { 'host': 'baz1', 'name': 'foo.bar#0000000003', 'oom': False, 'when': '123456789.3', 'state': 'finished', 'exitcode': 255 }) self.assertEqual( state_api.get('foo.bar#0000000004'), { 'host': 'baz1', 'name': 'foo.bar#0000000004', 'oom': False, 'signal': 11, 'when': '1234567890.4', 'state': 'finished' }) self.assertEqual( state_api.get('foo.bar#0000000005'), { 'oom': True, 'host': 'baz2', 'when': '1234567890.5', 'name': 'foo.bar#0000000005', 'state': 'killed' }) self.assertEqual( state_api.get('foo.bar#0000000006'), { 'oom': False, 'host': 'baz2', 'when': 1234567890.6, 'name': 'foo.bar#0000000006', 'state': 'terminated' }) self.assertEqual( state_api.get('foo.bar#0000000007'), { 'oom': False, 'host': 'baz2', 'when': '1234567890.7', 'name': 'foo.bar#0000000007', 'state': 'aborted', 'aborted_reason': 'TypeError' })