|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright oVirt Authors |
| 4 | +# SPDX-License-Identifier: GPL-2.0-or-later |
| 5 | +# |
| 6 | + |
| 7 | +import pytest |
| 8 | + |
| 9 | +from ost_utils import network_utils |
| 10 | + |
| 11 | +from ost_utils.pytest import pytest_collection_modifyitems |
| 12 | + |
| 13 | +from ost_utils.pytest.fixtures import root_password |
| 14 | + |
| 15 | +from ost_utils.pytest.fixtures.ansible import ansible_all |
| 16 | +from ost_utils.pytest.fixtures.ansible import ansible_by_hostname |
| 17 | +from ost_utils.pytest.fixtures.ansible import ansible_clean_private_dirs |
| 18 | +from ost_utils.pytest.fixtures.ansible import ansible_collect_logs |
| 19 | +from ost_utils.pytest.fixtures.ansible import ansible_engine |
| 20 | +from ost_utils.pytest.fixtures.ansible import ansible_engine_facts |
| 21 | +from ost_utils.pytest.fixtures.ansible import ansible_dwh |
| 22 | +from ost_utils.pytest.fixtures.ansible import ansible_dwh_facts |
| 23 | +from ost_utils.pytest.fixtures.ansible import ansible_host0_facts |
| 24 | +from ost_utils.pytest.fixtures.ansible import ansible_host0 |
| 25 | +from ost_utils.pytest.fixtures.ansible import ansible_host1 |
| 26 | +from ost_utils.pytest.fixtures.ansible import ansible_hosts |
| 27 | +from ost_utils.pytest.fixtures.ansible import ansible_inventory |
| 28 | +from ost_utils.pytest.fixtures.ansible import ansible_storage |
| 29 | +from ost_utils.pytest.fixtures.ansible import ansible_storage_facts |
| 30 | + |
| 31 | +from ost_utils.pytest.fixtures.artifacts import artifacts_dir |
| 32 | +from ost_utils.pytest.fixtures.artifacts import collect_artifacts |
| 33 | +from ost_utils.pytest.fixtures.artifacts import collect_vdsm_coverage_artifacts |
| 34 | +from ost_utils.pytest.fixtures.artifacts import dump_dhcp_leases |
| 35 | +from ost_utils.pytest.fixtures.artifacts import generate_sar_stat_plots |
| 36 | + |
| 37 | +from ost_utils.pytest.fixtures.backend import all_hostnames |
| 38 | +from ost_utils.pytest.fixtures.backend import backend |
| 39 | +from ost_utils.pytest.fixtures.backend import backend_engine_hostname |
| 40 | +from ost_utils.pytest.fixtures.backend import backend_dwh_hostname |
| 41 | +from ost_utils.pytest.fixtures.backend import deploy_scripts |
| 42 | +from ost_utils.pytest.fixtures.backend import host0_hostname |
| 43 | +from ost_utils.pytest.fixtures.backend import host1_hostname |
| 44 | +from ost_utils.pytest.fixtures.backend import hosts_hostnames |
| 45 | +from ost_utils.pytest.fixtures.backend import management_network_supports_ipv4 |
| 46 | +from ost_utils.pytest.fixtures.backend import storage_hostname |
| 47 | + |
| 48 | +from ost_utils.pytest.fixtures.defaults import * |
| 49 | + |
| 50 | +from ost_utils.pytest.fixtures.deployment import deploy |
| 51 | +from ost_utils.pytest.fixtures.deployment import run_scripts |
| 52 | +from ost_utils.pytest.fixtures.deployment import set_sar_interval |
| 53 | + |
| 54 | +from ost_utils.pytest.fixtures.engine import * |
| 55 | + |
| 56 | +from ost_utils.pytest.fixtures.grafana import * |
| 57 | + |
| 58 | +from ost_utils.pytest.fixtures.keycloak import * |
| 59 | + |
| 60 | +from ost_utils.pytest.fixtures.env import ost_images_distro |
| 61 | +from ost_utils.pytest.fixtures.env import root_dir |
| 62 | +from ost_utils.pytest.fixtures.env import ssh_key_file |
| 63 | +from ost_utils.pytest.fixtures.env import suite_dir |
| 64 | +from ost_utils.pytest.fixtures.env import working_dir |
| 65 | +from ost_utils.pytest.fixtures.env import master_storage_domain_type |
| 66 | + |
| 67 | +from ost_utils.pytest.fixtures.network import bonding_network_name |
| 68 | +from ost_utils.pytest.fixtures.network import management_gw_ip |
| 69 | +from ost_utils.pytest.fixtures.network import management_network_name |
| 70 | + |
| 71 | +from ost_utils.pytest.fixtures.node import * |
| 72 | + |
| 73 | +from ost_utils.pytest.fixtures.sdk import * |
| 74 | + |
| 75 | +from ost_utils.pytest.fixtures.storage import * |
| 76 | + |
| 77 | +from ost_utils.pytest.running_time import * |
| 78 | + |
| 79 | + |
| 80 | +@pytest.fixture(scope="session") |
| 81 | +def sd_iscsi_host_ip(storage_ips_for_network, storage_network_name): # pylint: disable=function-redefined |
| 82 | + return storage_ips_for_network(storage_network_name)[0] |
| 83 | + |
| 84 | + |
| 85 | +@pytest.fixture(scope="session") |
| 86 | +def sd_nfs_host_storage_name( |
| 87 | + storage_hostname, |
| 88 | +): # pylint: disable=function-redefined |
| 89 | + return storage_hostname |
| 90 | + |
| 91 | + |
| 92 | +@pytest.fixture(scope="session") |
| 93 | +def sd_iscsi_ansible_host( |
| 94 | + ansible_storage, |
| 95 | +): # pylint: disable=function-redefined |
| 96 | + return ansible_storage |
| 97 | + |
| 98 | + |
| 99 | +@pytest.fixture(scope="session") |
| 100 | +def engine_db_password(): |
| 101 | + return 'engine_db_password123' |
| 102 | + |
| 103 | + |
| 104 | +@pytest.fixture(scope="session") |
| 105 | +def dwh_fqdn(ansible_dwh_facts, suite): |
| 106 | + return ansible_dwh_facts.get("ansible_fqdn") |
| 107 | + |
| 108 | + |
| 109 | +@pytest.fixture(scope="session") |
| 110 | +def grafana_fqdn( |
| 111 | + dwh_fqdn, |
| 112 | +): # pylint: disable=function-redefined |
| 113 | + return dwh_fqdn |
| 114 | + |
| 115 | + |
| 116 | +@pytest.fixture(scope="session") |
| 117 | +def engine_answer_file_contents( |
| 118 | + engine_password, |
| 119 | + engine_fqdn, |
| 120 | + engine_full_username, |
| 121 | + engine_db_password, |
| 122 | +): # pylint: disable=function-redefined |
| 123 | + return ( |
| 124 | + '# action=setup\n' |
| 125 | + '[environment:default]\n' |
| 126 | + 'OVESETUP_DIALOG/confirmSettings=bool:True\n' |
| 127 | + 'OVESETUP_CONFIG/applicationMode=str:both\n' |
| 128 | + 'OVESETUP_CONFIG/remoteEngineSetupStyle=none:None\n' |
| 129 | + f'OVESETUP_CONFIG/adminPassword=str:{engine_password}\n' |
| 130 | + 'OVESETUP_CONFIG/storageIsLocal=bool:False\n' |
| 131 | + 'OVESETUP_CONFIG/firewallManager=str:firewalld\n' |
| 132 | + 'OVESETUP_CONFIG/remoteEngineHostRootPassword=none:None\n' |
| 133 | + 'OVESETUP_CONFIG/firewallChangesReview=none:None\n' |
| 134 | + 'OVESETUP_CONFIG/updateFirewall=bool:True\n' |
| 135 | + 'OVESETUP_CONFIG/remoteEngineHostSshPort=none:None\n' |
| 136 | + f'OVESETUP_CONFIG/fqdn=str:{engine_fqdn}\n' |
| 137 | + 'OVESETUP_CONFIG/storageType=none:None\n' |
| 138 | + 'OSETUP_RPMDISTRO/requireRollback=none:None\n' |
| 139 | + 'OSETUP_RPMDISTRO/enableUpgrade=bool:True\n' |
| 140 | + 'OVESETUP_DB/database=str:engine\n' |
| 141 | + 'OVESETUP_DB/fixDbViolations=none:None\n' |
| 142 | + 'OVESETUP_DB/secured=bool:False\n' |
| 143 | + 'OVESETUP_DB/host=str:localhost\n' |
| 144 | + 'OVESETUP_DB/user=str:engine\n' |
| 145 | + 'OVESETUP_DB/securedHostValidation=bool:False\n' |
| 146 | + f'OVESETUP_DB/password=str:{engine_db_password}\n' |
| 147 | + 'OVESETUP_DB/port=int:5432\n' |
| 148 | + 'OVESETUP_ENGINE_CORE/enable=bool:True\n' |
| 149 | + 'OVESETUP_CORE/engineStop=none:None\n' |
| 150 | + 'OVESETUP_SYSTEM/memCheckEnabled=bool:False\n' |
| 151 | + 'OVESETUP_SYSTEM/nfsConfigEnabled=bool:False\n' |
| 152 | + 'OVESETUP_PKI/organization=str:Test\n' |
| 153 | + 'OVESETUP_CONFIG/isoDomainMountPoint=none:None\n' |
| 154 | + 'OVESETUP_CONFIG/isoDomainName=none:None\n' |
| 155 | + 'OVESETUP_CONFIG/isoDomainACL=none:None\n' |
| 156 | + 'OVESETUP_AIO/configure=none:None\n' |
| 157 | + 'OVESETUP_AIO/storageDomainName=none:None\n' |
| 158 | + 'OVESETUP_AIO/storageDomainDir=none:None\n' |
| 159 | + 'OVESETUP_PROVISIONING/postgresProvisioningEnabled=bool:True\n' |
| 160 | + 'OVESETUP_APACHE/configureRootRedirection=bool:True\n' |
| 161 | + 'OVESETUP_APACHE/configureSsl=bool:True\n' |
| 162 | + 'OVESETUP_CONFIG/websocketProxyConfig=bool:True\n' |
| 163 | + f'OVESETUP_ENGINE_CONFIG/fqdn=str:{engine_fqdn}\n' |
| 164 | + 'OVESETUP_CONFIG/sanWipeAfterDelete=bool:False\n' |
| 165 | + 'OVESETUP_VMCONSOLE_PROXY_CONFIG/vmconsoleProxyConfig=bool:True\n' |
| 166 | + 'OVESETUP_DWH_CORE/enable=bool:False\n' |
| 167 | + 'QUESTION/1/OVESETUP_GRAFANA_ENABLE=str:no\n' |
| 168 | + f'OVESETUP_OVN/ovirtProviderOvnUser=str:{engine_full_username}\n' |
| 169 | + f'OVESETUP_OVN/ovirtProviderOvnPassword=str:{engine_password}\n' |
| 170 | + 'OVESETUP_CONFIG/imageioProxyConfig=bool:True\n' |
| 171 | + 'QUESTION/1/ovirt-cinderlib-enable=str:yes\n' |
| 172 | + ) |
| 173 | + |
| 174 | + |
| 175 | +@pytest.fixture(scope="session") |
| 176 | +def dwh_answer_file_contents( |
| 177 | + engine_password, |
| 178 | + engine_fqdn, |
| 179 | + dwh_fqdn, |
| 180 | + root_password, |
| 181 | + engine_db_password, |
| 182 | + engine_full_username, |
| 183 | +): # pylint: disable=function-redefined |
| 184 | + return ( |
| 185 | + '# action=setup\n' |
| 186 | + '[environment:default]\n' |
| 187 | + 'QUESTION/1/OVESETUP_ENGINE_ENABLE=str:no\n' |
| 188 | + 'QUESTION/1/OVESETUP_DWH_SCALE=str:2\n' |
| 189 | + 'QUESTION/1/OVESETUP_ENGINE_DB_DATABASE=str:engine\n' |
| 190 | + f'QUESTION/1/OVESETUP_ENGINE_DB_HOST=str:{engine_fqdn}\n' |
| 191 | + f'QUESTION/1/OVESETUP_ENGINE_DB_PASSWORD=str:{engine_db_password}\n' |
| 192 | + 'QUESTION/1/OVESETUP_ENGINE_DB_PORT=str:5432\n' |
| 193 | + 'QUESTION/1/OVESETUP_ENGINE_DB_SECURED=str:no\n' |
| 194 | + 'QUESTION/1/OVESETUP_ENGINE_DB_USER=str:engine\n' |
| 195 | + f'QUESTION/1/OVESETUP_NETWORK_FQDN_the_engine=str:{engine_fqdn}\n' |
| 196 | + f'QUESTION/1/OVESETUP_NETWORK_FQDN_this=str:{dwh_fqdn}\n' |
| 197 | + f'QUESTION/1/SSH_ACCESS_REMOTE_ENGINE_PASSWORD=str:{root_password}\n' |
| 198 | + f'QUESTION/1/queryEnvKey_input_OVESETUP_GRAFANA_CONFIG/adminPassword=str:{root_password}\n' |
| 199 | + f'QUESTION/1/queryEnvKey_input_second_password=str:{root_password}\n' |
| 200 | + 'QUESTION/1/queryEnvKey_warnverify_OVESETUP_GRAFANA_CONFIG/adminPassword=str:yes\n' |
| 201 | + 'QUESTION/1/ovirt-provider-ovn=str:no\n' |
| 202 | + 'QUESTION/1/OVESETUP_CONFIG_WEBSOCKET_PROXY=str:no\n' |
| 203 | + ) |
| 204 | + |
| 205 | + |
| 206 | +@pytest.fixture(scope="session") |
| 207 | +def dwh_answer_file_path(dwh_answer_file_contents, working_dir): |
| 208 | + file_path = os.path.join(working_dir, 'dwh-answer-file') |
| 209 | + with open(file_path, 'w') as f: |
| 210 | + f.write(dwh_answer_file_contents) |
| 211 | + return file_path |
0 commit comments