Skip to content

Commit

Permalink
ADBDEV-6920: Changes related to renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
RomaZe committed Dec 26, 2024
1 parent 866228c commit e535cc0
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 29 deletions.
8 changes: 5 additions & 3 deletions automation/arenadata/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ RUN mkdir -p /data1/master /data1/primary /data1/mirror && chmod -R 755 /data1 &
chown -R gpadmin:gpadmin /home/gpadmin && \
install_gpdb

# Create symlinks if needed
RUN if [ -d /usr/local/greengage-db-devel ]; then ln -s /usr/local/greengage-db-devel /usr/local/greenplum-db-devel; fi;
RUN if [ -e /usr/local/greengage-db-devel/greengage_path.sh ]; then ln -s /usr/local/greengage-db-devel/greengage_path.sh /usr/local/greenplum-db-devel/greenplum_path.sh; fi;

# Install PXF
ENV JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
COPY . /home/gpadmin/pxf_src
COPY ./automation/arenadata/scripts/compile_pxf_without_test.sh ./pxf_src/concourse/scripts/compile_pxf_without_test.sh
RUN chmod +x ./pxf_src/concourse/scripts/compile_pxf_without_test.sh
RUN source gpdb_src/concourse/scripts/common.bash && \
mkdir pxf_tarball && \
install_gpdb && \
source '/usr/local/greenplum-db-devel/greenplum_path.sh' && \
export SKIP_FDW_BUILD_REASON=0 && \
pxf_src/concourse/scripts/compile_pxf_without_test.sh && \
Expand Down Expand Up @@ -106,5 +108,5 @@ RUN set -eux; \
RUN cp /tmp/libs/* ${PXF_HOME}/lib/

RUN chmod a+x ./pxf_src/automation/arenadata/scripts/start_adb_cluster.sh
RUN chown -R gpadmin:gpadmin /usr/local/greenplum-db-devel
RUN if [ -d /usr/local/greengage-db-devel ]; then chown -R gpadmin:gpadmin /usr/local/greengage-db-devel; else chown -R gpadmin:gpadmin /usr/local/greenplum-db-devel; fi;
ENTRYPOINT ["/home/gpadmin/pxf_src/automation/arenadata/scripts/start_adb_cluster.sh"]
2 changes: 1 addition & 1 deletion automation/arenadata/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ services:
retries: 3

oracle:
image: "absolutapps/oracle-12c-ee"
image: "haoyu233/oracle-12c-ee"
restart: unless-stopped
container_name: oracle
hostname: oracle
Expand Down
6 changes: 5 additions & 1 deletion automation/arenadata/scripts/compile_pxf_without_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

set -eoux pipefail

GPHOME=/usr/local/greenplum-db-devel
if [ -d /usr/local/greengage-db-devel ]; then
GPHOME=/usr/local/greengage-db-devel
else
GPHOME=/usr/local/greenplum-db-devel
fi

# use a login shell for setting environment
bash --login -c "
Expand Down
93 changes: 76 additions & 17 deletions automation/arenadata/scripts/start_adb_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,49 @@ if [ "$HOSTNAME" == "$DOCKER_GP_MASTER_SERVER" ]; then
echo "----------------------------------"
echo "Run Greenplum cluster installation"
echo "----------------------------------"
sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile &&
/usr/local/greenplum-db-devel/bin/gpinitsystem -a -I /home/gpadmin/gpdb_src/gpAux/gpdemo/create_cluster.conf -l /home/gpadmin/gpAdminLogs"
sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile &&
psql -d postgres -Atc 'CREATE EXTENSION IF NOT EXISTS pxf;' &&
psql -d postgres -Atc 'CREATE EXTENSION IF NOT EXISTS pxf_fdw;' &&
echo 'local all testuser trust' >> /data1/master/gpseg-1/pg_hba.conf &&
echo 'host all gpadmin 0.0.0.0/0 trust' >> /data1/master/gpseg-1/pg_hba.conf &&
echo 'host all all 0.0.0.0/0 md5' >> /data1/master/gpseg-1/pg_hba.conf &&
gpconfig -c gp_resource_manager -v group &&
gpstop -aM fast && gpstart -a"

# Check cluster

echo "---------------------------------"
echo "Check ssh connection to the hosts"
echo "---------------------------------"
max_iterations=20
wait_seconds=5
iterations=0
while true
do
((iterations++))
echo "Check SSH connection. Attempt $iterations"
status=0
for server in $DOCKER_GP_CLUSTER_HOSTS
do
echo "Check SSH connection to the $server"
sudo -H -u gpadmin bash -c -l "ssh -o PasswordAuthentication=no $server 'exit'"
if ! [ $? -eq 0 ]; then
echo "Server $server is not available for ssh connection. We will try again..."
status=1
break
fi
done
if [ $status -eq 0 ]; then
echo "All Greenplum servers are available for SSH connection"
break
elif [ "$iterations" -ge "$max_iterations" ]; then
echo "Error to connect to some Greenplum server via SSH after $max_iterations tries. Exit from script!"
exit 1
else
echo "Wait $wait_seconds seconds and try again to connect to the servers"
sleep $wait_seconds
fi
done

echo "-------------------------"
echo "Install Greenplum cluster"
echo "-------------------------"
sudo -H -u gpadmin bash -c -l "/usr/local/greenplum-db-devel/bin/gpinitsystem -a -I /home/gpadmin/gpdb_src/gpAux/gpdemo/create_cluster.conf -l /home/gpadmin/gpAdminLogs"

echo "-------------------------------------"
echo "Check connection to Greenplum cluster"
echo "-------------------------------------"
result="$( sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile && /usr/local/greenplum-db-devel/bin/psql -d postgres -Atc 'SELECT 1;'" )"
result="$( sudo -H -u gpadmin bash -c -l "psql -d postgres -Atc 'SELECT 1;'" )"
if [ "${result}" == "1" ]; then
echo "--------------------------------------------"
echo "Fantastic!!! Greenplum cluster is available!"
Expand All @@ -194,20 +221,35 @@ if [ "$HOSTNAME" == "$DOCKER_GP_MASTER_SERVER" ]; then
echo "------------------------------"
echo "Activate standby master server"
echo "------------------------------"
sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile && /usr/local/greenplum-db-devel/bin/gpinitstandby -a -s $DOCKER_GP_STANDBY_SERVER"
sudo -H -u gpadmin bash -c -l "/usr/local/greenplum-db-devel/bin/gpinitstandby -a -s $DOCKER_GP_STANDBY_SERVER"
fi
else
echo "-------------------------------------"
echo "Error to connect to Greenplum cluster"
echo "-------------------------------------"
exit 1;
fi

echo "-------------------"
echo "Configure Greenplum"
echo "-------------------"
sudo -H -u gpadmin bash -c -l "psql -d postgres -Atc 'CREATE EXTENSION IF NOT EXISTS pxf;' &&
psql -d postgres -Atc 'CREATE EXTENSION IF NOT EXISTS pxf_fdw;' &&
echo 'local all testuser trust' >> /data1/master/gpseg-1/pg_hba.conf &&
echo 'host all gpadmin 0.0.0.0/0 trust' >> /data1/master/gpseg-1/pg_hba.conf &&
echo 'host all all 0.0.0.0/0 md5' >> /data1/master/gpseg-1/pg_hba.conf &&
gpconfig -c gp_resource_manager -v group"

echo "*******************"
echo "Restart ADB cluster"
echo "*******************"
sudo -H -u gpadmin bash -c -l "gpstop -aM fast && gpstart -a"
else
echo "-------------------------"
echo "Starting Greenplum server"
echo "-------------------------"
sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile && gpstart -a"
result="$( sudo -H -u gpadmin bash -c "source /home/gpadmin/.bash_profile && /usr/local/greenplum-db-devel/bin/psql -d postgres -Atc 'SELECT 1;'" )"
sudo -H -u gpadmin bash -c -l "gpstart -a"
result="$( sudo -H -u gpadmin bash -c -l "psql -d postgres -Atc 'SELECT 1;'" )"
if [ "${result}" == "1" ]; then
echo "--------------------------------------------"
echo "Fantastic!!! Greenplum cluster is available!"
Expand All @@ -233,9 +275,26 @@ do
echo "---------"
echo "Start PXF"
echo "---------"
# Init Vault environment
if [[ "$PXF_VAULT_ENABLED" = true ]]; then
echo "----------------------------------------"
echo "Init Vault env variables for PXF service"
echo "----------------------------------------"
ksh -c env | grep -E 'PXF_VAULT' | sed 's/^/export /' >> /home/gpadmin/.bash_profile
ksh -c env | grep -E 'PXF_VAULT' | sed 's/^/export /' >> /home/gpadmin/.bashrc
fi
# Init SSL environment
if [[ "$PXF_PROTOCOL" = "https" ]]; then
echo "--------------------------------------"
echo "Init SSL env variables for PXF service"
echo "--------------------------------------"
ksh -c env | grep -E 'PXF_SSL|PXF_HOST|PXF_PROTOCOL' | sed 's/^/export /' >> /home/gpadmin/.bash_profile
ksh -c env | grep -E 'PXF_SSL|PXF_HOST|PXF_PROTOCOL' | sed 's/^/export /' >> /home/gpadmin/.bashrc
fi

if [ "$HOSTNAME" == "$DOCKER_GP_MASTER_SERVER" ]; then
sudo -H -u gpadmin bash -c -l "pxf start && tail -f /data1/master/gpseg-1/pg_log/gpdb-*.csv"
else
sudo -H -u gpadmin bash -c -l "pxf start && tail -f /usr/local/greenplum-db-devel/pxf/logs/pxf-service.log"
fi
done
done
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
-- start_ignore
-- end_ignore
-- @description query01 for PXF test to check that the session is closed correctly

-- start_matchsubs
--
-- m/.*File '\/usr\/local\/.*\/pxf\/servers\/named\/wrong_file_name.sql.*/
-- s/.*File '\/usr\/local\/.*\/pxf\/servers\/named\/wrong_file_name.sql.*/ERROR: PXF server error : Failed to read text of query wrong_file_name : File '\/usr\/local\/greenplum-db-devel\/pxf\/servers\/named\/wrong_file_name.sql' does not exist/
--
-- end_matchsubs

SELECT * FROM named_query_read_ext_table ORDER BY id;
id | name
----+-------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
-- @description query01 for PXF test to check that the session is closed correctly

-- start_matchsubs
--
-- m/.*File '\/usr\/local\/.*\/pxf\/servers\/named\/wrong_file_name.sql.*/
-- s/.*File '\/usr\/local\/.*\/pxf\/servers\/named\/wrong_file_name.sql.*/ERROR: PXF server error : Failed to read text of query wrong_file_name : File '\/usr\/local\/greenplum-db-devel\/pxf\/servers\/named\/wrong_file_name.sql' does not exist/
--
-- end_matchsubs

SELECT * FROM named_query_read_ext_table ORDER BY id;

SELECT * FROM named_query_wrong_read_ext_table ORDER BY id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Gpdb extends DbSystemObject {

private static final String DEFAULT_PORT = "5432";
private static final String GREENPLUM_DATABASE_PREFIX = "Greenplum Database ";
private static final String GREENPLUM_DATABASE_PREFIX = "Database ";
private static final String IF_NOT_EXISTS_OPTION = "IF NOT EXISTS";

private String sshUserName;
Expand Down
4 changes: 0 additions & 4 deletions server/pxf-service/src/scripts/pxf
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ function installExtensions() {
if [[ -d ${parent_script_dir}/gpextable ]]; then
if [[ -z "${GPHOME}" ]]; then
echoYellow 'WARNING: environment variable GPHOME is not set, skipping install of Greenplum External Table PXF Extension'
elif [[ ! -f ${GPHOME}/greenplum_path.sh ]]; then
echoYellow "WARNING: environment variable GPHOME (${GPHOME}) must be set to a valid Greenplum installation, skipping install of Greenplum External Table PXF Extension'"
else
echoGreen "Installing Greenplum External Table PXF Extension into '${GPHOME}'"

Expand All @@ -267,8 +265,6 @@ function installExtensions() {
if [[ -d ${parent_script_dir}/fdw ]]; then
if [[ -z "${GPHOME}" ]]; then
echoYellow 'WARNING: environment variable GPHOME is not set, skipping install of Greenplum Foreign Data Wrapper PXF Extension'
elif [[ ! -f ${GPHOME}/greenplum_path.sh ]]; then
echoYellow "WARNING: environment variable GPHOME (${GPHOME}) must be set to a valid Greenplum installation, skipping install of Greenplum Foreign Data Wrapper PXF Extension'"
else
echoGreen "Installing Greenplum Foreign Data Wrapper PXF Extension into '${GPHOME}'"

Expand Down

0 comments on commit e535cc0

Please sign in to comment.