1
0
mirror of https://github.com/rancher/os.git synced 2025-07-02 17:51:49 +00:00
os/tests/integration/rancherostest/test_01_cloud_config.py

51 lines
1.4 KiB
Python
Raw Normal View History

2015-05-08 10:15:14 +00:00
import pytest
import rancherostest.util as u
import subprocess
2015-05-08 13:58:10 +00:00
import yaml
2015-05-08 10:15:14 +00:00
ssh_command = ['ssh', '-p', '2222', '-F', './assets/scripts_ssh_config', '-i', './tests/integration/assets/test.key',
'rancher@localhost']
2015-05-08 13:58:10 +00:00
cloud_config_path = './tests/integration/assets/cloud-config-01.yml'
2015-05-08 10:15:14 +00:00
@pytest.fixture(scope="module")
def qemu(request):
2015-05-08 13:58:10 +00:00
return u.run_qemu(request, ['--cloud-config', cloud_config_path])
@pytest.fixture(scope="module")
def cloud_config_01():
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 13:58:10 +00:00
def test_rancher_environment(qemu, cloud_config_01):
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 13:58:10 +00:00
assert v.strip() == cloud_config_01['rancher']['environment']['FLANNEL_NETWORK']
2015-05-08 14:39:09 +00:00
@pytest.mark.timeout(40)
def test_rancher_network(qemu, cloud_config_01):
assert qemu is not None
u.wait_for_ssh(ssh_command)
v = subprocess.check_output(
ssh_command + ['ip', 'route', 'get', 'to', '10.10.10.10'],
stderr=subprocess.STDOUT, universal_newlines=True)
assert v.split(' ')[2] == cloud_config_01['rancher']['network']['interfaces']['eth0']['gateway']