예제 #1
0
    def test_get_volume_args_s3(self):
        s3_store = V1ConnectionType(
            name="test_s3",
            kind=V1ConnectionKind.S3,
            schema=V1BucketConnection(bucket="s3//:foo"),
        )
        path_to = "/path-to/"
        path_from = os.path.join(s3_store.store_path, "")
        assert get_volume_args(s3_store, path_to, None) == "; ".join(
            [
                get_or_create_args(path=path_to),
                cp_s3_args(path_from=path_from, path_to=path_to, is_file=False),
            ]
        )

        s3_store = V1ConnectionType(
            name="test_s3",
            kind=V1ConnectionKind.S3,
            schema=V1BucketConnection(bucket="s3//:foo"),
        )
        base_path = "/path/to/"
        path_to1 = "/path/to/path1"
        path_to2 = "/path/to/path2"
        path_from1 = os.path.join(s3_store.store_path, "path1")
        path_from2 = os.path.join(s3_store.store_path, "path2")
        assert get_volume_args(
            s3_store, "/path/to", artifacts=V1ArtifactsType(files=["path1", "path2"])
        ) == "; ".join(
            [
                get_or_create_args(path=base_path),
                cp_s3_args(path_from=path_from1, path_to=path_to1, is_file=True),
                get_or_create_args(path=base_path),
                cp_s3_args(path_from=path_from2, path_to=path_to2, is_file=True),
            ]
        )
예제 #2
0
    def test_get_volume_args_host(self):
        host_path_store = V1ConnectionType(
            name="test_path",
            kind=V1ConnectionKind.HOST_PATH,
            schema=V1HostPathConnection(
                mount_path="/tmp", host_path="/tmp", read_only=True
            ),
        )
        path_to = "/path/to/"
        path_from = os.path.join(host_path_store.store_path, "")
        assert get_volume_args(host_path_store, path_to, None) == "; ".join(
            [
                get_or_create_args(path=path_to),
                cp_copy_args(path_from=path_from, path_to=path_to, is_file=False),
            ]
        )

        host_path_store = V1ConnectionType(
            name="test_claim",
            kind=V1ConnectionKind.HOST_PATH,
            schema=V1HostPathConnection(
                mount_path="/tmp", host_path="/tmp", read_only=True
            ),
        )
        base_path = "/path/to/"
        path_to1 = "/path/to/path1"
        path_to2 = "/path/to/path2"
        path_from1 = os.path.join(host_path_store.store_path, "path1")
        path_from2 = os.path.join(host_path_store.store_path, "path2")
        assert get_volume_args(
            host_path_store,
            "/path/to",
            artifacts=V1ArtifactsType(dirs=["path1", "path2"]),
        ) == "; ".join(
            [
                get_or_create_args(path=base_path),
                cp_copy_args(path_from=path_from1, path_to=path_to1, is_file=False),
                get_or_create_args(path=base_path),
                cp_copy_args(path_from=path_from2, path_to=path_to2, is_file=False),
            ]
        )
예제 #3
0
    def test_get_volume_args_claim(self):
        claim_store = V1ConnectionType(
            name="test_claim",
            kind=V1ConnectionKind.VOLUME_CLAIM,
            schema=V1ClaimConnection(mount_path="/tmp",
                                     volume_claim="test",
                                     read_only=True),
        )
        path_to = "/path/to/"
        path_from = os.path.join(claim_store.store_path, "")
        assert get_volume_args(claim_store, path_to, None) == "; ".join([
            get_or_create_args(path=path_to),
            cp_copy_args(path_from=path_from, path_to=path_to, is_file=False),
        ])

        claim_store = V1ConnectionType(
            name="test_claim",
            kind=V1ConnectionKind.VOLUME_CLAIM,
            schema=V1ClaimConnection(mount_path="/tmp",
                                     volume_claim="test",
                                     read_only=True),
        )
        base_path = "/path/to/"
        path_to1 = "/path/to/path1"
        path_to2 = "/path/to/path2"
        path_from1 = os.path.join(claim_store.store_path, "path1")
        path_from2 = os.path.join(claim_store.store_path, "path2")
        assert get_volume_args(
            claim_store,
            "/path/to",
            artifacts=V1ArtifactsType(files=["path1", "path2"])) == "; ".join([
                get_or_create_args(path=base_path),
                cp_copy_args(path_from=path_from1,
                             path_to=path_to1,
                             is_file=True),
                get_or_create_args(path=base_path),
                cp_copy_args(path_from=path_from2,
                             path_to=path_to2,
                             is_file=True),
            ])
예제 #4
0
    def test_get_volume_args_gcs(self):
        gcs_store = V1ConnectionType(
            name="test_gcs",
            kind=V1ConnectionKind.GCS,
            schema=V1BucketConnection(bucket="gs//:foo"),
        )
        path_to = "/path/to/"
        path_from = os.path.join(gcs_store.store_path, "")
        assert get_volume_args(gcs_store, path_to, None) == " ".join([
            get_or_create_args(path=path_to),
            cp_gcs_args(path_from=path_from, path_to=path_to, is_file=False),
        ])

        gcs_store = V1ConnectionType(
            name="test_gcs",
            kind=V1ConnectionKind.GCS,
            schema=V1BucketConnection(bucket="Congs//:foo"),
        )

        base_path = "/path/to/"
        path_to1 = "/path/to/path1"
        path_to2 = "/path/to/path2"
        path_from1 = os.path.join(gcs_store.store_path, "path1")
        path_from2 = os.path.join(gcs_store.store_path, "path2")
        assert get_volume_args(
            gcs_store,
            "/path/to",
            artifacts=V1ArtifactsType(dirs=["path1", "path2"])) == " ".join([
                get_or_create_args(path=base_path),
                cp_gcs_args(path_from=path_from1,
                            path_to=path_to1,
                            is_file=False),
                get_or_create_args(path=base_path),
                cp_gcs_args(path_from=path_from2,
                            path_to=path_to2,
                            is_file=False),
            ])
예제 #5
0
    def test_get_volume_args_az(self):
        az_store = V1ConnectionType(
            name="test_az",
            kind=V1ConnectionKind.WASB,
            schema=V1BucketConnection(bucket="Conwasb://[email protected]"),
        )
        path_to = "/path/to/"
        path_from = os.path.join(az_store.store_path, "")
        assert get_volume_args(az_store, path_to, None) == "; ".join(
            [
                get_or_create_args(path=path_to),
                cp_wasb_args(path_from=path_from, path_to=path_to, is_file=False),
            ]
        )

        az_store = V1ConnectionType(
            name="test_az",
            kind=V1ConnectionKind.WASB,
            schema=V1BucketConnection(bucket="Conwasb://[email protected]"),
        )
        base_path = "/path/to/"
        path_to1 = "/path/to/path1"
        path_to2 = "/path/to/path2"
        path_from1 = os.path.join(az_store.store_path, "path1")
        path_from2 = os.path.join(az_store.store_path, "path2")
        assert get_volume_args(
            az_store,
            "/path/to",
            artifacts=V1ArtifactsType(files=["path1"], dirs=["path2"]),
        ) == "; ".join(
            [
                get_or_create_args(path=base_path),
                cp_wasb_args(path_from=path_from1, path_to=path_to1, is_file=True),
                get_or_create_args(path=base_path),
                cp_wasb_args(path_from=path_from2, path_to=path_to2, is_file=False),
            ]
        )
예제 #6
0
 def test_get_or_create_args(self):
     assert (get_or_create_args(
         path="/foo") == 'if [ ! -d "/foo" ]; then mkdir -p /foo; fi')