Skip to content
Snippets Groups Projects
Commit aacbfdbf authored by Marcin's avatar Marcin
Browse files

fix problem with overwriting source code by the update test

parent fd69207e
No related branches found
No related tags found
4 merge requests!627merge in fix for get_current_block_age,!626Fix get_current_block_age function to avoid healthcheck fails,!622merge develop to master,!601test execution does not modify sources
Pipeline #113397 passed
...@@ -565,15 +565,3 @@ END; ...@@ -565,15 +565,3 @@ END;
$BODY$ $BODY$
; ;
CREATE OR REPLACE FUNCTION hive.test()
RETURNS VOID
LANGUAGE plpgsql
IMMUTABLE
AS
$BODY$
BEGIN
RETURN;
END;
$BODY$
;
#! /bin/bash #! /bin/bash -x
set -euo pipefail set -euo pipefail
...@@ -64,6 +64,13 @@ done ...@@ -64,6 +64,13 @@ done
test_extension_update() { test_extension_update() {
# copy sources to build directory, they will be modified there to create real new version of hfm extension
COPY_SRC_PATH="${HAF_DIR}/src_copy"
COPY_BUILD_PATH="${HAF_DIR}/src_copy/build"
rm -rf ${COPY_SRC_PATH}
mkdir -p ${COPY_SRC_PATH}
mkdir -p ${COPY_BUILD_PATH}
cp -a ${DIR}/. ${COPY_SRC_PATH}
POSTGRES_VERSION=17 POSTGRES_VERSION=17
echo "Add function testfun to schema hive" echo "Add function testfun to schema hive"
...@@ -72,18 +79,17 @@ test_extension_update() { ...@@ -72,18 +79,17 @@ test_extension_update() {
# old libhfm has to be removed so in case of an corrupted setup of haf the old libhfm won't be used # old libhfm has to be removed so in case of an corrupted setup of haf the old libhfm won't be used
sudo rm -rf /usr/lib/postgresql/${POSTGRES_VERSION}/lib/libhfm-* sudo rm -rf /usr/lib/postgresql/${POSTGRES_VERSION}/lib/libhfm-*
# modify the hived_api.sql file # modify the hived_api.sql file, new function test added to the new version of hfm
echo -e "CREATE OR REPLACE FUNCTION hive.test() \n RETURNS void \n LANGUAGE plpgsql \n VOLATILE AS \n\$BODY\$ \nBEGIN \nRAISE NOTICE 'test'; \nEND; \n\$BODY\$;" >> $DIR/src/hive_fork_manager/hived_api.sql echo -e "CREATE OR REPLACE FUNCTION hive.test() \n RETURNS void \n LANGUAGE plpgsql \n VOLATILE AS \n\$BODY\$ \nBEGIN \nRAISE NOTICE 'test'; \nEND; \n\$BODY\$;" >> "${COPY_SRC_PATH}/src/hive_fork_manager/hived_api.sql"
# commit changes to make a new hash # commit changes to make a new hash
git -C $DIR config --global user.name "abc" git -C ${COPY_BUILD_PATH} config --global user.name "abc"
git -C $DIR config --global user.email "abc@example.com" git -C ${COPY_BUILD_PATH} config --global user.email "abc@example.com"
git -C $DIR config --global --add safe.directory /builds/hive/haf git -C ${COPY_BUILD_PATH} config --global --add safe.directory /builds/hive/haf
git -C $DIR add src/hive_fork_manager/hived_api.sql git -C ${COPY_BUILD_PATH} add "${COPY_SRC_PATH}/src/hive_fork_manager/hived_api.sql"
git -C $DIR commit -m "test" git -C ${COPY_BUILD_PATH} commit -m "test"
# rebuild haf # rebuild copy of haf
test -n "$HAF_DIR" && rm "$HAF_DIR"/* -rf ${COPY_SRC_PATH}/scripts/build.sh --cmake-arg="-DHIVE_LINT=OFF" --haf-source-dir="${COPY_SRC_PATH}" --haf-binaries-dir="${COPY_BUILD_PATH}" extension.hive_fork_manager
$SETUP_DIR/build.sh --cmake-arg="-DHIVE_LINT=OFF" --haf-source-dir="$DIR" --haf-binaries-dir="$HAF_DIR" extension.hive_fork_manager (cd ${COPY_BUILD_PATH}; sudo ninja install)
(cd $HAF_DIR; sudo ninja install)
# run generator script # run generator script
sudo /usr/share/postgresql/${POSTGRES_VERSION}/extension/hive_fork_manager_update_script_generator.sh sudo /usr/share/postgresql/${POSTGRES_VERSION}/extension/hive_fork_manager_update_script_generator.sh
...@@ -101,7 +107,19 @@ test_extension_update() { ...@@ -101,7 +107,19 @@ test_extension_update() {
END END
\$\$ LANGUAGE plpgsql;" \$\$ LANGUAGE plpgsql;"
# check if function test added in new hfm version exists
sudo -Enu "$DB_ADMIN" psql -d "$DB_NAME" -v ON_ERROR_STOP=on -U "$DB_ADMIN" -c "
DO \$\$
BEGIN
ASSERT EXISTS (
SELECT 1
FROM pg_proc
JOIN pg_namespace ON pg_proc.pronamespace = pg_namespace.oid
WHERE pg_proc.proname = 'test'
AND pg_namespace.nspname = 'hive'
), 'Function hive.test() not exists when it should not.';
END
\$\$ LANGUAGE plpgsql;"
} }
test_extension_update test_extension_update
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment