From 070162eb55fa3adf3d05df743a89ef2fc24b63e3 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Fri, 8 May 2015 15:15:14 +0500 Subject: [PATCH] wip: test cloud-config --- tests/integration/assets/cloud-config-1.yml | 8 ++++++ tests/integration/assets/test.key | 27 ++++++++++++++++++ .../{test_system.py => test_00_system.py} | 2 +- .../rancherostest/test_01_cloud_config.py | 28 +++++++++++++++++++ tests/integration/rancherostest/util.py | 4 +-- 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 tests/integration/assets/cloud-config-1.yml create mode 100644 tests/integration/assets/test.key rename tests/integration/rancherostest/{test_system.py => test_00_system.py} (98%) create mode 100644 tests/integration/rancherostest/test_01_cloud_config.py diff --git a/tests/integration/assets/cloud-config-1.yml b/tests/integration/assets/cloud-config-1.yml new file mode 100644 index 00000000..cb48bd82 --- /dev/null +++ b/tests/integration/assets/cloud-config-1.yml @@ -0,0 +1,8 @@ +#cloud-config +rancher: + environment: + ETCD_DISCOVERY: https://discovery.etcd.io/c2c219023108cda9529364d6d983fe13 + FLANNEL_NETWORK: 10.244.0.0/16 + +ssh_authorized_keys: + - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt diff --git a/tests/integration/assets/test.key b/tests/integration/assets/test.key new file mode 100644 index 00000000..059f2aca --- /dev/null +++ b/tests/integration/assets/test.key @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+SuXfglSLjWra3VgLh6aho9/jQ7+7enrEru3JRvcCgYEAuo3484mmyN+gE0893PfQ +ebU3prOOJcHjpTIp1dB0gt1GcgSFpRpTn9RROwRVmoRoGe4pvVPPO763U0k0LPzf +IPij0OK+Y0rwC1kJJcd61LL8nJQ7Rhj60w26IbVOQSOzNZpiUQFQxLkfnx4kEmnA +VbIBD8Ap0SExFvAfFN3qZmsCgYA8c53meW1e8LC9TH/+xz4m5EEromhIVMg7eqbz +FXneBQaI/KonYQyrgFjIZY41E30GWAiNjiOGnkjMJf7UKSSlElRKucELBPLqGJ2s +vlvc6zXPCP8MhQ5/9J7OX1kXgEoxiOkh9nG8617xjOrlTWsG/oYCGk6gpgXrkUDy +/erUFQKBgQDY8h3pTIC3ZvFcy0+UpvVMceLWfaP9+/8dTpAr0HClNOjQC0Fuq6cV +nazAREnDB62y4keGV5xcZdHQ9bZBR4dq4h1oFQUq7RJr5fsgaxN13JPJht2xf/ra +hK3WKZN5oa/hrRu5m+z9rOwR4T7B863cBs/b1YNj3eKUIakHJEv5xw== +-----END RSA PRIVATE KEY----- diff --git a/tests/integration/rancherostest/test_system.py b/tests/integration/rancherostest/test_00_system.py similarity index 98% rename from tests/integration/rancherostest/test_system.py rename to tests/integration/rancherostest/test_00_system.py index 69bf852b..1df720a1 100644 --- a/tests/integration/rancherostest/test_system.py +++ b/tests/integration/rancherostest/test_00_system.py @@ -29,7 +29,7 @@ def test_system_boot(qemu): assert False -@pytest.mark.timeout(40) +@pytest.mark.timeout(60) def test_run_system_container(qemu): assert qemu.returncode is None diff --git a/tests/integration/rancherostest/test_01_cloud_config.py b/tests/integration/rancherostest/test_01_cloud_config.py new file mode 100644 index 00000000..0ca44798 --- /dev/null +++ b/tests/integration/rancherostest/test_01_cloud_config.py @@ -0,0 +1,28 @@ +import pytest +import rancherostest.util as u +import subprocess + + +ssh_command = ['ssh', '-p', '2222', '-F', './assets/scripts_ssh_config', '-i', './tests/integration/assets/test.key', + 'rancher@localhost'] + + +@pytest.fixture(scope="module") +def qemu(request): + return u.run_qemu(request, ['--cloud-config', './tests/integration/assets/cloud-config-1.yml']) + + +@pytest.mark.timeout(40) +def test_check_whats_going_on(qemu): + assert qemu.returncode is 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) + + with ssh, ssh.stdout as f: + for ln in iter(f.readline, ''): + print(str.strip(ln)) + + assert ssh.returncode == 0 diff --git a/tests/integration/rancherostest/util.py b/tests/integration/rancherostest/util.py index e5fd4e6c..d77ec9d8 100644 --- a/tests/integration/rancherostest/util.py +++ b/tests/integration/rancherostest/util.py @@ -19,6 +19,6 @@ def run_qemu(request, run_args=[]): @pytest.mark.timeout(10) -def wait_for_ssh(): - while subprocess.call(['./scripts/ssh', '/bin/true']) != 0: +def wait_for_ssh(ssh_command=['./scripts/ssh']): + while subprocess.call(ssh_command + ['/bin/true']) != 0: time.sleep(1)