2021-03-21 13:06:52 +01:00
|
|
|
SCRIPT_DIR="$( cd "$BATS_TEST_DIRNAME" &> /dev/null && pwd )"
|
|
|
|
|
export PATH=$(dirname ${SCRIPT_DIR})/bin:${PATH}
|
|
|
|
|
|
2021-06-09 22:16:15 +02:00
|
|
|
VAGRANT_CMD="vagrant"
|
2021-03-21 13:06:52 +01:00
|
|
|
VAGRANT_OPT="--provider=libvirt"
|
|
|
|
|
|
|
|
|
|
TEMPDIR=
|
|
|
|
|
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
|
2021-03-21 13:06:52 +01:00
|
|
|
setup_file() {
|
|
|
|
|
# set VAGRANT_HOME to something else to reuse for tests to avoid clashes with
|
|
|
|
|
# user installed plugins when running tests locally.
|
|
|
|
|
if [ -z "${VAGRANT_HOME:-}" ]
|
|
|
|
|
then
|
|
|
|
|
TEMPDIR=$(mktemp -d 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
export VAGRANT_HOME=${TEMPDIR}/.vagrant.d
|
|
|
|
|
echo "# Using ${VAGRANT_HOME} for VAGRANT_HOME" >&3
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
teardown_file() {
|
2021-05-14 19:11:33 +01:00
|
|
|
if [ -n "${TEMPDIR:-}" ] && [ -d "${TEMPDIR:-}" ]
|
|
|
|
|
then
|
|
|
|
|
rm -rf ${TEMPDIR:-}
|
|
|
|
|
fi
|
2021-03-21 13:06:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
|
${VAGRANT_CMD} destroy -f
|
|
|
|
|
if [ $? == "0" ]; then
|
|
|
|
|
return 0
|
|
|
|
|
else
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "destroy simple vm" {
|
|
|
|
|
export VAGRANT_LOG=debug
|
|
|
|
|
export VAGRANT_CWD=tests/simple
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "simple vm provision via shell" {
|
|
|
|
|
export VAGRANT_CWD=tests/simple_provision_shell
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
[ $(expr "$output" : ".*Hello.*") -ne 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bring up with custom default prefix" {
|
|
|
|
|
export VAGRANT_CWD=tests/default_prefix
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ $(expr "$output" : ".*changed_default_prefixdefault.*") -ne 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bring up with second disk" {
|
|
|
|
|
export VAGRANT_CWD=tests/second_disk
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*second_disk_default-vdb.*") -ne 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
@test "bring up with two disks" {
|
|
|
|
|
export VAGRANT_CWD=tests/two_disks
|
|
|
|
|
cleanup
|
2021-05-14 19:11:33 +01:00
|
|
|
tools/create_box_with_two_disks.sh ${VAGRANT_HOME} ${VAGRANT_CMD}
|
Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.
New format is:
{
'disks': [
{
'name': 'disk1.img',
'virtual_size': 10,
'format': 'qcow2'
},
{
'name': 'disk2.img',
'virtual_size': 15,
'format': 'qcow2'
},
{
'name': 'disk3.img',
}
],
'provider': 'libvirt',
'format': 'qcow2'
}
It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.
Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.
Partially fixes: #602
2020-09-10 10:03:00 +02:00
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*Image.*2G") -ne 0 ]
|
|
|
|
|
[ $(expr "$output" : ".*Image.*10G") -ne 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-21 13:06:52 +01:00
|
|
|
@test "bring up with adjusted memory settings" {
|
|
|
|
|
export VAGRANT_CWD=tests/memory
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*Memory.*1000M.*") -ne 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "bring up with adjusted cpu settings" {
|
|
|
|
|
export VAGRANT_CWD=tests/cpus
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*Cpus.*2.*") -ne 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@test "ip is reachable with private network" {
|
|
|
|
|
export VAGRANT_CWD=tests/private_network
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*Cpus.*2.*") -ne 0 ]
|
|
|
|
|
run fping 10.20.30.40
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
echo "${output}"
|
|
|
|
|
[ $(expr "$output" : ".*alive.*") -ne 0 ]
|
|
|
|
|
cleanup
|
|
|
|
|
}
|
2021-06-01 17:45:02 +01:00
|
|
|
|
|
|
|
|
@test "package simple domain" {
|
|
|
|
|
export VAGRANT_CWD=tests/package_simple
|
|
|
|
|
cleanup
|
|
|
|
|
run ${VAGRANT_CMD} up ${VAGRANT_OPT}
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run ${VAGRANT_CMD} halt
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run ${VAGRANT_CMD} package
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run ${VAGRANT_CMD} box add package.box --name test-package-simple-domain
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
run ${VAGRANT_CMD} box remove test-package-simple-domain
|
|
|
|
|
echo "${output}"
|
|
|
|
|
echo "status = ${status}"
|
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
rm -f package.box
|
|
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
}
|