Exemplo n.º 1
0
    def test_5_add_server(self):
        print('Add new server')
        d = DistributedDict('127.0.0.1', 9110)
        d['test'] = 0
        self.pool.stop(self.pool.ids)
        self.pool.start(self.pool.ids)

        self.pool.configs[10] = {
            'address': ('127.0.0.1', 9120),
            'cluster': {
                ('127.0.0.1', 9120),
            },
            'storage': '20.persist',
            'debug': False
        }
        self.pool.servers[10] = Process(target=self.pool._run_server,
                                        args=(self.pool.configs[10], ))
        self.pool.start(10)
        sleep(1)

        d.config_cluster('add', '127.0.0.1', 9120)
        sleep(1)

        del d
        d = DistributedDict('127.0.0.1', 9120)

        self.assertEqual(d, {'test': 0})
Exemplo n.º 2
0
    def test_6_remove_server(self):
        print('Remove server')
        d = DistributedDict('127.0.0.1', 9110)
        d.config_cluster('delete', '127.0.0.1', 9111)
        sleep(1)

        self.pool.stop(1)

        self.assertEqual(set(map(tuple, d.diagnostic['volatile']['cluster'])),
                         {('127.0.0.1', 9112), ('127.0.0.1', 9110)})