Changeset - 0f349663e20c
[Not reviewed]
0 5 0
Branko Majic (branko) - 7 years ago 2017-06-06 11:01:59
branko@majic.rs
MAR-30: Fixes for multiple platforms and more extensive testing:

- Include instructions on how to run tests against different platforms (Debian
versions).
- Use correct base box for Debian Stretch when testing role 'preseed'.
- Use fixed hostnames when runnig teets for role 'preseed'.
- Make sure to test preseed configuration file when providing overrides for a
host that does not include overrides as well in role 'preseed'.
5 files changed with 47 insertions and 9 deletions:
0 comments (0 inline, 0 general)
docs/development.rst
Show inline comments
 
@@ -78,10 +78,18 @@ In order to run tests for a specific role, perform the following steps:
 

	
 
     cd roles/ROLENAME/
 

	
 
3. Run tests::
 
3. List available supported platforms::
 

	
 
     molecule list
 

	
 
4. Run tests for default platform (Debian Jessie)::
 

	
 
     molecule test
 

	
 
5. Run tests for Debian Stretch (if role tests support it)::
 

	
 
     molecule test --platform debian-stretch64
 

	
 

	
 
.. _testsite:
 

	
roles/preseed/molecule.yml
Show inline comments
 
@@ -11,7 +11,7 @@ vagrant:
 
    - name: debian-jessie64
 
      box: debian/contrib-jessie64
 
    - name: debian-stretch64
 
      box: debian/contrib-stretch64
 
      box: debian/stretch64
 

	
 
  providers:
 
    - name: virtualbox
roles/preseed/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -40,13 +40,13 @@ def test_preseed_configuration_files(File, Sudo):
 
            assert preseed_file.mode == 0o640
 

	
 

	
 
def test_preseed_configuration_file_content(File, Sudo, TestinfraBackend):
 
def test_preseed_configuration_file_content(File, Sudo):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    with Sudo():
 
        preseed_file = File(os.path.join(os.getcwd(), ".molecule", "preseed_files", "%s.cfg" % TestinfraBackend.get_hostname()))
 
        preseed_file = File(os.path.join(os.getcwd(), ".molecule", "preseed_files", "parameters-mandatory.cfg"))
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
 

	
roles/preseed/tests/test_parameters_optional.py
Show inline comments
 
@@ -23,7 +23,7 @@ def test_preseed_directory(File, Sudo):
 
        assert preseed_directory.mode == 0o750
 

	
 

	
 
def test_preseed_configuration_files(File, Sudo, TestinfraBackend):
 
def test_preseed_configuration_files(File, Sudo):
 
    """
 
    Tests presence and permissions on created preseed configuration files.
 
    """
 
@@ -39,13 +39,13 @@ def test_preseed_configuration_files(File, Sudo, TestinfraBackend):
 
            assert preseed_file.mode == 0o640
 

	
 

	
 
def test_preseed_configuration_file_content(File, Sudo, TestinfraBackend):
 
def test_preseed_configuration_file_content(File, Sudo):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    with Sudo():
 
        preseed_file = File(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % TestinfraBackend.get_hostname()))
 
        preseed_file = File(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % 'parameters-optional'))
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
roles/preseed/tests/test_parameters_optional_with_overrides.py
Show inline comments
 
@@ -23,13 +23,43 @@ def test_preseed_directory(File, Sudo, Ansible):
 
        assert preseed_directory.mode == 0o750
 

	
 

	
 
def test_preseed_configuration_file_content(File, Sudo, TestinfraBackend):
 
def test_preseed_configuration_file_content_host_without_overrides(File, Sudo):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    with Sudo():
 
        preseed_file = File(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % TestinfraBackend.get_hostname()))
 
        preseed_file = File(os.path.join(PRESEED_DIRECTORY, "parameters-mandatory.cfg"))
 
        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(File, Sudo):
 
    """
 
    Tests content of generated preseed configuration file.
 
    """
 

	
 
    with Sudo():
 
        preseed_file = File(os.path.join(PRESEED_DIRECTORY, "parameters-optional-with-overrides.cfg"))
 
        preseed_file_content = preseed_file.content_string
 
        ssh_public_key = "CUSTOMKEY"
 

	
0 comments (0 inline, 0 general)