diff --git testutils/metastore/dbs/derby/execute.sh testutils/metastore/dbs/derby/execute.sh new file mode 100755 index 0000000..d60f05b --- /dev/null +++ testutils/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 diff --git testutils/metastore/dbs/derby/prepare.sh testutils/metastore/dbs/derby/prepare.sh new file mode 100755 index 0000000..d17822f --- /dev/null +++ testutils/metastore/dbs/derby/prepare.sh @@ -0,0 +1,54 @@ +#!/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 "####################################################" + +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!!!" + diff --git testutils/metastore/dbs/oracle/execute.sh testutils/metastore/dbs/oracle/execute.sh new file mode 100755 index 0000000..d63bf42 --- /dev/null +++ testutils/metastore/dbs/oracle/execute.sh @@ -0,0 +1,31 @@ +#!/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 Oracle: $1" +echo "####################################################" + +export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server +export PATH=$PATH:$ORACLE_HOME/bin + +echo quit | sqlplus -L hiveuser/hivepw@XE @$1 diff --git testutils/metastore/dbs/oracle/prepare.sh testutils/metastore/dbs/oracle/prepare.sh new file mode 100755 index 0000000..95780a2 --- /dev/null +++ testutils/metastore/dbs/oracle/prepare.sh @@ -0,0 +1,80 @@ +#!/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. + +# Cleanup existing installation + configuration. +echo "####################################################" +echo "Detecting any existing Oracle XE installation:" +echo "####################################################" + +INSTALL_INFO=($(dpkg -l oracle\* | grep ^i | tr -s ' ')) + +if [[ ${INSTALL_INFO[1]} == "oracle-xe" ]] && [[ ${INSTALL_INFO[2]} == 10.2* ]] +then + echo "Oracle XE already installed...Skipping" +else + echo "Oracle XE not installed or is of a different version" + apt-get purge -y --force-yes oracle-xe || /bin/true + echo "####################################################" + echo "Installing Oracle XE dependencies:" + echo "####################################################" + if grep -q "deb http://oss.oracle.com/debian unstable main non-free" /etc/apt/sources.list.d/oracle-xe.list + then + echo "Sources already listed" + else + echo "deb http://oss.oracle.com/debian unstable main non-free" >> /etc/apt/sources.list.d/oracle-xe.list + fi + + wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add - || /bin/true + apt-get update || /bin/true + apt-get install -y --force-yes oracle-xe +fi + +echo "####################################################" +echo "Configuring Oracle XE Environment:" +echo "####################################################" +echo "8080" > /tmp/silent.properties +echo "1521" >> /tmp/silent.properties +echo "hivepw" >> /tmp/silent.properties +echo "hivepw" >> /tmp/silent.properties +echo "y" >> /tmp/silent.properties + +/etc/init.d/oracle-xe configure < /tmp/silent.properties > /tmp/silentInstall.log || /bin/true + +export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server +export PATH=$PATH:$ORACLE_HOME/bin + +echo "####################################################" +echo "Setting up user account and Table space:" +echo "####################################################" +echo "drop user hiveuser cascade;" > /tmp/oraInit.sql +echo "alter database default tablespace SYSTEM;" >> /tmp/oraInit.sql +echo "drop tablespace hive_tbspace including contents and datafiles;" >> /tmp/oraInit.sql + +echo "create user hiveuser identified by hivepw;" >> /tmp/oraInit.sql +echo "grant connect to hiveuser;" >> /tmp/oraInit.sql +echo "grant create table to hiveuser;" >> /tmp/oraInit.sql +echo "create smallfile tablespace hive_tbspace datafile 'hive.dbf' size 100m;" >> /tmp/oraInit.sql +echo "alter database default tablespace hive_tbspace;" >> /tmp/oraInit.sql +echo "alter user hiveuser quota 100m on hive_tbspace;" >> /tmp/oraInit.sql +echo "exit;" >> /tmp/oraInit.sql + +sqlplus -L SYSTEM/hivepw@XE @/tmp/oraInit.sql + +echo "DONE!!!" diff --git testutils/metastore/dbs/postgres/execute.sh testutils/metastore/dbs/postgres/execute.sh new file mode 100755 index 0000000..cabcae4 --- /dev/null +++ testutils/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 diff --git testutils/metastore/dbs/postgres/prepare.sh testutils/metastore/dbs/postgres/prepare.sh new file mode 100755 index 0000000..ba959bb --- /dev/null +++ testutils/metastore/dbs/postgres/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 "$OS_VERSION" + +echo "####################################################" +echo "Begin for OS version $OS_VERSION" +echo "####################################################" + +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!!!" +