|
18 | 18 | from remote_command_executor import RemoteCommandExecutor |
19 | 19 | from troposphere import Ref, Template, ec2 |
20 | 20 | from troposphere.efs import MountTarget |
21 | | -from utils import generate_stack_name, get_vpc_snakecase_value |
| 21 | +from utils import generate_stack_name, get_compute_nodes_instance_ips, get_vpc_snakecase_value |
22 | 22 |
|
23 | 23 | from tests.storage.storage_common import ( |
| 24 | + get_efs_ids, |
24 | 25 | test_efs_correctly_mounted, |
25 | 26 | verify_directory_correctly_shared, |
26 | 27 | write_file_into_efs, |
@@ -65,10 +66,11 @@ def test_efs_same_az(region, pcluster_config_reader, clusters_factory, vpc_stack |
65 | 66 | _test_efs_correctly_shared(remote_command_executor, mount_dir, scheduler_commands) |
66 | 67 |
|
67 | 68 |
|
68 | | -@pytest.mark.usefixtures("scheduler", "instance") |
| 69 | +@pytest.mark.usefixtures("instance") |
69 | 70 | def test_multiple_efs( |
70 | 71 | os, |
71 | 72 | region, |
| 73 | + scheduler, |
72 | 74 | efs_stack_factory, |
73 | 75 | mount_target_stack_factory, |
74 | 76 | pcluster_config_reader, |
@@ -130,6 +132,12 @@ def test_multiple_efs( |
130 | 132 |
|
131 | 133 | run_benchmarks(remote_command_executor, scheduler_commands) |
132 | 134 |
|
| 135 | + if os == "alinux2" and scheduler == "slurm": |
| 136 | + logging.info("Checking EFS utils on Amazon linux 2") |
| 137 | + _test_efs_utils( |
| 138 | + remote_command_executor, scheduler_commands, cluster, region, all_mount_dirs, get_efs_ids(cluster, region) |
| 139 | + ) |
| 140 | + |
133 | 141 |
|
134 | 142 | def _add_mount_targets(subnet_ids, efs_ids, security_group, template): |
135 | 143 | subnet_response = boto3.client("ec2").describe_subnets(SubnetIds=subnet_ids)["Subnets"] |
@@ -230,3 +238,26 @@ def _assert_subnet_az_relations(region, vpc_stack, expected_in_same_az): |
230 | 238 | assert_that(head_node_subnet_az).is_equal_to(compute_subnet_az) |
231 | 239 | else: |
232 | 240 | assert_that(head_node_subnet_az).is_not_equal_to(compute_subnet_az) |
| 241 | + |
| 242 | + |
| 243 | +def _test_efs_utils(remote_command_executor, scheduler_commands, cluster, region, mount_dirs, efs_ids): |
| 244 | + # Collect a list of command executors of all compute nodes |
| 245 | + compute_node_remote_command_executors = [] |
| 246 | + for compute_node_ip in get_compute_nodes_instance_ips(cluster.name, region): |
| 247 | + compute_node_remote_command_executors.append(RemoteCommandExecutor(cluster, compute_node_ip=compute_node_ip)) |
| 248 | + # Unmount all EFS from head node and compute nodes |
| 249 | + for mount_dir in mount_dirs: |
| 250 | + command = f"sudo umount {mount_dir}" |
| 251 | + remote_command_executor.run_remote_command(command) |
| 252 | + for compute_node_remote_command_executor in compute_node_remote_command_executors: |
| 253 | + compute_node_remote_command_executor.run_remote_command(command) |
| 254 | + # Mount all EFS using EFS-utils |
| 255 | + assert_that(mount_dirs).is_length(len(efs_ids)) |
| 256 | + for mount_dir, efs_id in zip(mount_dirs, efs_ids): |
| 257 | + command = f"sudo mount -t efs -o tls {efs_id}:/ {mount_dir}" |
| 258 | + remote_command_executor.run_remote_command(command) |
| 259 | + for compute_node_remote_command_executor in compute_node_remote_command_executors: |
| 260 | + compute_node_remote_command_executor.run_remote_command(command) |
| 261 | + _test_efs_correctly_shared(remote_command_executor, mount_dir, scheduler_commands) |
| 262 | + for mount_dir in mount_dirs: |
| 263 | + test_efs_correctly_mounted(remote_command_executor, mount_dir) |
0 commit comments