|
11 | 11 | # See the License for the specific language governing permissions and limitations under the License. |
12 | 12 | import logging |
13 | 13 | import time |
| 14 | +from os import environ |
14 | 15 |
|
15 | 16 | import boto3 |
16 | 17 | import pytest |
@@ -74,6 +75,7 @@ def test_multiple_jobs_submission(scheduler, region, pcluster_config_reader, clu |
74 | 75 | def test_nodewatcher_terminates_failing_node(scheduler, region, pcluster_config_reader, clusters_factory, test_datadir): |
75 | 76 | # slurm test use more nodes because of internal request to test in multi-node settings |
76 | 77 | initial_queue_size = 5 if scheduler == "slurm" else 1 |
| 78 | + environ["AWS_DEFAULT_REGION"] = region |
77 | 79 | cluster_config = pcluster_config_reader(initial_queue_size=initial_queue_size) |
78 | 80 | cluster = clusters_factory(cluster_config) |
79 | 81 | remote_command_executor = RemoteCommandExecutor(cluster) |
@@ -119,6 +121,7 @@ def test_nodewatcher_terminates_failing_node(scheduler, region, pcluster_config_ |
119 | 121 | def test_scaling_with_manual_actions(scheduler, region, pcluster_config_reader, clusters_factory): |
120 | 122 | """Test that slurm-specific scaling logic is resistent to manual actions and failures.""" |
121 | 123 | num_compute_nodes = 5 |
| 124 | + environ["AWS_DEFAULT_REGION"] = region |
122 | 125 | cluster_config = pcluster_config_reader(initial_queue_size=num_compute_nodes) |
123 | 126 | cluster = clusters_factory(cluster_config) |
124 | 127 | remote_command_executor = RemoteCommandExecutor(cluster) |
@@ -258,7 +261,8 @@ def _assert_compute_node_states(scheduler_commands, compute_nodes, expected_stat |
258 | 261 |
|
259 | 262 |
|
260 | 263 | def _terminate_nodes_manually(instance_ids): |
261 | | - ec2_client = boto3.client("ec2") |
| 264 | + region = environ.get("AWS_DEFAULT_REGION") |
| 265 | + ec2_client = boto3.client("ec2", region_name=region) |
262 | 266 | for instance_id in instance_ids: |
263 | 267 | instance_states = ec2_client.terminate_instances(InstanceIds=[instance_id]).get("TerminatingInstances")[0] |
264 | 268 | assert_that(instance_states.get("InstanceId")).is_equal_to(instance_id) |
|
0 commit comments