Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testinfra fixes for dual distro #5529

Merged
merged 4 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion molecule/libvirt-staging-focal/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ verifier:
name: testinfra
lint:
name: flake8
directory: ../testinfra/staging/
directory: ../testinfra/
options:
n: auto
v: 2
Expand Down
3 changes: 2 additions & 1 deletion molecule/testinfra/app-code/test_securedrop_app_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

securedrop_test_vars = pytest.securedrop_test_vars
testinfra_hosts = [securedrop_test_vars.app_hostname]
python_version = securedrop_test_vars.python_version


def test_apache_default_docroot_is_absent(host):
Expand All @@ -21,7 +22,7 @@ def test_apache_default_docroot_is_absent(host):
'gnupg2',
'haveged',
'libapache2-mod-xsendfile',
'libpython3.5',
'libpython{}'.format(python_version),
'paxctld',
'python3',
'redis-server',
Expand Down
6 changes: 3 additions & 3 deletions molecule/testinfra/common/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
testinfra_hosts = [test_vars.app_hostname, test_vars.monitor_hostname]

# We expect Ubuntu Xenial
SUPPORTED_CODENAMES = ('xenial')
SUPPORTED_RELEASES = ('16.04')
SUPPORTED_CODENAMES = ('xenial', 'focal')
SUPPORTED_RELEASES = ('16.04', '20.04')


def test_ansible_version(host):
Expand All @@ -23,7 +23,7 @@ def test_ansible_version(host):

def test_platform(host):
"""
SecureDrop requires Ubuntu Ubuntu 16.04 LTS.
SecureDrop requires Ubuntu Ubuntu 16.04 or 20.04 LTS
"""
assert host.system_info.type == "linux"
assert host.system_info.distribution == "ubuntu"
Expand Down
1 change: 1 addition & 0 deletions molecule/testinfra/common/test_release_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_release_manager_upgrade_channel(host):
"""
expected_channels = {
"xenial": "never",
"focal": "never",
}

config_path = "/etc/update-manager/release-upgrades"
Expand Down
8 changes: 7 additions & 1 deletion molecule/testinfra/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import os
import yaml


# The config tests target staging by default. It's possible to override
# for e.g. prod, but the associated vars files are not yet ported.
target_host = os.environ.get('SECUREDROP_TESTINFRA_TARGET_HOST', 'staging')
Expand All @@ -28,6 +27,13 @@ def securedrop_import_testinfra_vars(hostname, with_header=False):
with io.open(filepath, 'r') as f:
hostvars = yaml.safe_load(f)

if os.environ.get("MOLECULE_SCENARIO_NAME").endswith("focal"):
hostvars['securedrop_venv_site_packages'] = hostvars["securedrop_venv_site_packages"].format("3.8") # noqa: E501
hostvars['python_version'] = "3.8"
else:
hostvars['securedrop_venv_site_packages'] = hostvars["securedrop_venv_site_packages"].format("3.5") # noqa: E501
hostvars['python_version'] = "3.5"

if with_header:
hostvars = dict(securedrop_test_vars=hostvars)

Expand Down
2 changes: 1 addition & 1 deletion molecule/testinfra/vars/app-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ wanted_apache_headers:

securedrop_venv: /opt/venvs/securedrop-app-code
securedrop_venv_bin: /opt/venvs/securedrop-app-code/bin
securedrop_venv_site_packages: /opt/venvs/securedrop-app-code/lib/python3.5/site-packages
securedrop_venv_site_packages: /opt/venvs/securedrop-app-code/lib/python{}/site-packages
securedrop_code: /var/www/securedrop
securedrop_data: /var/lib/securedrop
securedrop_user: www-data
Expand Down
2 changes: 1 addition & 1 deletion molecule/testinfra/vars/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ wanted_apache_headers:

securedrop_venv: /opt/venvs/securedrop-app-code
securedrop_venv_bin: /opt/venvs/securedrop-app-code/bin
securedrop_venv_site_packages: /opt/venvs/securedrop-app-code/lib/python3.5/site-packages
securedrop_venv_site_packages: /opt/venvs/securedrop-app-code/lib/python{}/site-packages
securedrop_code: /var/www/securedrop
securedrop_data: /var/lib/securedrop
securedrop_user: www-data
Expand Down