Skip to content

Commit dcef719

Browse files
committed
Make integration test covering multiple NICS use Capacity Reservation
Signed-off-by: chenwany <[email protected]>
1 parent 15f3a87 commit dcef719

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

tests/integration-tests/tests/multiple_nics/test_multiple_nics.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# or in the "LICENSE.txt" file accompanying this file.
1010
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
1111
# See the License for the specific language governing permissions and limitations under the License.
12+
import boto3
1213
import pytest
1314
from assertpy import assert_that
1415
from remote_command_executor import RemoteCommandExecutor
@@ -21,8 +22,17 @@
2122
@pytest.mark.instances(["p4d.24xlarge"])
2223
@pytest.mark.schedulers(["slurm"])
2324
@pytest.mark.usefixtures("os", "instance", "scheduler")
24-
def test_multiple_nics(scheduler, region, pcluster_config_reader, clusters_factory):
25-
cluster_config = pcluster_config_reader()
25+
def test_multiple_nics(
26+
scheduler, region, pcluster_config_reader, clusters_factory, s3_bucket_factory, test_datadir, instance
27+
):
28+
# Post-install script to use P4d targeted ODCR
29+
bucket_name = ""
30+
if instance == "p4d.24xlarge":
31+
bucket_name = s3_bucket_factory()
32+
bucket = boto3.resource("s3", region_name=region).Bucket(bucket_name)
33+
bucket.upload_file(str(test_datadir / "run_instance_override.sh"), "run_instance_override.sh")
34+
35+
cluster_config = pcluster_config_reader(bucket_name=bucket_name)
2636
cluster = clusters_factory(cluster_config)
2737
remote_command_executor = RemoteCommandExecutor(cluster)
2838
scheduler_commands = get_scheduler_commands(scheduler, remote_command_executor)

tests/integration-tests/tests/multiple_nics/test_multiple_nics/test_multiple_nics/pcluster.config.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ compute_instance_type = {{ instance }}
1313
initial_queue_size = 1
1414
maintain_initial_size = true
1515
vpc_settings = parallelcluster-vpc
16+
{% if instance == "p4d.24xlarge" %}
17+
# Needed to use the p4d capacity reservation
18+
additional_iam_policies = arn:aws:iam::aws:policy/AmazonEC2FullAccess
19+
post_install = s3://{{ bucket_name }}/run_instance_override.sh
20+
s3_read_resource = arn:aws:s3:::{{ bucket_name }}/*
21+
{% endif %}
1622

1723
[vpc parallelcluster-vpc]
1824
vpc_id = {{ vpc_id }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -ex
3+
. "/etc/parallelcluster/cfnconfig"
4+
5+
6+
if [[ $cfn_node_type == "MasterServer" ]]; then
7+
# Override run_instance attributes
8+
cat > /opt/slurm/etc/pcluster/run_instances_overrides.json << 'EOF'
9+
{
10+
"compute": {
11+
"p4d.24xlarge": {
12+
"CapacityReservationSpecification": {
13+
"CapacityReservationTarget": {
14+
"CapacityReservationId": "cr-0fa65fcdbd597f551"
15+
}
16+
}
17+
}
18+
}
19+
}
20+
EOF
21+
fi

0 commit comments

Comments
 (0)