1
0
mirror of https://github.com/rancher/os.git synced 2025-07-01 01:01:48 +00:00
os/tests/integration/rostest/test_01_cloud_config.py

94 lines
2.7 KiB
Python
Raw Normal View History

2015-09-11 15:27:00 +00:00
import string
2015-05-08 10:15:14 +00:00
import subprocess
import pytest
import rostest.util as u
import yaml
2015-05-08 10:15:14 +00:00
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
2015-09-11 15:27:00 +00:00
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
2015-05-08 10:15:14 +00:00
@pytest.fixture(scope="module")
def qemu(request):
q = u.run_qemu(request, ['--cloud-config', cloud_config_path,
'-net', 'nic,vlan=1,model=virtio', '-net', 'user,vlan=1,net=10.10.2.0/24'])
u.flush_out(q.stdout)
return q
2015-05-08 13:58:10 +00:00
@pytest.fixture(scope="module")
2015-05-08 17:22:26 +00:00
def cloud_config():
2015-05-08 13:58:10 +00:00
return yaml.load(open(cloud_config_path))
2015-05-08 10:15:14 +00:00
@pytest.mark.timeout(40)
2015-05-08 11:23:12 +00:00
def test_ssh_authorized_keys(qemu):
u.wait_for_ssh(qemu, ssh_command)
2015-05-08 11:23:12 +00:00
assert True
@pytest.mark.timeout(40)
2015-05-08 17:22:26 +00:00
def test_rancher_environment(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command)
2015-05-08 10:15:14 +00:00
2015-05-08 13:58:10 +00:00
v = subprocess.check_output(
ssh_command + ['sudo', 'ros', 'env', 'printenv', 'FLANNEL_NETWORK'],
2015-05-08 13:58:10 +00:00
stderr=subprocess.STDOUT, universal_newlines=True)
2015-05-08 10:15:14 +00:00
2015-05-08 17:22:26 +00:00
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
2015-05-08 14:39:09 +00:00
2015-09-11 15:27:00 +00:00
@pytest.mark.timeout(40)
def test_docker_args(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command)
2015-09-11 15:27:00 +00:00
v = subprocess.check_output(
ssh_command + ['sh', '-c', 'ps -ef | grep docker'],
stderr=subprocess.STDOUT, universal_newlines=True)
expected = string.join(cloud_config['rancher']['docker']['args'])
assert v.find(expected) != -1
@pytest.mark.timeout(40)
def test_dhcpcd(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command)
v = subprocess.check_output(
ssh_command + ['sh', '-c', 'ps -ef | grep dhcpcd'],
stderr=subprocess.STDOUT, universal_newlines=True)
assert v.find('dhcpcd -M') != -1
@pytest.mark.timeout(40)
def test_services_include(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command, ['docker inspect kernel-headers >/dev/null 2>&1'])
2015-11-17 13:08:37 +00:00
@pytest.mark.timeout(40)
def test_docker_tls_args(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command)
2015-11-17 13:08:37 +00:00
subprocess.check_call(
2015-12-11 08:40:24 +00:00
ssh_command + ['sudo', 'ros', 'tls', 'gen'],
2015-11-17 13:08:37 +00:00
stderr=subprocess.STDOUT, universal_newlines=True)
subprocess.check_call(
2015-12-11 12:38:00 +00:00
ssh_command + ['docker', '--tlsverify', 'version'],
2015-11-17 13:08:37 +00:00
stderr=subprocess.STDOUT, universal_newlines=True)
2015-05-08 14:39:09 +00:00
@pytest.mark.timeout(40)
2015-05-08 17:22:26 +00:00
def test_rancher_network(qemu, cloud_config):
u.wait_for_ssh(qemu, ssh_command)
2015-05-08 14:39:09 +00:00
v = subprocess.check_output(
2015-05-08 15:02:08 +00:00
ssh_command + ['ip', 'route', 'get', 'to', '10.10.2.120'],
2015-05-08 14:39:09 +00:00
stderr=subprocess.STDOUT, universal_newlines=True)
2015-05-08 15:02:08 +00:00
assert v.split(' ')[2] == 'eth1'
2015-05-08 17:22:26 +00:00
assert v.split(' ')[5] + '/24' == cloud_config['rancher']['network']['interfaces']['eth1']['address']