Skip to content

Commit

Permalink
Merge pull request #707 from lago-project/sdk_functional_move_fixtures
Browse files Browse the repository at this point in the history
SDK functional move fixtures and update images
  • Loading branch information
ovirt-infra authored Apr 15, 2018
2 parents 8291249 + cb3a4e7 commit 306d9aa
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 71 deletions.
14 changes: 6 additions & 8 deletions tests/functional-sdk/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import pytest
import shutil
from lago_fixtures import ( # noqa: F401
tmp_workdir, init_dict, init_fname, test_results,
external_log, env, vms, nets
)

_local_config = {
'check_patch': {
Expand All @@ -10,8 +14,8 @@
{
'images':
[
'el7.4-base', 'el6-base', 'fc25-base', 'fc26-base',
'fc27-base', 'ubuntu16.04-base', 'debian8-base'
'el7.4-base-1', 'el6-base', 'fc26-base', 'fc27-base',
'ubuntu16.04-base', 'debian8-base'
]
} # noqa: E123
}
Expand Down Expand Up @@ -61,9 +65,3 @@ def global_test_results():
shutil.rmtree(workdir)
os.makedirs(workdir)
return str(workdir)


@pytest.fixture(scope='module')
def tmp_workdir(tmpdir_factory):
env_workdir = tmpdir_factory.mktemp('env')
return env_workdir
73 changes: 73 additions & 0 deletions tests/functional-sdk/lago_fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import logging
import os
import shutil
import tempfile
import pytest
import yaml
from lago import sdk


@pytest.fixture(scope='module')
def tmp_workdir(tmpdir_factory):
env_workdir = tmpdir_factory.mktemp('env')
return env_workdir


@pytest.fixture(scope='module')
def init_dict(init_str):
return yaml.load(init_str)


@pytest.fixture(scope='module')
def init_fname(init_str):
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(init_str)
return f.name


@pytest.fixture(scope='module')
def test_results(request, global_test_results):
results_path = os.path.join(
global_test_results, str(request.module.__name__)
)
os.makedirs(results_path)
return results_path


@pytest.fixture(scope='module')
def external_log(tmpdir_factory):
return tmpdir_factory.mktemp('external_log').join('custom_log.log')


@pytest.fixture(scope='module', autouse=True)
def env(request, init_fname, test_results, tmp_workdir, external_log):
workdir = os.path.join(str(tmp_workdir), 'lago')
env = sdk.init(
init_fname,
workdir=workdir,
logfile=str(external_log),
loglevel=logging.DEBUG,
)
env.start()
try:
yield env
collect_path = os.path.join(test_results, 'collect')
env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
shutil.copytree(
workdir,
os.path.join(test_results, 'workdir'),
ignore=shutil.ignore_patterns('*images*')
)
finally:
env.stop()
env.destroy()


@pytest.fixture(scope='module')
def vms(env):
return env.get_vms()


@pytest.fixture(scope='module')
def nets(env):
return env.get_nets()
63 changes: 0 additions & 63 deletions tests/functional-sdk/test_sdk_sanity.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import pytest
import yaml
import textwrap
import tempfile
import os
import shutil
import logging
import uuid
import filecmp
from jinja2 import Environment, BaseLoader
from lago import sdk
from lago.utils import run_command
from lago.plugins.vm import ExtractPathNoPathError

from utils import RandomizedDir


Expand Down Expand Up @@ -69,66 +66,6 @@ def init_str(images):
return template.render(images=images)


@pytest.fixture(scope='module')
def init_dict(init_str):
return yaml.load(init_str)


@pytest.fixture(scope='module')
def init_fname(init_str):
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(init_str)
return f.name


@pytest.fixture(scope='module')
def test_results(request, global_test_results):
results_path = os.path.join(
global_test_results, str(request.module.__name__)
)
os.makedirs(results_path)
return results_path


@pytest.fixture(scope='module')
def external_log(tmpdir_factory):
return tmpdir_factory.mktemp('external_log').join('custom_log.log')


@pytest.fixture(scope='module', autouse=True)
def env(request, init_fname, test_results, tmp_workdir, external_log):
workdir = os.path.join(str(tmp_workdir), 'lago')
env = sdk.init(
init_fname,
workdir=workdir,
logfile=str(external_log),
loglevel=logging.DEBUG,
)
env.start()
try:
yield env
collect_path = os.path.join(test_results, 'collect')
env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
shutil.copytree(
workdir,
os.path.join(test_results, 'workdir'),
ignore=shutil.ignore_patterns('*images*')
)
finally:
env.stop()
env.destroy()


@pytest.fixture(scope='module')
def vms(env):
return env.get_vms()


@pytest.fixture(scope='module')
def nets(env):
return env.get_nets()


@pytest.fixture
def randomized_dir(tmpdir):
randomized_path = os.path.join(str(tmpdir), 'random')
Expand Down

0 comments on commit 306d9aa

Please sign in to comment.