Beispiel #1
0
 def test_push_image(self, mock_client):
     self.dc = mock_client
     pusher = build.PushTask(self.conf, self.image)
     pusher.run()
     mock_client().push.assert_called_once_with(self.image.canonical_name,
                                                decode=True,
                                                stream=True)
Beispiel #2
0
 def test_push_image_before_v3_0_0(self, mock_client):
     self.dc = mock_client
     pusher = build.PushTask(self.conf, self.image)
     pusher.run()
     mock_client().push.assert_called_once_with(self.image.canonical_name,
                                                stream=True,
                                                insecure_registry=True)
Beispiel #3
0
 def test_push_image_failure(self, mock_client):
     """failure on connecting Docker API"""
     self.dc = mock_client
     mock_client().push.side_effect = Exception
     pusher = build.PushTask(self.conf, self.image)
     pusher.run()
     mock_client().push.assert_called_once_with(
         self.image.canonical_name, decode=True, stream=True)
     self.assertFalse(pusher.success)
     self.assertEqual(build.STATUS_PUSH_ERROR, self.image.status)
Beispiel #4
0
 def test_push_image_failure_error(self, mock_client):
     """Docker connected, failure to push"""
     self.dc = mock_client
     mock_client().push.return_value = [{'errorDetail': {'message':
                                                         'mock push fail'}}]
     pusher = build.PushTask(self.conf, self.image)
     pusher.run()
     mock_client().push.assert_called_once_with(
         self.image.canonical_name, decode=True, stream=True)
     self.assertFalse(pusher.success)
     self.assertEqual(build.STATUS_PUSH_ERROR, self.image.status)
Beispiel #5
0
    def test_push_image_failure_retry(self, mock_client):
        """failure on connecting Docker API, success on retry"""
        self.dc = mock_client
        mock_client().push.side_effect = [Exception, []]
        pusher = build.PushTask(self.conf, self.image)
        pusher.run()
        mock_client().push.assert_called_once_with(
            self.image.canonical_name, decode=True, stream=True)
        self.assertFalse(pusher.success)
        self.assertEqual(build.STATUS_PUSH_ERROR, self.image.status)

        # Try again, this time without exception.
        pusher.reset()
        pusher.run()
        self.assertEqual(2, mock_client().push.call_count)
        self.assertTrue(pusher.success)
        self.assertEqual(build.STATUS_BUILT, self.image.status)
Beispiel #6
0
    def test_push_image_failure_error_retry(self, mock_client):
        """Docker connected, failure to push, success on retry"""
        self.dc = mock_client
        mock_client().push.return_value = [{'errorDetail': {'message':
                                                            'mock push fail'}}]
        pusher = build.PushTask(self.conf, self.image)
        pusher.run()
        mock_client().push.assert_called_once_with(
            self.image.canonical_name, decode=True, stream=True)
        self.assertFalse(pusher.success)
        self.assertEqual(build.STATUS_PUSH_ERROR, self.image.status)

        # Try again, this time without exception.
        mock_client().push.return_value = [{'stream': 'mock push passes'}]
        pusher.reset()
        pusher.run()
        self.assertEqual(2, mock_client().push.call_count)
        self.assertTrue(pusher.success)
        self.assertEqual(build.STATUS_BUILT, self.image.status)