diff options
author | Samuli Silvius <s.silvius@partner.samsung.com> | 2019-03-22 09:33:05 +0200 |
---|---|---|
committer | Samuli Silvius <s.silvius@partner.samsung.com> | 2019-04-16 08:19:10 +0300 |
commit | 9367c59e3cfda457fce7494a1ec065c7aa80853b (patch) | |
tree | fccbe9e6cc115476571442b97fecb383bc2b2b88 /ansible/roles/resource-data/molecule/default/tests | |
parent | 52eb50721e990e277ed8729225faff305dee11da (diff) |
Molecule tests for resource-data role
Initial molecule tests. Tests now ssh transfer but
test files fully supports also testing nfs transfer.
Creating nfs transfer as separate scenario later when
find out better ways to share common code.
Issue-ID: OOM-1754
Change-Id: Ia728ecfed4378c01f7e305d5a4446b0172fe42d9
Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com>
Diffstat (limited to 'ansible/roles/resource-data/molecule/default/tests')
-rw-r--r-- | ansible/roles/resource-data/molecule/default/tests/test_default.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ansible/roles/resource-data/molecule/default/tests/test_default.py b/ansible/roles/resource-data/molecule/default/tests/test_default.py new file mode 100644 index 00000000..7cff76a7 --- /dev/null +++ b/ansible/roles/resource-data/molecule/default/tests/test_default.py @@ -0,0 +1,56 @@ +import os +import pytest + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('infrastructure-server') + + +@pytest.fixture +def group_vars(host): + all_file = "file=group_vars/all.yml name=all" + return host.ansible("include_vars", all_file)["ansible_facts"]["all"] + + +@pytest.mark.parametrize('dir', [ + 'app_data_path', + 'aux_data_path' +]) +def test_data_target_dirs(host, dir, group_vars): + tested_dir = host.file(group_vars[dir]) + assert tested_dir.exists + assert tested_dir.is_directory + + +@pytest.mark.parametrize('target_file', [ + 'resource1.txt', + 'resource2.txt', + 'resource3.txt', + 'somedir/resource4.txt' +]) +def test_transferred_resources_files(host, target_file, group_vars): + tested_file = host.file(group_vars["app_data_path"] + "/" + target_file) + assert tested_file.exists + assert tested_file.is_file + + flag_file = \ + host.file(group_vars["app_data_path"] + "/" + + group_vars["resources_filename"] + "-uploaded") + assert flag_file.exists + assert flag_file.is_file + + +@pytest.mark.parametrize('target_file', [ + 'auxdata' +]) +def test_transferred_aux_resources_files(host, target_file, group_vars): + tested_file = host.file(group_vars["aux_data_path"] + "/" + target_file) + assert tested_file.exists + assert tested_file.is_file + + flag_file = \ + host.file(group_vars["aux_data_path"] + "/" + + group_vars["aux_resources_filename"] + "-uploaded") + assert flag_file.exists + assert flag_file.is_file |