Beispiel #1
0
 def test_update_hints(self):
     modules = ['foo', 'bar', 'baz1', 'baz2', 'm1', 'm2']
     hgs = ['hg0', 'hg1', 'hg2', 'hg3', 'hg4']
     for module in modules:
         create_module_event(module)
     for hg in hgs:
         create_hostgroup_event(hg)
     hints = fetch_update_hints()
     for m in modules:
         self.assertTrue(m in hints['modules'])
     for h in hgs:
         self.assertTrue(h in hints['hostgroups'])
     self.assertTrue('common' in hints)
     self.assertEqual(0, len(hints['common']))
     create_module_event('m1')
     create_common_event('baz')
     hints = fetch_update_hints()
     self.assertTrue('hostgroups' in hints)
     self.assertEqual(0, len(hints['hostgroups']))
     self.assertTrue('baz' in hints['common'])
     self.assertEqual(1, len(hints['modules']))
     self.assertTrue('m1' in hints['modules'])
Beispiel #2
0
 def test_update_hints(self):
     modules = ['foo', 'bar', 'baz1', 'baz2', 'm1', 'm2']
     hgs = ['hg0', 'hg1', 'hg2', 'hg3', 'hg4']
     for module in modules:
         create_module_event(module)
     for hg in hgs:
         create_hostgroup_event(hg)
     hints = fetch_update_hints(self.lock)
     for m in modules:
         self.assertTrue(m in hints['modules'])
     for h in hgs:
         self.assertTrue(h in hints['hostgroups'])
     self.assertTrue('common' in hints)
     self.assertEquals(0, len(hints['common']))
     create_module_event('m1')
     create_common_event('baz')
     hints = fetch_update_hints(self.lock)
     self.assertTrue('hostgroups' in hints)
     self.assertEquals(0, len(hints['hostgroups']))
     self.assertTrue('baz' in hints['common'])
     self.assertEquals(1, len(hints['modules']))
     self.assertTrue('m1' in hints['modules'])
Beispiel #3
0
 def test_fetch_all_messages_noerrors(self):
     create_module_event('foo')
     create_hostgroup_event('bar')
     msgs = _fetch_all_messages()
     self.assertEquals(2, len(msgs))
Beispiel #4
0
 def test_update_hints_no_dups(self):
     create_module_event('foo')
     create_module_event('foo')
     hints = fetch_update_hints(self.lock)
     self.assertEquals(1, len(hints['modules']))
Beispiel #5
0
 def test_count_some_messages_queue_error(self, mock_queue):
     create_hostgroup_event('bar')
     create_module_event('foo')
     self.assertRaises(JensMessagingError, count_pending_hints)
Beispiel #6
0
 def test_count_some_messages(self):
     create_hostgroup_event('bar')
     create_module_event('foo')
     count = count_pending_hints()
     self.assertEquals(2, count)
Beispiel #7
0
 def test_fetch_all_messages_ioerror_when_dequeuing(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertLogErrors()
     mock_queue.assert_called_once()
     self.assertEquals(0, len(msgs))
Beispiel #8
0
 def test_fetch_all_messages_locked_item(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertEquals(0, len(msgs))
     mock_queue.assert_called_once()
Beispiel #9
0
 def test_fetch_all_messages_noerrors(self):
     create_module_event('foo')
     create_hostgroup_event('bar')
     msgs = _fetch_all_messages()
     self.assertEqual(2, len(msgs))
Beispiel #10
0
 def test_update_hints_no_dups(self):
     create_module_event('foo')
     create_module_event('foo')
     hints = fetch_update_hints()
     self.assertEqual(1, len(hints['modules']))
Beispiel #11
0
 def test_count_some_messages_queue_error(self, mock_queue):
     create_hostgroup_event('bar')
     create_module_event('foo')
     self.assertRaises(JensMessagingError, count_pending_hints)
Beispiel #12
0
 def test_count_some_messages(self):
     create_hostgroup_event('bar')
     create_module_event('foo')
     count = count_pending_hints()
     self.assertEqual(2, count)
Beispiel #13
0
 def test_fetch_all_messages_ioerror_when_dequeuing(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertLogErrors()
     mock_queue.assert_called_once()
     self.assertEqual(0, len(msgs))
Beispiel #14
0
 def test_fetch_all_messages_locked_item(self, mock_queue):
     create_module_event('foo')
     msgs = _fetch_all_messages()
     self.assertEqual(0, len(msgs))
     mock_queue.assert_called_once()
Beispiel #15
0
 def test_update_hints_no_dups(self):
     create_module_event(self.settings, 'foo')
     create_module_event(self.settings, 'foo')
     hints = fetch_update_hints(self.settings, self.lock)
     self.assertEquals(1, len(hints['modules']))