116205f054fbb9758dafe5190892e6ee6cb41413
[oom/offline-installer.git] / ansible / roles / application / molecule / default / tests / test_default.py
1 import os
2
3 import testinfra.utils.ansible_runner
4
5 testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
6     os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
7
8
9 def test_helm_commands(host):
10     fc = host.file('/tmp/helm_simu_output').content_string.strip()
11     helm_release = host.ansible.get_variables()['helm_version']
12     if helm_release == 'v2':
13         expected_content = """home
14 init --upgrade --skip-refresh
15 version --tiller-connection-timeout 10
16 repo list
17 serve
18 repo list
19 repo add local http://127.0.0.1:8879
20 deploy moleculetestapp local/moleculetestapp --namespace \
21 moleculetestapp -f /opt/moleculetestapp/helm_charts/onap/resources/\
22 overrides/onap-all.yaml -f /opt/moleculetestapp/override.yaml \
23 --timeout 1800"""
24         expected_plugin_path = '/plugins/deploy/deploy.sh'
25     elif helm_release == 'v3':
26         expected_content = """env
27 repo list
28 repo add local http://127.0.0.1:8879
29 deploy moleculetestapp local/moleculetestapp --namespace \
30 moleculetestapp -f /opt/moleculetestapp/helm_charts/onap/resources/\
31 overrides/onap-all.yaml -f /opt/moleculetestapp/override.yaml \
32 --timeout 1800s"""
33         expected_plugin_path = '/root/.local/share/helm/plugins/deploy/' +\
34                                'deploy.sh'
35     assert fc == expected_content
36     assert host.file(expected_plugin_path).exists
37
38
39 def test_helm_override_file(host):
40     fc = host.file('/opt/moleculetestapp/override.yaml').content_string.strip()
41     expected_content = """global:
42     cacert: 'this is dummy server certificate value
43
44         '"""
45     assert fc == expected_content