Ejemplo n.º 1
0
 def test_dequeue_preflight(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'),
     ]
     self.assertCountEqual(expected, workitem['tasks'])
     self.assertSequenceEqual(expected, workitem['tasks'])
Ejemplo n.º 2
0
 def test_dequeue_multi(self, m_delete, m_put, m_get_lock, m_get_prefix):
     jobname, workitem = etcd.dequeue('node01')
     self.assertEqual('somejob', jobname)
     expected = [
         tasks.PreflightInstanceTask('diff_uuid'),
         tasks.StartInstanceTask('fake_uuid'),
         tasks.ErrorInstanceTask('fake_uuid'),
     ]
     self.assertCountEqual(expected, workitem['tasks'])
     self.assertSequenceEqual(expected, workitem['tasks'])
Ejemplo n.º 3
0
    def test_decode_PreflightInstanceTask(self):
        obs = etcd.decodeTasks({
            'tasks': [{
                'instance_uuid': 'fake_uuid',
                'network': None,
                'task': 'instance_preflight',
                'version': 1,
            }]
        })

        self.assertItemsEqual(
            {'tasks': [tasks.PreflightInstanceTask('fake_uuid')]}, obs)
Ejemplo n.º 4
0
    def test_put_PreflightInstanceTask(self, mock_put):
        etcd.put('objecttype', 'subtype', 'name',
                 tasks.PreflightInstanceTask('fake_uuid'))

        path = '/sf/objecttype/subtype/name'
        encoded = '''{
    "instance_uuid": "fake_uuid",
    "network": [],
    "task": "instance_preflight",
    "version": 1
}'''
        mock_put.assert_called_with(path, encoded, lease=None)
Ejemplo n.º 5
0
    def test_decode_multi(self):
        obs = etcd.decodeTasks({'tasks': [
            {
                'instance_uuid': 'fake_uuid',
                'network': None,
                'task': 'instance_preflight',
                'version': 1,
            },
            {
                'instance_uuid': 'fake_uuid',
                'task': 'image_fetch',
                'url': 'http://whoknows',
                'version': 1,
            }]})

        self.assertItemsEqual(
            {'tasks': [
                tasks.PreflightInstanceTask('fake_uuid'),
                tasks.FetchImageTask('http://whoknows', 'fake_uuid')
            ]},
            obs)
Ejemplo n.º 6
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.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'))