HIVE-10239: Create scripts to do metastore upgrade tests on jenkins for Derby 
and PostgreSQL (Naveen Gangam, reviewed by Sergio Pena)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/39972026
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/39972026
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/39972026

Branch: refs/heads/llap
Commit: 399720263d875897cdd31a3de2521872cc565eb7
Parents: d39c829
Author: Sergio Pena <[email protected]>
Authored: Wed May 6 14:29:23 2015 -0500
Committer: Sergio Pena <[email protected]>
Committed: Wed May 6 14:29:23 2015 -0500

----------------------------------------------------------------------
 metastore/dbs/derby/execute.sh    | 37 +++++++++++++++++
 metastore/dbs/derby/prepare.sh    | 63 +++++++++++++++++++++++++++++
 metastore/dbs/postgres/execute.sh | 29 ++++++++++++++
 metastore/dbs/postgres/prepare.sh | 72 ++++++++++++++++++++++++++++++++++
 4 files changed, 201 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/39972026/metastore/dbs/derby/execute.sh
----------------------------------------------------------------------
diff --git a/metastore/dbs/derby/execute.sh b/metastore/dbs/derby/execute.sh
new file mode 100644
index 0000000..d60f05b
--- /dev/null
+++ b/metastore/dbs/derby/execute.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# This script executes all hive metastore upgrade scripts on an specific
+# database server in order to verify that upgrade scripts are working
+# properly.
+
+cd $(dirname $1)
+
+echo "####################################################"
+echo "Executing script for Derby SQL: $1"
+echo "####################################################"
+
+export DERBY_HOME=/usr/share/javadb
+export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+export PATH=$PATH:$DERBY_HOME/bin:$JAVA_HOME/bin
+export 
CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar:$DERBY_HOME/lib/derbyclient.jar
+
+echo "connect 'jdbc:derby:/tmp/hive_hms_testing;create=true';" > 
/tmp/derbyRun.sql
+echo "run '$1';" >> /tmp/derbyRun.sql
+echo "quit;" >> /tmp/derbyRun.sql
+
+ij /tmp/derbyRun.sql

http://git-wip-us.apache.org/repos/asf/hive/blob/39972026/metastore/dbs/derby/prepare.sh
----------------------------------------------------------------------
diff --git a/metastore/dbs/derby/prepare.sh b/metastore/dbs/derby/prepare.sh
new file mode 100644
index 0000000..fe4b2c3
--- /dev/null
+++ b/metastore/dbs/derby/prepare.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# This script executes all hive metastore upgrade scripts on an specific
+# database server in order to verify that upgrade scripts are working
+# properly.
+
+export DEBIAN_FRONTEND=noninteractive
+OS_VERSION=`lsb_release -c | cut -d":" -f2`
+
+echo "####################################################"
+echo "Begin for OS version $OS_VERSION"
+echo "####################################################"
+
+HTTPS_INFO=($(dpkg -l apt-transport-https | grep ^i | tr -s ' '))
+if [[ ${HTTPS_INFO[1]} == "apt-transport-https" ]]
+then
+  echo "apt-transport-https package installed"
+else
+  echo "apt-transport-https package not installed"
+  apt-get install -y --force-yes apt-transport-https
+fi
+
+INSTALL_INFO=($(dpkg -l \*javadb-core\* | grep ^ii | tr -s ' '))
+
+if [[ ${INSTALL_INFO[1]} == "sun-javadb-core" ]]
+then
+  echo "Derby already installed...Skipping"
+else
+  echo "Derby not installed"
+  # Cleanup existing installation + configuration.
+  apt-get purge -y --force-yes derby-tools sun-javadb-client sun-javadb-core 
sun-javadb-common libderby-java openjdk-7-jre openjdk-7-jre 
openjdk-7-jre-headless || /bin/true
+  echo "####################################################"
+  echo "Installing Derby dependencies:"
+  echo "####################################################"
+  apt-get update || /bin/true
+  apt-get install -y --force-yes -o Dpkg::Options::="--force-overwrite" 
sun-javadb-core sun-javadb-client derby-tools
+fi
+
+export DERBY_HOME=/usr/share/javadb
+export JAVA_HOME=//usr/lib/jvm/java-7-openjdk-amd64
+export PATH=$PATH:/usr/share/javadb/bin:$JAVA_HOME/bin
+export 
CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar:$DERBY_HOME/lib/derbyclient.jar
+rm -rf /tmp/hive_hms_testing;
+
+echo "connect 'jdbc:derby:/tmp/hive_hms_testing;create=true';" > 
/tmp/derbyInit.sql
+ij /tmp/derbyInit.sql 
+
+echo "DONE!!!"
+

http://git-wip-us.apache.org/repos/asf/hive/blob/39972026/metastore/dbs/postgres/execute.sh
----------------------------------------------------------------------
diff --git a/metastore/dbs/postgres/execute.sh 
b/metastore/dbs/postgres/execute.sh
new file mode 100644
index 0000000..cabcae4
--- /dev/null
+++ b/metastore/dbs/postgres/execute.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# This script executes all hive metastore upgrade scripts on an specific
+# database server in order to verify that upgrade scripts are working
+# properly.
+
+cd $(dirname $1)
+
+echo "####################################################"
+echo "Executing script for PostgreSQL: $1"
+echo "####################################################"
+
+export PGPASSWORD=hivepw
+psql -h localhost -U hiveuser -d hive_hms_testing -f $1

http://git-wip-us.apache.org/repos/asf/hive/blob/39972026/metastore/dbs/postgres/prepare.sh
----------------------------------------------------------------------
diff --git a/metastore/dbs/postgres/prepare.sh 
b/metastore/dbs/postgres/prepare.sh
new file mode 100644
index 0000000..2036354
--- /dev/null
+++ b/metastore/dbs/postgres/prepare.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# This script executes all hive metastore upgrade scripts on an specific
+# database server in order to verify that upgrade scripts are working
+# properly.
+
+export DEBIAN_FRONTEND=noninteractive
+OS_VERSION=`lsb_release -c | cut -d":" -f2`
+echo "$OS_VERSION"
+
+echo "####################################################"
+echo "Begin for OS version $OS_VERSION"
+echo "####################################################"
+
+HTTPS_INFO=($(dpkg -l apt-transport-https | grep ^i | tr -s ' '))
+if [[ ${HTTPS_INFO[1]} == "apt-transport-https" ]]
+then
+  echo "apt-transport-https package installed"
+else
+  echo "apt-transport-https package not installed"
+  apt-get install -y --force-yes apt-transport-https
+fi
+
+INSTALL_INFO=($(dpkg -l postgresql-9.4\* | grep ^i | tr -s ' '))
+
+if [[ ${INSTALL_INFO[1]} == "postgresql-9.4" ]]
+then
+  echo "PostgreSQL already installed...Skipping"
+else
+  echo "PostgreSQL not installed"
+  # Cleanup existing installation + configuration.
+  apt-get purge -y --force-yes postgressql-9.4 || /bin/true
+  echo "####################################################"
+  echo "Installing PostgreSQL dependencies:"
+  echo "####################################################"
+  if grep -q "deb http://apt.postgresql.org/pub/repos/apt/ $OS_VERSION-pgdg 
main" /etc/apt/sources.list.d/postgreSQL.list
+  then
+    echo "Sources already listed"
+  else
+    echo "deb http://apt.postgresql.org/pub/repos/apt/ $OS_VERSION-pgdg main" 
>> /etc/apt/sources.list.d/postgreSQL.list
+  fi
+
+  wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo 
apt-key add -
+  apt-get update  || /bin/true
+  apt-get install -y --force-yes postgresql-9.4
+fi
+
+echo "####################################################"
+echo "Configuring PostgreSQL Environment:"
+echo "####################################################"
+echo "drop database if exists hive_hms_testing;" > /tmp/postgresInit.sql
+echo "drop user if exists hiveuser;" >> /tmp/postgresInit.sql
+echo "create user hiveuser createdb createuser password 'hivepw';" >> 
/tmp/postgresInit.sql
+echo "create database hive_hms_testing owner hiveuser;" >> 
/tmp/postgresInit.sql
+sudo -u postgres psql -f /tmp/postgresInit.sql
+
+echo "DONE!!!"
+

Reply via email to