Skip to content

Commit

Permalink
test(csi/node): add test for NodeStage with bad uri
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <[email protected]>
  • Loading branch information
tiagolobocastro committed Dec 10, 2024
1 parent fc7a02c commit 01ec679
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/bdd/features/csi/node/node.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Feature: CSI node plugin
When staging a volume with a volume_capability with a mount with an unsupported fs_type
Then the request should fail

Scenario: stage volume request with incorrect uri in the publish context
When staging a volume with an incorrect uri
But the rest client is enabled
Then the request should succeed

Scenario: staging a single writer volume
When staging an "ext4" volume as "MULTI_NODE_SINGLE_WRITER"
Then the request should succeed
Expand Down
46 changes: 45 additions & 1 deletion tests/bdd/features/csi/node/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_volume_capability(volume, read_only):

@pytest.fixture(scope="module")
def setup():
Deployer.start(1, csi_node=True)
Deployer.start(1, csi_node=True, csi_rest=True)

# Create 2 pools.
pool_labels = disk_pool_label
Expand Down Expand Up @@ -237,6 +237,13 @@ def test_stage_volume_request_with_unsupported_fs_type():
"""Stage volume request with unsupported fs_type."""


@scenario(
"node.feature", "stage volume request with incorrect uri in the publish context"
)
def test_stage_volume_request_with_incorrect_uri_in_the_publish_context():
"""stage volume request with incorrect uri in the publish context."""


@scenario("node.feature", "stage volume request without specified access_mode")
def test_stage_volume_request_without_specified_access_mode():
"""Stage volume request without specified access_mode."""
Expand Down Expand Up @@ -624,6 +631,37 @@ def attempt_to_stage_volume_with_unsupported_fs_type(
assert error.value.code() == grpc.StatusCode.INVALID_ARGUMENT


@when("staging a volume with an incorrect uri")
def _(
get_published_nexus, csi_instance, staging_target_path, io_timeout, staged_volumes
):
nexus = get_published_nexus
volume = Volume(
nexus.uuid,
nexus.protocol,
nexus.uri,
"MULTI_NODE_SINGLE_WRITER",
staging_target_path,
"ext4",
)
csi_instance.node.NodeStageVolume(
pb.NodeStageVolumeRequest(
volume_id=nexus.uuid,
publish_context={"uri": "bad", "ioTimeout": io_timeout},
staging_target_path=staging_target_path,
volume_capability=pb.VolumeCapability(
access_mode=pb.VolumeCapability.AccessMode(
mode=pb.VolumeCapability.AccessMode.Mode.MULTI_NODE_SINGLE_WRITER
),
mount=pb.VolumeCapability.MountVolume(fs_type="ext4", mount_flags=[]),
),
secrets={},
volume_context={},
)
)
staged_volumes[volume.uuid] = volume


@when(parsers.parse('staging an "{fs_type}" volume as "{mode}"'))
def stage_new_volume(
get_published_nexus, stage_volume, staging_target_path, fs_type, mode
Expand Down Expand Up @@ -775,6 +813,12 @@ def _(generic_staged_volume):
wait_nvme_gone_device(uri)


@when("the rest client is enabled")
def _():
"""the rest client is enabled."""
pass


@then("the volume should be stageable again")
def _(publish_nexus, generic_staged_volume, stage_volume):
"""the volume should be stageable again."""
Expand Down

0 comments on commit 01ec679

Please sign in to comment.