Ejemplo n.º 1
0
 def test_conf_store_merge_02no_key(self):
     Conf.set('src_index', 'new_key', 'new_value')
     Conf.save('src_index')
     Conf.merge('dest_index', 'src_index')
     Conf.save('dest_index')
     self.assertEqual(Conf.get('dest_index', 'new_key'), 'new_value')
     self.assertIn('new_key', Conf.get_keys('dest_index'))
Ejemplo n.º 2
0
 def test_conf_store_merge_03already_key(self):
     Conf.set('dest_index', 'cortx>software>kafka>servers[0]', 'host2.com')
     Conf.save('dest_index')
     Conf.set('src_index', 'cortx>software>kafka>servers[0]', 'host1.com')
     Conf.merge('dest_index', 'src_index')
     Conf.save('dest_index')
     self.assertEqual('host2.com', Conf.get('dest_index',\
         'cortx>software>kafka>servers[0]'))
Ejemplo n.º 3
0
 def test_conf_store_merge_05update_multiple(self):
     Conf.set('src_index', 'cortx>software>kafka>servers[0]', 'host1.com')
     Conf.set('src_index', 'cortx>software>kafka>servers[1]', 'host2.com')
     Conf.set('src_index', 'cortx>software>kafka>servers[2]', 'host3.com')
     Conf.save('src_index')
     Conf.merge('dest_index', 'src_index')
     Conf.save('dest_index')
     self.assertNotEqual(
         'host1.com',
         Conf.get('dest_index', 'cortx>software>kafka>servers[0]'))
     self.assertEqual(
         'host2.com',
         Conf.get('dest_index', 'cortx>software>kafka>servers[1]'))
     self.assertEqual(
         'host3.com',
         Conf.get('dest_index', 'cortx>software>kafka>servers[2]'))
Ejemplo n.º 4
0
    def merge(args):
        """ merges source conf file into dest. conf file. """

        src_index = 'src_index'
        dest_index = ConfCli._index
        ConfCli.load(args.src_url, src_index)
        if not args.keys:  # no keys provided
            keys = Conf.get_keys(src_index)  # getting src file keys
        else:
            keys = args.keys[0].split(';')
            src_keys = Conf.get_keys(src_index)
            for key in keys:
                if key not in src_keys:
                    raise ConfError(errno.ENOENT, "%s is not present in %s", \
                        key, args.src_url)
        Conf.merge(dest_index, src_index, keys)
        Conf.save(dest_index)
Ejemplo n.º 5
0
 def test_conf_store_merge_06_with_keys(self):
     Conf.set('src_index', 'cortx>software>common>test_key1', 'test_value')
     Conf.set('src_index', 'cortx>software>common>test_key2', 'test_value')
     Conf.set('src_index', 'cortx>software>common>message_bus_type',\
         'rabbitmq')
     Conf.save('src_index')
     Conf.merge('dest_index', 'src_index', keys=\
         ['cortx>software>common>test_key1',
          'cortx>software>common>test_key2',
          'cortx>software>common>message_bus_type'])
     Conf.save('dest_index')
     self.assertEqual('test_value', Conf.get('dest_index',\
         'cortx>software>common>test_key1'))
     self.assertEqual('test_value', Conf.get('dest_index',\
         'cortx>software>common>test_key2'))
     self.assertEqual('kafka', Conf.get('dest_index',\
         'cortx>software>common>message_bus_type'))
Ejemplo n.º 6
0
 def test_conf_store_merge_01new_file(self):
     self.assertEqual(Conf.get_keys('dest_index'), [])
     Conf.merge('dest_index', 'src_index')
     Conf.save('dest_index')
     self.assertEqual(Conf.get_keys('dest_index'),
                      Conf.get_keys('src_index'))