Beispiel #1
0
    def test_run_verify_checksum_mismatch(self):
        """This tests that SwiftDownloadIntegrityError is raised and swift
        download cmd does not run when original backup checksum does not match
        swift object etag"""

        context = TroveContext()
        location = "/backup/location/123"
        is_zipped = False
        backup_checksum = "checksum_different_then_fake_swift_etag"

        swift_client = FakeSwiftConnection()
        when(swift).create_swift_client(context).thenReturn(swift_client)

        storage_strategy = SwiftStorage(context)
        download_stream = storage_strategy.load(context,
                                                location,
                                                is_zipped,
                                                backup_checksum)

        self.assertEqual(download_stream.container, "location")
        self.assertEqual(download_stream.filename, "123")

        self.assertRaises(SwiftDownloadIntegrityError,
                          download_stream.__enter__)

        self.assertEqual(download_stream.process, None,
                         "SwiftDownloadStream process/cmd was not supposed"
                         "to run.")
Beispiel #2
0
    def test_run_verify_checksum(self):
        """This tests that swift download cmd runs if original backup checksum
        matches swift object etag"""

        context = TroveContext()
        location = "/backup/location/123"
        is_zipped = False
        backup_checksum = "fake-md5-sum"

        swift_client = FakeSwiftConnection()
        when(swift).create_swift_client(context).thenReturn(swift_client)
        download_process = MockProcess()
        subprocess = mock(swift.subprocess)
        when(subprocess).Popen(any(), any(),
                               any(), any()).thenReturn(download_process)
        when(swift.utils).raise_if_process_errored().thenReturn(None)

        storage_strategy = SwiftStorage(context)
        download_stream = storage_strategy.load(context,
                                                location,
                                                is_zipped,
                                                backup_checksum)

        self.assertEqual(download_stream.container, "location")
        self.assertEqual(download_stream.filename, "123")

        with download_stream as stream:
            print "Testing SwiftDownloadStream context manager: %s" % stream

        self.assertIsNotNone(download_stream.process,
                             "SwiftDownloadStream process/cmd is supposed "
                             "to run.")
        self.assertIsNotNone(download_stream.pid,
                             "SwiftDownloadStream process/cmd is supposed "
                             "to run.")
Beispiel #3
0
    def test_run_verify_checksum_mismatch(self):
        """This tests that SwiftDownloadIntegrityError is raised and swift
        download cmd does not run when original backup checksum does not match
        swift object etag"""

        context = TroveContext()
        location = "/backup/location/123"
        is_zipped = False
        backup_checksum = "checksum_different_then_fake_swift_etag"

        swift_client = fake_create_swift_client()
        when(swift).create_swift_client(context).thenReturn(swift_client)

        storage_strategy = SwiftStorage(context)
        download_stream = storage_strategy.load(context, location, is_zipped,
                                                backup_checksum)

        self.assertEqual(download_stream.container, "location")
        self.assertEqual(download_stream.filename, "123")

        self.assertRaises(SwiftDownloadIntegrityError,
                          download_stream.__enter__)

        self.assertEqual(
            download_stream.process, None,
            "SwiftDownloadStream process/cmd was not supposed"
            "to run.")
Beispiel #4
0
    def test_run_verify_checksum(self):
        """This tests that swift download cmd runs if original backup checksum
        matches swift object etag"""

        context = TroveContext()
        location = "/backup/location/123"
        is_zipped = False
        backup_checksum = "fake-md5-sum"

        swift_client = fake_create_swift_client()
        when(swift).create_swift_client(context).thenReturn(swift_client)
        download_process = MockProcess()
        subprocess = mock(swift.subprocess)
        when(subprocess).Popen(any(), any(), any(),
                               any()).thenReturn(download_process)
        when(swift.utils).raise_if_process_errored().thenReturn(None)

        storage_strategy = SwiftStorage(context)
        download_stream = storage_strategy.load(context, location, is_zipped,
                                                backup_checksum)

        self.assertEqual(download_stream.container, "location")
        self.assertEqual(download_stream.filename, "123")

        with download_stream as stream:
            print "Testing SwiftDownloadStream context manager: %s" % stream

        self.assertIsNotNone(
            download_stream.process,
            "SwiftDownloadStream process/cmd is supposed "
            "to run.")
        self.assertIsNotNone(
            download_stream.pid, "SwiftDownloadStream process/cmd is supposed "
            "to run.")
Beispiel #5
0
    def test_run_verify_checksum(self):
        """This tests that swift download cmd runs if original backup checksum
            matches swift object etag
        """

        context = TroveContext()
        location = "/backup/location/123"
        backup_checksum = "fake-md5-sum"

        swift_client = FakeSwiftConnection()
        when(swift).create_swift_client(context).thenReturn(swift_client)

        storage_strategy = SwiftStorage(context)
        download_stream = storage_strategy.load(location, backup_checksum)
        self.assertIsNotNone(download_stream)