def test_ssh(self): self.shell.run_cmdline('/SSH generate') self.assertInSysOut('Key pair generated.') self.assertNotEqual(PillarManager.get('ceph-salt:ssh:private_key'), None) self.assertNotEqual(PillarManager.get('ceph-salt:ssh:public_key'), None)
def test_pillar_reset(self): PillarManager.set('ceph-salt:test', 'some text') val = PillarManager.get('ceph-salt:test') self.assertEqual(val, 'some text') PillarManager.reset('ceph-salt:test') val = PillarManager.get('ceph-salt:test') self.assertIsNone(val)
def assertValueOption(self, path, pillar_key, value): self.shell.run_cmdline('{} set {}'.format(path, value)) self.assertInSysOut('Value set.') self.assertEqual(PillarManager.get(pillar_key), value) self.shell.run_cmdline('{} reset'.format(path)) self.assertInSysOut('Value reset.') self.assertEqual(PillarManager.get(pillar_key), None)
def assertListOption(self, path, pillar_key, values): for value in values: self.shell.run_cmdline('{} add {}'.format(path, value)) self.assertInSysOut('Value added.') self.assertEqual(PillarManager.get(pillar_key), values) for value in values: self.shell.run_cmdline('{} remove {}'.format(path, value)) self.assertInSysOut('Value removed.') self.assertEqual(PillarManager.get(pillar_key), [])
def assertFlagOption(self, path, pillar_key, reset_supported=True): self.shell.run_cmdline('{} enable'.format(path)) self.assertInSysOut('Enabled.') self.assertEqual(PillarManager.get(pillar_key), True) self.shell.run_cmdline('{} disable'.format(path)) self.assertInSysOut('Disabled.') self.assertEqual(PillarManager.get(pillar_key), False) if reset_supported: self.shell.run_cmdline('{} reset'.format(path)) self.assertInSysOut('Value reset.') self.assertEqual(PillarManager.get(pillar_key), None)
def test_cluster_roles_mgr(self): self.shell.run_cmdline('/Cluster/Minions add node1.ceph.com') self.clearSysOut() self.shell.run_cmdline('/Cluster/Roles/Mgr add node1.ceph.com') self.assertInSysOut('1 minion added.') self.assertGrains('node1.ceph.com', 'ceph-salt', { 'member': True, 'roles': ['mgr'] }) self.assertEqual(PillarManager.get('ceph-salt:minions:all'), ['node1']) self.assertEqual(PillarManager.get('ceph-salt:minions:mgr'), ['node1']) self.assertEqual(PillarManager.get('ceph-salt:minions:mon'), {}) self.assertEqual(PillarManager.get('ceph-salt:bootstrap_minion'), None) self.shell.run_cmdline('/Cluster/Roles/Mgr rm node1.ceph.com') self.assertInSysOut('1 minion removed.') self.assertGrains('node1.ceph.com', 'ceph-salt', { 'member': True, 'roles': [] }) self.assertEqual(PillarManager.get('ceph-salt:minions:all'), ['node1']) self.assertEqual(PillarManager.get('ceph-salt:minions:mgr'), []) self.assertEqual(PillarManager.get('ceph-salt:minions:mon'), {}) self.assertEqual(PillarManager.get('ceph-salt:bootstrap_minion'), None) self.shell.run_cmdline('/Cluster/Minions rm node1.ceph.com')
def test_cluster_minions_add_invalid_ip(self): fqdn_ip4 = GrainsManager.get_grain('node1.ceph.com', 'fqdn_ip4') GrainsManager.set_grain('node1.ceph.com', 'fqdn_ip4', ['127.0.0.1']) self.shell.run_cmdline('/Cluster/Minions add node1.ceph.com') self.assertInSysOut( "Host 'node1.ceph.com' FQDN resolves to the loopback interface IP " "address") self.assertIsNone(PillarManager.get('ceph-salt:minions:all')) GrainsManager.set_grain('node1.ceph.com', 'fqdn_ip4', fqdn_ip4)
def test_cluster_minions_rm_with_role(self): self.shell.run_cmdline('/Cluster/Minions add node1.ceph.com') self.shell.run_cmdline('/Cluster/Roles/Mgr add node1.ceph.com') self.clearSysOut() self.shell.run_cmdline('/Cluster/Minions rm node1.ceph.com') self.assertInSysOut( "Cannot remove host 'node1.ceph.com' because it has roles defined: " "{'mgr'}") self.assertEqual(PillarManager.get('ceph-salt:minions:all'), ['node1']) self.shell.run_cmdline('/Cluster/Roles/Mgr rm node1.ceph.com') self.shell.run_cmdline('/Cluster/Minions rm node1.ceph.com')