def setup_fake_gparray(): master = GpDB.initFromString("1|-1|p|p|s|u|mdw|mdw|5432|None|/data/master||/data/master/base/10899,/data/master/base/1,/data/master/base/10898,/data/master/base/25780,/data/master/base/34782") primary0 = GpDB.initFromString("2|0|p|p|s|u|sdw1|sdw1|40000|41000|/data/primary0||/data/primary0/base/10899,/data/primary0/base/1,/data/primary0/base/10898,/data/primary0/base/25780,/data/primary0/base/34782") primary1 = GpDB.initFromString("3|1|p|p|s|u|sdw2|sdw2|40001|41001|/data/primary1||/data/primary1/base/10899,/data/primary1/base/1,/data/primary1/base/10898,/data/primary1/base/25780,/data/primary1/base/34782") mirror0 = GpDB.initFromString("4|0|m|m|s|u|sdw2|sdw2|50000|51000|/data/mirror0||/data/mirror0/base/10899,/data/mirror0/base/1,/data/mirror0/base/10898,/data/mirror0/base/25780,/data/mirror0/base/34782") mirror1 = GpDB.initFromString("5|1|m|m|s|u|sdw1|sdw1|50001|51001|/data/mirror1||/data/mirror1/base/10899,/data/mirror1/base/1,/data/mirror1/base/10898,/data/mirror1/base/25780,/data/mirror1/base/34782") return GpArray([master,primary0,primary1,mirror0,mirror1])
def setup_fake_gparray(): master = GpDB.initFromString( "1|-1|p|p|s|u|mdw|mdw|5432|None|/data/master||/data/master/base/10899,/data/master/base/1,/data/master/base/10898,/data/master/base/25780,/data/master/base/34782" ) primary0 = GpDB.initFromString( "2|0|p|p|s|u|sdw1|sdw1|40000|41000|/data/primary0||/data/primary0/base/10899,/data/primary0/base/1,/data/primary0/base/10898,/data/primary0/base/25780,/data/primary0/base/34782" ) primary1 = GpDB.initFromString( "3|1|p|p|s|u|sdw2|sdw2|40001|41001|/data/primary1||/data/primary1/base/10899,/data/primary1/base/1,/data/primary1/base/10898,/data/primary1/base/25780,/data/primary1/base/34782" ) mirror0 = GpDB.initFromString( "4|0|m|m|s|u|sdw2|sdw2|50000|51000|/data/mirror0||/data/mirror0/base/10899,/data/mirror0/base/1,/data/mirror0/base/10898,/data/mirror0/base/25780,/data/mirror0/base/34782" ) mirror1 = GpDB.initFromString( "5|1|m|m|s|u|sdw1|sdw1|50001|51001|/data/mirror1||/data/mirror1/base/10899,/data/mirror1/base/1,/data/mirror1/base/10898,/data/mirror1/base/25780,/data/mirror1/base/34782" ) return GpArray([master, primary0, primary1, mirror0, mirror1])
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)
def test_startAll_fails(self, mock1, mock2): result = StartSegmentsResult() failed_segment = GpDB.initFromString( "2|0|p|p|s|u|sdw1|sdw1|40000|41000|/data/primary0||/data/primary0/base/10899,/data/primary0/base/1,/data/primary0/base/10898,/data/primary0/base/25780,/data/primary0/base/34782" ) result.addFailure(failed_segment, 'reason', 'reasoncode') mock1.return_value.startSegments.return_value = result result = self.buildMirrorSegs._GpMirrorListToBuild__startAll( Mock(), [Mock(), Mock()], []) self.assertFalse(result) self.logger.warn.assert_any_call( 'Failed to start segment. The fault prober will shortly mark it as down. ' 'Segment: sdw1:/data/primary0:content=0:dbid=2:mode=s:status=u: REASON: reason' )
def setSegments(self, segmentData, faultStrategy): lines = segmentData.strip().split("\n") assert len(lines[1].split("+")) == len( lines[0].split("|")) # verify header is listed self.__configurationProvider = configurationImplTest.GpConfigurationProviderForTesting( ) self.__configurationProvider.setFaultStrategy(faultStrategy) for line in lines[2:len(lines)]: row = [s.strip() for s in line.strip().split("|")] dbId = int(row[0]) contentId = int(row[1]) role = row[2] preferredRole = row[3] mode = row[4] status = row[5] hostName = row[6] address = row[7] port = int(row[8]) dataDirectory = row[9] replicationPort = None if row[10] == "" else int(row[10]) segment = GpDB(content=contentId, preferred_role=preferredRole, dbid=dbId, role=role, mode=mode, status=status, hostname=hostName, address=address, port=port, datadir=dataDirectory, replicationPort=replicationPort) self.__configurationProvider.addTestSegment(segment) registerConfigurationProvider(self.__configurationProvider) self.__fileSystemProvider = fileSystemImplTest.GpFileSystemProviderForTest( ) fileSystemInterface.registerFileSystemProvider( self.__fileSystemProvider) osInterface.registerOsProvider(osImplTest.GpOsProviderForTest()) faultProberInterface.registerFaultProber( faultProberImplTest.GpFaultProberImplForTest()) pass