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

67 lines
1.9 KiB
Python
Raw Normal View History

2015-05-08 10:15:14 +00:00
import pytest
import rancherostest.util as u
2015-09-11 15:27:00 +00:00
import string
2015-05-08 10:15:14 +00:00
import subprocess
2015-05-08 13:58:10 +00:00
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):
2015-05-08 15:02:08 +00:00
return 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'])
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):
assert qemu is not None
u.wait_for_ssh(ssh_command)
assert True
@pytest.mark.timeout(40)
2015-05-08 17:22:26 +00:00
def test_rancher_environment(qemu, cloud_config):
2015-05-08 11:23:12 +00:00
assert qemu is not None
2015-05-08 10:15:14 +00:00
u.wait_for_ssh(ssh_command)
2015-05-08 13:58:10 +00:00
v = subprocess.check_output(
ssh_command + ['sudo', 'rancherctl', 'env', 'printenv', 'FLANNEL_NETWORK'],
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):
assert qemu is not None
u.wait_for_ssh(ssh_command)
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
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):
2015-05-08 14:39:09 +00:00
assert qemu is not None
u.wait_for_ssh(ssh_command)
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']