mirror of
https://github.com/rancher/os.git
synced 2025-09-23 11:30:49 +00:00
@@ -8,5 +8,8 @@ tmp
|
|||||||
state
|
state
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
assets
|
|
||||||
Godeps/_workspace/pkg
|
Godeps/_workspace/pkg
|
||||||
|
tests/integration/.venv*
|
||||||
|
tests/integration/.tox
|
||||||
|
*/*/*/*.pyc
|
||||||
|
*/*/*/__pycache__
|
||||||
|
@@ -7,5 +7,8 @@ gopath
|
|||||||
tmp
|
tmp
|
||||||
state
|
state
|
||||||
build
|
build
|
||||||
assets
|
|
||||||
Godeps/_workspace/pkg
|
Godeps/_workspace/pkg
|
||||||
|
tests/integration/.venv*
|
||||||
|
tests/integration/.tox
|
||||||
|
*/*/*/*.pyc
|
||||||
|
*/*/*/__pycache__
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,3 +10,5 @@
|
|||||||
/tests/integration/MANIFEST
|
/tests/integration/MANIFEST
|
||||||
/tests/integration/.venv*
|
/tests/integration/.venv*
|
||||||
/tests/integration/.tox
|
/tests/integration/.tox
|
||||||
|
*.pyc
|
||||||
|
__pychache__
|
||||||
|
@@ -2,7 +2,8 @@ FROM debian:jessie
|
|||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get -y dist-upgrade && \
|
apt-get -y dist-upgrade && \
|
||||||
apt-get -y install locales sudo vim less curl wget git rsync build-essential syslinux isolinux xorriso \
|
apt-get -y install locales sudo vim less curl wget git rsync build-essential syslinux isolinux xorriso \
|
||||||
libblkid-dev libmount-dev libselinux1-dev
|
libblkid-dev libmount-dev libselinux1-dev genisoimage qemu-kvm python-pip
|
||||||
|
RUN ln -s /usr/bin/genisoimage /usr/bin/mkisofs
|
||||||
RUN locale-gen en_US.UTF-8
|
RUN locale-gen en_US.UTF-8
|
||||||
RUN curl -sSL https://get.docker.com/ | sh
|
RUN curl -sSL https://get.docker.com/ | sh
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ RUN curl -sSL https://get.docker.com/ | sh
|
|||||||
#ENV LC_ALL en_US.UTF-8
|
#ENV LC_ALL en_US.UTF-8
|
||||||
#ENV TERM linux
|
#ENV TERM linux
|
||||||
|
|
||||||
|
RUN pip install tox
|
||||||
|
|
||||||
ENV GOLANG_VERSION 1.4.2
|
ENV GOLANG_VERSION 1.4.2
|
||||||
RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz | tar -v -C /usr/src -xz
|
RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz | tar -v -C /usr/src -xz
|
||||||
RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
|
RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
|
||||||
|
@@ -60,5 +60,7 @@ build-all: \
|
|||||||
$(DIST)/artifacts/rancheros.iso \
|
$(DIST)/artifacts/rancheros.iso \
|
||||||
$(DIST)/artifacts/iso-checksums.txt
|
$(DIST)/artifacts/iso-checksums.txt
|
||||||
|
|
||||||
|
integration-tests:
|
||||||
|
cd tests/integration && tox
|
||||||
|
|
||||||
.PHONY: build-all installer version bin/rancheros
|
.PHONY: build-all installer version bin/rancheros integration-tests
|
||||||
|
Binary file not shown.
@@ -9,4 +9,4 @@ fi
|
|||||||
|
|
||||||
docker build -t ros-build-base -f Dockerfile.build-base .
|
docker build -t ros-build-base -f Dockerfile.build-base .
|
||||||
docker build -t ros-build -f Dockerfile.build .
|
docker build -t ros-build -f Dockerfile.build .
|
||||||
./scripts/docker-run.sh make -f Makefile.docker build-all
|
./scripts/docker-run.sh make -f Makefile.docker build-all integration-tests
|
||||||
|
@@ -8,6 +8,9 @@ if [ -n "$BIND_DIR" ]; then
|
|||||||
fi
|
fi
|
||||||
DOCKER_ARGS="-t -v $BIND_DIR:/go/src/github.com/rancherio/os"
|
DOCKER_ARGS="-t -v $BIND_DIR:/go/src/github.com/rancherio/os"
|
||||||
fi
|
fi
|
||||||
|
if [ -c /dev/kvm ] || [ "${PRIVILEGED}" == "1" ]; then
|
||||||
|
DOCKER_ARGS="${DOCKER_ARGS} --privileged"
|
||||||
|
fi
|
||||||
|
|
||||||
docker rm -fv ros-build >/dev/null 2>&1 || true
|
docker rm -fv ros-build >/dev/null 2>&1 || true
|
||||||
exec docker run -i -v /var/run/docker.sock:/var/run/docker.sock $DOCKER_ARGS --name=ros-build ros-build "$@"
|
exec docker run -i -v /var/run/docker.sock:/var/run/docker.sock $DOCKER_ARGS --name=ros-build ros-build "$@"
|
||||||
|
43
scripts/run
43
scripts/run
@@ -22,7 +22,7 @@ HD_GZ=${BASE}/assets/empty-hd.img.gz
|
|||||||
INITRD_TMP=${BUILD}/$(${sha1sum} ${INITRD} | awk '{print $1}')
|
INITRD_TMP=${BUILD}/$(${sha1sum} ${INITRD} | awk '{print $1}')
|
||||||
INITRD_CURRENT=${BUILD}/initrd-current
|
INITRD_CURRENT=${BUILD}/initrd-current
|
||||||
INITRD_TEST=${BUILD}/initrd.test
|
INITRD_TEST=${BUILD}/initrd.test
|
||||||
USER_DATA=cloud-init/openstack/latest/user_data
|
USER_DATA=${BUILD}/cloud-config/openstack/latest/user_data
|
||||||
|
|
||||||
# PREREQ: brew install coreutils
|
# PREREQ: brew install coreutils
|
||||||
path() {
|
path() {
|
||||||
@@ -45,6 +45,11 @@ while [ "$#" -gt 0 ]; do
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--xhyve)
|
||||||
|
if [ "$UNAME" == "Darwin" ] && [ -x $(which xhyve) ]; then
|
||||||
|
XHYVE=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@@ -77,14 +82,15 @@ ln -sf ${INITRD_TMP} ${INITRD_CURRENT}
|
|||||||
mkdir -p ${INITRD_TMP}/usr/{bin,share/ros}
|
mkdir -p ${INITRD_TMP}/usr/{bin,share/ros}
|
||||||
cp bin/rancheros ${INITRD_TMP}/usr/bin/ros
|
cp bin/rancheros ${INITRD_TMP}/usr/bin/ros
|
||||||
cp -f os-config.yml ${INITRD_TMP}/usr/share/ros
|
cp -f os-config.yml ${INITRD_TMP}/usr/share/ros
|
||||||
cd ${INITRD_TMP}
|
|
||||||
|
|
||||||
|
pushd ${INITRD_TMP}
|
||||||
find . | cpio -H newc -o > ${INITRD_TEST}
|
find . | cpio -H newc -o > ${INITRD_TEST}
|
||||||
|
popd
|
||||||
|
|
||||||
if [ ! -e ${HD} ]; then
|
if [ ! -e ${HD} ]; then
|
||||||
mkdir -p $(dirname ${HD})
|
mkdir -p $(dirname ${HD})
|
||||||
if [ "$UNAME" == "Darwin" ]; then qemu-img create -f raw -o size=10G ${HD}
|
if [ "$XHYVE" == "1" ]; then qemu-img create -f raw -o size=10G ${HD}
|
||||||
elif [ "$UNAME" == "Linux" ]; then gzip -dc ${HD_GZ} > ${HD};
|
else qemu-img create -f qcow2 -o size=10G ${HD}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -103,18 +109,18 @@ else
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
KERNEL_ARGS="rancher.password=rancher rancher.modules=[9p,9pnet_virtio] console=ttyS0 ${QEMU_APPEND}"
|
KERNEL_ARGS="quiet rancher.password=rancher console=ttyS0 ${QEMU_APPEND}"
|
||||||
|
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
||||||
|
|
||||||
if [ "$UNAME" == "Darwin" ] && [ -x $(which xhyve) ]; then
|
CLOUD_CONFIG_ISO="${BUILD}/cloud-config.iso"
|
||||||
|
rm -rf ${CLOUD_CONFIG_ISO}
|
||||||
|
|
||||||
CLOUD_CONFIG_ISO="$(pwd)/cloud-config.iso"
|
mkisofs -R -V config-2 -o "${CLOUD_CONFIG_ISO}" "$BUILD/cloud-config"
|
||||||
rm -rf ${CLOUD_CONFIG_ISO}
|
|
||||||
|
|
||||||
# PREREQ: brew install cdrtools
|
if [ "$XHYVE" == "1" ]; then
|
||||||
mkisofs -R -V config-2 -o "${CLOUD_CONFIG_ISO}" "$(pwd)/cloud-init"
|
|
||||||
|
|
||||||
echo PWD=`pwd`
|
echo PWD=`pwd`
|
||||||
exec sudo xhyve -A -H -P -u \
|
exec sudo -n xhyve -A -H -P -u \
|
||||||
-m 4G \
|
-m 4G \
|
||||||
-s 0:0,hostbridge -s 31,lpc \
|
-s 0:0,hostbridge -s 31,lpc \
|
||||||
-l com1,stdio \
|
-l com1,stdio \
|
||||||
@@ -122,9 +128,12 @@ if [ "$UNAME" == "Darwin" ] && [ -x $(which xhyve) ]; then
|
|||||||
-s 3,ahci-cd,${CLOUD_CONFIG_ISO} \
|
-s 3,ahci-cd,${CLOUD_CONFIG_ISO} \
|
||||||
-s 4,virtio-blk,${HD} \
|
-s 4,virtio-blk,${HD} \
|
||||||
-U a01fb25c-3a19-4759-a47a-2e353e51807d \
|
-U a01fb25c-3a19-4759-a47a-2e353e51807d \
|
||||||
-f kexec,${KERNEL},${INITRD_TEST},"earlyprintk=serial elevator=noop rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda] ${KERNEL_ARGS}"
|
-f kexec,${KERNEL},${INITRD_TEST},"earlyprintk=serial elevator=noop ${KERNEL_ARGS}"
|
||||||
|
|
||||||
elif [ "$UNAME" == "Linux" ] && [ -x $(which qemu-system-x86_64) ]; then
|
elif [ -x $(which qemu-system-x86_64) ]; then
|
||||||
|
if [ -c /dev/kvm ] && [ -r /dev/kvm ] && [ -w /dev/kvm ]; then
|
||||||
|
KVM_ENABLE="-machine accel=kvm -cpu host"
|
||||||
|
fi
|
||||||
exec qemu-system-x86_64 -serial stdio \
|
exec qemu-system-x86_64 -serial stdio \
|
||||||
-kernel ${KERNEL} \
|
-kernel ${KERNEL} \
|
||||||
-initrd ${INITRD_TEST} \
|
-initrd ${INITRD_TEST} \
|
||||||
@@ -132,14 +141,12 @@ elif [ "$UNAME" == "Linux" ] && [ -x $(which qemu-system-x86_64) ]; then
|
|||||||
-net nic,vlan=0,model=virtio \
|
-net nic,vlan=0,model=virtio \
|
||||||
-net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher-dev \
|
-net user,vlan=0,hostfwd=tcp::2222-:22,hostname=rancher-dev \
|
||||||
-drive if=virtio,file=${HD} \
|
-drive if=virtio,file=${HD} \
|
||||||
-machine accel=kvm \
|
${KVM_ENABLE} \
|
||||||
-cpu host \
|
|
||||||
-smp 4 \
|
-smp 4 \
|
||||||
-fsdev local,id=conf,security_model=none,readonly,path=$(pwd)/cloud-init \
|
-cdrom ${CLOUD_CONFIG_ISO} \
|
||||||
-device virtio-9p-pci,fsdev=conf,mount_tag=config-2 \
|
|
||||||
-append "${KERNEL_ARGS}" \
|
-append "${KERNEL_ARGS}" \
|
||||||
-serial mon:telnet:localhost:4444,server,nowait \
|
|
||||||
-nographic \
|
-nographic \
|
||||||
|
-display none \
|
||||||
${QEMU_ARGS} "${@}"
|
${QEMU_ARGS} "${@}"
|
||||||
else
|
else
|
||||||
exit 42
|
exit 42
|
||||||
|
18
scripts/ssh
18
scripts/ssh
@@ -7,10 +7,24 @@ chmod 0600 ./assets/rancher.key
|
|||||||
|
|
||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
|
|
||||||
if [ "$UNAME" == "Darwin" ]; then
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--xhyve)
|
||||||
|
shift 1
|
||||||
|
if [ "$UNAME" == "Darwin" ] && [ -x $(which xhyve) ]; then
|
||||||
|
XHYVE=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$XHYVE" == "1" ]; then
|
||||||
HOST=192.168.64.2 # consult `/var/db/dhcpd_leases` or delete it
|
HOST=192.168.64.2 # consult `/var/db/dhcpd_leases` or delete it
|
||||||
exec ssh -F ./assets/scripts_ssh_config -i ./assets/rancher.key rancher@${HOST} "$@"
|
exec ssh -F ./assets/scripts_ssh_config -i ./assets/rancher.key rancher@${HOST} "$@"
|
||||||
elif [ "$UNAME" == "Linux" ]; then
|
else
|
||||||
exec ssh -p 2222 -F ./assets/scripts_ssh_config -i ./assets/rancher.key rancher@localhost "$@"
|
exec ssh -p 2222 -F ./assets/scripts_ssh_config -i ./assets/rancher.key rancher@localhost "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
RancherOS In-VM Integration Tests
|
|
@@ -1,6 +0,0 @@
|
|||||||
def func(x):
|
|
||||||
return x + 1
|
|
||||||
|
|
||||||
|
|
||||||
def test_answer():
|
|
||||||
assert func(3) == 4
|
|
@@ -1,3 +0,0 @@
|
|||||||
flake8==2.4.0
|
|
||||||
pytest==2.7.0
|
|
||||||
tox==1.9.2
|
|
@@ -1,11 +0,0 @@
|
|||||||
from distutils.core import setup
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name='RancherOSInVMTests',
|
|
||||||
version='0.1',
|
|
||||||
packages=[
|
|
||||||
'rancheros.invmtest'
|
|
||||||
],
|
|
||||||
license='ASL 2.0',
|
|
||||||
long_description=open('README.txt').read(),
|
|
||||||
)
|
|
@@ -1,12 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist=flake8, py27
|
|
||||||
|
|
||||||
[testenv]
|
|
||||||
deps=-rrequirements.txt
|
|
||||||
changedir={toxinidir}
|
|
||||||
commands=py.test --durations=20 {posargs}
|
|
||||||
|
|
||||||
[testenv:flake8]
|
|
||||||
deps=-rrequirements.txt
|
|
||||||
changedir={toxinidir}
|
|
||||||
commands=flake8 rancheros
|
|
@@ -1,10 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
def chdir_to_project_root():
|
def chdir_to_project_root():
|
||||||
os.chdir('../..')
|
os.chdir('../..')
|
||||||
print('\nChdir to project root dir')
|
print('\nChdir to project root dir: ' + subprocess.check_output('pwd'))
|
||||||
os.chmod('./tests/integration/assets/test.key', 0o600)
|
os.chmod('./tests/integration/assets/test.key', 0o600)
|
||||||
print('Also, `chmod 600 tests/integration/assets/test.key` to make ssh happy')
|
print('Also, `chmod 600 tests/integration/assets/test.key` to make ssh happy')
|
||||||
|
@@ -10,7 +10,7 @@ def qemu(request):
|
|||||||
|
|
||||||
def rancheros_version():
|
def rancheros_version():
|
||||||
with open('./scripts/version') as f:
|
with open('./scripts/version') as f:
|
||||||
for ln in iter(f.readline, ''):
|
for ln in f:
|
||||||
(k, _, v) = ln.partition('=')
|
(k, _, v) = ln.partition('=')
|
||||||
if k == 'VERSION' and v.strip() != '':
|
if k == 'VERSION' and v.strip() != '':
|
||||||
return v.strip()
|
return v.strip()
|
||||||
@@ -19,13 +19,14 @@ def rancheros_version():
|
|||||||
|
|
||||||
@pytest.mark.timeout(30)
|
@pytest.mark.timeout(30)
|
||||||
def test_system_boot(qemu):
|
def test_system_boot(qemu):
|
||||||
with qemu.stdout as f:
|
version = rancheros_version()
|
||||||
for ln in iter(f.readline, ''):
|
print('parsed version: ' + version)
|
||||||
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=rancheros_version()))
|
for ln in u.iter_lines(qemu.stdout):
|
||||||
print(str.strip(ln))
|
ros_booted_substr = str.find(ln, 'RancherOS {v} started'.format(v=version))
|
||||||
if ros_booted_substr > -1:
|
print(str.strip(ln))
|
||||||
assert True
|
if ros_booted_substr > -1:
|
||||||
return
|
assert True
|
||||||
|
return
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
|
||||||
@@ -38,8 +39,8 @@ def test_run_system_container(qemu):
|
|||||||
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
|
'./scripts/ssh sudo system-docker run --rm busybox /bin/true', shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||||
|
|
||||||
with ssh, ssh.stdout as f:
|
for ln in u.iter_lines(ssh.stdout):
|
||||||
for ln in iter(f.readline, ''):
|
print(str.strip(ln))
|
||||||
print(str.strip(ln))
|
ssh.wait()
|
||||||
|
|
||||||
assert ssh.returncode == 0
|
assert ssh.returncode == 0
|
||||||
|
@@ -3,6 +3,10 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
def iter_lines(s):
|
||||||
|
return iter(s.readline, '')
|
||||||
|
|
||||||
|
|
||||||
def run_qemu(request, run_args=[]):
|
def run_qemu(request, run_args=[]):
|
||||||
subprocess.check_call('rm -f ./state/empty-hd.img', shell=True)
|
subprocess.check_call('rm -f ./state/empty-hd.img', shell=True)
|
||||||
print('\nrm ./state/*')
|
print('\nrm ./state/*')
|
||||||
|
@@ -1,10 +1,2 @@
|
|||||||
PyYAML.Yandex==3.11.1
|
PyYAML==3.11
|
||||||
flake8==2.4.0
|
pytest==2.7.2
|
||||||
mccabe==0.3
|
|
||||||
pep8==1.6.2
|
|
||||||
py==1.4.27
|
|
||||||
pyflakes==0.8.1
|
|
||||||
pytest==2.7.0
|
|
||||||
pytest-timeout==0.4
|
|
||||||
tox==1.9.2
|
|
||||||
virtualenv==12.1.1
|
|
||||||
|
@@ -1,14 +1,13 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist=flake8, py34
|
envlist=flake8, py27
|
||||||
|
skipsdist=True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps=-rrequirements.txt
|
deps=-rrequirements.txt
|
||||||
changedir={toxinidir}
|
commands=py.test -s --durations=20 rancherostest {posargs}
|
||||||
commands=py.test --durations=20 {posargs}
|
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
deps=-rrequirements.txt
|
deps=flake8
|
||||||
changedir={toxinidir}
|
|
||||||
commands=flake8 rancherostest
|
commands=flake8 rancherostest
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
|
Reference in New Issue
Block a user