Skip to content

Commit 13d4418

Browse files
Rextilne
authored andcommitted
Fix scaling manual test
* Fix scaling manual test by adding region to EC2 calls Signed-off-by: Rex <[email protected]>
1 parent 4a31b6f commit 13d4418

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

tests/integration-tests/tests/scaling/test_scaling.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# See the License for the specific language governing permissions and limitations under the License.
1212
import logging
1313
import time
14+
from os import environ
1415

1516
import boto3
1617
import pytest
@@ -74,6 +75,7 @@ def test_multiple_jobs_submission(scheduler, region, pcluster_config_reader, clu
7475
def test_nodewatcher_terminates_failing_node(scheduler, region, pcluster_config_reader, clusters_factory, test_datadir):
7576
# slurm test use more nodes because of internal request to test in multi-node settings
7677
initial_queue_size = 5 if scheduler == "slurm" else 1
78+
environ["AWS_DEFAULT_REGION"] = region
7779
cluster_config = pcluster_config_reader(initial_queue_size=initial_queue_size)
7880
cluster = clusters_factory(cluster_config)
7981
remote_command_executor = RemoteCommandExecutor(cluster)
@@ -119,6 +121,7 @@ def test_nodewatcher_terminates_failing_node(scheduler, region, pcluster_config_
119121
def test_scaling_with_manual_actions(scheduler, region, pcluster_config_reader, clusters_factory):
120122
"""Test that slurm-specific scaling logic is resistent to manual actions and failures."""
121123
num_compute_nodes = 5
124+
environ["AWS_DEFAULT_REGION"] = region
122125
cluster_config = pcluster_config_reader(initial_queue_size=num_compute_nodes)
123126
cluster = clusters_factory(cluster_config)
124127
remote_command_executor = RemoteCommandExecutor(cluster)
@@ -258,7 +261,8 @@ def _assert_compute_node_states(scheduler_commands, compute_nodes, expected_stat
258261

259262

260263
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)
262266
for instance_id in instance_ids:
263267
instance_states = ec2_client.terminate_instances(InstanceIds=[instance_id]).get("TerminatingInstances")[0]
264268
assert_that(instance_states.get("InstanceId")).is_equal_to(instance_id)

tests/integration-tests/tests/scaling/test_scaling/test_scaling_with_manual_actions/pcluster.config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ scheduler = {{ scheduler }}
1212
master_instance_type = {{ instance }}
1313
compute_instance_type = {{ instance }}
1414
initial_queue_size = {{ initial_queue_size }}
15+
max_queue_size = {{ initial_queue_size }}
1516
maintain_initial_size = true
1617

1718
[vpc parallelcluster-vpc]

tests/integration-tests/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,13 @@ def get_compute_nodes_instance_ids(stack_name, region):
131131
raise
132132

133133

134-
def get_instance_ids_to_compute_hostnames_dict(instance_ids):
134+
def get_instance_ids_to_compute_hostnames_dict(instance_ids, region=None):
135135
"""Return dict of instanceIDs to hostnames."""
136136
try:
137+
if not region:
138+
region = os.environ.get("AWS_DEFAULT_REGION")
137139
instance_id_to_hostname = {}
138-
ec2_client = boto3.client("ec2")
140+
ec2_client = boto3.client("ec2", region_name=region)
139141
response = ec2_client.describe_instances(InstanceIds=instance_ids).get("Reservations")
140142
for reservation in response:
141143
for instance in reservation.get("Instances"):

0 commit comments

Comments
 (0)