Created
May 7, 2017 14:19
-
-
Save nvgoldin/f89b2bac5c61a2f352dbd5e1734e25a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
import textwrap | |
import tempfile | |
from lago import sdk | |
def generate_config(): | |
conf = """ | |
domains: | |
vm-el73: | |
nics: | |
- net: lago | |
disks: | |
- template_name: el7.3-base | |
type: template | |
name: root | |
dev: sda | |
format: qcow2 | |
nets: | |
lago: | |
type: nat | |
dhcp: | |
start: 100 | |
end: 254 | |
management: true | |
dns_domain_name: lago.local | |
""" | |
with tempfile.NamedTemporaryFile(delete=False) as f: | |
f.write(textwrap.dedent(conf)) | |
return f.name | |
@pytest.fixture(scope='module') | |
def env(): | |
env = sdk.init(config=generate_config(), workdir='/tmp/pytest-lago') | |
env.start() | |
yield env | |
env.destroy() | |
@pytest.fixture(scope='module') | |
def vm(env): | |
vm = env.get_vms()['vm-el73'] | |
return vm | |
def test_ls(vm): | |
res = vm.ssh(['ls', '-lsah']) | |
assert res.code == 0 | |
def test_hostname(vm): | |
res = vm.ssh(['hostname -f']) | |
assert res.code == 0 | |
assert str.strip(res.out) == 'vm-el73.lago.local' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment