提交 25b2f19e 编写于 作者: A Ashwin Agrawal

TINC: Remove FTS test files.

上级 784b0899
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
from time import sleep
import tinctest
from mpp.lib.PSQL import PSQL
from mpp.lib.config import GPDBConfig
from tinctest.lib import local_path, run_shell_command
from mpp.lib.filerep_util import Filerepe2e_Util
from mpp.lib.gprecoverseg import GpRecover
from gppylib.gparray import GpArray
from gppylib.db import dbconn
from mpp.gpdb.tests.storage.lib.dbstate import DbStateClass
from mpp.gpdb.tests.storage.lib.common_utils import Gpstate
from mpp.gpdb.tests.storage.lib.common_utils import Gpprimarymirror
from gppylib.commands.base import Command
from mpp.models import MPPTestCase
from mpp.lib.gpstart import GpStart
from mpp.lib.gpstop import GpStop
class FtsTransitions(MPPTestCase):
def __init__(self, methodName):
self.pgport = os.environ.get('PGPORT')
self.fileutil = Filerepe2e_Util()
self.gpstate = Gpstate()
self.gpprimarymirror = Gpprimarymirror()
self.gpstart = GpStart()
self.gpstop = GpStop()
super(FtsTransitions,self).__init__(methodName)
def kill_first_mirror(self):
mirror_data_loc = self.get_default_fs_loc(role='m',content=0)
gpconfig = GPDBConfig()
(host, port) = gpconfig.get_hostandport_of_segment(psegmentNumber = 0, pRole = 'm')
cmdString = 'ps -ef|grep -v grep|grep \'%s\'|awk \'{print $2}\'|xargs kill -9'%mirror_data_loc
remote = Command(name ='kill first mirror', cmdStr = cmdString, ctxt=2, remoteHost=host)
remote.run()
tinctest.logger.info('run command %s'%cmdString)
rc = remote.get_results().rc
result = remote.get_results().stdout
tinctest.logger.info('Command returning, rc: %s, result: %s'%(rc,result))
def kill_master_process(self, ProcName=None):
cmdString = 'ps -ef|grep postgres| grep %s | grep \'%s\'| awk \'{print $2}\'|xargs kill -9'%(self.pgport,ProcName)
cmd = Command('kill process on master', cmdStr = cmdString)
cmd.run()
tinctest.logger.info('run command %s'%cmdString)
rc = cmd.get_results().rc
result = cmd.get_results().stdout
tinctest.logger.info('Command returning, rc: %s, result: %s'%(rc,result))
def get_default_fs_loc(self, role='m', content=0):
fs_sql = '''select fselocation from pg_filespace_entry
where fsefsoid = 3052 and fsedbid = (select dbid from gp_segment_configuration
where role = \'%s\' and content = %s);'''%(role,content)
result = PSQL.run_sql_command(fs_sql, flags = '-q -t', dbname= 'template1')
result = result.strip()
filespace_loc = result.split('\n')
return filespace_loc[0]
def set_faults(self,fault_name, type, role='mirror', port=None, occurence=None, sleeptime=None, seg_id=None):
''' Reset the fault and then issue the fault with the given type'''
self.fileutil.inject_fault(f=fault_name, y=type, r=role, p=port , o=occurence, sleeptime=sleeptime, seg_id=seg_id)
def resume_faults(self,fault_name, role='mirror'):
''' Resume the fault issues '''
self.fileutil.inject_fault(f=fault_name, y='resume', r=role)
def corrupt_ct_logfile(self, write_string='*', corruption_offset=1, start_of_file=True):
# Force flush CT file to disk
PSQL.run_sql_command("CHECKPOINT", flags = '-q -t', dbname= 'postgres')
gparray = GpArray.initFromCatalog(dbconn.DbURL())
primary_segs = [seg for seg in gparray.getDbList() if seg.isSegmentPrimary()]
for seg in primary_segs:
file = '%s/pg_changetracking/CT_LOG_FULL' % seg.datadir
try:
with open(file, "r+b") as f:
if start_of_file:
f.seek(corruption_offset, 0)
else:
f.seek(corruption_offset, 2)
f.write(write_string)
f.close()
except Exception, e:
pass
def incremental_recoverseg(self, workerPool=False):
gprecover = GpRecover(GPDBConfig())
gprecover.incremental(workerPool)
def full_recoverseg(self):
gprecover = GpRecover(GPDBConfig())
gprecover.full()
def run_recoverseg_if_ct(self):
gpconfig = GPDBConfig()
num_down = gpconfig.count_of_nodes_in_mode('c')
if (int(num_down) > 0):
self.incremental_recoverseg()
def wait_till_change_tracking(self):
self.fileutil.wait_till_change_tracking_transition()
def wait_till_insync(self):
gprecover = GpRecover(GPDBConfig())
gprecover.wait_till_insync_transition()
def run_gpstate(self, type, phase):
self.gpstate.run_gpstate(type, phase)
def run_gpprimarymirror(self):
self.gpprimarymirror.run_gpprimarymirror()
def verify_gpprimarymirror_output(self, total_resync=0, cur_resync=0):
status = self.gpprimarymirror.verify_gpprimarymirror_output(total_resync, cur_resync)
self.assertTrue(status, 'Total and Cur resync object count mismatch')
def run_gpstate_shell_cmd(self, options):
self.gpstate.run_gpstate_shell_cmd(options)
def verify_gpstate_output(self):
status = self.gpstate.verify_gpstate_output()
self.assertTrue(status, 'Total and Cur resync object count mismatch')
def run_trigger_sql(self, wait_for_db=True):
''' Run a sql statement to trigger postmaster reset '''
PSQL.run_sql_file(local_path('test_ddl.sql'))
if wait_for_db:
PSQL.wait_for_database_up()
def run_fts_test_ddl_dml(self):
PSQL.run_sql_file(local_path('fts_test_ddl_dml.sql'))
def run_fts_test_ddl_dml_before_ct(self):
PSQL.run_sql_file(local_path('fts_test_ddl_dml_before_ct.sql'))
def run_fts_test_ddl_dml_ct(self):
PSQL.run_sql_file(local_path('fts_test_ddl_dml_ct.sql'))
def run_fts_test_ddl_dml_checksum_ct_recoverseg(self):
PSQL.run_sql_file(local_path('fts_test_ddl_dml_checksum_ct_recoverseg.sql'))
def restart_db(self):
self.gpstop.run_gpstop_cmd(immediate = True)
self.gpstart.run_gpstart_cmd()
def stop_db_with_no_rc_check(self):
''' Gpstop and dont check for rc '''
cmd = Command('Gpstop_a', 'gpstop -a')
tinctest.logger.info('Executing command: gpstop -a')
cmd.run()
def start_db_with_no_rc_check(self):
''' Gpstart and dont check for rc '''
cmd = Command('Gpstart_a', 'gpstart -a')
tinctest.logger.info('Executing command: gpstart -a')
cmd.run()
def restart_db_with_no_rc_check(self):
self.stop_db_with_no_rc_check()
self.start_db_with_no_rc_check()
def check_fault_status(self, fault_name, seg_id=None, role=None):
status = self.fileutil.check_fault_status(fault_name = fault_name, status ='triggered', max_cycle=20, role=role, seg_id=seg_id)
self.assertTrue(status, 'The fault is not triggered in the time expected')
def cluster_state(self):
gpconfig = GPDBConfig()
state = gpconfig.is_not_insync_segments()
self.assertTrue(state,'The cluster is not up and in sync')
-- This file should be run when primary is in changetracking. Number
-- of blocks changed should be greater than gp_filerep_ct_batch_size.
show gp_filerep_ct_batch_size;
gp_filerep_ct_batch_size
--------------------------
3
(1 row)
-- Change blocks of resync_bug_table in a particular order such that a
-- higher numbered block has lower LSN. Schema of resync_bug_table is
-- such that one block accommodates 901 tuples. Leverage this to
-- identify a block. Change Block 4 first so that it has lower LSN
-- than blocks 0, 1, 2.
delete from resync_bug_table where a = 1 and b = 901*5;
DELETE 1
-- Block 0
delete from resync_bug_table where a = 1 and b = 901;
DELETE 1
-- Block 1
delete from resync_bug_table where a = 1 and b = 901*2;
DELETE 1
-- Block 2
delete from resync_bug_table where a = 1 and b = 901*3;
DELETE 1
-- Block 3
delete from resync_bug_table where a = 1 and b = 901*4;
DELETE 1
select * from resync_bug_table where a = 1 and
b in (901, 901*2, 901*3, 901*4, 901*5);
a | b
---+---
(0 rows)
-- Create table and insert data while cluster is in-sync.
drop table if exists resync_bug_table;
DROP TABLE
create table resync_bug_table(a int, b int) distributed by (a);
CREATE TABLE
-- Insert tuples on a single statement. Insert enough tuples to
-- occupy 5 blocks on that segment. About 901 tuples having this
-- schema can be accommodated on one block.
insert into resync_bug_table select 1 ,i from generate_series(1,5000)i;
INSERT 0 5000
-- Checkpoint isn't really necessary but doesn't harm either.
checkpoint;
CHECKPOINT
select * from resync_bug_table where a = 1 and
b in (901, 901*2, 901*3, 901*4, 901*5);
a | b
---+---
(0 rows)
drop table test_heap;
CREATE TABLE test_heap ( phase text,a int,col001 char DEFAULT 'z',col002 numeric,col003 boolean DEFAULT false,col004 bit(3) DEFAULT '111',col005 text DEFAULT 'pookie', col006 integer[] DEFAULT '{5, 4, 3, 2, 1}',
col007 character varying(512) DEFAULT 'Now is the time', col008 character varying DEFAULT 'Now is the time', col009 character varying(512)[], col010 numeric(8),col011 int,col012 double precision, col013 bigint, col014 char(8),
col015 bytea,col016 timestamp with time zone,col017 interval, col018 cidr, col019 inet, col020 macaddr,col022 money, col024 timetz,col025 circle, col026 box, col027 name,col028 path, col029 int2,
col031 bit varying(256),col032 date, col034 lseg,col035 point,col036 polygon,col037 real,col039 time, col040 timestamp )distributed by (a);
INSERT INTO test_heap VALUES ('heap1',generate_series(1,5000),'a',11,true,'111', '1_one', '{1,2,3,4,5}', 'Hello .. how are you 1', 'Hello .. how are you 1', '{one,two,three,four,five}', 12345678, 1, 111.1111, 11, '1_one_11', 'd',
'2001-12-13 01:51:15+1359', '11', '0.0.0.0', '0.0.0.0', 'AA:AA:AA:AA:AA:AA', '34.23', '00:00:00+1359', '((2,2),1)', '((1,2),(2,1))', 'hello', '((1,2),(2,1))', 11, '010101', '2001-12-13', '((1,1),(2,2))', '(1,1)', '((1,2),(2,3),(3,4),(4,3),(3,2),(2,1))', 111111, '23:00:00', '2001-12-13 01:51:15');
drop table test_ao;
CREATE TABLE test_ao ( phase text,a int,col001 char DEFAULT 'z',col002 numeric,col003 boolean DEFAULT false,col004 bit(3) DEFAULT '111',col005 text DEFAULT 'pookie', col006 integer[] DEFAULT '{5, 4, 3, 2, 1}',
col007 character varying(512) DEFAULT 'Now is the time', col008 character varying DEFAULT 'Now is the time', col009 character varying(512)[], col010 numeric(8),col011 int,col012 double precision, col013 bigint, col014 char(8),
col015 bytea,col016 timestamp with time zone,col017 interval, col018 cidr, col019 inet, col020 macaddr,col022 money, col024 timetz,col025 circle, col026 box, col027 name,col028 path, col029 int2,
col031 bit varying(256),col032 date, col034 lseg,col035 point,col036 polygon,col037 real,col039 time, col040 timestamp )with ( appendonly='true') distributed by (a);
INSERT INTO test_ao VALUES ('ao1',generate_series(1,100),'a',11,true,'111', '1_one', '{1,2,3,4,5}', 'Hello .. how are you 1', 'Hello .. how are you 1', '{one,two,three,four,five}', 12345678, 1, 111.1111, 11, '1_one_11', 'd',
'2001-12-13 01:51:15+1359', '11', '0.0.0.0', '0.0.0.0', 'AA:AA:AA:AA:AA:AA', '34.23', '00:00:00+1359', '((2,2),1)', '((1,2),(2,1))', 'hello', '((1,2),(2,1))', 11, '010101', '2001-12-13', '((1,1),(2,2))', '(1,1)', '((1,2),(2,3),(3,4),(4,3),(3,2),(2,1))', 111111, '23:00:00', '2001-12-13 01:51:15');
drop table test_co;
CREATE TABLE test_co ( phase text,a int,col001 char DEFAULT 'z',col002 numeric,col003 boolean DEFAULT false,col004 bit(3) DEFAULT '111',col005 text DEFAULT 'pookie', col006 integer[] DEFAULT '{5, 4, 3, 2, 1}',
col007 character varying(512) DEFAULT 'Now is the time', col008 character varying DEFAULT 'Now is the time', col009 character varying(512)[], col010 numeric(8),col011 int,col012 double precision, col013 bigint, col014 char(8),
col015 bytea,col016 timestamp with time zone,col017 interval, col018 cidr, col019 inet, col020 macaddr,col022 money, col024 timetz,col025 circle, col026 box, col027 name,col028 path, col029 int2,
col031 bit varying(256),col032 date, col034 lseg,col035 point,col036 polygon,col037 real,col039 time, col040 timestamp )with (orientation='column',appendonly=true)distributed by (a);
INSERT INTO test_co VALUES ('co1',generate_series(1,100),'a',11,true,'111', '1_one', '{1,2,3,4,5}', 'Hello .. how are you 1', 'Hello .. how are you 1', '{one,two,three,four,five}', 12345678, 1, 111.1111, 11, '1_one_11', 'd',
'2001-12-13 01:51:15+1359', '11', '0.0.0.0', '0.0.0.0', 'AA:AA:AA:AA:AA:AA', '34.23', '00:00:00+1359', '((2,2),1)', '((1,2),(2,1))', 'hello', '((1,2),(2,1))', 11, '010101', '2001-12-13', '((1,1),(2,2))', '(1,1)', '((1,2),(2,3),(3,4),(4,3),(3,2),(2,1))', 111111, '23:00:00', '2001-12-13 01:51:15');
drop table test_co;
CREATE TABLE test_co (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_ao (a int, b int) with (appendonly=true);
CREATE TABLE heap (a int, b int);
DROP TABLE IF EXISTS test_co_checksum_01;
DROP TABLE IF EXISTS test_co_checksum_02;
DROP TABLE IF EXISTS test_co_checksum_03;
DROP TABLE IF EXISTS test_co_checksum_04;
DROP TABLE IF EXISTS test_co_checksum_05;
DROP TABLE IF EXISTS test_co_checksum_06;
DROP TABLE IF EXISTS test_co_checksum_07;
DROP TABLE IF EXISTS test_co_checksum_08;
DROP TABLE IF EXISTS test_co_checksum_09;
DROP TABLE IF EXISTS test_co_checksum_10;
CREATE TABLE test_co_checksum_01 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_02 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_03 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_04 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_05 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_06 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_07 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_08 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_09 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_checksum_10 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
drop table test_co;
CREATE TABLE test_co_01 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
CREATE TABLE test_co_02 (a int, b int, c int, d int, e int) with (appendonly=true, orientation=column);
-- This file should be run when primary is in changetracking. Number
-- of blocks changed should be greater than gp_filerep_ct_batch_size.
show gp_filerep_ct_batch_size;
-- Change blocks of resync_bug_table in a particular order such that a
-- higher numbered block has lower LSN. Schema of resync_bug_table is
-- such that one block accommodates 901 tuples. Leverage this to
-- identify a block. Change Block 4 first so that it has lower LSN
-- than blocks 0, 1, 2.
delete from resync_bug_table where a = 1 and b = 901*5;
-- Block 0
delete from resync_bug_table where a = 1 and b = 901;
-- Block 1
delete from resync_bug_table where a = 1 and b = 901*2;
-- Block 2
delete from resync_bug_table where a = 1 and b = 901*3;
-- Block 3
delete from resync_bug_table where a = 1 and b = 901*4;
select * from resync_bug_table where a = 1 and
b in (901, 901*2, 901*3, 901*4, 901*5);
-- This file is only to help debugging, in case the test fails. It
-- should be executed in utility mode on the segment that is in
-- changetracking.
-- Flush CT log to disk
checkpoint;
select * from gp_changetracking_log(0) where rel =
(select relfilenode from pg_class where relname = 'resync_bug_table')
and
db = (select oid from pg_database where datname = current_database())
order by xlogloc;
-- Create table and insert data while cluster is in-sync.
drop table if exists resync_bug_table;
create table resync_bug_table(a int, b int) distributed by (a);
-- Insert tuples on a single statement. Insert enough tuples to
-- occupy 5 blocks on that segment. About 901 tuples having this
-- schema can be accommodated on one block.
insert into resync_bug_table select 1 ,i from generate_series(1,5000)i;
-- Checkpoint isn't really necessary but doesn't harm either.
checkpoint;
select * from resync_bug_table where a = 1 and
b in (901, 901*2, 901*3, 901*4, 901*5);
drop table fts_test;
create table fts_test( a int) distributed by (a);
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import tinctest
from mpp.gpdb.tests.storage.fts.fts_transitions.fts_transitions import FTSTestCase
class FtsTransitionsPart01(FTSTestCase):
''' State of FTS at different fault points
'''
def __init__(self, methodName):
super(FtsTransitionsPart01,self).__init__(methodName)
def test_filerep_sync_ct(self):
'''
@data_provider sync_ct_tests
'''
fault_name = self.test_data[1][0]
fault_type = self.test_data[1][1]
fault_role = self.test_data[1][2]
filerep_state = self.test_data[1][3]
filerep_role = self.test_data[1][4]
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: %s " % self.test_data[0][1])
tinctest.logger.info("\n ===============================================")
self.filerep_sync_ct(fault_name, fault_type, fault_role, filerep_state, filerep_role)
@tinctest.dataProvider('sync_ct_tests')
def test_sync_ct():
data = {'test_01_mirror_sync_postmaster_reset_filerep_sender': ['filerep_sender','panic','mirror','ct','mirror'],
'test_02_mirror_sync_postmaster_reset_filerep_receiver': ['filerep_receiver','panic','mirror','ct','mirror'],
'test_03_mirror_sync_postmaster_reset_filerep_flush': ['filerep_flush','panic','mirror','ct','mirror'],
'test_04_mirror_sync_postmaster_reset_filerep_consumer': ['filerep_consumer','panic','mirror','ct','mirror'],
'test_10_mirror_sync_filerep_process_error_failover': ['filerep_sender','error','mirror','ct','primary'],
'test_11_primary_sync_filerep_process_error_failover': ['filerep_sender','error','primary','ct','mirror'],
'test_14_mirror_sync_dealock_failover': ['filerep_sender','infinite_loop','mirror','ct','primary'],
'test_15_primary_sync_deadlock_failover': ['filerep_sender','infinite_loop','primary','ct','mirror'],
'test_16_primary_sync_filerep_network_failover': ['filerep_receiver','fault','primary','ct','mirror'],
'test_18_primary_sync_process_missing_failover': ['postmaster','panic','primary','ct','mirror'],
'test_42_mirror_sync_filerep_network': ['filerep_receiver','fault','mirror','ct','mirror'],
'test_43_mirror_sync_system_io_failover': ['filerep_flush', 'error', 'mirror','ct','mirror'],
'test_44_mirror_sync_postmaster_missing_failover': ['postmaster', 'panic', 'mirror','ct','mirror'],
'test_postmaster_reset_mpp13689': ['filerep_receiver','fatal','mirror','ct','primary']}
return data
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import tinctest
from mpp.gpdb.tests.storage.fts.fts_transitions.fts_transitions import FTSTestCase
class FtsTransitionsPart02(FTSTestCase):
''' State of FTS at different fault points
'''
def __init__(self, methodName):
super(FtsTransitionsPart02,self).__init__(methodName)
def test_gpstate_resync_object_count(self):
'''
@product_version gpdb: [4.3.5.0-]
'''
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: GPSTATE RESYNC OBJ COUNT ")
tinctest.logger.info("\n ===============================================")
self.gpstate_resync_object_count()
def test_ctchecksum_resync(self):
tinctest.logger.info("\n ======================================================")
tinctest.logger.info("\n Starting New Test: CT Checksum corruption inc resync")
tinctest.logger.info("\n ======================================================")
self.checksum_ct_logfile_recoverseg()
def test_ctchecksum_restart_after_corrupt_inline(self):
tinctest.logger.info("\n ===================================================================================")
tinctest.logger.info("\n Starting New Test: CT Checksum corruption restart DB after corruping CT file inline")
tinctest.logger.info("\n ===================================================================================")
self.checksum_ct_logfile_restartdb_corrupt_inline()
def test_ctchecksum_restart_after_corrupt_by_appending_partial_page(self):
tinctest.logger.info("\n ============================================================================================")
tinctest.logger.info("\n Starting New Test: CT Checksum corruption restart DB after appending partial page to CT file")
tinctest.logger.info("\n ============================================================================================")
self.checksum_ct_logfile_restartdb_corrupt_by_appending_partial_page()
def test_ctchecksum_resync_restart(self):
tinctest.logger.info("\n ======================================================")
tinctest.logger.info("\n Starting New Test: CT Checksum corruption resync and restart DB")
tinctest.logger.info("\n ======================================================")
self.checksum_ct_logfile_recoverseg_restartdb()
def test_sync_postmaster_reset(self):
'''
@data_provider sync_postmaster_tests
'''
fault_name = self.test_data[1][0]
fault_type = self.test_data[1][1]
fault_role = self.test_data[1][2]
filerep_state = self.test_data[1][3]
filerep_role = self.test_data[1][4]
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: %s " % self.test_data[0][1])
tinctest.logger.info("\n ===============================================")
self.sync_postmaster_reset(fault_name, fault_type, fault_role, filerep_state, filerep_role)
def test_primary_sync_mirror_cannot_keepup_failover(self):
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: test_primary_sync_mirror_cannot_keepup_failover")
tinctest.logger.info("\n ===============================================")
self.primary_sync_mirror_cannot_keepup_failover()
def test_21_change_tracking_transition_failover(self):
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: test_21_change_tracking_transition_failover" )
tinctest.logger.info("\n ===============================================")
self.change_tracking_transition_failover()
def test_mirror_resync_postmaster_reset_filerep_fault(self):
'''
@data_provider filerep_fault
'''
filerep_fault = self.test_data[1][0]
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: %s " % self.test_data[0][1])
tinctest.logger.info("\n ===============================================")
self.mirror_resync_postmaster_reset_filerep_fault(filerep_fault)
def test_wait_for_shutdown_before_commit(self):
'''
@product_version gpdb: [4.3.4.0-]
'''
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: test_wait_for_shutdown_before_commit" )
tinctest.logger.info("\n ===============================================")
self.wait_for_shutdown_before_commit()
@tinctest.dataProvider('sync_postmaster_tests')
def test_postmaster_reset():
data = {'test_05_primary_sync_postmaster_reset_filerep_sender': ['filerep_sender','panic','primary','sync1','mirror'],
'test_06_primary_sync_postmaster_reset_filerep_receiver': ['filerep_receiver','panic','primary','sync1','mirror'],
'test_07_primary_sync_postmaster_reset_checkpoint': ['checkpoint','panic','primary','sync1','mirror'],
'test_08_primary_sync_postmaster_reset_filerep_flush': ['filerep_flush','panic','primary','sync1','mirror'],
'test_09_primary_sync_postmaster_reset_filerep_consumer': ['filerep_consumer','panic','primary','sync1','mirror'],
'test_postmaster_reset_mpp13971': ['filerep_flush','panic','primary','sync1','mirror'] }
return data
@tinctest.dataProvider('filerep_fault')
def test_filerep_fault():
data = {'test_23_mirror_resync_postmaster_reset_filerep_sender': ['filerep_sender'],
'test_24_mirror_resync_postmaster_reset_filerep_receiver': ['filerep_receiver'],
'test_25_mirror_resync_postmaster_reset_filerep_flush': ['filerep_flush']}
return data
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
from gppylib.commands.base import Command
import tinctest
from tinctest.lib import Gpdiff, local_path
from mpp.gpdb.tests.storage.fts.fts_transitions.fts_transitions import FTSTestCase
from mpp.lib.config import GPDBConfig
from mpp.lib.filerep_util import Filerepe2e_Util
from mpp.lib.gprecoverseg import GpRecover
from mpp.lib.PSQL import PSQL
from mpp.models import MPPTestCase
class ResyncBug(MPPTestCase):
def __init__(self, methodName):
super(ResyncBug, self).__init__(methodName)
def run_sql(self, filename):
sql_file = local_path('sql/%s.sql' % filename)
ans_file = local_path('expected/%s.ans' % filename)
out_file = local_path('output/%s.out' % filename)
assert PSQL.run_sql_file(sql_file, out_file), sql_file
assert Gpdiff.are_files_equal(out_file, ans_file), out_file
def test_resync_ct_blocks_per_query(self):
'''Catch a bug in resync that manifests only after rebalance.
The logic used by a resync worker to obtain changed blocks
from CT log had a bug. The SQL query used to obtain a batch
of changed blocks from CT log was incorrectly using LSN to
filter out changed blocks. All of the following must be true
for the bug to occur:
* More than gp_filerep_ct_batch_size blocks of a relation
are changed on a segment in changetracking.
* A block with a higher number is changed earlier (lower
LSN) than lower numbered blocks.
* The first batch of changed blocks obtained by resync worker
from CT log for this relation contains only lower
(according to block number) blocks. The higher block with
lower LSN is not included in this batch. Another query
must be run against CT log to obtain this block.
* The SQL query used to obtain next batch of changed blocks
for this relation contains incorrect WHERE clause involving
a filter based on LSN of previously obtained blocks. The
higher numbered block is missed out - not returned by the
query as changed block for the relation. The block is
never shipped from primary to mirror, resulting in data
loss. The test aims to verify that this doesn't happen as
the bug is now fixed.
'''
config = GPDBConfig()
assert (config.is_not_insync_segments() &
config.is_balanced_segments()), 'cluster not in-sync and balanced'
# Create table and insert data so that adequate number of
# blocks are occupied.
self.run_sql('resync_bug_setup')
# Bring down primaries and transition mirrors to
# changetracking.
filerep = Filerepe2e_Util()
filerep.inject_fault(y='fault', f='segment_probe_response',
r='primary')
# Trigger the fault by running a sql file.
PSQL.run_sql_file(local_path('test_ddl.sql'))
filerep.wait_till_change_tracking_transition()
# Set gp_filerep_ct_batch_size = 3.
cmd = Command('reduce resync batch size',
'gpconfig -c gp_filerep_ct_batch_size -v 3')
cmd.run()
assert cmd.get_results().rc == 0, 'gpconfig failed'
cmd = Command('load updated config', 'gpstop -au')
cmd.run()
assert cmd.get_results().rc == 0, '"gpstop -au" failed'
self.run_sql('change_blocks_in_ct')
# Capture change tracking log contents from the segment of
# interest for debugging, in case the test fails.
(host, port) = GPDBConfig().get_hostandport_of_segment(0, 'p')
assert PSQL.run_sql_file_utility_mode(
sql_file=local_path('sql/ct_log_contents.sql'),
out_file=local_path('output/ct_log_contents.out'),
host=host, port=port), sql_file
gprecover = GpRecover(GPDBConfig())
gprecover.incremental(False)
gprecover.wait_till_insync_transition()
# Rebalance, so that original primary is back in the role
gprecover = GpRecover(GPDBConfig())
gprecover.rebalance()
gprecover.wait_till_insync_transition()
# Reset gp_filerep_ct_batch_size
cmd = Command('reset resync batch size',
'gpconfig -r gp_filerep_ct_batch_size')
cmd.run()
assert cmd.get_results().rc == 0, 'gpconfig failed'
cmd = Command('load updated config', 'gpstop -au')
cmd.run()
assert cmd.get_results().rc == 0, '"gpstop -au" failed'
self.run_sql('select_after_rebalance')
class FtsTransitionsPart03(FTSTestCase):
''' State of FTS at different fault points
'''
def __init__(self, methodName):
super(FtsTransitionsPart03,self).__init__(methodName)
def test_primary_resync_postmaster_reset_with_faults(self):
'''
@data_provider pr_faults
'''
filerep_fault = self.test_data[1][0]
fault_type = self.test_data[1][1]
filerep_role = self.test_data[1][2]
gpstate_role = self.test_data[1][3]
gprecover = self.test_data[1][4]
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: %s " % self.test_data[0][1])
tinctest.logger.info("\n ===============================================")
self.primary_resync_postmaster_reset_with_faults(filerep_fault, fault_type, filerep_role, gpstate_role, gprecover)
def test_mirror_resync_postmaster_reset_with_faults(self):
tinctest.logger.info("\n ===============================================")
tinctest.logger.info("\n Starting New Test: test_mirror_resync_postmaster_reset_with_faults ")
tinctest.logger.info("\n ===============================================")
self.mirror_resync_postmaster_reset_with_faults()
@tinctest.dataProvider('pr_faults')
def test_pr_faults():
data = {'test_27_primary_resync_postmaster_reset_checkpoint': ['checkpoint','panic', 'primary', 'mirror', 'no'],
'test_28_primary_resync_postmaster_reset_filerep_flush': ['filerep_flush','panic','primary', 'mirror', 'no'],
'test_29_primary_resync_postmaster_reset_filerep_consumer': ['filerep_consumer','panic', 'primary', 'mirror', 'no'],
'test_30_mirror_resync_process_missing_failover': ['filerep_sender','error', 'mirror', 'mirror', 'yes'],
'test_31_primary_resync_process_missing_failover': ['filerep_sender','error', 'primary', 'primary', 'yes'],
'test_32_mirror_resync_deadlock_failover': ['filerep_sender', 'infinite_loop', 'mirror', 'mirror', 'yes'],
'test_33_primary_resync_deadlock_failover': ['filerep_sender', 'infinite_loop', 'primary', 'primary', 'yes'],
'test_34_primary_resync_filerep_network_failover': ['filerep_consumer', 'panic', 'mirror', 'mirror', 'yes'],
'test_36_primary_resync_postmaster_missing_failover': ['postmaster', 'panic', 'primary', 'mirror', 'no'],
'test_37_primary_resync_system_failover': ['filerep_resync_worker_read', 'fault', 'primary', 'mirror', 'yes'],
'test_38_primary_resync_mirror_cannot_keepup_failover': ['filerep_receiver', 'sleep', 'primary', 'mirror', 'no'],
'test_39_mirror_resync_filerep_network': ['filerep_receiver', 'fault', 'mirror', 'primary', 'yes'],
'test_40_mirror_resync_system_failover': ['filerep_flush', 'fault', 'mirror', 'primary', 'yes'],
'test_41_mirror_resync_postmaster_missing_failover': ['postmaster', 'panic', 'mirror', 'primary', 'yes'],
'test_46_primary_resync_postmaster_reset_filerep_sender': ['filerep_sender', 'panic', 'primary', 'primary', 'yes']}
return data
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册