Use a temporary dir for ssh keys during testing

resolves path problems with sudo, we already have the same change
in the AWS test script.

(cherry picked from commit 16260c1569)
This commit is contained in:
Alexander Todorov 2018-12-06 15:32:35 +02:00 committed by Brian C. Lane
parent c4f3ceb0ec
commit 9584cbd96f
3 changed files with 15 additions and 19 deletions

View File

@ -93,10 +93,9 @@ rlJournalStart
rlPhaseStartTest "Start VM instance"
VM_NAME="Composer-Auto-VM-$UUID"
if [ ! -f ~/.ssh/id_rsa.pub ]; then
rlRun -t -c "ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa"
fi
SSH_PUB_KEY=`cat ~/.ssh/id_rsa.pub`
SSH_KEY_DIR=`mktemp -d /tmp/composer-ssh-keys.XXXXXX`
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
SSH_PUB_KEY=`cat $SSH_KEY_DIR/id_rsa.pub`
cat > azure-playbook.yaml << __EOF__
---
@ -134,7 +133,7 @@ __EOF__
rlPhaseStartTest "Verify VM instance"
# verify we can login into that instance
rlRun -t -c "ssh -oStrictHostKeyChecking=no azure-user@$IP_ADDRESS 'cat /etc/redhat-release'"
rlRun -t -c "ssh -oStrictHostKeyChecking=no -i $SSH_KEY_DIR/id_rsa azure-user@$IP_ADDRESS 'cat /etc/redhat-release'"
rlPhaseEnd
rlPhaseStartCleanup
@ -142,7 +141,7 @@ __EOF__
rlRun -t -c "ansible localhost -m azure_rm_image -a 'resource_group=$AZURE_RESOURCE_GROUP name=$OS_IMAGE_NAME state=absent'"
rlRun -t -c "ansible localhost -m azure_rm_storageblob -a 'resource_group=$AZURE_RESOURCE_GROUP storage_account_name=$AZURE_STORAGE_ACCOUNT container=$AZURE_STORAGE_CONTAINER blob=$IMAGE state=absent'"
rlRun -t -c "$CLI compose delete $UUID"
rlRun -t -c "rm -rf $IMAGE azure-playbook.yaml"
rlRun -t -c "rm -rf $IMAGE $SSH_KEY_DIR azure-playbook.yaml"
rlPhaseEnd
rlJournalEnd

View File

@ -94,10 +94,9 @@ __EOF__
rlPhaseStartTest "Start VM instance"
VM_NAME="Composer-Auto-VM-$UUID"
if [ ! -f ~/.ssh/id_rsa.pub ]; then
rlRun -t -c "ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa"
fi
rlRun -t -c "ansible localhost -m os_keypair -a 'name=$VM_NAME-key public_key_file=$(readlink -f ~/.ssh/id_rsa.pub)'"
SSH_KEY_DIR=`mktemp -d /tmp/composer-ssh-keys.XXXXXX`
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
rlRun -t -c "ansible localhost -m os_keypair -a 'name=$VM_NAME-key public_key_file=$SSH_KEY_DIR/id_rsa.pub'"
response=`ansible localhost -m os_server -a "name=$VM_NAME image=$OS_IMAGE_UUID flavor=t2.medium key_name=$VM_NAME-key auto_ip=yes"`
rlAssert0 "VM started successfully" $?
@ -112,7 +111,7 @@ __EOF__
rlPhaseStartTest "Verify VM instance"
# verify we can login into that instance
rlRun -t -c "ssh -oStrictHostKeyChecking=no cloud-user@$IP_ADDRESS 'cat /etc/redhat-release'"
rlRun -t -c "ssh -oStrictHostKeyChecking=no -i $SSH_KEY_DIR/id_rsa cloud-user@$IP_ADDRESS 'cat /etc/redhat-release'"
rlPhaseEnd
rlPhaseStartCleanup
@ -120,7 +119,7 @@ __EOF__
rlRun -t -c "ansible localhost -m os_server -a 'name=$VM_NAME state=absent'"
rlRun -t -c "ansible localhost -m os_image -a 'name=$OS_IMAGE_NAME state=absent'"
rlRun -t -c "$CLI compose delete $UUID"
rlRun -t -c "rm -rf $IMAGE http-with-rng.toml"
rlRun -t -c "rm -rf $IMAGE $SSH_KEY_DIR $TMP_DIR"
rlPhaseEnd
rlJournalEnd

View File

@ -65,11 +65,9 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose start"
if [ ! -f ~/.ssh/id_rsa.pub ]; then
rlRun -t -c "ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa"
fi
PUB_KEY=`cat ~/.ssh/id_rsa.pub`
SSH_KEY_DIR=`mktemp -d /tmp/composer-ssh-keys.XXXXXX`
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
PUB_KEY=`cat $SSH_KEY_DIR/id_rsa.pub`
cat > $TMP_DIR/vmware.toml << __EOF__
name = "vmware"
@ -143,7 +141,7 @@ __EOF__
rlPhaseStartTest "Verify VM instance"
# verify we can login into that instance
rlRun -t -c "ssh -oStrictHostKeyChecking=no root@$IP_ADDRESS 'cat /etc/redhat-release'"
rlRun -t -c "ssh -oStrictHostKeyChecking=no -i $SSH_KEY_DIR/id_rsa root@$IP_ADDRESS 'cat /etc/redhat-release'"
rlPhaseEnd
rlPhaseStartCleanup
@ -151,7 +149,7 @@ __EOF__
python3 $SAMPLES/destroy_vm.py -S -s $V_HOST -u $V_USERNAME -p $V_PASSWORD --uuid $INSTANCE_UUID
rlAssert0 "VM destroyed" $?
rlRun -t -c "$CLI compose delete $UUID"
rlRun -t -c "rm -rf $IMAGE $TMP_DIR"
rlRun -t -c "rm -rf $IMAGE $TMP_DIR $SSH_KEY_DIR"
rlPhaseEnd
rlJournalEnd