github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/tests/suites/constraints/constraints_aws.sh (about) 1 run_constraints_aws() { 2 name="constraints-aws" 3 4 # Echo out to ensure nice output to the test suite. 5 echo 6 echo "==> Checking for dependencies" 7 check_dependencies aws 8 9 file="${TEST_DIR}/constraints-aws.txt" 10 11 ensure "${name}" "${file}" 12 13 # In order to test the image-id constraint in AWS, we need to create a ami. 14 add_clean_func "run_cleanup_ami" 15 local ami_id 16 create_ami_and_wait_available "ami_id" 17 18 echo "Deploy 2 machines with different constraints" 19 juju add-machine --constraints "cores=2" 20 juju add-machine --constraints "image-id=${ami_id}" 21 22 wait_for_machine_agent_status "0" "started" 23 wait_for_machine_agent_status "1" "started" 24 25 echo "Ensure machine 0 has 2 cores" 26 machine0_hardware=$(juju machines --format json | jq -r '.["machines"]["0"]["hardware"]') 27 check_contains "${machine0_hardware}" "cores=2" 28 29 echo "Ensure machine 1 uses the correct AMI ID from image-id constraint" 30 machine_instance_id=$(juju show-machine --format json | jq -r '.["machines"]["1"]["instance-id"]') 31 aws ec2 describe-instances --instance-ids "${machine_instance_id}" --query 'Reservations[0].Instances[0].ImageId' --output text | check "${ami_id}" 32 33 destroy_model "${name}" 34 }