Skip to content

Commit

Permalink
Make integration test covering multiple NICS use Capacity Reservation
Browse files Browse the repository at this point in the history
Signed-off-by: chenwany <[email protected]>
  • Loading branch information
chenwany committed Nov 10, 2022
1 parent 15f3a87 commit dcef719
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/integration-tests/tests/multiple_nics/test_multiple_nics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# or in the "LICENSE.txt" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.
import boto3
import pytest
from assertpy import assert_that
from remote_command_executor import RemoteCommandExecutor
Expand All @@ -21,8 +22,17 @@
@pytest.mark.instances(["p4d.24xlarge"])
@pytest.mark.schedulers(["slurm"])
@pytest.mark.usefixtures("os", "instance", "scheduler")
def test_multiple_nics(scheduler, region, pcluster_config_reader, clusters_factory):
cluster_config = pcluster_config_reader()
def test_multiple_nics(
scheduler, region, pcluster_config_reader, clusters_factory, s3_bucket_factory, test_datadir, instance
):
# Post-install script to use P4d targeted ODCR
bucket_name = ""
if instance == "p4d.24xlarge":
bucket_name = s3_bucket_factory()
bucket = boto3.resource("s3", region_name=region).Bucket(bucket_name)
bucket.upload_file(str(test_datadir / "run_instance_override.sh"), "run_instance_override.sh")

cluster_config = pcluster_config_reader(bucket_name=bucket_name)
cluster = clusters_factory(cluster_config)
remote_command_executor = RemoteCommandExecutor(cluster)
scheduler_commands = get_scheduler_commands(scheduler, remote_command_executor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ compute_instance_type = {{ instance }}
initial_queue_size = 1
maintain_initial_size = true
vpc_settings = parallelcluster-vpc
{% if instance == "p4d.24xlarge" %}
# Needed to use the p4d capacity reservation
additional_iam_policies = arn:aws:iam::aws:policy/AmazonEC2FullAccess
post_install = s3://{{ bucket_name }}/run_instance_override.sh
s3_read_resource = arn:aws:s3:::{{ bucket_name }}/*
{% endif %}

[vpc parallelcluster-vpc]
vpc_id = {{ vpc_id }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -ex
. "/etc/parallelcluster/cfnconfig"


if [[ $cfn_node_type == "MasterServer" ]]; then
# Override run_instance attributes
cat > /opt/slurm/etc/pcluster/run_instances_overrides.json << 'EOF'
{
"compute": {
"p4d.24xlarge": {
"CapacityReservationSpecification": {
"CapacityReservationTarget": {
"CapacityReservationId": "cr-0fa65fcdbd597f551"
}
}
}
}
}
EOF
fi

0 comments on commit dcef719

Please sign in to comment.