diff --git a/OracleDatabase/dockerfiles/11.2.0.2/Dockerfile.xe b/OracleDatabase/dockerfiles/11.2.0.2/Dockerfile.xe index a741e929ef..d0b3adbac6 100644 --- a/OracleDatabase/dockerfiles/11.2.0.2/Dockerfile.xe +++ b/OracleDatabase/dockerfiles/11.2.0.2/Dockerfile.xe @@ -41,14 +41,15 @@ ENV ORACLE_BASE=/u01/app/oracle \ INSTALL_DIR="$HOME/install" \ CONFIG_RSP="xe.rsp" \ RUN_FILE="runOracle.sh" \ - PWD_FILE="setPassword.sh" + PWD_FILE="setPassword.sh" \ + CHECK_DB_FILE="checkDBStatus.sh" # Use second ENV so that variable get substituted ENV PATH=$ORACLE_HOME/bin:$PATH # Copy binaries # ------------- -COPY $INSTALL_FILE_1 $CONFIG_RSP $RUN_FILE $PWD_FILE $INSTALL_DIR/ +COPY $INSTALL_FILE_1 $CONFIG_RSP $RUN_FILE $PWD_FILE $CHECK_DB_FILE $INSTALL_DIR/ # Install Oracle Express Edition # ------------------------------ @@ -67,6 +68,7 @@ RUN yum -y install unzip libaio bc initscripts net-tools openssl && \ mv $INSTALL_DIR/$CONFIG_RSP $ORACLE_BASE/ && \ mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && \ mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && \ + mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && \ ln -s $ORACLE_BASE/$PWD_FILE / && \ cd $HOME && \ rm -rf $INSTALL_DIR && \ @@ -74,5 +76,7 @@ RUN yum -y install unzip libaio bc initscripts net-tools openssl && \ VOLUME ["$ORACLE_BASE/oradata"] EXPOSE 1521 8080 +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 CMD exec $ORACLE_BASE/$RUN_FILE diff --git a/OracleDatabase/dockerfiles/11.2.0.2/checkDBStatus.sh b/OracleDatabase/dockerfiles/11.2.0.2/checkDBStatus.sh new file mode 100755 index 0000000000..3d51d9f054 --- /dev/null +++ b/OracleDatabase/dockerfiles/11.2.0.2/checkDBStatus.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# LICENSE UPL 1.0 +# +# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved. +# +# Since: May, 2017 +# Author: gerald.venzl@oracle.com +# Description: Checks the status of Oracle Database. +# Return codes: 0 = Database is open and ready to use +# 1 = Database is not open +# 2 = Sql Plus execution failed +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# + +ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`" +ORAENV_ASK=NO +source oraenv + +# Check Oracle DB status and store it in status +status=`sqlplus -s / as sysdba << EOF + set heading off; + set pagesize 0; + select status from v\\$instance; + exit; +EOF` + +# Store return code from SQL*Plus +ret=$? + +# SQL Plus execution was successful and database is open +if [ $ret -eq 0 ] && [ "$status" = "OPEN" ]; then + exit 0; +# Database is not open +elif [ "$status" != "OPEN" ]; then + exit 1; +# SQL Plus execution failed +else + exit 2; +fi; diff --git a/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.ee b/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.ee index 5295fdb3f1..115b5430e7 100644 --- a/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.ee +++ b/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.ee @@ -76,6 +76,8 @@ WORKDIR /home/oracle VOLUME ["$ORACLE_BASE/oradata"] EXPOSE 1521 5500 +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 # Define default command to start Oracle Database. CMD exec $ORACLE_BASE/$RUN_FILE diff --git a/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.se2 b/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.se2 index b0e31adb8d..2cccae4bef 100644 --- a/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.se2 +++ b/OracleDatabase/dockerfiles/12.1.0.2/Dockerfile.se2 @@ -76,6 +76,8 @@ WORKDIR /home/oracle VOLUME ["$ORACLE_BASE/oradata"] EXPOSE 1521 5500 - +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 + # Define default command to start Oracle Database. CMD exec $ORACLE_BASE/$RUN_FILE diff --git a/OracleDatabase/dockerfiles/12.1.0.2/checkDBStatus.sh b/OracleDatabase/dockerfiles/12.1.0.2/checkDBStatus.sh index 2ccd16043a..37f76010b5 100755 --- a/OracleDatabase/dockerfiles/12.1.0.2/checkDBStatus.sh +++ b/OracleDatabase/dockerfiles/12.1.0.2/checkDBStatus.sh @@ -6,24 +6,16 @@ # Since: May, 2017 # Author: gerald.venzl@oracle.com # Description: Checks the status of Oracle Database. -# The ORACLE_HOME, ORACLE_SID and the PATH has to be set. -# +# Return codes: 0 = Database is open and ready to use +# 1 = Database is not open +# 2 = Sql Plus execution failed # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # -# Check that ORACLE_HOME is set -if [ "$ORACLE_HOME" == "" ]; then - script_name=`basename "$0"` - echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script." - exit 3; -fi; - -# Check that ORACLE_SID is set -if [ "$ORACLE_SID" == "" ]; then - script_name=`basename "$0"` - echo "$script_name: ERROR - ORACLE_SID is not set. Please set ORACLE_SID before invoking this script." - exit 3; -fi; +ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`" +ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`" +ORAENV_ASK=NO +source oraenv # Check Oracle DB status and store it in status status=`sqlplus -s / as sysdba << EOF diff --git a/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.ee b/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.ee index d96efa1e50..101396ae9c 100644 --- a/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.ee +++ b/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.ee @@ -73,6 +73,8 @@ WORKDIR /home/oracle VOLUME ["$ORACLE_BASE/oradata"] EXPOSE 1521 5500 - +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 + # Define default command to start Oracle Database. CMD exec $ORACLE_BASE/$RUN_FILE diff --git a/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.se2 b/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.se2 index dc2001793b..8988e9eaf5 100644 --- a/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.se2 +++ b/OracleDatabase/dockerfiles/12.2.0.1/Dockerfile.se2 @@ -73,6 +73,8 @@ WORKDIR /home/oracle VOLUME ["$ORACLE_BASE/oradata"] EXPOSE 1521 5500 +HEALTHCHECK --interval=1m --start-period=5m \ + CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 # Define default command to start Oracle Database. CMD exec $ORACLE_BASE/$RUN_FILE diff --git a/OracleDatabase/dockerfiles/12.2.0.1/checkDBStatus.sh b/OracleDatabase/dockerfiles/12.2.0.1/checkDBStatus.sh index 2ccd16043a..37f76010b5 100755 --- a/OracleDatabase/dockerfiles/12.2.0.1/checkDBStatus.sh +++ b/OracleDatabase/dockerfiles/12.2.0.1/checkDBStatus.sh @@ -6,24 +6,16 @@ # Since: May, 2017 # Author: gerald.venzl@oracle.com # Description: Checks the status of Oracle Database. -# The ORACLE_HOME, ORACLE_SID and the PATH has to be set. -# +# Return codes: 0 = Database is open and ready to use +# 1 = Database is not open +# 2 = Sql Plus execution failed # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # -# Check that ORACLE_HOME is set -if [ "$ORACLE_HOME" == "" ]; then - script_name=`basename "$0"` - echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script." - exit 3; -fi; - -# Check that ORACLE_SID is set -if [ "$ORACLE_SID" == "" ]; then - script_name=`basename "$0"` - echo "$script_name: ERROR - ORACLE_SID is not set. Please set ORACLE_SID before invoking this script." - exit 3; -fi; +ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`" +ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`" +ORAENV_ASK=NO +source oraenv # Check Oracle DB status and store it in status status=`sqlplus -s / as sysdba << EOF diff --git a/OracleDatabase/tests/runAllTests.sh b/OracleDatabase/tests/runAllTests.sh index a9571284d5..ac351d5a0e 100755 --- a/OracleDatabase/tests/runAllTests.sh +++ b/OracleDatabase/tests/runAllTests.sh @@ -11,5 +11,5 @@ # # Run image build tests -./runImageBuildTests.sh +./runImageBuildTests.sh && \ ./runContainerTests.sh diff --git a/OracleDatabase/tests/runContainerTests.sh b/OracleDatabase/tests/runContainerTests.sh index 60e1cb772c..3dc0e3c617 100755 --- a/OracleDatabase/tests/runContainerTests.sh +++ b/OracleDatabase/tests/runContainerTests.sh @@ -27,7 +27,7 @@ function runContainerTest { echo "" # Run and start container - docker run -d -e ORACLE_SID="$ORACLE_SID" --name "$CON_NAME" "$IMAGE" + docker run -d --shm-size=1g -e ORACLE_SID="$ORACLE_SID" --name "$CON_NAME" "$IMAGE" # Check whether Oracle is OK checkOracle "$TEST_NAME" "$CON_NAME" "$ORACLE_SID" @@ -80,29 +80,32 @@ function checkOracle { done; } -###################### TEST ########################### +###################### TEST 11.2.0.2 XE default ########################### -# Run 12.1.0.2 SE2 default container -runContainerTest "12.1.0.2 SE2 default database" "12.1.0.2-SE2-default" "oracle/database:12.1.0.2-se2" +# Run 11.2.0.2 XE default container +runContainerTest "11.2.0.2 XE default database" "11.2.0.2-XE-default" "oracle/database:11.2.0.2-xe" -###################### TEST ########################### +###################### TEST 12.2.0.1 EE default ########################### -# Run 12.1.0.2 EE default container -runContainerTest "12.1.0.2 EE default database" "12.1.0.2-EE-default" "oracle/database:12.1.0.2-ee" +# Run 12.2.0.1 EE default container +runContainerTest "12.2.0.1 EE default database" "12.2.0.1-EE-default" "oracle/database:12.2.0.1-ee" + +###################### TEST 12.2.0.1 EE custom DB ########################### + +# Run 12.2.0.1 EE custom container +runContainerTest "12.2.0.1-EE-custom database" "12.2.0.1-EE-custom" "oracle/database:12.2.0.1-ee" "TEST" -###################### TEST ########################### +###################### TEST 12.2.0.1 SE2 default ########################### # Run 12.2.0.1 SE2 default container runContainerTest "12.2.0.1 SE2 default database" "12.2.0.1-SE2-default" "oracle/database:12.2.0.1-se2" -###################### TEST ########################### +###################### TEST 12.1.0.2 EE default ########################### -# Run 12.2.0.1 EE default container -runContainerTest "12.2.0.1 EE default database" "12.2.0.1-EE-default" "oracle/database:12.2.0.1-ee" +# Run 12.1.0.2 EE default container +runContainerTest "12.1.0.2 EE default database" "12.1.0.2-EE-default" "oracle/database:12.1.0.2-ee" -###################### TEST ########################### +###################### TEST 12.1.0.2 SE2 default ########################### -# Run 12.2.0.1 EE custom container -runContainerTest "12.2.0.1-EE-custom database" "12.2.0.1-EE-custom" "oracle/database:12.2.0.1-ee" "TEST" - -# Run 12.2.0.1 EE custom characterset +# Run 12.1.0.2 SE2 default container +runContainerTest "12.1.0.2 SE2 default database" "12.1.0.2-SE2-default" "oracle/database:12.1.0.2-se2" diff --git a/OracleDatabase/tests/runImageBuildTests.sh b/OracleDatabase/tests/runImageBuildTests.sh index 13d9a80d83..2af4ed8610 100755 --- a/OracleDatabase/tests/runImageBuildTests.sh +++ b/OracleDatabase/tests/runImageBuildTests.sh @@ -25,7 +25,6 @@ function checkError { if [ "$RETURN_CODE" != "0" ]; then echo "Test $TEST_NAME: FAILED!"; - cleanup; exit 1; else echo "Test $TEST_NAME: OK"; @@ -36,7 +35,7 @@ function checkError { cd "../dockerfiles" -###################### TEST ########################### +###################### TEST 11.2.0.2 XE ########################### # Copy binary file cp $BIN_DIR/oracle-xe-11.2.0-1.0.x86_64.rpm.zip ./11.2.0.2/ @@ -48,19 +47,24 @@ checkError "Build 11.2.0.2 XE image" $? # Delete binary file rm ./11.2.0.2/oracle-xe-11.2.0-1.0.x86_64.rpm.zip -###################### TEST ########################### +###################### TEST 12.1.0.1 EE ########################### # Copy binary file -cp $BIN_DIR/linuxamd64_12102_database_se2_*.zip ./12.1.0.2/ +cp $BIN_DIR/linuxx64_12201_database.zip ./12.2.0.1/ -# Build 12.1.0.2 SE2 images -./buildDockerImage.sh -s -v 12.1.0.2 -checkError "Build 12.1.0.2 SE2 image" $? +# Build 12.2.0.1 EE images +./buildDockerImage.sh -e -v 12.2.0.1 +checkError "Build 12.2.0.1 EE image" $? -# Delete binary file -rm ./12.1.0.2/*.zip +###################### TEST 12.2.0.1 SE2 ########################### + +# Build 12.2.0.1 SE2 images +./buildDockerImage.sh -s -v 12.2.0.1 +checkError "Build 12.2.0.1 SE2 image" $? + +rm ./12.2.0.1/*.zip -###################### TEST ########################### +###################### TEST 12.1.0.2 EE ########################### # Copy binary file cp $BIN_DIR/linuxamd64_12102_database_1of2.zip ./12.1.0.2/ @@ -73,21 +77,18 @@ checkError "Build 12.1.0.2 EE image" $? # Delete binary file rm ./12.1.0.2/*.zip -###################### TEST ########################### +###################### TEST 12.1.0.2 SE2 ########################### # Copy binary file -cp $BIN_DIR/linuxx64_12201_database.zip ./12.2.0.1/ - -# Build 12.2.0.1 SE2 images -./buildDockerImage.sh -s -v 12.2.0.1 -checkError "Build 12.2.0.1 SE2 image" $? +cp $BIN_DIR/linuxamd64_12102_database_se2_*.zip ./12.1.0.2/ -###################### TEST ########################### +# Build 12.1.0.2 SE2 images +./buildDockerImage.sh -s -v 12.1.0.2 +checkError "Build 12.1.0.2 SE2 image" $? -# Build 12.2.0.1 EE images -./buildDockerImage.sh -e -v 12.2.0.1 -checkError "Build 12.2.0.1 EE image" $? +# Delete binary file +rm ./12.1.0.2/*.zip -rm ./12.2.0.1/*.zip +######################### END OF TESTS ############################ -cd "$WORKDIR"; \ No newline at end of file +cd "$WORKDIR";