def test_update_db_packages_gce(self):
        sct_update_db_packages = 'gs://scratch.scylladb.com/sct_test/'

        class FakeObject:  # pylint: disable=too-few-public-methods
            def __init__(self, name):
                self.name = name

            @staticmethod
            def download(destination_path, overwrite_existing, *_, **__):
                Path(destination_path).touch(exist_ok=overwrite_existing)

        self.clear_cloud_downloaded_path(sct_update_db_packages)
        test_file_names = [
            "sct_test/", "sct_test/bentsi.txt", "sct_test/charybdis.fs"
        ]
        with unittest.mock.patch(
                "libcloud.storage.drivers.google_storage.GoogleStorageDriver.list_container_objects",
                return_value=[
                    FakeObject(name=fname) for fname in test_file_names
                ]):
            update_db_packages = download_dir_from_cloud(
                sct_update_db_packages)
        for fname in test_file_names:
            assert (Path(update_db_packages) /
                    os.path.basename(fname)).exists()
Example #2
0
    def test_update_db_packages_gce(self):
        sct_update_db_packages = 'gs://scratch.scylladb.com/sct_test/'

        self.clear_cloud_downloaded_path(sct_update_db_packages)

        update_db_packages = download_dir_from_cloud(sct_update_db_packages)
        assert os.path.exists(os.path.join(update_db_packages, "text.txt"))
Example #3
0
    def test_update_db_packages_s3(self):
        sct_update_db_packages = 's3://downloads.scylladb.com/rpm/centos/scylladb-nightly/scylla/7/x86_64/repodata/'

        self.clear_cloud_downloaded_path(sct_update_db_packages)

        update_db_packages = download_dir_from_cloud(sct_update_db_packages)
        assert os.path.exists(os.path.join(update_db_packages, "repomd.xml"))
    def test_update_db_packages_s3(self):
        sct_update_db_packages = 's3://downloads.scylladb.com/rpm/centos/scylladb-nightly/scylla/7/x86_64/repodata/'

        self.clear_cloud_downloaded_path(sct_update_db_packages)

        def touch_file(client, bucket, key, local_file_path):  # pylint: disable=unused-argument
            Path(local_file_path).touch()

        with unittest.mock.patch("sdcm.utils.common._s3_download_file", new=touch_file):
            update_db_packages = download_dir_from_cloud(sct_update_db_packages)

        assert os.path.exists(os.path.join(update_db_packages, "repomd.xml"))
    def test_update_db_packages_gce(self):
        sct_update_db_packages = 'gs://scratch.scylladb.com/sct_test/'

        self.clear_cloud_downloaded_path(sct_update_db_packages)

        def touch_file(**kwargs):
            Path(kwargs["destination_path"]).touch()

        with unittest.mock.patch("libcloud.storage.base.Object.download",
                                 side_effect=touch_file):
            update_db_packages = download_dir_from_cloud(
                sct_update_db_packages)

        assert os.path.exists(os.path.join(update_db_packages, "text.txt"))
 def test_update_db_packages_none():
     sct_update_db_packages = None
     update_db_packages = download_dir_from_cloud(sct_update_db_packages)
     assert update_db_packages is None