Beispiel #1
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'))
Beispiel #2
0
 def test_dequeue_delete(self, m_delete, m_put, m_get_lock, m_get_prefix):
     jobname, workitem = etcd.dequeue('node01')
     self.assertEqual('somejob', jobname)
     expected = [
         tasks.DeleteInstanceTask('fake_uuid'),
     ]
     self.assertCountEqual(expected, workitem['tasks'])
     self.assertSequenceEqual(expected, workitem['tasks'])
Beispiel #3
0
 def test_dequeue_multi(self, m_delete, m_put, m_get_lock, m_get_prefix):
     jobname, workitem = etcd.dequeue('node01')
     self.assertEqual('1631269187.890441', jobname)
     expected = [
         tasks.PreflightInstanceTask('diff_uuid'),
         tasks.StartInstanceTask('fake_uuid'),
         tasks.DeleteInstanceTask('fake_uuid'),
     ]
     self.assertCountEqual(expected, workitem['tasks'])
     self.assertSequenceEqual(expected, workitem['tasks'])
Beispiel #4
0
    def test_put_DeleteInstanceTask(self, mock_put):
        etcd.put('objecttype', 'subtype', 'name',
                 tasks.DeleteInstanceTask('fake_uuid'))

        path = '/sf/objecttype/subtype/name'
        encoded = '''{
    "instance_uuid": "fake_uuid",
    "network": [],
    "task": "instance_delete",
    "version": 1
}'''
        mock_put.assert_called_with(path, encoded, lease=None)