def test_groupmirror_layout(self): """ Basic group mirroring """ mirror_type = 'grouped' primary_portbase = 5000 mirror_portbase = 6000 interface_list = [1] dir_prefix = 'gpseg' hostlist = ['host1'] primary_list = ['/db1'] mirror_list = ['/mir1'] #not enough with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix) primary_list.append('/db2') mirror_list.append('/mir2') with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix) #enough hostlist = ['host1', 'host2'] primary_list = ['/db1', '/db2'] mirror_list = ['/mir1', '/mir2'] #typical thumper hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4'] mirror_list = [ '/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror' ] self._validate_array( self._setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix)) #typical Thor hostlist = [ 'sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5', 'sdw6', 'sdw7', 'sdw8', 'sdw9' ] primary_list = [ '/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4', '/dbfast5', '/dbfast6', '/dbfast7', '/dbfast8' ] mirror_list = [ '/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror', '/dbfast5/mirror', '/dbfast6/mirror', '/dbfast7/mirror', '/dbfast8/mirror' ] self._validate_array( self._setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix))
def _setup_gparray(self, hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix): master = Segment(content = -1, preferred_role = 'p', dbid = 0, role = 'p', mode = 's', status = 'u', hostname = 'masterhost', address = 'masterhost-1', port = 5432, datadir = '/masterdir') allrows = [] allrows.append(master) rows = createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix) for row in rows: newrow = Segment(content = row.content, preferred_role = 'p' if convert_bool(row.isprimary) else 'm', dbid = row.dbid, role = 'p' if convert_bool(row.isprimary) else 'm', mode = 's', status = 'u', hostname = row.host, address = row.address, port = row.port, datadir = row.fulldir) allrows.append(newrow) gparray = GpArray(allrows) return gparray
def test_get_segment_list(self): mirror_type = 'grouped' primary_portbase = 5000 mirror_portbase = 6000 interface_list = [1] dir_prefix = 'gpseg' hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror'] gparray = self._setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix) self._validate_array(gparray) # test without expansion segments expansion_hosts = [] self._validate_get_segment_list(gparray, hostlist, expansion_hosts, primary_list) # test with expansion segments expansion_hosts = ['sdw6', 'sdw7'] rows = createSegmentRows(expansion_hosts, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix) offset = len(hostlist) * len(primary_list) # need to continue numbering where the last createSegmentRows left off for row in rows: gparray.addExpansionSeg(row.content+offset, 'p' if convert_bool(row.isprimary) else 'm', row.dbid+offset, 'p' if convert_bool(row.isprimary) else 'm', row.host, row.address, row.port, row.fulldir) self._validate_get_segment_list(gparray, hostlist, expansion_hosts, primary_list)
def setup_gparray(self, hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase): master = GpDB(content = -1, preferred_role = 'p', dbid = 0, role = 'p', mode = 's', status = 'u', hostname = 'masterhost', address = 'masterhost-1', port = 5432, datadir = '/masterdir', replicationPort = 5433) allrows = [] allrows.append(master) rows = createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) for row in rows: newrow = GpDB(content = row.content, preferred_role = 'p' if convert_bool(row.isprimary) else 'm', dbid = row.dbid, role = 'p' if convert_bool(row.isprimary) else 'm', mode = 's', status = 'u', hostname = row.host, address = row.address, port = row.port, datadir = row.fulldir, replicationPort = row.prPort) allrows.append(newrow) gparray = GpArray(allrows) return gparray
def test_get_segment_list(self): mirror_type = 'grouped' primary_portbase = 5000 mirror_portbase = 6000 interface_list = [1] primary_replication_portbase = 7000 mirror_replication_portbase = 8000 dir_prefix = 'gpseg' hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror'] gparray = self.setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) self._validate_array(gparray) # test without expansion segments expansion_hosts = [] self._validate_get_segment_list(gparray, hostlist, expansion_hosts, primary_list) # test with expansion segments expansion_hosts = ['sdw6', 'sdw7'] rows = createSegmentRows(expansion_hosts, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) offset = len(hostlist) * len(primary_list) # need to continue numbering where the last createSegmentRows left off for row in rows: gparray.addExpansionSeg(row.content+offset, 'p' if convert_bool(row.isprimary) else 'm', row.dbid+offset, 'p' if convert_bool(row.isprimary) else 'm', row.host, row.address, row.port, row.fulldir, row.prPort) self._validate_get_segment_list(gparray, hostlist, expansion_hosts, primary_list)
def test_groupmirror_layout(self): """ Basic group mirroring """ mirror_type = 'grouped' primary_portbase = 5000 mirror_portbase = 6000 interface_list = [1] primary_replication_portbase = 7000 mirror_replication_portbase = 8000 dir_prefix = 'gpseg' hostlist = ['host1'] primary_list = ['/db1'] mirror_list = ['/mir1'] #not enough with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) primary_list.append('/db2') mirror_list.append('/mir2') with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) #enough hostlist = ['host1', 'host2'] primary_list = ['/db1', '/db2'] mirror_list = ['/mir1', '/mir2'] #typical thumper hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror'] self._validate_array(self.setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase)) #typical Thor hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5', 'sdw6', 'sdw7', 'sdw8', 'sdw9'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4', '/dbfast5', '/dbfast6', '/dbfast7', '/dbfast8'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror', '/dbfast5/mirror', '/dbfast6/mirror', '/dbfast7/mirror', '/dbfast8/mirror'] self._validate_array(self.setup_gparray(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase))
def test_spreadmirror_layout(self): """ Basic spread mirroring """ mirror_type = 'spread' interface_list = [1] primary_portbase = 5000 mirror_portbase = 6000 primary_replication_portbase = 7000 mirror_replication_portbase = 8000 hostlist = ['host1'] primary_list = ['/db1'] mirror_list = ['/mir1'] dir_prefix = 'gpseg' #need to have enough hosts otherwise we get exceptions with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) primary_list.append('/db2') mirror_list.append('/mir2') with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) hostlist.append('host2') with self.assertRaises(Exception): createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) #now we have enough hostlist.append('host3') self.mirrorlayout_test(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) #enough hostlist = ['host1', 'host2', 'host3'] primary_list = ['/db1', '/db2'] mirror_list = ['/mir1', '/mir2'] self.mirrorlayout_test(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) #typical thumper hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror'] self.mirrorlayout_test(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) #typical Thor hostlist = ['sdw1', 'sdw2', 'sdw3', 'sdw4', 'sdw5', 'sdw6', 'sdw7', 'sdw8', 'sdw9'] primary_list = ['/dbfast1', '/dbfast2', '/dbfast3', '/dbfast4', '/dbfast5', '/dbfast6', '/dbfast7', '/dbfast8'] mirror_list = ['/dbfast1/mirror', '/dbfast2/mirror', '/dbfast3/mirror', '/dbfast4/mirror', '/dbfast5/mirror', '/dbfast6/mirror', '/dbfast7/mirror', '/dbfast8/mirror'] self.mirrorlayout_test(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase)
def mirrorlayout_test(self, hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase): master = GpDB(content=-1, preferred_role='p', dbid=0, role='p', mode='s', status='u', hostname='masterhost', address='masterhost-1', port=5432, datadir='/masterdir', replicationPort=5433) allrows = [] allrows.append(master) rows = createSegmentRows(hostlist, interface_list, primary_list, primary_portbase, mirror_type, mirror_list, mirror_portbase, dir_prefix, primary_replication_portbase, mirror_replication_portbase) for row in rows: newrow = GpDB( content=row.content, preferred_role='p' if convert_bool(row.isprimary) else 'm', dbid=row.dbid, role='p' if convert_bool(row.isprimary) else 'm', mode='s', status='u', hostname=row.host, address=row.address, port=row.port, datadir=row.fulldir, replicationPort=row.prPort) allrows.append(newrow) gparray = GpArray(allrows) self._validate_array(gparray)