From 3eefe3785ba20266d924e14ccbf742abdce7a413 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Fri, 8 May 2015 18:58:10 +0500 Subject: [PATCH] test_rancher_environment --- ...cloud-config-1.yml => cloud-config-01.yml} | 0 .../rancherostest/test_01_cloud_config.py | 23 +++++++++++-------- tests/integration/requirements.txt | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) rename tests/integration/assets/{cloud-config-1.yml => cloud-config-01.yml} (100%) diff --git a/tests/integration/assets/cloud-config-1.yml b/tests/integration/assets/cloud-config-01.yml similarity index 100% rename from tests/integration/assets/cloud-config-1.yml rename to tests/integration/assets/cloud-config-01.yml diff --git a/tests/integration/rancherostest/test_01_cloud_config.py b/tests/integration/rancherostest/test_01_cloud_config.py index b94e8e28..d90439d2 100644 --- a/tests/integration/rancherostest/test_01_cloud_config.py +++ b/tests/integration/rancherostest/test_01_cloud_config.py @@ -1,15 +1,22 @@ import pytest import rancherostest.util as u import subprocess +import yaml ssh_command = ['ssh', '-p', '2222', '-F', './assets/scripts_ssh_config', '-i', './tests/integration/assets/test.key', 'rancher@localhost'] +cloud_config_path = './tests/integration/assets/cloud-config-01.yml' @pytest.fixture(scope="module") def qemu(request): - return u.run_qemu(request, ['--cloud-config', './tests/integration/assets/cloud-config-1.yml']) + 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)) @pytest.mark.timeout(40) @@ -20,16 +27,12 @@ def test_ssh_authorized_keys(qemu): @pytest.mark.timeout(40) -def test_rancher_environment(qemu): +def test_rancher_environment(qemu, cloud_config_01): assert qemu is not None u.wait_for_ssh(ssh_command) - ssh = subprocess.Popen( - ssh_command + ['sudo', 'rancherctl', 'c', 'get', 'environment'], - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) + v = subprocess.check_output( + ssh_command + ['sudo', 'rancherctl', 'env', 'printenv', 'FLANNEL_NETWORK'], + stderr=subprocess.STDOUT, universal_newlines=True) - with ssh, ssh.stdout as f: - for ln in iter(f.readline, ''): - print(str.strip(ln)) - - assert ssh.returncode == 0 + assert v.strip() == cloud_config_01['rancher']['environment']['FLANNEL_NETWORK'] diff --git a/tests/integration/requirements.txt b/tests/integration/requirements.txt index 4dd47293..9f903942 100644 --- a/tests/integration/requirements.txt +++ b/tests/integration/requirements.txt @@ -1,3 +1,4 @@ +PyYAML.Yandex==3.11.1 flake8==2.4.0 mccabe==0.3 pep8==1.6.2