def test_get_volume(self): # Empty dir volume = get_volume(volume="test") assert volume.name == "test" assert isinstance(volume.empty_dir, k8s_schemas.V1EmptyDirVolumeSource) # Claim volume = get_volume(volume="test", claim_name="claim_name", read_only=True) assert volume.name == "test" assert volume.persistent_volume_claim.claim_name == "claim_name" assert volume.persistent_volume_claim.read_only is True # Host path volume = get_volume(volume="test", host_path="/tmp", read_only=True) assert volume.name == "test" assert volume.host_path.path == "/tmp"
def setUp(self): super().setUp() # Secrets and config maps self.non_mount_resource1 = V1K8sResourceType( name="non_mount_test1", schema=V1K8sResourceSchema(name="ref", items=["item1", "item2"]), is_requested=False, ) self.non_mount_resource2 = V1K8sResourceType( name="non_mount_test2", schema=V1K8sResourceSchema(name="ref"), is_requested=False, ) self.mount_resource1 = V1K8sResourceType( name="mount_test1", schema=V1K8sResourceSchema(name="ref", items=["item1", "item2"], mount_path="/tmp1"), is_requested=False, ) self.mount_resource2 = V1K8sResourceType( name="mount_test2", schema=V1K8sResourceSchema(name="ref", mount_path="/tmp2"), is_requested=False, ) # Volumes self.vol1 = get_volume(volume="vol1", claim_name="claim1") self.vol2 = get_volume(volume="vol2", host_path="/path2") self.vol3 = get_volume(volume="vol3") # connections self.s3_store = V1ConnectionType( name="test_s3", kind=V1ConnectionKind.S3, schema=V1BucketConnection(bucket="s3//:foo"), secret=self.mount_resource1.schema, ) self.gcs_store = V1ConnectionType( name="test_gcs", kind=V1ConnectionKind.GCS, schema=V1BucketConnection(bucket="gs//:foo"), secret=self.mount_resource1.schema, ) self.az_store = V1ConnectionType( name="test_az", kind=V1ConnectionKind.WASB, schema=V1BucketConnection( bucket="wasb://[email protected]"), secret=self.mount_resource1.schema, ) self.claim_store = V1ConnectionType( name="test_claim", kind=V1ConnectionKind.VOLUME_CLAIM, schema=V1ClaimConnection(mount_path="/tmp", volume_claim="test", read_only=True), ) self.host_path_store = V1ConnectionType( name="test_path", kind=V1ConnectionKind.HOST_PATH, schema=V1HostPathConnection(mount_path="/tmp", host_path="/tmp", read_only=True), )