Changeset - 3d3f7f804487
[Not reviewed]
0 3 0
Branko Majic (branko) - 7 years ago 2017-06-07 16:58:31
branko@majic.rs
MAR-22: Added missing tests for common role and did small clean-up:

- Removed deployment of SSH client configuration from helper machine.
- Added tests for verifying backup configuration (deployed via meta
dependencies).
3 files changed with 30 insertions and 28 deletions:
0 comments (0 inline, 0 general)
roles/common/playbook.yml
Show inline comments
 
@@ -15,34 +15,6 @@
 
        name: apt-cacher-ng
 
        state: installed
 

	
 
    - name: Set-up SSH directory
 
      file:
 
        path: /home/vagrant/.ssh/
 
        state: directory
 
        owner: vagrant
 
        group: vagrant
 
        mode: 0700
 

	
 
    - name: Deploy SSH client private keys
 
      copy:
 
        src: "{{ item.key }}"
 
        dest: "{{ item.value }}"
 
        owner: vagrant
 
        group: vagrant
 
        mode: 0600
 
      with_dict:
 
        "tests/data/ssh/clientkey1": "/home/vagrant/.ssh/clientkey1"
 
        "tests/data/ssh/clientkey2": "/home/vagrant/.ssh/clientkey2"
 
        "tests/data/ssh/clientkey3": "/home/vagrant/.ssh/clientkey3"
 

	
 
    - name: Deploy SSH client configuration
 
      copy:
 
        src: "tests/data/ssh/ssh_config"
 
        dest: "/home/vagrant/.ssh/config"
 
        owner: vagrant
 
        group: vagrant
 
        mode: 0600
 

	
 
- hosts: parameters-mandatory
 
  roles:
 
    - role: common
roles/common/tests/test_parameters_mandatory.py
Show inline comments
 
@@ -112,3 +112,13 @@ def test_pipreqcheck_virtualenv_user(Group, User):
 
    assert user.uid == 1001
 
    assert user.group == 'pipreqcheck'
 
    assert user.groups == ['pipreqcheck']
 

	
 

	
 
def test_backup_configuration_absent(File, Sudo):
 
    """
 
    Tests if backup configuration is absent. This should be the case when only
 
    mandatory parameters are provided.
 
    """
 

	
 
    with Sudo():
 
        assert not File('/etc/duply/main/patterns/common').exists
roles/common/tests/test_parameters_optional.py
Show inline comments
 
@@ -251,3 +251,23 @@ def test_pipreqcheck_virtualenv_user(Group, User):
 
    assert user.uid == 2500
 
    assert user.group == 'pipreqcheck'
 
    assert user.groups == ['pipreqcheck']
 

	
 

	
 
def test_backup_configuration(File, Sudo):
 
    """
 
    Tests if backup configuration has been deployed correctly.
 
    """
 

	
 
    with Sudo():
 

	
 
        common = File('/etc/duply/main/patterns/common')
 
        assert common.is_file
 
        assert "/var/log" in common.content.split("\n")
 
        assert "/etc/shadow" in common.content.split("\n")
 
        assert "/var/mail" in common.content.split("\n")
 
        assert "/var/spool/cron" in common.content.split("\n")
 

	
 
        common_extra = File('/etc/duply/main/patterns/common_extra')
 
        assert common_extra.is_file
 
        assert "/home/user1" in common_extra.content.split("\n")
 
        assert "/home/user2" in common_extra.content.split("\n")
0 comments (0 inline, 0 general)