Skip to content

Commit

Permalink
Fix for #23: timezone file missing
Browse files Browse the repository at this point in the history
Signed-off-by: gvenzl <[email protected]>
  • Loading branch information
gvenzl committed Sep 30, 2023
1 parent f01ba6f commit f7199bc
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 8 deletions.
19 changes: 11 additions & 8 deletions install.23.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1917,14 +1917,17 @@ if [ "${BUILD_MODE}" == "REGULAR" ] || [ "${BUILD_MODE}" == "SLIM" ]; then
rm "${ORACLE_HOME}"/lib/*.jar

# Remove unnecessary timezone information
rm "${ORACLE_HOME}"/oracore/zoneinfo/readme.txt
rm "${ORACLE_HOME}"/oracore/zoneinfo/timezdif.csv
rm -r "${ORACLE_HOME}"/oracore/zoneinfo/big
rm -r "${ORACLE_HOME}"/oracore/zoneinfo/little
rm "${ORACLE_HOME}"/oracore/zoneinfo/timezone*
mv "${ORACLE_HOME}"/oracore/zoneinfo/timezlrg_40.dat "${ORACLE_HOME}"/oracore/zoneinfo/current.dat
rm "${ORACLE_HOME}"/oracore/zoneinfo/timezlrg*
mv "${ORACLE_HOME}"/oracore/zoneinfo/current.dat "${ORACLE_HOME}"/oracore/zoneinfo/timezlrg_40.dat
# Create temporary folder
mkdir "${ORACLE_HOME}"/oracore/tmp_current_tz
# Move timelrg*.dat with the highest number to temporary folder
mv $(ls -v "${ORACLE_HOME}"/oracore/zoneinfo/timezlrg* | tail -n 1) \
"${ORACLE_HOME}"/oracore/tmp_current_tz/
# Delete all remaining folders and files in "zoneinfo"
rm -r "${ORACLE_HOME}"/oracore/zoneinfo/*
# Move current timelrg*.dat file back into place
mv "${ORACLE_HOME}"/oracore/tmp_current_tz/* "${ORACLE_HOME}"/oracore/zoneinfo/
# Remove temporary folder
rm -r "${ORACLE_HOME}"/oracore/tmp_current_tz

# Remove Multimedia
rm -r "${ORACLE_HOME}"/ord/im
Expand Down
62 changes: 62 additions & 0 deletions tests/test_container_23.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,65 @@ unset EXPECTED_RESULT
unset APP_USER
unset APP_USER_PASSWORD
unset ORACLE_DATABASE

################################################
##### Test for timezone file failure (#23) #####
################################################

# Tell test method not to tear down container
NO_TEAR_DOWN="true"
# Let's keep the container name in a var to keep it simple
CONTAINER_NAME="timezone-test"
# Let's keep the test name in a var to keep it simple too
TEST_NAME="TIMEZONE TEST"
# This is what we want to have back from the SQL statement
EXPECTED_RESULT="Hi from your Oracle PDB"
# App user
APP_USER="my_test_user"
# App user password
APP_USER_PASSWORD="ThatAppUserPassword1"
# Oracle PDB
ORACLE_DATABASE="timezone_pdb"

# Spin up container
runContainerTest "${TEST_NAME}" "${CONTAINER_NAME}" "gvenzl/oracle-free:23.3-slim-faststart"

# Test the random password, if it works we will get "OK" back from the SQL statement
result=$(podman exec -i ${CONTAINER_NAME} sqlplus -s "${APP_USER}"/"${APP_USER_PASSWORD}"@//localhost/"${ORACLE_DATABASE}" <<EOF
whenever sqlerror exit sql.sqlcode;
set heading off;
set echo off;
set pagesize 0;
CREATE TABLE FOO (id INT);
INSERT INTO FOO VALUES (1);
-- This should NOT throw:
-- ORA-04088: error during execution of trigger 'SYS.DELETE_ENTRIES'
-- ORA-00604: Error occurred at recursive SQL level 1. Check subsequent errors.
-- ORA-01804: failure to initialize timezone information
DROP TABLE FOO;
SELECT '${EXPECTED_RESULT}' FROM dual;
exit;
EOF
)

# See whether we got "OK" back from our test
if [ "${result}" == "${EXPECTED_RESULT}" ]; then
echo "TEST ${TEST_NAME}: OK";
echo "";
else
echo "TEST ${TEST_NAME}: FAILED!";
exit 1;
fi;

# Tear down the container, no longer needed
tear_down_container "${CONTAINER_NAME}"

# Clean up environment variables, all tests should remain self-contained
unset CONTAINER_NAME
unset NO_TEAR_DOWN
unset TEST_NAME
unset EXPECTED_RESULT
unset APP_USER
unset APP_USER_PASSWORD
unset ORACLE_DATABASE

0 comments on commit f7199bc

Please sign in to comment.