From cc9d98774b734ccbfcadec4b77abb5e7ba01a8fe Mon Sep 17 00:00:00 2001 From: Kalen Krempely Date: Thu, 18 Apr 2019 16:03:49 -0700 Subject: [PATCH] gpmovemirrors: add multi-host tablespace test Create the tablespace directory on all segments to support running multi-host tablespace tests. Co-authored-by: Jacob Champion (cherry picked from commit 83f48aac090734bae3c28606bc0906d158b8c96c) --- .../behave/mgmt_utils/gpmovemirrors.feature | 18 +++++++++++++++++- .../mgmt_utils/steps/tablespace_mgmt_utils.py | 12 ++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gpMgmt/test/behave/mgmt_utils/gpmovemirrors.feature b/gpMgmt/test/behave/mgmt_utils/gpmovemirrors.feature index c9362f2f63..4b2ad8e687 100644 --- a/gpMgmt/test/behave/mgmt_utils/gpmovemirrors.feature +++ b/gpMgmt/test/behave/mgmt_utils/gpmovemirrors.feature @@ -97,4 +97,20 @@ Feature: Tests for gpmovemirrors And the segments are synchronized And verify that mirror segments are in "group" configuration And verify that mirrors are recognized after a restart - And the user runs "gpstop -aqM fast" + + @concourse_cluster + Scenario: tablespaces work on a multi-host environment + Given verify that mirror segments are in "group" configuration + And a tablespace is created with data + And a sample gpmovemirrors input file is created in "spread" configuration + When the user runs "gpmovemirrors --input=/tmp/gpmovemirrors_input_spread" + Then gpmovemirrors should return a return code of 0 + And verify the database has mirrors + And all the segments are running + And the segments are synchronized + And verify that mirrors are recognized after a restart + And the tablespace is valid + + When user stops all primary processes + And user can start transactions + Then the tablespace is valid diff --git a/gpMgmt/test/behave/mgmt_utils/steps/tablespace_mgmt_utils.py b/gpMgmt/test/behave/mgmt_utils/steps/tablespace_mgmt_utils.py index f3e25216f0..25382fb52d 100644 --- a/gpMgmt/test/behave/mgmt_utils/steps/tablespace_mgmt_utils.py +++ b/gpMgmt/test/behave/mgmt_utils/steps/tablespace_mgmt_utils.py @@ -1,3 +1,4 @@ +import pipes import shutil import tempfile @@ -5,7 +6,8 @@ from behave import given, when, then from pygresql import pg from gppylib.db import dbconn - +from gppylib.gparray import GpArray +from test.behave_utils.utils import run_cmd class Tablespace: def __init__(self, name): @@ -15,6 +17,10 @@ class Tablespace: self.table_counter = 0 self.initial_data = None + gparray = GpArray.initFromCatalog(dbconn.DbURL()) + for host in gparray.getHostList(): + run_cmd('ssh %s mkdir -p %s' % (pipes.quote(host), pipes.quote(self.path))) + with dbconn.connect(dbconn.DbURL()) as conn: db = pg.DB(conn) db.query("CREATE TABLESPACE %s LOCATION '%s'" % (self.name, self.path)) @@ -40,7 +46,9 @@ class Tablespace: # before removing them below. _checkpoint_and_wait_for_replication_replay(db) - shutil.rmtree(self.path) + gparray = GpArray.initFromCatalog(dbconn.DbURL()) + for host in gparray.getHostList(): + run_cmd('ssh %s rm -rf %s' % (pipes.quote(host), pipes.quote(self.path))) def verify(self, hostname=None, port=0): """ -- GitLab