diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 2b8a10c92..7a20a8cf4 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -264,5 +264,39 @@ create or replace package body ut_runner is end loop; end; + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is + l_start_pos pls_integer := 1; + l_end_pos pls_integer := 1; + l_result varchar2(4000); + l_item varchar2(4000); + l_at_end boolean := false; + begin + if a_random_seed is null then + l_result := a_path; + end if; + if a_path is not null then + loop + l_end_pos := instr(a_path,'.',l_start_pos); + if l_end_pos = 0 then + l_end_pos := length(a_path)+1; + l_at_end := true; + end if; + l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos); + if l_item is not null then + l_result := + l_result || + dbms_crypto.hash( + to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ), + dbms_crypto.hash_sh1 + ); + end if; + exit when l_at_end; + l_result := l_result || chr(0); + l_start_pos := l_end_pos + 1; + end loop; + end if; + return l_result; + end; + end ut_runner; / diff --git a/source/api/ut_runner.pks b/source/api/ut_runner.pks index a6ba28556..38167ac57 100644 --- a/source/api/ut_runner.pks +++ b/source/api/ut_runner.pks @@ -140,5 +140,10 @@ create or replace package ut_runner authid current_user is */ function get_reporters_list return tt_reporters_info pipelined; + /* + * Returns a hash value of suitepath based on input path and random seed + */ + function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2; + end ut_runner; / diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index 5b505d63e..009e2741d 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -331,11 +331,9 @@ create or replace package body ut_annotation_manager as end if; end; - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined is + function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor is l_annotation_objs_info ut_annotation_objs_cache_info; l_cursor sys_refcursor; - l_results ut_annotated_objects; - c_object_fetch_limit constant integer := 10; l_full_scan_needed boolean := not ut_trigger_check.is_alive(); begin ut_event_manager.trigger_event('get_annotated_objects - start'); @@ -344,15 +342,8 @@ create or replace package body ut_annotation_manager as --pipe annotations from cache l_cursor := ut_annotation_cache_manager.get_annotations_for_objects(l_annotation_objs_info, a_parse_date); - loop - fetch l_cursor bulk collect into l_results limit c_object_fetch_limit; - for i in 1 .. l_results.count loop - pipe row (l_results(i)); - end loop; - exit when l_cursor%notfound; - end loop; - close l_cursor; ut_event_manager.trigger_event('get_annotated_objects - end'); + return l_cursor; end; procedure purge_cache(a_object_owner varchar2, a_object_type varchar2) is @@ -360,39 +351,5 @@ create or replace package body ut_annotation_manager as ut_annotation_cache_manager.purge_cache(a_object_owner, a_object_type); end; - function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2 is - l_start_pos pls_integer := 1; - l_end_pos pls_integer := 1; - l_result varchar2(4000); - l_item varchar2(4000); - l_at_end boolean := false; - begin - if a_random_seed is null then - l_result := a_path; - end if; - if a_path is not null then - loop - l_end_pos := instr(a_path,'.',l_start_pos); - if l_end_pos = 0 then - l_end_pos := length(a_path)+1; - l_at_end := true; - end if; - l_item := substr(a_path,l_start_pos,l_end_pos-l_start_pos); - if l_item is not null then - l_result := - l_result || - dbms_crypto.hash( - to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ), - dbms_crypto.hash_sh1 - ); - end if; - exit when l_at_end; - l_result := l_result || chr(0); - l_start_pos := l_end_pos + 1; - end loop; - end if; - return l_result; - end; - end ut_annotation_manager; / diff --git a/source/core/annotations/ut_annotation_manager.pks b/source/core/annotations/ut_annotation_manager.pks index c2527fcd2..1d6bd3d71 100644 --- a/source/core/annotations/ut_annotation_manager.pks +++ b/source/core/annotations/ut_annotation_manager.pks @@ -30,7 +30,7 @@ create or replace package ut_annotation_manager authid current_user as * @param a_parse_date date when object was last parsed * @return array containing annotated objects along with annotations for each object (nested) */ - function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined; + function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return sys_refcursor; /** * Rebuilds annotation cache for a specified schema and object type. @@ -57,10 +57,5 @@ create or replace package ut_annotation_manager authid current_user as procedure purge_cache(a_object_owner varchar2, a_object_type varchar2); - /* - * Returns a hash value of suitepath based on input path and random seed - */ - function hash_suite_path(a_path varchar2, a_random_seed positiven) return varchar2; - end ut_annotation_manager; / diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 1ffd5ea49..65cefdc81 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -491,7 +491,7 @@ create or replace package body ut_suite_manager is c.line_no, :a_random_seed]' else - ' {:owner:}.ut_annotation_manager.hash_suite_path( + ' {:owner:}.ut_runner.hash_suite_path( c.path, :a_random_seed ) desc nulls last' end; @@ -614,14 +614,9 @@ create or replace package body ut_suite_manager is begin ut_event_manager.trigger_event('refresh_cache - start'); l_suite_cache_time := ut_suite_cache_manager.get_schema_parse_time(a_owner_name); - open l_annotations_cursor for - q'[select value(x) - from table( - ]' || ut_utils.ut_owner || q'[.ut_annotation_manager.get_annotated_objects( - :a_owner_name, 'PACKAGE', :a_suite_cache_parse_time - ) - )x ]' - using a_owner_name, l_suite_cache_time; + l_annotations_cursor := ut_annotation_manager.get_annotated_objects( + a_owner_name, 'PACKAGE', l_suite_cache_time + ); build_and_cache_suites(a_owner_name, l_annotations_cursor); diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index 30b79cffb..c19d86261 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -31,9 +31,12 @@ whenever oserror exit failure rollback alter session set current_schema = &&ut3_owner; +--expectations grant execute on &&ut3_owner..ut_expectation to public; grant execute on &&ut3_owner..ut_expectation_compound to public; grant execute on &&ut3_owner..ut_expectation_json to public; + +--matchers grant execute on &&ut3_owner..ut_be_between to public; grant execute on &&ut3_owner..ut_be_empty to public; grant execute on &&ut3_owner..ut_be_false to public; @@ -48,8 +51,22 @@ grant execute on &&ut3_owner..ut_be_true to public; grant execute on &&ut3_owner..ut_equal to public; grant execute on &&ut3_owner..ut_have_count to public; grant execute on &&ut3_owner..ut_match to public; + +--public API grant execute on &&ut3_owner..ut to public; grant execute on &&ut3_owner..ut_runner to public; +grant execute on &&ut3_owner..ut_file_mappings to public; +grant execute on &&ut3_owner..ut_file_mapping to public; +grant execute on &&ut3_owner..ut_file_mapper to public; +grant execute on &&ut3_owner..ut_key_value_pairs to public; +grant execute on &&ut3_owner..ut_key_value_pair to public; + +--generic types +grant execute on &&ut3_owner..ut_varchar2_list to public; +grant execute on &&ut3_owner..ut_varchar2_rows to public; +grant execute on &&ut3_owner..ut_integer_list to public; + +--reporters grant execute on &&ut3_owner..ut_debug_reporter to public; grant execute on &&ut3_owner..ut_teamcity_reporter to public; grant execute on &&ut3_owner..ut_xunit_reporter to public; @@ -60,37 +77,39 @@ grant execute on &&ut3_owner..ut_coverage_html_reporter to public; grant execute on &&ut3_owner..ut_coverage_sonar_reporter to public; grant execute on &&ut3_owner..ut_coveralls_reporter to public; grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to public; +grant execute on &&ut3_owner..ut_realtime_reporter to public; +grant execute on &&ut3_owner..ut_sonar_test_reporter to public; + +--reporters base grant execute on &&ut3_owner..ut_reporters to public; -grant execute on &&ut3_owner..ut_varchar2_list to public; -grant execute on &&ut3_owner..ut_varchar2_rows to public; -grant execute on &&ut3_owner..ut_integer_list to public; grant execute on &&ut3_owner..ut_reporter_base to public; grant execute on &&ut3_owner..ut_output_reporter_base to public; -grant execute on &&ut3_owner..ut_output_data_row to public; -grant execute on &&ut3_owner..ut_output_data_rows to public; grant execute on &&ut3_owner..ut_coverage_reporter_base to public; grant execute on &&ut3_owner..ut_console_reporter_base to public; + +--coverage grant execute on &&ut3_owner..ut_coverage to public; grant execute on &&ut3_owner..ut_coverage_options to public; grant execute on &&ut3_owner..ut_coverage_helper to public; + +--outputs +grant execute on &&ut3_owner..ut_output_data_row to public; +grant execute on &&ut3_owner..ut_output_data_rows to public; grant execute on &&ut3_owner..ut_output_buffer_base to public; grant execute on &&ut3_owner..ut_output_table_buffer to public; grant execute on &&ut3_owner..ut_output_clob_table_buffer to public; -grant execute on &&ut3_owner..ut_file_mappings to public; -grant execute on &&ut3_owner..ut_file_mapping to public; -grant execute on &&ut3_owner..ut_file_mapper to public; -grant execute on &&ut3_owner..ut_key_value_pairs to public; -grant execute on &&ut3_owner..ut_key_value_pair to public; + +--user temp tables grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to public; grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to public; -grant execute on &&ut3_owner..ut_sonar_test_reporter to public; + grant execute on &&ut3_owner..ut_annotations to public; grant execute on &&ut3_owner..ut_annotation to public; -grant execute on &&ut3_owner..ut_annotation_manager to public; grant execute on &&ut3_owner..ut_annotated_object to public; grant execute on &&ut3_owner..ut_annotated_objects to public; grant select on &&ut3_owner..ut_annotation_cache_info to public; grant select on &&ut3_owner..ut_annotation_cache to public; + grant execute on &&ut3_owner..ut_executables to public; grant execute on &&ut3_owner..ut_executable_test to public; grant select on &&ut3_owner..ut_suite_cache to public; @@ -102,7 +121,6 @@ grant execute on &&ut3_owner..ut_annotation_objs_cache_info to public; grant execute on &&ut3_owner..ut_annotation_obj_cache_info to public; grant execute on &&ut3_owner..ut_suite_items_info to public; grant execute on &&ut3_owner..ut_suite_item_info to public; -grant execute on &&ut3_owner..ut_realtime_reporter to public; grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to public; grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to public; grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public; diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index 911c1074f..9da5ebebb 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -51,10 +51,12 @@ whenever oserror exit failure rollback alter session set current_schema = &&ut3_owner; +--expectations grant execute on &&ut3_owner..ut_expectation to &ut3_user; grant execute on &&ut3_owner..ut_expectation_compound to &ut3_user; grant execute on &&ut3_owner..ut_expectation_json to &ut3_user; +--matchers grant execute on &&ut3_owner..ut_be_between to &ut3_user; grant execute on &&ut3_owner..ut_be_empty to &ut3_user; grant execute on &&ut3_owner..ut_be_false to &ut3_user; @@ -69,8 +71,22 @@ grant execute on &&ut3_owner..ut_be_true to &ut3_user; grant execute on &&ut3_owner..ut_equal to &ut3_user; grant execute on &&ut3_owner..ut_have_count to &ut3_user; grant execute on &&ut3_owner..ut_match to &ut3_user; + +--public API grant execute on &&ut3_owner..ut to &ut3_user; grant execute on &&ut3_owner..ut_runner to &ut3_user; +grant execute on &&ut3_owner..ut_file_mappings to &ut3_user; +grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; +grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; +grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; +grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; + +--generic types +grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; +grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; +grant execute on &&ut3_owner..ut_integer_list to &ut3_user; + +--reporters grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user; grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user; grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user; @@ -81,41 +97,42 @@ grant execute on &&ut3_owner..ut_coverage_html_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_sonar_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coveralls_reporter to &ut3_user; grant execute on &&ut3_owner..ut_coverage_cobertura_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; + +--reporters base grant execute on &&ut3_owner..ut_reporters to &ut3_user; -grant execute on &&ut3_owner..ut_varchar2_list to &ut3_user; -grant execute on &&ut3_owner..ut_varchar2_rows to &ut3_user; -grant execute on &&ut3_owner..ut_integer_list to &ut3_user; grant execute on &&ut3_owner..ut_reporter_base to &ut3_user; grant execute on &&ut3_owner..ut_output_reporter_base to &ut3_user; grant execute on &&ut3_owner..ut_coverage_reporter_base to &ut3_user; grant execute on &&ut3_owner..ut_console_reporter_base to &ut3_user; + +--coverage grant execute on &&ut3_owner..ut_coverage to &ut3_user; grant execute on &&ut3_owner..ut_coverage_options to &ut3_user; grant execute on &&ut3_owner..ut_coverage_helper to &ut3_user; + +--outputs grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; grant execute on &&ut3_owner..ut_output_data_row to &ut3_user; grant execute on &&ut3_owner..ut_output_data_rows to &ut3_user; grant execute on &&ut3_owner..ut_output_table_buffer to &ut3_user; grant execute on &&ut3_owner..ut_output_clob_table_buffer to &ut3_user; -grant execute on &&ut3_owner..ut_file_mappings to &ut3_user; -grant execute on &&ut3_owner..ut_file_mapping to &ut3_user; -grant execute on &&ut3_owner..ut_file_mapper to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; -grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; + +--user temp tables grant select, insert, update, delete on &&ut3_owner..ut_compound_data_tmp to &ut3_user; grant select, insert, update, delete on &&ut3_owner..ut_compound_data_diff_tmp to &ut3_user; -grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; + grant execute on &&ut3_owner..ut_annotations to &ut3_user; grant execute on &&ut3_owner..ut_annotation to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_manager to &ut3_user; grant execute on &&ut3_owner..ut_annotated_object to &ut3_user; grant execute on &&ut3_owner..ut_annotated_objects to &ut3_user; grant select on &&ut3_owner..ut_annotation_cache_info to &ut3_user; grant select on &&ut3_owner..ut_annotation_cache to &ut3_user; + grant execute on &&ut3_owner..ut_executables to &ut3_user; grant execute on &&ut3_owner..ut_executable_test to &ut3_user; grant select on &&ut3_owner..ut_suite_cache to &ut3_user; -grant select on &&ut3_owner..ut_suite_cache_package to public; +grant select on &&ut3_owner..ut_suite_cache_package to &ut3_user; grant select on &&ut3_owner..ut_suite_cache_schema to &ut3_user; grant execute on &&ut3_owner..ut_annotation_cache_manager to &ut3_user; grant execute on &&ut3_owner..ut_annotation_parser to &ut3_user; diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pkb b/test/ut3_tester/core/annotations/test_annotation_manager.pkb index e64adc861..944f6451d 100644 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pkb @@ -372,15 +372,17 @@ create or replace package body test_annotation_manager is end; procedure no_data_for_dropped_object is - l_actual sys_refcursor; + l_result sys_refcursor; + l_data ut3.ut_annotated_objects; + l_actual sys_refcursor; begin --Arrange ut3.ut_annotation_manager.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); drop_dummy_test_package(); --Act - open l_actual for - select * from table(ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE')) - where object_name = 'DUMMY_TEST_PACKAGE'; + l_result := ut3.ut_annotation_manager.get_annotated_objects(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + fetch l_result bulk collect into l_data; + open l_actual for select object_name from table(l_data) where object_name = 'DUMMY_TEST_PACKAGE'; --Assert ut.expect(l_actual).to_be_empty(); end; diff --git a/test/ut3_tester_helper/main_helper.pkb b/test/ut3_tester_helper/main_helper.pkb index ffccc3185..de28083f9 100644 --- a/test/ut3_tester_helper/main_helper.pkb +++ b/test/ut3_tester_helper/main_helper.pkb @@ -110,7 +110,7 @@ create or replace package body main_helper is execute immediate q'[ create or replace procedure ut3$user#.parse_annotations is begin - ut3.ut_annotation_manager.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); + ut3.ut_runner.rebuild_annotation_cache('UT3_TESTER','PACKAGE'); end;]'; end;