Exemple #1
0
    def test_storage_missing_attribute(self, mock_localclient):
        fake_data = {
            'node1': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node2': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node3': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node4': {
                'roles': 'storage'
            }
        }

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.errors) == 0
        validator.storage()
        assert "missing storage attribute" in validator.errors['storage'][0]
 def test_salt_updates_1(self, mock_localclient):
     """
     updates
     repo refresh works on one node
     """
     validate.__utils__ = {'deepsea_minions.show': lambda: '*'}
     validate.__utils__.update({'deepsea_minions.matches': lambda: ['node1', 'node2']})
     fake_data = {'admin.ceph': {'packages': [{'arch': 'x86_64',
                                               'name': 'ceph'},
                                               {'arch': 'x86_64',
                                               'name': 'salt-minion'}],
                                 'status': False},
                  'data1.ceph': {'packages': [{'arch': 'x86_64',
                                               'name': 'ceph'},
                                               {'arch': 'x86_64',
                                               'name': 'salt-master'}],
                                 'status': True}}
     local = mock_localclient.return_value
     local.cmd.return_value = fake_data
     validator = validate.Validate("setup", search_pillar=True)
     validator.salt_updates()
     assert len(validator.errors) == 1
     assert len(validator.warnings) == 1
     assert "You have a salt update pending" in validator.errors['salt_updates'][0]
     assert "Experienced trouble refreshing repositories" in validator.warnings['refresh_repos'][0]
Exemple #3
0
    def test_storage(self, mock_localclient):
        fake_data = {
            'node1': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node2': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node3': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            },
            'node4': {
                'roles': 'storage',
                'ceph': {
                    'storage': 'dummy_osds'
                }
            }
        }

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.passed) == 0
        validator.storage()
        assert validator.passed['storage'] == 'valid'
Exemple #4
0
    def test_no_salt_updates_1(self, mock_localclient):
        """
        updates present
        refresh failed on one node
        """
        validate.__utils__ = {'deepsea_minions.show': lambda: '*'}
        validate.__utils__.update(
            {'deepsea_minions.matches': lambda: ['node1', 'node2']})
        fake_data = {
            'admin.ceph': {
                'packages': [],
                'status': False
            },
            'data1.ceph': {
                'packages': [],
                'status': True
            }
        }

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)
        validator.salt_updates()
        assert len(validator.errors) == 0
        assert len(validator.warnings) == 1
        assert "Experienced trouble refreshing repositories" in validator.warnings[
            'refresh_repos'][0]
Exemple #5
0
    def test_no_salt_updates(self, mock_localclient):
        """
        updates present
        refresh works
        """
        validate.__utils__ = {'deepsea_minions.show': lambda: '*'}
        validate.__utils__.update(
            {'deepsea_minions.matches': lambda: ['node1', 'node2']})
        fake_data = {
            'admin.ceph': {
                'packages': [],
                'status': True
            },
            'data1.ceph': {
                'packages': [],
                'status': True
            }
        }

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)
        validator.salt_updates()
        assert len(validator.errors) == 0
        assert len(validator.warnings) == 0
Exemple #6
0
    def test_dev_env(self, mock_localclient, mock_deepsea, monkeypatch):
        monkeypatch.setenv('DEV_ENV', 'true')
        validator = validate.Validate("setup")

        assert len(validator.passed) == 0
        validator.dev_env()
        assert validator.passed['DEV_ENV'] == 'True'
    def test_rgw_succeeds(self, mock_localclient):
        fake_data = {'node1': {'roles': 'rgw'}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        validator.rgw()
        assert 'rgw' not in validator.errors
    def test_dev_env(self, mock_localclient, monkeypatch):
        validate.__utils__ = {'deepsea_minions.show': lambda: '*'}
        validate.__utils__.update({'deepsea_minions.matches': lambda: ['node1', 'node2']})
        monkeypatch.setenv('DEV_ENV', 'true')
        validator = validate.Validate("setup")

        assert len(validator.passed) == 0
        validator.dev_env()
        assert validator.passed['DEV_ENV'] == 'True'
Exemple #9
0
    def test_ceph_updates_1(self, mock_localclient):
        """
        Refresh fails for one of the minions
        and there are new packages
        """
        validate.__utils__ = {'deepsea_minions.show': lambda: '*'}
        validate.__utils__.update(
            {'deepsea_minions.matches': lambda: ['node1', 'node2']})

        fake_data = {
            'admin.ceph': {
                'packages': [{
                    'arch': 'x86_64',
                    'edition': '13.2.1.427+g6cd01d4dd2-1.10',
                    'edition-old': '13.2.1.427+g6cd01d4dd2-1.8',
                    'kind': 'package',
                    'name': 'ceph'
                }, {
                    'arch': 'x86_64',
                    'edition': '13.2.1.427+g6cd01d4dd2-1.10',
                    'edition-old': '13.2.1.427+g6cd01d4dd2-1.8',
                    'kind': 'package',
                    'name': 'python3-cephfs'
                }],
                'status':
                False
            },
            'data1.ceph': {
                'packages': [{
                    'arch': 'x86_64',
                    'edition': '13.2.1.427+g6cd01d4dd2-1.10',
                    'edition-old': '13.2.1.427+g6cd01d4dd2-1.8',
                    'kind': 'package',
                    'name': 'ceph'
                }, {
                    'arch': 'x86_64',
                    'edition': '13.2.1.427+g6cd01d4dd2-1.10',
                    'edition-old': '13.2.1.427+g6cd01d4dd2-1.8',
                    'kind': 'package',
                    'name': 'python3-cephfs'
                }],
                'status':
                True
            }
        }

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)
        validator.ceph_updates()
        assert len(validator.errors) == 0
        assert len(validator.warnings) == 2
        assert "On or more of your minions have updates pending that might cause ceph-daemons to restart. This might extend the duration of this Stage depending on your cluster size." in validator.warnings[
            'ceph_updates'][0]
        assert "Experienced trouble refreshing the repositories" in validator.warnings[
            'refresh_repos'][0]
Exemple #10
0
    def test_check_ipversion_fails(self, mock_localclient):
        with patch.object(validate.Validate, "__init__", lambda self, n: None):
            validator = validate.Validate("setup")
            validator.errors = {}
            validator.warnings = {}
            validator.passed = {}
            validator.ipversion = set([4, 6])

            validator.check_ipversion()
            assert "Networks must be" in validator.errors['ip_version'][0]
Exemple #11
0
    def test_check_ipversion(self, mock_localclient):
        with patch.object(validate.Validate, "__init__", lambda self, n: None):
            validator = validate.Validate("setup")
            validator.errors = {}
            validator.warnings = {}
            validator.passed = {}
            validator.ipversion = set([4])

            validator.check_ipversion()
            assert validator.passed['ip_version'] == "valid"
Exemple #12
0
    def test_check_installed_succeeds(self, mock_localclient):
        fake_data = {'admin.ceph': {'ceph-common': {'version': '13.0.1'}},
                     'data.ceph': {'ceph-common': {'version': '13.0.1'}}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup")

        validator._check_installed()
        assert 'ceph_version' not in validator.errors
Exemple #13
0
    def test_salt_version_unsupported(self, mock_localclient):
        fake_data = {'admin.ceph': '2016.11.9', 'data.ceph': '2018.1.99'}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_grains=True)

        assert len(validator.warnings) == 0
        validator.salt_version()
        assert 'not supported' in validator.warnings['salt_version'][0]
Exemple #14
0
    def test_salt_version(self, mock_localclient):
        fake_data = {'admin.ceph': '2018.1.99', 'data.ceph': '2018.1.99'}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_grains=True)

        assert len(validator.passed) == 0
        validator.salt_version()
        assert validator.passed['salt_version'] == 'valid'
Exemple #15
0
    def test_mgrs_too_few(self, mock_localclient):
        fake_data = {'mgr1': {'roles': 'mgr'}, 'mgr2': {'roles': 'mgr'}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.errors) == 0
        validator.mgrs()
        assert "Too few mgrs" in validator.errors['mgrs'][0]
Exemple #16
0
    def test_check_installed_is_not_installed(self, mock_localclient):
        fake_data = {'admin.ceph': 'ERROR: package ceph-common is not installed',
                     'data.ceph': {'ceph-common': {'version': '13.0.1'}}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup")

        validator._check_installed()
        assert 'admin.ceph' in validator.uninstalled
Exemple #17
0
    def test_check_installed_has_broken_version(self, mock_localclient):
        fake_data = {'admin.ceph': {'ceph-common': {'nope': 'x.x.x'}},
                     'data.ceph': {'ceph-common': {'version': '13.0.1'}}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup")

        validator._check_installed()
        assert 'admin.ceph' in validator.errors['ceph_version']
Exemple #18
0
    def test_rgw_fails(self, mock_localclient):
        fake_data = {'node1': {'roles': 'rgw-ssl',
                               'rgw_configurations': 'rgw-ssl',
                               'rgw_init': 'default-ssl'}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        validator.rgw()
        assert 'rgw' in validator.errors
Exemple #19
0
    def test_fsid_too_short(self, mock_localclient):
        fsid = 'too short'
        fake_data = {'admin.ceph': {'fsid': fsid}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.errors) == 0
        validator.fsid()
        assert "characters, not 36" in validator.errors['fsid'][0]
Exemple #20
0
    def test_fsid_invalid(self, mock_localclient):
        fsid = 'not a valid-uuid  but still 36 chars'
        fake_data = {'admin.ceph': {'fsid': fsid}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.errors) == 0
        validator.fsid()
        assert "does not appear to be a UUID" in validator.errors['fsid'][0]
Exemple #21
0
    def test_fsid(self, mock_localclient):
        fsid = 'ba0ae5e1-4282-3282-a745-2bf12888a393'
        fake_data = {'admin.ceph': {'fsid': fsid}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.passed) == 0
        validator.fsid()
        assert validator.passed['fsid'] == 'valid'
Exemple #22
0
    def test_check_available_has_no_repo(self, mock_localclient):
        fake_data = {'admin.ceph': '',
                     'data.ceph': {'ceph-common': {'version': '13.0.1'}}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup")

        validator.uninstalled = ['admin.ceph']
        validator._check_available()
        assert 'admin.ceph' in validator.errors['ceph_version']
Exemple #23
0
    def test_storage_too_few(self, mock_localclient):
        fake_data = {'node1': {'roles': 'storage',
                               'ceph': {'storage': 'dummy_osds'}}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.errors) == 0
        validator.storage()
        assert "Too few storage nodes" in validator.errors['storage'][0]
Exemple #24
0
    def test_mgrs(self, mock_localclient):
        fake_data = {'mgr1': { 'roles': 'mgr'},
                     'mgr2': { 'roles': 'mgr'},
                     'mgr3': { 'roles': 'mgr'}}

        local = mock_localclient.return_value
        local.cmd.return_value = fake_data
        validator = validate.Validate("setup", search_pillar=True)

        assert len(validator.passed) == 0
        validator.mgrs()
        assert validator.passed['mgrs'] == "valid"
Exemple #25
0
    def test_public_interface_for_ipv4_only(self, mock_localclient):
        data = {'mon.ceph': {'public_network': '192.168.0.0/24'},
                'mgr.ceph': {'public_network': '192.168.0.0/24'}}
        grains = {'mon.ceph': {'ipv4': ['192.168.0.100']},
                  'mgr.ceph': {'ipv4': ['192.168.0.101']}}

        with patch.object(validate.Validate, "__init__", lambda self, n: None):
            validator = validate.Validate("setup")
            validator.errors = {}
            validator.warnings = {}
            validator.passed = {}
            validator.data = data
            validator.grains = grains

            validator.public_interface()
            assert validator.passed['public_interface'] == "valid"
Exemple #26
0
    def test_public_interface_for_ipv6_errors(self, mock_localclient):
        data = {'mon.ceph': {'public_network': 'fd01::/64'},
                'mgr.ceph': {'public_network': 'fd01::/64'}}
        grains = {'mon.ceph': {'ipv4': ['192.168.0.100'], 'ipv6': ['fd00::1']},
                  'mgr.ceph': {'ipv4': ['192.168.0.101'], 'ipv6': ['fd00::2']}}

        with patch.object(validate.Validate, "__init__", lambda self, n: None):
            validator = validate.Validate("setup")
            validator.errors = {}
            validator.warnings = {}
            validator.passed = {}
            validator.data = data
            validator.grains = grains

            validator.public_interface()
            assert "missing address" in validator.errors['public_interface'][0]
Exemple #27
0
    def test_subvolume_fails(self):
        data = {'mon.ceph': {},
                'mgr.ceph': {}}

        client = mock.Mock()
        with patch.object(validate.Validate, "__init__", lambda self, n: None):
            validator = validate.Validate("setup")
            validator.local = client.return_value
            validator.local.cmd.return_value = {'mon.ceph': [False, "/var/lib/ceph subvolume missing"]}
            validator.errors = {}
            validator.warnings = {}
            validator.passed = {}
            validator.data = data
            validator.grains = {}

            validator.subvolume()
            assert "/var/lib/ceph subvolume missing on mon.ceph" in validator.errors['subvolume']
Exemple #28
0
    def test_check_available_succeeds_with_no_minions(self, mock_localclient):
        validator = validate.Validate("setup")

        validator.uninstalled = []
        validator._check_available()
        assert 'ceph_version' not in validator.errors