コード例 #1
0
 def test_dequeue_error(self, m_delete, m_put, m_get_lock, m_get_prefix):
     jobname, workitem = etcd.dequeue('node01')
     self.assertEqual('somejob', jobname)
     expected = [
         tasks.ErrorInstanceTask('fake_uuid'),
     ]
     self.assertCountEqual(expected, workitem['tasks'])
     self.assertSequenceEqual(expected, workitem['tasks'])
コード例 #2
0
    def test_put_ErrorInstanceTask(self, mock_put):
        etcd.put('objecttype', 'subtype', 'name',
                 tasks.ErrorInstanceTask('fake_uuid', 'dunno'))

        path = '/sf/objecttype/subtype/name'
        encoded = '''{
    "error_msg": "dunno",
    "instance_uuid": "fake_uuid",
    "network": [],
    "task": "instance_error",
    "version": 1
}'''
        mock_put.assert_called_with(path, encoded, lease=None)
コード例 #3
0
    def test_QueueTask_eq(self):
        self.assertEqual(tasks.PreflightInstanceTask('abcd'),
                         tasks.PreflightInstanceTask('abcd'))

        self.assertEqual(tasks.PreflightInstanceTask('abcd', []),
                         tasks.PreflightInstanceTask('abcd', []))

        self.assertEqual(tasks.PreflightInstanceTask('abcd'),
                         tasks.PreflightInstanceTask('abcd', []))

        self.assertNotEqual(tasks.PreflightInstanceTask('abcd'),
                            tasks.PreflightInstanceTask('abcd', ['netuuid']))

        self.assertEqual(tasks.PreflightInstanceTask('abcd', ['a1', 'b2']),
                         tasks.PreflightInstanceTask('abcd', ['a1', 'b2']))

        self.assertNotEqual(tasks.PreflightInstanceTask('abcd', ['a1', 'b2']),
                            tasks.PreflightInstanceTask('abcd', ['a1']))

        with testtools.ExpectedException(NotImplementedError):
            self.assertEqual(tasks.PreflightInstanceTask('abcd', ['a1', 'b2']),
                             42)

        self.assertEqual(tasks.DeleteInstanceTask('abcd'),
                         tasks.DeleteInstanceTask('abcd'))

        self.assertEqual(tasks.ErrorInstanceTask('abcd', 'someExcuse'),
                         tasks.ErrorInstanceTask('abcd', 'someExcuse'))

        self.assertNotEqual(tasks.ErrorInstanceTask('abcd', 'someExcuse'),
                            tasks.ErrorInstanceTask('abcd', 'something'))

        self.assertEqual(tasks.ErrorInstanceTask('abcd', 'dunno'),
                         tasks.ErrorInstanceTask('abcd', 'dunno'))

        self.assertEqual(tasks.ImageTask('http://someurl'),
                         tasks.ImageTask('http://someurl'))

        self.assertNotEqual(tasks.ImageTask('http://someurl'),
                            tasks.ImageTask('http://someur'))

        self.assertEqual(tasks.FetchImageTask('http://someurl', 'fake_uuid'),
                         tasks.FetchImageTask('http://someurl', 'fake_uuid'))

        self.assertNotEqual(
            tasks.FetchImageTask('http://someurl'),
            tasks.FetchImageTask('http://someurl', 'fake_uuid'))

        self.assertNotEqual(
            tasks.FetchImageTask('http://someurl', 'fake_uuid'),
            tasks.FetchImageTask('http://someurl', 'fake_uudd'))

        self.assertNotEqual(
            tasks.FetchImageTask('http://someurl', 'fake_uuid'),
            tasks.FetchImageTask('http://someurm', 'fake_uuid'))
コード例 #4
0
    def test_ErrorInstanceTask(self):
        self.assertIsNone(tasks.ErrorInstanceTask('uuid', None).error_msg())

        self.assertEqual('broken',
                         tasks.ErrorInstanceTask('uuid', 'broken').error_msg())