def test_single_connections(self): self.assert_single_artifacts_store(store=self.s3_store, results=[]) self.assert_single_artifacts_store(store=self.gcs_store, results=[]) self.assert_single_artifacts_store(store=self.az_store, results=[]) self.assert_single_artifacts_store( store=self.claim_store, results=[get_volume_from_connection(connection=self.claim_store)], ) self.assert_single_artifacts_store( store=self.host_path_store, results=[ get_volume_from_connection(connection=self.host_path_store) ], ) # Managed versions ctx_volume_name = constants.CONTEXT_VOLUME_ARTIFACTS self.assert_single_init_artifacts_store( store=self.s3_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.gcs_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.az_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_secret(secret=self.mount_resource1), ], ) self.assert_single_init_artifacts_store( store=self.claim_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_connection(connection=self.claim_store), ], ) self.assert_single_init_artifacts_store( store=self.host_path_store, results=[ get_connections_context_volume(name=ctx_volume_name), get_volume_from_connection(connection=self.host_path_store), ], )
def test_artifacts_store(self): self.assert_artifacts_store(store=self.s3_store, results=[get_artifacts_context_volume()]) self.assert_artifacts_store(store=self.gcs_store, results=[get_artifacts_context_volume()]) self.assert_artifacts_store(store=self.az_store, results=[get_artifacts_context_volume()]) self.assert_artifacts_store( store=self.claim_store, results=[ get_artifacts_context_volume(), get_volume_from_connection(connection=self.claim_store), ], ) self.assert_artifacts_store( store=self.host_path_store, results=[ get_artifacts_context_volume(), get_volume_from_connection(connection=self.host_path_store), ], )
def test_get_volume_from_connection(self): # No store assert get_volume_from_connection(connection=None) is None # Bucket store store = V1ConnectionType( name="test", kind=V1ConnectionKind.S3, schema=V1BucketConnection(bucket="s3//:foo"), ) assert get_volume_from_connection(connection=store) is None # Claim store store = V1ConnectionType( name="test", kind=V1ConnectionKind.VOLUME_CLAIM, schema=V1ClaimConnection( mount_path="/tmp", volume_claim="test", read_only=True ), ) volume = get_volume_from_connection(connection=store) assert volume.name == store.name assert volume.persistent_volume_claim.claim_name == store.schema.volume_claim assert volume.persistent_volume_claim.read_only == store.schema.read_only # Host path store = V1ConnectionType( name="test", kind=V1ConnectionKind.HOST_PATH, schema=V1HostPathConnection( mount_path="/tmp", host_path="/tmp", read_only=True ), ) volume = get_volume_from_connection(connection=store) assert volume.name == store.name assert volume.host_path == k8s_schemas.V1HostPathVolumeSource( path=store.schema.host_path )
def add_volume_from_connection(connection: V1ConnectionType): volume = get_volume_from_connection(connection=connection) if volume: volumes.append(volume)