mirror of
https://github.com/rancher/os.git
synced 2025-09-02 15:24:32 +00:00
Merge pull request #825 from imikushin/qemu-arm
Run tests on qemu-system-aarch64
This commit is contained in:
@@ -39,6 +39,7 @@ RUN if [ "${TOOLCHAIN}" != "" ] && ! which ${TOOLCHAIN}-gcc; then \
|
|||||||
;fi
|
;fi
|
||||||
|
|
||||||
RUN if [ "${TOOLCHAIN}" != "" ]; then \
|
RUN if [ "${TOOLCHAIN}" != "" ]; then \
|
||||||
|
apt-get update && \
|
||||||
cd /usr/local/src && \
|
cd /usr/local/src && \
|
||||||
for i in libselinux libsepol pcre3 util-linux; do \
|
for i in libselinux libsepol pcre3 util-linux; do \
|
||||||
apt-get build-dep -y $i && \
|
apt-get build-dep -y $i && \
|
||||||
@@ -75,3 +76,6 @@ RUN if [ "${TOOLCHAIN}" != "" ]; then \
|
|||||||
make -j$(nproc) && \
|
make -j$(nproc) && \
|
||||||
make install \
|
make install \
|
||||||
;fi
|
;fi
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y install dosfstools
|
||||||
|
@@ -177,7 +177,7 @@ func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Proj
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for event := range projectEvents {
|
for event := range projectEvents {
|
||||||
if event.EventType == project.EventContainerStarted && event.ServiceName == "network" {
|
if event.EventType == project.EventContainerStarted && event.ServiceName == "ntp" {
|
||||||
network = true
|
network = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -105,7 +105,7 @@ rancher:
|
|||||||
io.rancher.os.detach: "false"
|
io.rancher.os.detach: "false"
|
||||||
io.rancher.os.reloadconfig: "true"
|
io.rancher.os.reloadconfig: "true"
|
||||||
io.rancher.os.scope: system
|
io.rancher.os.scope: system
|
||||||
io.rancher.os.after: cloud-init-pre, wait-for-network
|
io.rancher.os.after: cloud-init-pre, wait-for-network, ntp
|
||||||
net: host
|
net: host
|
||||||
uts: host
|
uts: host
|
||||||
privileged: true
|
privileged: true
|
||||||
@@ -208,7 +208,7 @@ rancher:
|
|||||||
image: {{.OS_IMAGES_ROOT}}/os-ntp:{{.VERSION}}{{.SUFFIX}}
|
image: {{.OS_IMAGES_ROOT}}/os-ntp:{{.VERSION}}{{.SUFFIX}}
|
||||||
labels:
|
labels:
|
||||||
io.rancher.os.scope: system
|
io.rancher.os.scope: system
|
||||||
io.rancher.os.after: cloud-init, wait-for-network
|
io.rancher.os.after: wait-for-network
|
||||||
net: host
|
net: host
|
||||||
uts: host
|
uts: host
|
||||||
privileged: true
|
privileged: true
|
||||||
|
67
scripts/run
67
scripts/run
@@ -1,6 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/..
|
||||||
|
|
||||||
@@ -23,10 +22,18 @@ hd_amd64() {
|
|||||||
echo "-drive if=virtio,file=$1"
|
echo "-drive if=virtio,file=$1"
|
||||||
}
|
}
|
||||||
hd_arm() {
|
hd_arm() {
|
||||||
echo "-drive if=none,file=$1,id=hd0 -device virtio-blk-device,drive=hd0"
|
echo "-drive if=none,id=hd0,file=$1 -device virtio-blk-device,drive=hd0"
|
||||||
}
|
}
|
||||||
declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" )
|
declare -A hd=( ["amd64"]="hd_amd64" ["arm"]="hd_arm" ["arm64"]="hd_arm" )
|
||||||
|
|
||||||
|
cd_amd64() {
|
||||||
|
echo "-hdc $1"
|
||||||
|
}
|
||||||
|
cd_arm() {
|
||||||
|
echo "-drive if=none,id=cd0,file=$1 -device virtio-blk-device,drive=cd0"
|
||||||
|
}
|
||||||
|
declare -A cd=( ["amd64"]="cd_amd64" ["arm"]="cd_arm" ["arm64"]="cd_arm" )
|
||||||
|
|
||||||
BASE=$(pwd)
|
BASE=$(pwd)
|
||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
|
|
||||||
@@ -56,12 +63,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--xhyve)
|
|
||||||
if [ -x $(which xhyve) ]; then
|
|
||||||
XHYVE=1
|
|
||||||
QEMU=0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
--arch)
|
--arch)
|
||||||
shift 1
|
shift 1
|
||||||
ARCH="$1"
|
ARCH="$1"
|
||||||
@@ -152,18 +153,28 @@ if [ "$KVM" == "" ] && [ -c /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ]; th
|
|||||||
KVM=1
|
KVM=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$XHYVE" == "1" ] || [ "$QEMU" == "1" ]; then
|
if [ "$QEMU" == "1" ]; then
|
||||||
|
|
||||||
HD=${BASE}/state/hd.img
|
HD=${BASE}/state/hd.img
|
||||||
[ "$FRESH" == "1" ] && rm -f ${HD} >/dev/null 2>&1 || :
|
[ "$FRESH" == "1" ] && rm -f ${HD} >/dev/null 2>&1 || :
|
||||||
if [ ! -e ${HD} ]; then
|
if [ ! -e ${HD} ]; then
|
||||||
mkdir -p $(dirname ${HD})
|
mkdir -p $(dirname ${HD})
|
||||||
if [ "$XHYVE" == "1" ]; then qemu-img create -f raw -o size=10G ${HD}
|
qemu-img create -f qcow2 -o size=10G ${HD}
|
||||||
else qemu-img create -f qcow2 -o size=10G ${HD}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
USER_DATA=${BUILD}/cloud-config/openstack/latest/user_data
|
|
||||||
|
CCIMG=${BUILD}/cc.img
|
||||||
|
CCDEV=$(losetup -f)
|
||||||
|
CCROOT=${BUILD}/cloud-config
|
||||||
|
dd if=/dev/zero of=${CCIMG} bs=1024 count=512
|
||||||
|
losetup ${CCDEV} ${CCIMG}
|
||||||
|
mkfs.vfat -n "config-2" ${CCDEV}
|
||||||
|
|
||||||
|
rm -rf ${CCROOT}
|
||||||
|
mkdir -p ${CCROOT}
|
||||||
|
mount ${CCDEV} ${CCROOT}
|
||||||
|
|
||||||
|
USER_DATA=${CCROOT}/openstack/latest/user_data
|
||||||
mkdir -p $(dirname ${USER_DATA})
|
mkdir -p $(dirname ${USER_DATA})
|
||||||
rm -f ${USER_DATA} || :
|
rm -f ${USER_DATA} || :
|
||||||
if [ -n "$CLOUD_CONFIG" ]; then
|
if [ -n "$CLOUD_CONFIG" ]; then
|
||||||
@@ -174,51 +185,34 @@ if [ "$XHYVE" == "1" ] || [ "$QEMU" == "1" ]; then
|
|||||||
echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA}
|
echo "- $(<${BASE}/assets/rancher.key.pub)" >> ${USER_DATA}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CLOUD_CONFIG_ISO="${BUILD}/cloud-config.iso"
|
umount ${CCROOT}
|
||||||
rm -rf ${CLOUD_CONFIG_ISO}
|
losetup -d ${CCDEV}
|
||||||
mkisofs -R -V config-2 -o "${CLOUD_CONFIG_ISO}" "$BUILD/cloud-config"
|
|
||||||
|
|
||||||
if [ "$XHYVE" == "1" ]; then
|
|
||||||
|
|
||||||
exec sudo -n xhyve -A -H -P -u \
|
|
||||||
-m 4G \
|
|
||||||
-s 0:0,hostbridge -s 31,lpc \
|
|
||||||
-l com1,stdio \
|
|
||||||
-s 2:0,virtio-net \
|
|
||||||
-s 3,ahci-cd,${CLOUD_CONFIG_ISO} \
|
|
||||||
-s 4,virtio-blk,${HD} \
|
|
||||||
-U a01fb25c-3a19-4759-a47a-2e353e51807d \
|
|
||||||
-f kexec,${KERNEL},${INITRD},"earlyprintk=serial elevator=noop ${KERNEL_ARGS}" \
|
|
||||||
"${@}"
|
|
||||||
|
|
||||||
elif [ "$QEMU" == "1" ]; then
|
|
||||||
|
|
||||||
CPU=${cpu["$ARCH"]}
|
CPU=${cpu["$ARCH"]}
|
||||||
if [ "$KVM" == "1" ] && [ "$ARCH" == "$HOST_ARCH" ]; then
|
if [ "$KVM" == "1" ] && [ "$ARCH" == "$HOST_ARCH" ]; then
|
||||||
KVM_ENABLE="-enable-kvm"
|
KVM_ENABLE="-enable-kvm"
|
||||||
CPU="-cpu host"
|
CPU="-cpu host"
|
||||||
fi
|
fi
|
||||||
|
set -x
|
||||||
exec qemu-system-${QEMUARCH} -serial stdio \
|
exec qemu-system-${QEMUARCH} -serial stdio \
|
||||||
|
-rtc base=utc,clock=host \
|
||||||
${KVM_ENABLE} \
|
${KVM_ENABLE} \
|
||||||
${CPU} \
|
${CPU} \
|
||||||
${machine["$ARCH"]} \
|
${machine["$ARCH"]} \
|
||||||
-kernel ${KERNEL} \
|
-kernel ${KERNEL} \
|
||||||
-initrd ${INITRD} \
|
-initrd ${INITRD} \
|
||||||
-m 1024 \
|
-m 2048 \
|
||||||
${network["$ARCH"]} \
|
${network["$ARCH"]} \
|
||||||
|
$(eval "${cd["$ARCH"]} ${CCIMG}") \
|
||||||
$(eval "${hd["$ARCH"]} ${HD}") \
|
$(eval "${hd["$ARCH"]} ${HD}") \
|
||||||
-smp 1 \
|
-smp 1 \
|
||||||
-cdrom ${CLOUD_CONFIG_ISO} \
|
|
||||||
-append "${KERNEL_ARGS}" \
|
-append "${KERNEL_ARGS}" \
|
||||||
-nographic \
|
-nographic \
|
||||||
-display none \
|
-display none \
|
||||||
${QEMU_ARGS} \
|
${QEMU_ARGS} \
|
||||||
"${@}"
|
"${@}"
|
||||||
|
|
||||||
else
|
|
||||||
exit 42
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ "$QIND" == "1" ]; then
|
elif [ "$QIND" == "1" ]; then
|
||||||
|
|
||||||
NAME=${NAME:-ros-qind}
|
NAME=${NAME:-ros-qind}
|
||||||
@@ -246,6 +240,7 @@ elif [ "$QIND" == "1" ]; then
|
|||||||
SSH_PUB_ENABLE="--ssh-pub /stuff/rancher.key.pub"
|
SSH_PUB_ENABLE="--ssh-pub /stuff/rancher.key.pub"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
docker create --name=${NAME} -it ${KVM_ENABLE} \
|
docker create --name=${NAME} -it ${KVM_ENABLE} \
|
||||||
rancher/qind \
|
rancher/qind \
|
||||||
--hostname "rancher-dev" \
|
--hostname "rancher-dev" \
|
||||||
|
@@ -4,4 +4,4 @@ set -e
|
|||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/..
|
||||||
. ./scripts/dapper-common
|
. ./scripts/dapper-common
|
||||||
|
|
||||||
exec dapper -s
|
exec dapper -d -s
|
||||||
|
@@ -18,10 +18,6 @@ while [ "$#" -gt 0 ]; do
|
|||||||
--notty)
|
--notty)
|
||||||
INTERACTIVE=""
|
INTERACTIVE=""
|
||||||
;;
|
;;
|
||||||
--xhyve)
|
|
||||||
XHYVE=1
|
|
||||||
QEMU=0
|
|
||||||
;;
|
|
||||||
--qemu)
|
--qemu)
|
||||||
QEMU=1
|
QEMU=1
|
||||||
;;
|
;;
|
||||||
@@ -40,10 +36,7 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$XHYVE" == "1" ]; then
|
if [ "$QEMU" == "1" ]; then
|
||||||
HOST=192.168.64.2 # consult `/var/db/dhcpd_leases` or delete it
|
|
||||||
exec ssh -F ./assets/scripts_ssh_config -i ${KEY:-./assets/rancher.key} rancher@${HOST} "$@"
|
|
||||||
elif [ "$QEMU" == "1" ]; then
|
|
||||||
exec ssh -p 2222 -F ./assets/scripts_ssh_config -i ${KEY:-./assets/rancher.key} rancher@localhost "$@"
|
exec ssh -p 2222 -F ./assets/scripts_ssh_config -i ${KEY:-./assets/rancher.key} rancher@localhost "$@"
|
||||||
elif [ "$QIND" == "1" ]; then
|
elif [ "$QIND" == "1" ]; then
|
||||||
NAME=${NAME:-ros-qind}
|
NAME=${NAME:-ros-qind}
|
||||||
|
@@ -9,7 +9,7 @@ rancher:
|
|||||||
interfaces:
|
interfaces:
|
||||||
eth*:
|
eth*:
|
||||||
dhcp: true
|
dhcp: true
|
||||||
eth1:
|
"mac=52:54:00:12:34:59":
|
||||||
address: 10.10.2.17/24
|
address: 10.10.2.17/24
|
||||||
gateway: 10.10.2.2
|
gateway: 10.10.2.2
|
||||||
mtu: 1500
|
mtu: 1500
|
||||||
|
@@ -18,12 +18,15 @@ def test_system_boot(qemu):
|
|||||||
u.flush_out(qemu.stdout, 'RancherOS {v} started'.format(v=version))
|
u.flush_out(qemu.stdout, 'RancherOS {v} started'.format(v=version))
|
||||||
|
|
||||||
|
|
||||||
|
busybox = {'amd64': 'busybox', 'arm': 'armhf/busybox', 'arm64': 'aarch64/busybox'}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(60)
|
@pytest.mark.timeout(60)
|
||||||
def test_run_system_container(qemu):
|
def test_run_system_container(qemu):
|
||||||
u.wait_for_ssh(qemu)
|
u.wait_for_ssh(qemu)
|
||||||
|
|
||||||
ssh = subprocess.Popen(
|
ssh = subprocess.Popen(
|
||||||
'./scripts/ssh --qemu sudo system-docker run --rm busybox /bin/true',
|
'./scripts/ssh --qemu sudo system-docker run --rm ' + busybox[u.arch] + ' /bin/true',
|
||||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
for ln in u.iter_lines(ssh.stdout):
|
for ln in u.iter_lines(ssh.stdout):
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import string
|
import string
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
@@ -10,10 +9,16 @@ ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/t
|
|||||||
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
|
||||||
|
|
||||||
|
|
||||||
|
net_args = {'amd64': ['-net', 'nic,vlan=1,model=virtio,macaddr=52:54:00:12:34:59',
|
||||||
|
'-net', 'user,vlan=1,net=10.10.2.0/24'],
|
||||||
|
'arm64': ['-netdev', 'user,id=net1,net=10.10.2.0/24',
|
||||||
|
'-device', 'virtio-net-device,netdev=net1,mac=52:54:00:12:34:59']}
|
||||||
|
net_args['arm'] = net_args['arm64']
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def qemu(request):
|
def qemu(request):
|
||||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path,
|
q = u.run_qemu(request, ['--cloud-config', cloud_config_path] + net_args[u.arch])
|
||||||
'-net', 'nic,vlan=1,model=virtio', '-net', 'user,vlan=1,net=10.10.2.0/24'])
|
|
||||||
u.flush_out(q.stdout)
|
u.flush_out(q.stdout)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
@@ -31,22 +36,18 @@ def test_ssh_authorized_keys(qemu):
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_rancher_environment(qemu, cloud_config):
|
def test_rancher_environment(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
sudo ros env printenv FLANNEL_NETWORK
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sudo', 'ros', 'env', 'printenv', 'FLANNEL_NETWORK'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
|
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_docker_args(qemu, cloud_config):
|
def test_docker_args(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ps -ef | grep docker
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sh', '-c', 'ps -ef | grep docker'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
expected = string.join(cloud_config['rancher']['docker']['args'])
|
expected = string.join(cloud_config['rancher']['docker']['args'])
|
||||||
|
|
||||||
@@ -55,11 +56,9 @@ def test_docker_args(qemu, cloud_config):
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_dhcpcd(qemu, cloud_config):
|
def test_dhcpcd(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ps -ef | grep dhcpcd
|
||||||
v = subprocess.check_output(
|
'''.strip())
|
||||||
ssh_command + ['sh', '-c', 'ps -ef | grep dhcpcd'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.find('dhcpcd -M') != -1
|
assert v.find('dhcpcd -M') != -1
|
||||||
|
|
||||||
@@ -71,31 +70,26 @@ def test_services_include(qemu, cloud_config):
|
|||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_docker_tls_args(qemu, cloud_config):
|
def test_docker_tls_args(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
SSH(qemu, ssh_command).check_call('''
|
||||||
|
set -e -x
|
||||||
subprocess.check_call(
|
sudo ros tls gen
|
||||||
ssh_command + ['sudo', 'ros', 'tls', 'gen'],
|
sleep 5
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
docker --tlsverify version
|
||||||
|
'''.strip())
|
||||||
subprocess.check_call(
|
|
||||||
ssh_command + ['docker', '--tlsverify', 'version'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_rancher_network(qemu, cloud_config):
|
def test_rancher_network(qemu, cloud_config):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
|
ip route get to 10.10.2.120
|
||||||
|
'''.strip())
|
||||||
|
|
||||||
v = subprocess.check_output(
|
assert v.split(' ')[5] + '/24' == \
|
||||||
ssh_command + ['ip', 'route', 'get', 'to', '10.10.2.120'],
|
cloud_config['rancher']['network']['interfaces']['mac=52:54:00:12:34:59']['address']
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
assert v.split(' ')[2] == 'eth1'
|
|
||||||
assert v.split(' ')[5] + '/24' == cloud_config['rancher']['network']['interfaces']['eth1']['address']
|
|
||||||
|
|
||||||
|
|
||||||
def test_docker_not_pid_one(qemu):
|
def test_docker_not_pid_one(qemu):
|
||||||
SSH(qemu, ssh_command=ssh_command).check_call('bash', '-c', '''
|
SSH(qemu, ssh_command).check_call('''
|
||||||
set -e -x
|
set -e -x
|
||||||
for i in $(pidof docker); do
|
for i in $(pidof docker); do
|
||||||
[ $i != 1 ]
|
[ $i != 1 ]
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import subprocess
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
|
from rostest.util import SSH
|
||||||
|
|
||||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||||
cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
|
||||||
@@ -14,17 +15,24 @@ def qemu(request):
|
|||||||
return q
|
return q
|
||||||
|
|
||||||
|
|
||||||
|
nginx = {'amd64': 'nginx', 'arm': 'armhfbuild/nginx', 'arm64': 'armhfbuild/nginx'}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_reboot_with_container_running(qemu):
|
def test_reboot_with_container_running(qemu):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
try:
|
||||||
subprocess.check_call(ssh_command + ['docker', 'run', '-d', '--restart=always', 'nginx'],
|
SSH(qemu, ssh_command).check_call('''
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
set -ex
|
||||||
|
docker run -d --restart=always %(image)s
|
||||||
|
sudo reboot
|
||||||
|
'''.strip() % {'image': nginx[u.arch]})
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
subprocess.call(ssh_command + ['sudo', 'reboot'],
|
time.sleep(3)
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
|
||||||
|
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
v = SSH(qemu, ssh_command).check_output('''
|
||||||
v = subprocess.check_output(ssh_command + ['docker', 'ps', '-f', 'status=running'],
|
docker ps -f status=running
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
'''.strip())
|
||||||
|
|
||||||
assert v.find('nginx') != -1
|
assert v.find('nginx') != -1
|
||||||
|
@@ -20,7 +20,7 @@ def test_ros_install_on_formatted_disk(qemu):
|
|||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
subprocess.check_call(ssh_command + ['sudo', 'ros', 'install', '-f', '--no-reboot', '-d', '/dev/vda',
|
subprocess.check_call(ssh_command + ['sudo', 'ros', 'install', '-f', '--no-reboot', '-d', '/dev/vda',
|
||||||
'-i', 'rancher/os:v0.4.1'],
|
'-i', 'rancher/os:v0.4.4-dev' + u.suffix],
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
subprocess.call(ssh_command + ['sudo', 'reboot'],
|
subprocess.call(ssh_command + ['sudo', 'reboot'],
|
||||||
|
@@ -13,18 +13,21 @@ def qemu(request):
|
|||||||
u.flush_out(q.stdout)
|
u.flush_out(q.stdout)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
docker_url = {'amd64': 'https://experimental.docker.com/builds/Linux/x86_64/docker-1.10.0-dev',
|
||||||
|
'arm': 'https://github.com/rancher/docker/releases/download/v1.10.3-arm/docker-1.10.3_arm',
|
||||||
|
'arm64': 'https://github.com/rancher/docker/releases/download/v1.10.3-arm/docker-1.10.3_arm64'}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.timeout(40)
|
@pytest.mark.timeout(40)
|
||||||
def test_system_docker_survives_custom_docker_install(qemu):
|
def test_system_docker_survives_custom_docker_install(qemu):
|
||||||
u.wait_for_ssh(qemu, ssh_command)
|
u.wait_for_ssh(qemu, ssh_command)
|
||||||
subprocess.check_call(ssh_command + ['curl', '-OL',
|
subprocess.check_call(ssh_command + ['curl', '-Lfo', './docker', docker_url[u.arch]],
|
||||||
'https://experimental.docker.com/builds/Linux/x86_64/docker-1.10.0-dev'],
|
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
subprocess.check_call(ssh_command + ['chmod', '+x', '/home/rancher/docker-1.10.0-dev'],
|
subprocess.check_call(ssh_command + ['chmod', '+x', '/home/rancher/docker'],
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
subprocess.check_call(ssh_command + ['sudo', 'ln', '-sf', '/home/rancher/docker-1.10.0-dev', '/usr/bin/docker'],
|
subprocess.check_call(ssh_command + ['sudo', 'ln', '-sf', '/home/rancher/docker', '/usr/bin/docker'],
|
||||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
subprocess.check_call(ssh_command + ['sudo', 'system-docker', 'restart', 'docker'],
|
subprocess.check_call(ssh_command + ['sudo', 'system-docker', 'restart', 'docker'],
|
||||||
|
@@ -11,7 +11,7 @@ def qemu(request):
|
|||||||
|
|
||||||
|
|
||||||
def test_system_docker_survives_custom_docker_install(qemu):
|
def test_system_docker_survives_custom_docker_install(qemu):
|
||||||
SSH(qemu).check_call('bash', '-c', '''
|
SSH(qemu).check_call('''
|
||||||
set -x -e
|
set -x -e
|
||||||
mkdir x
|
mkdir x
|
||||||
sudo mount $(sudo ros dev LABEL=RANCHER_STATE) x
|
sudo mount $(sudo ros dev LABEL=RANCHER_STATE) x
|
||||||
|
@@ -12,12 +12,13 @@ def qemu(request):
|
|||||||
|
|
||||||
|
|
||||||
def test_oem(qemu):
|
def test_oem(qemu):
|
||||||
SSH(qemu).check_call('sudo', 'bash', '-c', '''
|
try:
|
||||||
|
SSH(qemu).check_call('''
|
||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
sudo mkfs.ext4 -L RANCHER_OEM /dev/vda
|
sudo mkfs.ext4 -L RANCHER_OEM /dev/vda
|
||||||
sudo mount /dev/vda /mnt
|
sudo mount /dev/vda /mnt
|
||||||
cat > /tmp/oem-config.yml << "EOF"
|
cat > /tmp/oem-config.yml << EOF
|
||||||
#cloud-config
|
#cloud-config
|
||||||
rancher:
|
rancher:
|
||||||
upgrade:
|
upgrade:
|
||||||
@@ -25,11 +26,14 @@ rancher:
|
|||||||
EOF
|
EOF
|
||||||
sudo cp /tmp/oem-config.yml /mnt
|
sudo cp /tmp/oem-config.yml /mnt
|
||||||
sudo umount /mnt
|
sudo umount /mnt
|
||||||
sudo reboot >/dev/null 2>&1 &'''.strip())
|
sudo reboot
|
||||||
|
'''.strip())
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(3)
|
||||||
|
|
||||||
SSH(qemu).check_call('bash', '-c', '''
|
SSH(qemu).check_call('''
|
||||||
set -x
|
set -x
|
||||||
if [ ! -e /usr/share/ros/oem/oem-config.yml ]; then
|
if [ ! -e /usr/share/ros/oem/oem-config.yml ]; then
|
||||||
echo Failed to find /usr/share/ros/oem/oem-config.yml
|
echo Failed to find /usr/share/ros/oem/oem-config.yml
|
||||||
|
@@ -11,7 +11,7 @@ def qemu(request):
|
|||||||
|
|
||||||
|
|
||||||
def test_ssh_key_merging(qemu):
|
def test_ssh_key_merging(qemu):
|
||||||
SSH(qemu).check_call('bash', '-c', '''cat > test-merge << "SCRIPT"
|
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||||
set -x -e
|
set -x -e
|
||||||
rm /var/lib/rancher/conf/cloud-config.yml
|
rm /var/lib/rancher/conf/cloud-config.yml
|
||||||
|
|
||||||
|
@@ -2,26 +2,27 @@ import pytest
|
|||||||
import rostest.util as u
|
import rostest.util as u
|
||||||
from rostest.util import SSH
|
from rostest.util import SSH
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.skipif(u.arch != 'amd64', reason='amd64 network setup impossible to replicate for arm64')
|
||||||
|
|
||||||
cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
|
cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
|
||||||
|
|
||||||
|
net_args_arch = {'amd64': ['-net', 'nic,vlan=0,model=virtio'],
|
||||||
|
'arm64': ['-device', 'virtio-net-device']}
|
||||||
|
net_args_arch['arm'] = net_args_arch['arm64']
|
||||||
|
net_args = net_args_arch[u.arch]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def qemu(request):
|
def qemu(request):
|
||||||
q = u.run_qemu(request, run_args=['--cloud-config', cloud_config_path,
|
q = u.run_qemu(request,
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
run_args=['--cloud-config', cloud_config_path] +
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
net_args + net_args + net_args + net_args + net_args + net_args + net_args)
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio',
|
|
||||||
'-net', 'nic,vlan=0,model=virtio'])
|
|
||||||
u.flush_out(q.stdout)
|
u.flush_out(q.stdout)
|
||||||
return q
|
return q
|
||||||
|
|
||||||
|
|
||||||
def test_network_conf(qemu):
|
def test_network_conf(qemu):
|
||||||
SSH(qemu).check_call('bash', '-c', '''cat > test-merge << "SCRIPT"
|
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||||
set -x -e
|
set -x -e
|
||||||
|
|
||||||
ip link show dev br0
|
ip link show dev br0
|
||||||
@@ -37,7 +38,7 @@ sudo bash test-merge
|
|||||||
|
|
||||||
|
|
||||||
def test_network_dns_ros_set(qemu):
|
def test_network_dns_ros_set(qemu):
|
||||||
SSH(qemu).check_call('bash', '-c', '''
|
SSH(qemu).check_call('''
|
||||||
set -x -e
|
set -x -e
|
||||||
|
|
||||||
sudo ros config set rancher.network.dns.search '[a,b]'
|
sudo ros config set rancher.network.dns.search '[a,b]'
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
def func(x):
|
|
||||||
return x + 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_answer():
|
|
||||||
assert func(3) == 4
|
|
@@ -1,12 +1,18 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import itertools as it
|
import itertools as it
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
ros_test = 'ros-test'
|
ros_test = 'ros-test'
|
||||||
|
arch = os.environ['ARCH']
|
||||||
|
|
||||||
|
suffix = ''
|
||||||
|
if arch != 'amd64':
|
||||||
|
suffix = '_' + arch
|
||||||
|
|
||||||
|
|
||||||
def iter_lines(s):
|
def iter_lines(s):
|
||||||
@@ -84,8 +90,8 @@ def wait_for_ssh(qemu, ssh_command=['./scripts/ssh', '--qemu'], command=['docker
|
|||||||
i += 1
|
i += 1
|
||||||
print('\nWaiting for ssh and docker... ' + str(i))
|
print('\nWaiting for ssh and docker... ' + str(i))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if i > 60:
|
if i > 150:
|
||||||
raise 'Failed to connect to SSH'
|
raise AssertionError('Failed to connect to SSH')
|
||||||
assert qemu.returncode is None
|
assert qemu.returncode is None
|
||||||
|
|
||||||
|
|
||||||
@@ -95,11 +101,19 @@ class SSH:
|
|||||||
self._ssh_command = ssh_command
|
self._ssh_command = ssh_command
|
||||||
self._waited = False
|
self._waited = False
|
||||||
|
|
||||||
def check_call(self, *args, **kw):
|
def wait(self):
|
||||||
if not self._waited:
|
if not self._waited:
|
||||||
wait_for_ssh(self._qemu, ssh_command=self._ssh_command)
|
wait_for_ssh(self._qemu, ssh_command=self._ssh_command)
|
||||||
self._waited = True
|
self._waited = True
|
||||||
|
|
||||||
|
def check_call(self, *args, **kw):
|
||||||
|
self.wait()
|
||||||
kw['stderr'] = subprocess.STDOUT
|
kw['stderr'] = subprocess.STDOUT
|
||||||
kw['universal_newlines'] = True
|
kw['universal_newlines'] = True
|
||||||
return subprocess.check_call(self._ssh_command + list(args), **kw)
|
return subprocess.check_call(self._ssh_command + list(args), **kw)
|
||||||
|
|
||||||
|
def check_output(self, *args, **kw):
|
||||||
|
self.wait()
|
||||||
|
kw['stderr'] = subprocess.STDOUT
|
||||||
|
kw['universal_newlines'] = True
|
||||||
|
return subprocess.check_output(self._ssh_command + list(args), **kw)
|
||||||
|
12
util/util.go
12
util/util.go
@@ -294,6 +294,16 @@ func DirLs(dir string) ([]interface{}, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func retryHttp(f func() (*http.Response, error), times int) (resp *http.Response, err error) {
|
||||||
|
for i := 0; i < times; i++ {
|
||||||
|
if resp, err = f(); err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Warnf("Error making HTTP request: %s. Retrying", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func LoadResource(location string, network bool, urls []string) ([]byte, error) {
|
func LoadResource(location string, network bool, urls []string) ([]byte, error) {
|
||||||
var bytes []byte
|
var bytes []byte
|
||||||
err := ErrNotFound
|
err := ErrNotFound
|
||||||
@@ -302,7 +312,7 @@ func LoadResource(location string, network bool, urls []string) ([]byte, error)
|
|||||||
if !network {
|
if !network {
|
||||||
return nil, ErrNoNetwork
|
return nil, ErrNoNetwork
|
||||||
}
|
}
|
||||||
resp, err := http.Get(location)
|
resp, err := retryHttp(func() (*http.Response, error) { return http.Get(location) }, 8)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user