Changeset - d20f150f3cca
[Not reviewed]
0 3 0
Branko Majic (branko) - 6 years ago 2020-05-07 22:39:04
branko@majic.rs
MAR-149: Fixed typo error in the tests for preseed role (extra _string at end).
3 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
roles/preseed/molecule/default/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -32,45 +32,45 @@ def test_preseed_configuration_files(host):
 

	
 
    with host.sudo():
 

	
 
        # Preseed directory created at same level as inventory.
 
        preseed_directory_path = os.path.join('/tmp/molecule/preseed/default/inventory', 'preseed_files')
 

	
 
        # Verify that preseed configuration files are created for all hosts.
 
        for testinfra_host in testinfra_hosts:
 

	
 
            preseed_file = host.file(os.path.join(preseed_directory_path, "%s.cfg" % testinfra_host))
 

	
 
            assert preseed_file.is_file
 
            assert preseed_file.mode == 0o640
 

	
 

	
 
def test_preseed_configuration_file_content(host):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join("/tmp/molecule/preseed/default/inventory", "preseed_files", "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string_string
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
 

	
 
    assert "d-i debian-installer/language string en" in preseed_file_content
 
    assert "d-i debian-installer/country string SE" in preseed_file_content
 
    assert "d-i debian-installer/locale string en_US.UTF-8" in preseed_file_content
 
    assert "d-i keyboard-configuration/xkb-keymap select us" in preseed_file_content
 
    assert "d-i netcfg/choose_interface select eth0" in preseed_file_content
 

	
 
    assert """# DHCP network configuration.
 
d-i netcfg/disable_autoconfig boolean false
 
d-i netcfg/get_hostname string ignored-value
 
d-i netcfg/get_domain string ignored-value""" in preseed_file_content
 

	
 
    assert "d-i mirror/http/hostname string ftp.se.debian.org" in preseed_file_content
 
    assert "d-i mirror/http/directory string /debian" in preseed_file_content
 
    assert "d-i mirror/http/proxy string " in preseed_file_content
 
    assert "d-i passwd/root-password password root" in preseed_file_content
 
    assert "d-i passwd/root-password-again password root" in preseed_file_content
 
    assert "d-i time/zone string Europe/Stockholm" in preseed_file_content
 
    assert ssh_public_key in preseed_file_content
roles/preseed/molecule/default/tests/test_parameters_optional.py
Show inline comments
 
@@ -27,49 +27,49 @@ def test_preseed_configuration_files(host):
 
    """
 
    Tests presence and permissions on created preseed configuration files.
 
    """
 

	
 
    with host.sudo():
 

	
 
        # Verify that preseed configuration files are created for all hosts.
 
        for testinfra_host in testinfra_hosts:
 

	
 
            preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % testinfra_host))
 

	
 
            assert preseed_file.is_file
 
            assert preseed_file.mode == 0o640
 

	
 

	
 
def test_preseed_configuration_file_content(host):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = host.run('hostname').stdout.strip()
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string_string
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string sr" in preseed_file_content
 
    assert "d-i debian-installer/country string RS" in preseed_file_content
 
    assert "d-i debian-installer/locale string en_UK.UTF-8" in preseed_file_content
 
    assert "d-i keyboard-configuration/xkb-keymap select sv" in preseed_file_content
 
    assert "d-i netcfg/choose_interface select eth1" in preseed_file_content
 

	
 
    assert """# Manual network configuration.
 
d-i netcfg/disable_autoconfig boolean true
 
d-i netcfg/get_ipaddress string 3.3.3.3
 
d-i netcfg/get_netmask string 255.255.0.0
 
d-i netcfg/get_gateway string 2.2.2.2
 
d-i netcfg/get_nameservers string 1.1.1.1
 
d-i netcfg/confirm_static boolean true
 

	
 
# Hostname and domain configuration.
 
d-i netcfg/get_hostname string testing
 
d-i netcfg/get_domain string example.com""" in preseed_file_content
 

	
 
    assert "d-i mirror/http/hostname string ftp.de.debian.org" in preseed_file_content
 
    assert "d-i mirror/http/directory string /" in preseed_file_content
 
    assert "d-i mirror/http/proxy string http://proxy.local" in preseed_file_content
 
    assert "d-i passwd/root-password password myrootpassword" in preseed_file_content
roles/preseed/molecule/default/tests/test_parameters_optional_with_overrides.py
Show inline comments
 
@@ -11,81 +11,81 @@ PRESEED_DIRECTORY = '/tmp/custom_preseed_files_location'
 

	
 

	
 
def test_preseed_directory(host):
 
    """
 
    Test presence and permissions of preseed directory.
 
    """
 

	
 
    with host.sudo():
 

	
 
        preseed_directory = host.file(PRESEED_DIRECTORY)
 

	
 
        assert preseed_directory.is_directory
 
        assert preseed_directory.mode == 0o750
 

	
 

	
 
def test_preseed_configuration_file_content_host_without_overrides(host):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = 'parameters-mandatory-stretch64'
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string_string
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string en" in preseed_file_content
 
    assert "d-i debian-installer/country string SE" in preseed_file_content
 
    assert "d-i debian-installer/locale string en_US.UTF-8" in preseed_file_content
 
    assert "d-i keyboard-configuration/xkb-keymap select us" in preseed_file_content
 
    assert "d-i netcfg/choose_interface select eth0" in preseed_file_content
 

	
 
    assert """# DHCP network configuration.
 
d-i netcfg/disable_autoconfig boolean false
 
d-i netcfg/get_hostname string ignored-value
 
d-i netcfg/get_domain string ignored-value""" in preseed_file_content
 

	
 
    assert "d-i mirror/http/hostname string ftp.se.debian.org" in preseed_file_content
 
    assert "d-i mirror/http/directory string /debian" in preseed_file_content
 
    assert "d-i mirror/http/proxy string " in preseed_file_content
 
    assert "d-i passwd/root-password password root" in preseed_file_content
 
    assert "d-i passwd/root-password-again password root" in preseed_file_content
 
    assert "d-i time/zone string Europe/Stockholm" in preseed_file_content
 
    assert ssh_public_key in preseed_file_content
 

	
 

	
 
def test_preseed_configuration_file_content_host_with_overrides(host):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    hostname = 'parameters-optional-with-overrides-stretch64'
 

	
 
    with host.sudo():
 
        preseed_file = host.file(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % hostname))
 
        preseed_file_content = preseed_file.content_string_string
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
 
    assert "d-i debian-installer/language string sr" in preseed_file_content
 
    assert "d-i debian-installer/country string RS" in preseed_file_content
 
    assert "d-i debian-installer/locale string en_UK.UTF-8" in preseed_file_content
 
    assert "d-i keyboard-configuration/xkb-keymap select sv" in preseed_file_content
 
    assert "d-i netcfg/choose_interface select eth1" in preseed_file_content
 

	
 
    assert """# Manual network configuration.
 
d-i netcfg/disable_autoconfig boolean true
 
d-i netcfg/get_ipaddress string 3.3.3.3
 
d-i netcfg/get_netmask string 255.255.0.0
 
d-i netcfg/get_gateway string 2.2.2.2
 
d-i netcfg/get_nameservers string 1.1.1.1
 
d-i netcfg/confirm_static boolean true
 

	
 
# Hostname and domain configuration.
 
d-i netcfg/get_hostname string testing
 
d-i netcfg/get_domain string example.com""" in preseed_file_content
 

	
 
    assert "d-i mirror/http/hostname string ftp.de.debian.org" in preseed_file_content
 
    assert "d-i mirror/http/directory string /" in preseed_file_content
 
    assert "d-i mirror/http/proxy string http://proxy.local" in preseed_file_content
 
    assert "d-i passwd/root-password password myrootpassword" in preseed_file_content
0 comments (0 inline, 0 general)