Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not be better to remove function get_hash from ut_compound_data_helper and put it into ut_utils then refer to that function rather than directly to dbms_crypto.hash that way it would be kept in one place?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. Didn't notice the comment.
Can take care of it later.

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;
/
5 changes: 5 additions & 0 deletions source/api/ut_runner.pks
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/
47 changes: 2 additions & 45 deletions source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -344,55 +342,14 @@ 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
begin
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;
/
7 changes: 1 addition & 6 deletions source/core/annotations/ut_annotation_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
/
13 changes: 4 additions & 9 deletions source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
44 changes: 31 additions & 13 deletions source/create_synonyms_and_grants_for_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
39 changes: 28 additions & 11 deletions source/create_user_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions test/ut3_tester/core/annotations/test_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/ut3_tester_helper/main_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down