Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/haf
  • dan/haf
2 results
Show changes
Commits on Source (3)
Subproject commit 015c4c0dc6b76d8b256363335609c5eadbcfaaeb
Subproject commit a181ebfab21471951a369b138adb2f5003d7a642
......@@ -13,6 +13,7 @@ test_start
export CTEST_NUMBER_OF_JOBS="${CTEST_NUMBER_OF_JOBS:-4}"
cd "/home/haf_admin/build" && ctest -j${CTEST_NUMBER_OF_JOBS} --output-on-failure -R test.functional.hive_fork_manager*
cd "/home/haf_admin/build" && ctest -j${CTEST_NUMBER_OF_JOBS} --output-on-failure -R test_update_script
cd "/home/haf_admin/build" && ctest -j${CTEST_NUMBER_OF_JOBS} --output-on-failure -R test.functional.update.hive_fork_manager*
cd "/home/haf_admin/build" && ctest --output-on-failure -R test.functional.query_supervisor.*
cd "/home/haf_admin/build" && ctest --output-on-failure -R test.unit.*
......
......@@ -108,10 +108,8 @@ verify_table_schema() {
echo "Table schema is inconsistent"
echo "COLUMNS"
diff --suppress-common-lines before_update_columns.txt after_update_columns.txt || true
echo "CONSTRAINTS"
diff --suppress-common-lines before_update_constraints.txt after_update_constraings.txt || true
echo "INDEXES"
diff --suppress-common-lines before_update_indexes.txt after_update_indexes.txt || true
echo "PROVIDERS"
ate diff --suppress-common-lines before_update_providers.txt after_update_providers.txt || true
echo "Dropping temporary database"
psql_do -a -d postgres -c "DROP DATABASE IF EXISTS $DB_NAME_AFTER_UPDATE;"
find -type f -name '*.txt' > /dev/null 2>&1
......@@ -144,6 +142,7 @@ make_update() {
echo "Attempting to update your database..."
psql_do -d "$DB_NAME" -c "ALTER EXTENSION hive_fork_manager UPDATE"
psql_do -d "$DB_NAME" -c "SELECT hive.state_providers_update_runtime();"
}
save_views() {
......@@ -212,7 +211,7 @@ check_tables_dont_reference_haf_types() {
WHERE
cls.relkind = 'r' AND
col.udt_schema='hive' AND
( col.table_schema='hive' OR col.table_schema='hafd' )"
col.table_schema<>'hive'"
psql_do -d "$DB_NAME" -q -t -A -c "$query" | \
awk -F'|' '{print($1"."$2, "contains column", $3, "of type", $4"."$5, "which would be dropped on upgrade")} END{exit NR > 0 ? 4 : 0}'
}
......@@ -228,7 +227,7 @@ check_tables_dont_reference_haf_domains() {
WHERE
cls.relkind = 'r' AND
col.domain_schema='hive' AND
( col.table_schema='hive' OR col.table_schema='hafd' )"
col.table_schema<>'hive'"
psql_do -d "$DB_NAME" -q -t -A -c "$query" | \
awk -F'|' '{print($1"."$2, "contains column", $3, "of type", $4"."$5, "which would be dropped on upgrade")} END{exit NR > 0 ? 4 : 0}'
}
......
......@@ -4,7 +4,7 @@ CREATE OR REPLACE FUNCTION hive.state_provider_update_runtime( _provider hafd.st
AS
$BODY$
BEGIN
EXECUTE format('hive.runtimecode_provider_%s(%L)', _provider, _context );
EXECUTE format('SELECT hive.runtimecode_provider_%s(%L)', _provider, _context );
END;
$BODY$
;
......@@ -23,5 +23,4 @@ END;
$BODY$
;
SELECT hive.state_providers_update_runtime();
......@@ -328,6 +328,7 @@ ADD_TEST( NAME test_update_script
ADD_SQL_FUNCTIONAL_TEST( state_providers/import_state_provider_negative_non_context_owner_create_table.sql )
ADD_SQL_FUNCTIONAL_TEST( state_providers/switch_state_provider_to_forkable.sql )
ADD_SQL_FUNCTIONAL_TEST( state_providers/hash.sql )
ADD_SQL_FUNCTIONAL_TEST( state_providers/update_state_provider_runtime.sql )
ADD_SQL_FUNCTIONAL_TEST( authorization/alice_access_to_bob_negative.sql )
ADD_SQL_FUNCTIONAL_TEST( authorization/alice_access_events_infrustructure.sql )
......
CREATE OR REPLACE FUNCTION hafd.create_function_a()
RETURNS VOID
LANGUAGE plpgsql
AS
$BODY$
BEGIN
EXECUTE 'CREATE OR REPLACE FUNCTION hive.a()
RETURNS VOID
LANGUAGE plpgsql
AS
$BODY2$
BEGIN
END;
$BODY2$;
';
END;
$BODY$;
CREATE OR REPLACE PROCEDURE haf_admin_test_given()
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
ALTER TYPE hafd.state_providers ADD VALUE 'TESTS';
END;
$BODY$
;
CREATE OR REPLACE PROCEDURE alice_test_given()
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
CREATE SCHEMA A;
PERFORM hive.app_create_context( _name => 'context', _schema => 'a' );
CREATE SCHEMA alice;
CREATE TABLE alice.tab( id INT ) INHERITS( a.context );
END;
$BODY$
;
CREATE OR REPLACE PROCEDURE alice_test_when()
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
---------------------------- TEST PROVIDER ----------------------------------------------
EXECUTE 'CREATE OR REPLACE FUNCTION hive.start_provider_tests( _context hafd.context_name )
RETURNS TEXT[]
LANGUAGE plpgsql
AS
$$
DECLARE
__table_1_name TEXT := _context || ''_tests1'';
__table_2_name TEXT := _context || ''_tests2'';
BEGIN
EXECUTE format( ''CREATE TABLE hafd.%I(
id SERIAL
)'', __table_1_name
);
EXECUTE format( ''CREATE TABLE hafd.%I(
id SERIAL
)'', __table_2_name
);
RETURN ARRAY[ __table_1_name, __table_2_name ];
END;
$$
;';
EXECUTE 'CREATE OR REPLACE FUNCTION hive.runtimecode_provider_tests(_context hafd.context_name)
RETURNS VOID
LANGUAGE plpgsql
AS
$$
BEGIN
PERFORM hafd.create_function_a();
END;
$$;';
---------------------------END OF TEST PROVIDER -------------------------------------------------------------------
PERFORM hive.app_state_provider_import( 'ACCOUNTS', 'context' );
PERFORM hive.app_state_provider_import( 'TESTS', 'context' );
PERFORM hive.state_providers_update_runtime();
END;
$BODY$
;
CREATE OR REPLACE PROCEDURE haf_admin_test_then()
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
ASSERT ( SELECT COUNT(*) FROM hafd.state_providers_registered WHERE context_id = 1 AND state_provider = 'ACCOUNTS' AND tables = ARRAY[ 'context_accounts' ]::TEXT[] ) = 1, 'State provider not registered';
ASSERT EXISTS ( SELECT FROM information_schema.tables WHERE table_schema='hafd' AND table_name = 'context_accounts' ), 'Accounts table was not created';
ASSERT EXISTS ( SELECT FROM information_schema.tables WHERE table_schema='hafd' AND table_name = 'context_tests1' ), 'Tests1 table was not created';
ASSERT EXISTS ( SELECT FROM information_schema.tables WHERE table_schema='hafd' AND table_name = 'context_tests2' ), 'Tests2 table was not created';
ASSERT ( SELECT COUNT(*) FROM hafd.registered_tables WHERE origin_table_schema = 'hafd' AND origin_table_name = 'context_accounts' AND context_id = 1 ) = 1, 'State provider table is not registered';
ASSERT ( SELECT COUNT(*) FROM hafd.registered_tables WHERE origin_table_schema = 'hafd' AND origin_table_name = 'context_tests1' AND context_id = 1 ) = 1, 'State provider tests1 is not registered';
ASSERT ( SELECT COUNT(*) FROM hafd.registered_tables WHERE origin_table_schema = 'hafd' AND origin_table_name = 'context_tests2' AND context_id = 1 ) = 1, 'State provider tests2 is not registered';
ASSERT EXISTS (
SELECT 1
FROM pg_proc
JOIN pg_namespace ON pg_proc.pronamespace = pg_namespace.oid
WHERE pg_proc.proname = 'a' AND pg_namespace.nspname = 'hive'
), 'Function hive.a does not exists';
END;
$BODY$
;
CREATE OR REPLACE PROCEDURE bob_test_then()
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
-- bob as member of hive_applications_group got select permission for state provider tables
PERFORM * FROM hafd.context_accounts;
PERFORM * FROM hafd.context_tests1;
PERFORM * FROM hafd.context_tests2;
END;
$BODY$
;
......@@ -6,7 +6,7 @@ set -eu -o pipefail
SCRIPTPATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)"
SCRIPTS_DIR="$SCRIPTPATH/../../../../scripts"
UPDATE_DB_NAME=update-db-test
UPDATE_DB_NAME=update_db_test
POSTGRES_VERSION=17
export PGUSER="haf_admin"
......@@ -140,22 +140,22 @@ check_relation_structure public.bad_table "id|integer|||\ncomment|hive.comment_o
printf "\nTEST: Creating table referencing disallowed HAF domain. Upgrade should fail.\n"
prepare_database
exec_sql "create table public.bad_table(id int, account hafd.account_name_type)"
exec_sql "create table public.bad_table(id int, account hive.account_name_type)"
failswith 4 update_database
check_relation_structure public.bad_table "id|integer|||\naccount|hafd.account_name_type|||"
check_relation_structure public.bad_table "id|integer|||\naccount|hive.account_name_type|||"
printf "\nTEST: Creating table referencing allowed HAF domain. Upgrade should pass.\n"
prepare_database
exec_sql "create table public.good_table(id int, amount hive.hive_amount)"
exec_sql "create table public.good_table(id int, amount hafd.hive_amount)"
update_database
check_relation_structure public.good_table "id|integer|||\namount|hive.hive_amount|||"
check_relation_structure public.good_table "id|integer|||\namount|hafd.hive_amount|||"
printf "\nTEST: Creating view referencing allowed types. This should pass\n"
prepare_database
exec_sql "create view public.good_view as select num, total_vesting_fund_hive, total_vesting_shares, current_hbd_supply, hbd_interest_rate from hafd.blocks"
exec_sql "comment on view public.good_view is 'foo'"
update_database
check_relation_structure public.good_view "num|integer|||\ntotal_vesting_fund_hive|hive.hive_amount|||\ntotal_vesting_shares|hive.vest_amount|||\ncurrent_hbd_supply|hive.hbd_amount|||\nhbd_interest_rate|hive.interest_rate|||"
check_relation_structure public.good_view "num|integer|||\ntotal_vesting_fund_hive|hafd.hive_amount|||\ntotal_vesting_shares|hafd.vest_amount|||\ncurrent_hbd_supply|hafd.hbd_amount|||\nhbd_interest_rate|hafd.interest_rate|||"
check_relation_comment public.good_view foo
printf "\nTEST: Creating view referencing disallowed type. This should still pass and the view should be recreated.\n"
......@@ -170,15 +170,15 @@ exec_sql "comment on view public.bad_mixed_view is 'baz'"
update_database
check_table_is_empty hafd.deps_saved_ddl
check_relation_structure public.bad_type_view "id|bigint|||\nbody_binary|hive.transfer_operation|||\namount|hive.asset|||"
check_relation_structure public.bad_domain_view "id|bigint|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_mixed_view "id|bigint|||\namount|hive.asset|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_domain_view "id|bigint|||\nmemo|hive.memo|||"
check_relation_structure public.bad_mixed_view "id|bigint|||\namount|hive.asset|||\nmemo|hive.memo|||"
check_relation_comment public.bad_type_view foo
check_relation_comment public.bad_domain_view bar
check_relation_comment public.bad_mixed_view baz
printf "\nTEST: Creating view referencing disallowed type with no update taking place. This should pass and the view should be recreated.\n"
prepare_database
exec_sql "create view public.bad_type_view_2 as select id,body_binary::hive.transfer_operation,(body_binary::hive.transfer_operation).amount from hive.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "create view public.bad_type_view_2 as select id,body_binary::hive.transfer_operation,(body_binary::hive.transfer_operation).amount from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on view public.bad_type_view_2 is 'foo'"
exec_sql "create view public.bad_domain_view_2 as select id,(body_binary::hive.transfer_operation).memo from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on view public.bad_domain_view_2 is 'bar'"
......@@ -187,8 +187,8 @@ exec_sql "comment on view public.bad_mixed_view_2 is 'baz'"
update_database
check_table_is_empty hafd.deps_saved_ddl
check_relation_structure public.bad_type_view_2 "id|bigint|||\nbody_binary|hive.transfer_operation|||\namount|hive.asset|||"
check_relation_structure public.bad_domain_view_2 "id|bigint|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_mixed_view_2 "id|bigint|||\namount|hive.asset|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_domain_view_2 "id|bigint|||\nmemo|hive.memo|||"
check_relation_structure public.bad_mixed_view_2 "id|bigint|||\namount|hive.asset|||\nmemo|hive.memo|||"
check_relation_comment public.bad_type_view_2 foo
check_relation_comment public.bad_domain_view_2 bar
check_relation_comment public.bad_mixed_view_2 baz
......@@ -198,7 +198,7 @@ prepare_database
exec_sql "create materialized view public.good_materialized_view as select num, total_vesting_fund_hive, total_vesting_shares, current_hbd_supply, hbd_interest_rate from hafd.blocks"
exec_sql "comment on materialized view public.good_materialized_view is 'foo'"
update_database
check_relation_structure public.good_materialized_view "num|integer|||\ntotal_vesting_fund_hive|hive.hive_amount|||\ntotal_vesting_shares|hive.vest_amount|||\ncurrent_hbd_supply|hive.hbd_amount|||\nhbd_interest_rate|hive.interest_rate|||"
check_relation_structure public.good_materialized_view "num|integer|||\ntotal_vesting_fund_hive|hafd.hive_amount|||\ntotal_vesting_shares|hafd.vest_amount|||\ncurrent_hbd_supply|hafd.hbd_amount|||\nhbd_interest_rate|hafd.interest_rate|||"
check_relation_comment public.good_materialized_view foo
printf "\nTEST: Creating materialized view referencing disallowed type. This should still pass and the view should be recreated.\n"
......@@ -206,15 +206,15 @@ prepare_sql_script 0000000000000000000000000000000000000000
prepare_database --version="0000000000000000000000000000000000000000"
exec_sql "create materialized view public.bad_type_materialized_view as select id,body_binary::hive.transfer_operation,(body_binary::hive.transfer_operation).amount from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_type_materialized_view is 'foo'"
exec_sql "create materialized view public.bad_domain_materialized_view as select id,(body_binary::hive.transfer_operation).memo from hafd.operations where hive_data.operation_id_to_type_id(id)=1"
exec_sql "create materialized view public.bad_domain_materialized_view as select id,(body_binary::hive.transfer_operation).memo from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_domain_materialized_view is 'bar'"
exec_sql "create materialized view public.bad_mixed_materialized_view as select id,(body_binary::hive.transfer_operation).amount,(body_binary::hive.transfer_operation).memo from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_mixed_materialized_view is 'baz'"
update_database
check_table_is_empty hafd.deps_saved_ddl
check_relation_structure public.bad_type_materialized_view "id|bigint|||\nbody_binary|hive.transfer_operation|||\namount|hive.asset|||"
check_relation_structure public.bad_domain_materialized_view "id|bigint|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_mixed_materialized_view "id|bigint|||\namount|hive.asset|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_domain_materialized_view "id|bigint|||\nmemo|hive.memo|||"
check_relation_structure public.bad_mixed_materialized_view "id|bigint|||\namount|hive.asset|||\nmemo|hive.memo|||"
check_relation_comment public.bad_type_materialized_view foo
check_relation_comment public.bad_domain_materialized_view bar
check_relation_comment public.bad_mixed_materialized_view baz
......@@ -223,22 +223,22 @@ printf "\nTEST: Creating materialized view referencing disallowed type with no u
prepare_database
exec_sql "create materialized view public.bad_type_materialized_view_2 as select id,body_binary::hive.transfer_operation,(body_binary::hive.transfer_operation).amount from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_type_materialized_view_2 is 'foo'"
exec_sql "create materialized view public.bad_domain_materialized_view_2 as select id,(body_binary::hive.transfer_operation).memo from hive_data.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "create materialized view public.bad_domain_materialized_view_2 as select id,(body_binary::hive.transfer_operation).memo from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_domain_materialized_view_2 is 'bar'"
exec_sql "create materialized view public.bad_mixed_materialized_view_2 as select id,(body_binary::hive.transfer_operation).amount,(body_binary::hive.transfer_operation).memo from hafd.operations where hafd.operation_id_to_type_id(id)=1"
exec_sql "comment on materialized view public.bad_mixed_materialized_view_2 is 'baz'"
update_database
check_table_is_empty hafd.deps_saved_ddl
check_relation_structure public.bad_type_materialized_view_2 "id|bigint|||\nbody_binary|hive.transfer_operation|||\namount|hive.asset|||"
check_relation_structure public.bad_domain_materialized_view_2 "id|bigint|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_mixed_materialized_view_2 "id|bigint|||\namount|hive.asset|||\nmemo|hafd.memo|||"
check_relation_structure public.bad_domain_materialized_view_2 "id|bigint|||\nmemo|hive.memo|||"
check_relation_structure public.bad_mixed_materialized_view_2 "id|bigint|||\namount|hive.asset|||\nmemo|hive.memo|||"
check_relation_comment public.bad_type_materialized_view_2 foo
check_relation_comment public.bad_domain_materialized_view_2 bar
check_relation_comment public.bad_mixed_materialized_view_2 baz
printf "\nTEST: Check that function defined in hive namespace that doesn't reference current commit hash fails the upgrade.\n"
printf "\nTEST: Check that function defined in hafd namespace that doesn't reference current commit hash fails the upgrade.\n"
prepare_database
exec_sql "CREATE FUNCTION hive.bad_function() RETURNS VOID VOLATILE AS '/lib/postgresql/${POSTGRES_VERSION}/lib/tablefunc.so', 'crosstab' language c;"
exec_sql "CREATE FUNCTION hafd.bad_function() RETURNS VOID VOLATILE AS '/lib/postgresql/${POSTGRES_VERSION}/lib/tablefunc.so', 'crosstab' language c;"
failswith 3 update_database
echo "Succeeded"