Fix "provisioning" functional tests
"Provisions" family of bunctional tests depend of "hardcoded" SSH-key. This fix removes this dependency. Change-Id: I2c7a1ef8ebd57a3b402bb1534a6f01221a8cd32b
This commit is contained in:
parent
477933a85d
commit
525051d0bc
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
script="$0"
|
||||||
|
user="$1"
|
||||||
|
key="$2"
|
||||||
|
ROOT="$3"
|
||||||
|
|
||||||
|
if [ -n "$ROOT" ]; then
|
||||||
|
mkdir -p "$ROOT/tmp"
|
||||||
|
cp "$script" "$ROOT/tmp/$(basename "$0")"
|
||||||
|
cp "$key" "$ROOT/tmp/upload-key.pub"
|
||||||
|
exec chroot "$ROOT" "/tmp/$(basename "$0")" "$user" \
|
||||||
|
/tmp/upload-key.pub
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$user" -o -z "$key" ]; then
|
||||||
|
echo "Invalid arguments" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
user_home="$(eval echo ~"$user")"
|
||||||
|
user_uid=$(getent passwd "$user" | cut -d: -f1)
|
||||||
|
user_gid=$(getent group "$user" | cut -d: -f1)
|
||||||
|
|
||||||
|
cd "$user_home"
|
||||||
|
|
||||||
|
mkdir -p .ssh
|
||||||
|
chmod 700 .ssh
|
||||||
|
cat "$key" >> .ssh/authorized_keys
|
||||||
|
chmod 600 .ssh/authorized_keys
|
||||||
|
|
||||||
|
chown -R "$user_uid:$user_gid" .ssh
|
||||||
|
|
||||||
|
rm -f "$key"
|
||||||
|
rm -f "$script"
|
|
@ -17,6 +17,8 @@ import json
|
||||||
import utils
|
import utils
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from bareon import tests_functional
|
from bareon import tests_functional
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,13 +102,19 @@ Number Start End Size File system Name Flags
|
||||||
"""
|
"""
|
||||||
|
|
||||||
utils.assertNoDiff(expected, actual)
|
utils.assertNoDiff(expected, actual)
|
||||||
|
node.run_cmd('mount /dev/vda2 /tmp/target')
|
||||||
|
node.run_cmd('mount /dev/vda3 /tmp/target/usr')
|
||||||
|
try:
|
||||||
|
self.upload_ssh_key(node, 'root')
|
||||||
|
finally:
|
||||||
|
node.run_cmd('umount /tmp/target/usr')
|
||||||
|
node.run_cmd('umount /tmp/target')
|
||||||
|
|
||||||
node.reboot_to_hdd()
|
node.reboot_to_hdd()
|
||||||
node.wait_for_boot()
|
node.wait_for_boot()
|
||||||
|
|
||||||
# Set node.ssh_key to "path to tenant key"
|
# Set node.ssh_key to "path to tenant key"
|
||||||
# (if tenant key is different than deploy key)
|
# (if tenant key is different than deploy key)
|
||||||
node.ssh_login = "centos"
|
|
||||||
actual = node.run_cmd('uname -a')[0]
|
actual = node.run_cmd('uname -a')[0]
|
||||||
expected = ('Linux fpa-func-test-tenant-vm 3.10.0-229.20.1.el7.x86_64'
|
expected = ('Linux fpa-func-test-tenant-vm 3.10.0-229.20.1.el7.x86_64'
|
||||||
' #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64'
|
' #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64'
|
||||||
|
@ -177,12 +185,19 @@ Number Start End Size File system Name Flags
|
||||||
|
|
||||||
utils.assertNoDiff(expected, actual)
|
utils.assertNoDiff(expected, actual)
|
||||||
|
|
||||||
|
node.run_cmd('mount /dev/vda2 /tmp/target')
|
||||||
|
node.run_cmd('mount /dev/vda3 /tmp/target/usr')
|
||||||
|
try:
|
||||||
|
self.upload_ssh_key(node, 'root')
|
||||||
|
finally:
|
||||||
|
node.run_cmd('umount /tmp/target/usr')
|
||||||
|
node.run_cmd('umount /tmp/target')
|
||||||
|
|
||||||
node.reboot_to_hdd()
|
node.reboot_to_hdd()
|
||||||
node.wait_for_boot()
|
node.wait_for_boot()
|
||||||
|
|
||||||
# Set node.ssh_key to "path to tenant key"
|
# Set node.ssh_key to "path to tenant key"
|
||||||
# (if tenant key is different than deploy key)
|
# (if tenant key is different than deploy key)
|
||||||
node.ssh_login = "centos"
|
|
||||||
actual = node.run_cmd('uname -a')[0]
|
actual = node.run_cmd('uname -a')[0]
|
||||||
expected = ('Linux fpa-func-test-tenant-vm 3.10.0-229.20.1.el7.x86_64'
|
expected = ('Linux fpa-func-test-tenant-vm 3.10.0-229.20.1.el7.x86_64'
|
||||||
' #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64'
|
' #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64'
|
||||||
|
@ -190,6 +205,21 @@ Number Start End Size File system Name Flags
|
||||||
|
|
||||||
utils.assertNoDiff(expected, actual)
|
utils.assertNoDiff(expected, actual)
|
||||||
|
|
||||||
|
def upload_ssh_key(self, node, user):
|
||||||
|
script = pkg_resources.resource_filename(
|
||||||
|
__name__, 'node_helper/put-ssh-key.sh')
|
||||||
|
|
||||||
|
key = node.ssh_key
|
||||||
|
key = '{}.pub'.format(key)
|
||||||
|
|
||||||
|
node.put_file(script, '/tmp/put-ssh-key.sh')
|
||||||
|
node.run_cmd('chmod u+x /tmp/put-ssh-key.sh', check_ret_code=True)
|
||||||
|
node.put_file(key, '/tmp/ssh-key.pub')
|
||||||
|
|
||||||
|
node.run_cmd(
|
||||||
|
'/tmp/put-ssh-key.sh "{user}" /tmp/ssh-key.pub /tmp/target'.format(
|
||||||
|
user=user), check_ret_code=True)
|
||||||
|
|
||||||
|
|
||||||
class MultipleProvisioningTestCase(tests_functional.TestCase):
|
class MultipleProvisioningTestCase(tests_functional.TestCase):
|
||||||
def test_multiple_provisioning(self):
|
def test_multiple_provisioning(self):
|
||||||
|
|
Loading…
Reference in New Issue