Skip to content

Commit d4ed57d

Browse files
Integ-tests: EFS utils
Signed-off-by: Hanwen <[email protected]>
1 parent c9f81fa commit d4ed57d

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

tests/integration-tests/tests/storage/storage_common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ def check_fsx(
208208
assert_fsx_correctly_shared(scheduler_commands, remote_command_executor, mount_dir)
209209

210210

211+
def get_efs_ids(cluster, region):
212+
return retrieve_cfn_outputs(cluster.cfn_name, region).get("EFSIds").split(",")
213+
214+
211215
def get_fsx_ids(cluster, region):
212216
return retrieve_cfn_outputs(cluster.cfn_name, region).get("FSXIds").split(",")
213217

tests/integration-tests/tests/storage/test_efs.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
from remote_command_executor import RemoteCommandExecutor
1919
from troposphere import Ref, Template, ec2
2020
from troposphere.efs import MountTarget
21-
from utils import generate_stack_name, get_vpc_snakecase_value
21+
from utils import generate_stack_name, get_vpc_snakecase_value, get_compute_nodes_instance_ips
2222

2323
from tests.storage.storage_common import (
2424
test_efs_correctly_mounted,
2525
verify_directory_correctly_shared,
26-
write_file_into_efs,
26+
write_file_into_efs, get_efs_ids,
2727
)
2828

2929

@@ -130,6 +130,8 @@ def test_multiple_efs(
130130

131131
run_benchmarks(remote_command_executor, scheduler_commands)
132132

133+
_test_efs_utils(remote_command_executor, scheduler_commands, cluster, region, all_mount_dirs, get_efs_ids(cluster, region))
134+
133135

134136
def _add_mount_targets(subnet_ids, efs_ids, security_group, template):
135137
subnet_response = boto3.client("ec2").describe_subnets(SubnetIds=subnet_ids)["Subnets"]
@@ -230,3 +232,21 @@ def _assert_subnet_az_relations(region, vpc_stack, expected_in_same_az):
230232
assert_that(head_node_subnet_az).is_equal_to(compute_subnet_az)
231233
else:
232234
assert_that(head_node_subnet_az).is_not_equal_to(compute_subnet_az)
235+
236+
237+
def _test_efs_utils(remote_command_executor, scheduler_commands, cluster, region, mount_dirs, efs_ids):
238+
compute_node_remote_command_executors = []
239+
for compute_node_ip in get_compute_nodes_instance_ips(cluster.name, region):
240+
compute_node_remote_command_executors(RemoteCommandExecutor(cluster, compute_node_ip=compute_node_ip))
241+
for mount_dir in mount_dirs:
242+
remote_command_executor.run_remote_command(f"sudo umount {mount_dir}")
243+
for compute_node_remote_command_executor in compute_node_remote_command_executors:
244+
compute_node_remote_command_executor.run_remote_command(f"sudo umount {mount_dir}")
245+
assert_that(mount_dirs).is_length(len(efs_ids))
246+
for mount_dir, efs_id in zip(mount_dirs, efs_ids):
247+
remote_command_executor.run_remote_command(f"sudo mount -t efs -o tls {efs_id}:/ {mount_dir}")
248+
for compute_node_remote_command_executor in compute_node_remote_command_executors:
249+
compute_node_remote_command_executor.run_remote_command(f"sudo mount -t efs -o tls {efs_id}:/ {mount_dir}")
250+
_test_efs_correctly_shared(remote_command_executor, mount_dir, scheduler_commands)
251+
for mount_dir in mount_dirs:
252+
test_efs_correctly_mounted(remote_command_executor, mount_dir)

tests/integration-tests/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ def get_cluster_nodes_instance_ids(stack_name, region, instance_types=None, node
214214
raise
215215

216216

217+
def get_compute_nodes_instance_ips(stack_name, region):
218+
"""Return a list of compute Instances Ip's."""
219+
try:
220+
instances = _describe_cluster_instances(
221+
stack_name,
222+
region,
223+
filter_by_node_type="Compute",
224+
)
225+
return [instance["PrivateIpAddress"] for instance in instances]
226+
except Exception as e:
227+
logging.error("Failed retrieving instance pds with exception: %s", e)
228+
raise
229+
230+
217231
def _describe_cluster_instances(
218232
stack_name,
219233
region,

0 commit comments

Comments
 (0)