Exemplo n.º 1
0
    def run( self ):
        try:
            id = self.server['id']

            util.log('copy binaries, server_id=%d' % id)
            util.copy_smrreplicator( id )
            util.copy_gw( id )
            util.copy_redis_server( id )
            util.copy_cluster_util( id )

        except IOError as e:
            util.log(e)
            util.log('Error: can not find file or read data')
            self.assertEqual(0, 1, 'Error: can not find file or read data')

        except:
            util.log('Error: file open error.')

        self.success = True
Exemplo n.º 2
0
    def run(self):
        try:
            id = self.server['id']

            util.log('copy binaries, server_id=%d' % id)
            util.copy_smrreplicator(id)
            util.copy_gw(id)
            util.copy_redis_server(id)
            util.copy_cluster_util(id)

        except IOError as e:
            util.log(e)
            util.log('Error: can not find file or read data')
            self.assertEqual(0, 1, 'Error: can not find file or read data')

        except:
            util.log('Error: file open error.')

        self.success = True
Exemplo n.º 3
0
def copy_binaries(id, opt_32bit_binary_test):
    try:
        util.copy_smrreplicator(id)
        util.copy_gw(id)
        util.copy_redis_server(id)
        util.copy_cluster_util(id)
        util.copy_dump_util(id)
        util.copy_dump_util_plugin(id)
        util.copy_log_util(id)
        util.copy_capi_so_file(id)
        util.copy_capi_test_server(id)
        util.copy_cm(id)

        if opt_32bit_binary_test:
            util.copy_capi32_so_file(id)
            util.copy_capi32_test_server(id)

    except IOError as e:
        print e
        util.log('Error: can not find file or read data')
        return -1

    return 0
Exemplo n.º 4
0
def copy_binaries( id, opt_32bit_binary_test ):
    try:
        util.copy_smrreplicator( id )
        util.copy_gw( id )
        util.copy_redis_server( id )
        util.copy_cluster_util( id )
        util.copy_dump_util( id )
        util.copy_dump_util_plugin( id )
        util.copy_log_util( id )
        util.copy_capi_so_file( id )
        util.copy_capi_test_server( id )
        util.copy_cm( id )

        if opt_32bit_binary_test:
            util.copy_capi32_so_file( id )
            util.copy_capi32_test_server( id )

    except IOError as e:
        print e
        util.log('Error: can not find file or read data')
        return -1

    return 0
Exemplo n.º 5
0
    def test_large_scale_master_election( self ):
        util.print_frame()

        # initialize cluster information
        pgs_id = 10
        cluster = {
                    'cluster_name' : 'large_scale',
                    'keyspace_size' : 8192,
                    'quorum_policy' : '0:1',
                    'slots' : [],
                    'pg_id_list' : [],
                    'servers' : []
                  }
        pg_max = 32
        pgs_per_pg = 3
        for pg_id in range(pg_max):
            cluster['pg_id_list'].append(pg_id)
            cluster['slots'].append(8192 / pg_max * pg_id)
            if pg_id == pg_max - 1:
                cluster['slots'].append(8191)
            else:
                cluster['slots'].append(8192 / pg_max * (pg_id + 1) - 1)

            for pgs in range(pgs_per_pg):
                smr_base_port = 15000 + pgs_id * 20
                smr_mgmt_port = smr_base_port + 3
                gateway_port = smr_base_port + 10
                redis_port = smr_base_port + 9

                server = {}
                server['id'] = pgs_id
                pgs_id = pgs_id + 1
                server['cluster_name'] = cluster['cluster_name']
                server['ip'] = self.cluster['servers'][0]['ip']
                server['pm_name'] = self.cluster['servers'][0]['pm_name']
                server['cm_port'] = None
                server['pg_id'] = pg_id
                server['smr_base_port'] = smr_base_port
                server['smr_mgmt_port'] = smr_mgmt_port
                server['gateway_port'] = gateway_port
                server['redis_port'] = redis_port
                server['zk_port'] = 2181

                cluster['servers'].append(server)

        # send initialize commands to confmaster
        testbase.initialize_cluster(cluster, self.leader_cm)

        # set up pgs binaries
        try:
            for server in cluster['servers']:
                id = server['id']

                util.log('copy binaries, server_id=%d' % id)
                util.copy_smrreplicator( id )
                util.copy_gw( id )
                util.copy_redis_server( id )
                util.copy_cluster_util( id )

        except IOError as e:
            util.log(e)
            util.log('Error: can not find file or read data')
            self.assertEqual(0, 1, 'Error: can not find file or read data')

        except:
            util.log('Error: file open error.')

        # cleanup servers`s directories
        for server in cluster['servers']:
            ret = testbase.cleanup_pgs_log_and_ckpt( cluster['cluster_name'], server )
            self.assertEqual(ret, 0, 'failed to cleanup_test_environment, id=%d' % server['id'])

        # start pgs
        for server in cluster['servers']:
            ret = testbase.request_to_start_smr( server )
            self.assertEqual(ret, 0, 'failed to request_to_start_smr, id=%d' % server['id'])

        for server in cluster['servers']:
            ret = testbase.request_to_start_redis( server, check=False )
            self.assertEqual(ret, 0, 'failed to request_to_start_smr, id=%d' % server['id'])

        for server in cluster['servers']:
            ret = testbase.wait_until_finished_to_set_up_role(server)
            self.assertEqual(ret, 0, 'failed to role set up, id=%d' % server['id'])

        for i in range(4):
            server = cluster['servers'][i]
            ret = testbase.request_to_start_gateway( cluster['cluster_name'], server, self.leader_cm )
            self.assertEqual(ret, 0, 'failed to request_to_start_gateway, id=%d' % server['id'])

        clusters = cluster_ls()
        self.assertNotEqual(len(clusters), 0, 'There is no clsuter.')

        ok = True
        for c in clusters:
            if not util.check_cluster(str(c), self.leader_cm['ip'], self.leader_cm['cm_port'], check_quorum=True):
                ok = False

        self.assertEqual(ok, True, 'failed to initlize roles of pgs')
Exemplo n.º 6
0
    def test_large_scale_master_election(self):
        util.print_frame()

        # initialize cluster information
        pgs_id = 10
        cluster = {
            'cluster_name': 'large_scale',
            'keyspace_size': 8192,
            'quorum_policy': '0:1',
            'slots': [],
            'pg_id_list': [],
            'servers': []
        }
        pg_max = 32
        pgs_per_pg = 3
        for pg_id in range(pg_max):
            cluster['pg_id_list'].append(pg_id)
            cluster['slots'].append(8192 / pg_max * pg_id)
            if pg_id == pg_max - 1:
                cluster['slots'].append(8191)
            else:
                cluster['slots'].append(8192 / pg_max * (pg_id + 1) - 1)

            for pgs in range(pgs_per_pg):
                smr_base_port = 15000 + pgs_id * 20
                smr_mgmt_port = smr_base_port + 3
                gateway_port = smr_base_port + 10
                redis_port = smr_base_port + 9

                server = {}
                server['id'] = pgs_id
                pgs_id = pgs_id + 1
                server['cluster_name'] = cluster['cluster_name']
                server['ip'] = self.cluster['servers'][0]['ip']
                server['pm_name'] = self.cluster['servers'][0]['pm_name']
                server['cm_port'] = None
                server['pg_id'] = pg_id
                server['smr_base_port'] = smr_base_port
                server['smr_mgmt_port'] = smr_mgmt_port
                server['gateway_port'] = gateway_port
                server['redis_port'] = redis_port
                server['zk_port'] = 2181

                cluster['servers'].append(server)

        # send initialize commands to confmaster
        testbase.initialize_cluster(cluster, self.leader_cm)

        # set up pgs binaries
        try:
            for server in cluster['servers']:
                id = server['id']

                util.log('copy binaries, server_id=%d' % id)
                util.copy_smrreplicator(id)
                util.copy_gw(id)
                util.copy_redis_server(id)
                util.copy_cluster_util(id)

        except IOError as e:
            util.log(e)
            util.log('Error: can not find file or read data')
            self.assertEqual(0, 1, 'Error: can not find file or read data')

        except:
            util.log('Error: file open error.')

        # cleanup servers`s directories
        for server in cluster['servers']:
            ret = testbase.cleanup_pgs_log_and_ckpt(cluster['cluster_name'],
                                                    server)
            self.assertEqual(
                ret, 0,
                'failed to cleanup_test_environment, id=%d' % server['id'])

        # start pgs
        for server in cluster['servers']:
            ret = testbase.request_to_start_smr(server)
            self.assertEqual(
                ret, 0, 'failed to request_to_start_smr, id=%d' % server['id'])

        for server in cluster['servers']:
            ret = testbase.request_to_start_redis(server, check=False)
            self.assertEqual(
                ret, 0, 'failed to request_to_start_smr, id=%d' % server['id'])

        for server in cluster['servers']:
            ret = testbase.wait_until_finished_to_set_up_role(server)
            self.assertEqual(ret, 0,
                             'failed to role set up, id=%d' % server['id'])

        for i in range(4):
            server = cluster['servers'][i]
            ret = testbase.request_to_start_gateway(cluster['cluster_name'],
                                                    server, self.leader_cm)
            self.assertEqual(
                ret, 0,
                'failed to request_to_start_gateway, id=%d' % server['id'])

        clusters = cluster_ls()
        self.assertNotEqual(len(clusters), 0, 'There is no clsuter.')

        ok = True
        for c in clusters:
            if not util.check_cluster(str(c),
                                      self.leader_cm['ip'],
                                      self.leader_cm['cm_port'],
                                      check_quorum=True):
                ok = False

        self.assertEqual(ok, True, 'failed to initlize roles of pgs')