提交 723a21e0 编写于 作者: B Bhuvnesh Chaudhary

Add test

上级 08a3612f
...@@ -919,6 +919,12 @@ check_preferred_roles(void) ...@@ -919,6 +919,12 @@ check_preferred_roles(void)
int content; int content;
PGconn *conn; PGconn *conn;
/*
* We only need to check the segment roles on master
*/
if (!is_greenplum_dispatcher_mode())
return;
prep_status("Checking for segments not in preferred role"); prep_status("Checking for segments not in preferred role");
snprintf(output_path, sizeof(output_path), "segment_roles_switched.txt"); snprintf(output_path, sizeof(output_path), "segment_roles_switched.txt");
...@@ -968,4 +974,4 @@ check_preferred_roles(void) ...@@ -968,4 +974,4 @@ check_preferred_roles(void)
else else
check_ok(); check_ok();
} }
\ No newline at end of file
...@@ -2,4 +2,5 @@ export MASTER_PORT=50000 ...@@ -2,4 +2,5 @@ export MASTER_PORT=50000
export STANDBY_PORT=50001 export STANDBY_PORT=50001
export PORT_BASE=50002 export PORT_BASE=50002
export DATADIRS="$PWD/gpdb5-data" export DATADIRS="$PWD/gpdb5-data"
export PGPORT=50000 export PGPORT=50000
\ No newline at end of file export MASTER_DATA_DIRECTORY="$DATADIRS/qddir/demoDataDir-1"
...@@ -9,3 +9,4 @@ test: unsupported_tsquery_col ...@@ -9,3 +9,4 @@ test: unsupported_tsquery_col
test: gphdfs test: gphdfs
test: mismatched_aopartition_indexes test: mismatched_aopartition_indexes
test: different_name_index_backed_constraint test: different_name_index_backed_constraint
test: preferred_roles
-- start_ignore
create language plpythonu;
-- end_ignore
-- stop a primary in order to trigger a mirror promotion
create or replace function stop_segment(datadir text)
returns text as $$
import subprocess
cmd = 'pg_ctl -l postmaster.log -D %s -w -m immediate stop' % datadir
return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '')
$$ language plpythonu;
-- function to wait for a segment to take a role
create or replace function wait_for_content0(target_mode char) /*in func*/ returns void as $$ /*in func*/ declare /*in func*/ iterations int := 0; /*in func*/ begin /*in func*/ while iterations < 120 loop /*in func*/ perform pg_sleep(1); /*in func*/ if exists (select * from gp_segment_configuration where content = 0 and mode = target_mode) then /*in func*/ return; /*in func*/ end if; /*in func*/ iterations := iterations + 1; /*in func*/ end loop; /*in func*/ end $$ /*in func*/ language plpgsql;
checkpoint;
-- the check should not return any failure
! ./gpdb6/bin/pg_upgrade --mode=dispatcher --old-gp-dbid=1 --new-gp-dbid=1 --check --old-bindir=@upgrade_test_path@/gpdb5/bin --new-bindir=@upgrade_test_path@/gpdb6/bin --old-datadir=@upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1 --new-datadir=@upgrade_test_path@/gpdb6-data/qddir/demoDataDir-1 --old-port=@old_port@;
-- Stop content 0 primary and let the mirror take over
select stop_segment(fselocation) from pg_filespace_entry fe, gp_segment_configuration c, pg_filespace f
where fe.fsedbid = c.dbid and c.content=0 and c.role='p' and f.oid = fe.fsefsoid and f.fsname = 'pg_system';
select wait_for_content0('c');
-- one of the segment has switched role, the check should catch it
! ./gpdb6/bin/pg_upgrade --mode=dispatcher --old-gp-dbid=1 --new-gp-dbid=1 --check --old-bindir=@upgrade_test_path@/gpdb5/bin --new-bindir=@upgrade_test_path@/gpdb6/bin --old-datadir=@upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1 --new-datadir=@upgrade_test_path@/gpdb6-data/qddir/demoDataDir-1 --old-port=@old_port@;
-- start_ignore
! ./gpdb5/bin/gprecoverseg -a -d @upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1;
select wait_for_content0('s');
! ./gpdb5/bin/gprecoverseg -a -r -d @upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1;
select wait_for_content0('s');
-- end_ignore
-- start_ignore
create language plpythonu;
-- end_ignore
-- stop a primary in order to trigger a mirror promotion
create or replace function stop_segment(datadir text) returns text as $$ import subprocess cmd = 'pg_ctl -l postmaster.log -D %s -w -m immediate stop' % datadir return subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).replace('.', '') $$ language plpythonu;
CREATE
-- function to wait for a segment to take a role
create or replace function wait_for_content0(target_mode char) /*in func*/ returns void as $$ /*in func*/ declare /*in func*/ iterations int := 0; /*in func*/ begin /*in func*/ while iterations < 120 loop /*in func*/ perform pg_sleep(1); /*in func*/ if exists (select * from gp_segment_configuration where content = 0 and mode = target_mode) then /*in func*/ return; /*in func*/ end if; /*in func*/ iterations := iterations + 1; /*in func*/ end loop; /*in func*/ end $$ /*in func*/ language plpgsql;
CREATE
checkpoint;
CHECKPOINT
-- the check should not return any failure
! ./gpdb6/bin/pg_upgrade --mode=dispatcher --old-gp-dbid=1 --new-gp-dbid=1 --check --old-bindir=@upgrade_test_path@/gpdb5/bin --new-bindir=@upgrade_test_path@/gpdb6/bin --old-datadir=@upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1 --new-datadir=@upgrade_test_path@/gpdb6-data/qddir/demoDataDir-1 --old-port=@old_port@;
Performing Consistency Checks on Old Live Server
------------------------------------------------
Creating a dump of all tablespace metadata. ok
*Clusters are compatible*
-- Stop content 0 primary and let the mirror take over
select stop_segment(fselocation) from pg_filespace_entry fe, gp_segment_configuration c, pg_filespace f where fe.fsedbid = c.dbid and c.content=0 and c.role='p' and f.oid = fe.fsefsoid and f.fsname = 'pg_system';
stop_segment
------------------------------------------------------
waiting for server to shut down done
server stopped
(1 row)
select wait_for_content0('c');
wait_for_content0
-------------------
(1 row)
-- one of the segment has switched role, the check should catch it
! ./gpdb6/bin/pg_upgrade --mode=dispatcher --old-gp-dbid=1 --new-gp-dbid=1 --check --old-bindir=@upgrade_test_path@/gpdb5/bin --new-bindir=@upgrade_test_path@/gpdb6/bin --old-datadir=@upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1 --new-datadir=@upgrade_test_path@/gpdb6-data/qddir/demoDataDir-1 --old-port=@old_port@;
Performing Consistency Checks on Old Live Server
------------------------------------------------
Creating a dump of all tablespace metadata. ok
Checking for segments not in preferred roles fatal
| The segments should be in their preferred roles for upgrade.
| Segments not operating in the preferred roles must be recovered
| and/or rebalanced using gprecoverseg. The list of such segments
| is in the file:
segment_roles_switched.txt
Failure, exiting
-- start_ignore
! ./gpdb5/bin/gprecoverseg -a -d @upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1;
select wait_for_content0('s');
! ./gpdb5/bin/gprecoverseg -a -r -d @upgrade_test_path@/gpdb5-data/qddir/demoDataDir-1;
select wait_for_content0('s');
-- end_ignore
...@@ -13,7 +13,7 @@ main() { ...@@ -13,7 +13,7 @@ main() {
local new_port=60000 local new_port=60000
# need python for sql isolation test modules. # need python for sql isolation test modules.
source gpdb6/greenplum_path.sh source gpdb5/greenplum_path.sh
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
...@@ -34,6 +34,9 @@ main() { ...@@ -34,6 +34,9 @@ main() {
--old-port=$old_port \ --old-port=$old_port \
$gpdb5_input $gpdb5_input
./scripts/gpdb5-cluster stop ./scripts/gpdb5-cluster stop
# need python for sql isolation test modules.
source gpdb6/greenplum_path.sh
./scripts/upgrade-cluster ./scripts/upgrade-cluster
./scripts/gpdb6-cluster start ./scripts/gpdb6-cluster start
./pg_upgrade_regress --use-existing \ ./pg_upgrade_regress --use-existing \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册