diff --git a/.travis/install.sh b/.travis/install.sh index 646458489..9d4ff6026 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -97,7 +97,7 @@ end; PROMPT Granting $UT3_OWNER tables to $UT3_TESTER begin - for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_TYPE is NULL) + for i in ( select table_name from all_tables t where owner = 'UT3' and nested = 'NO' and IOT_NAME is NULL) loop execute immediate 'grant select on UT3.'||i.table_name||' to UT3_TESTER'; end loop; diff --git a/source/api/ut_runner.pkb b/source/api/ut_runner.pkb index 7a20a8cf4..2068bca3c 100644 --- a/source/api/ut_runner.pkb +++ b/source/api/ut_runner.pkb @@ -44,7 +44,6 @@ create or replace package body ut_runner is procedure finish_run(a_run ut_run, a_force_manual_rollback boolean) is begin - ut_utils.cleanup_temp_tables; ut_event_manager.trigger_event(ut_event_manager.gc_finalize, a_run); ut_metadata.reset_source_definition_cache; ut_utils.read_cache_to_dbms_output(); @@ -52,6 +51,7 @@ create or replace package body ut_runner is ut_compound_data_helper.cleanup_diff(); if not a_force_manual_rollback then rollback; + ut_utils.cleanup_session_temp_tables; end if; end; @@ -196,7 +196,7 @@ create or replace package body ut_runner is function get_suites_info(a_owner varchar2 := null, a_package_name varchar2 := null) return ut_suite_items_info pipelined is l_cursor sys_refcursor; l_results ut_suite_items_info; - c_bulk_limit constant integer := 10; + c_bulk_limit constant integer := 100; begin l_cursor := ut_suite_manager.get_suites_info( nvl(a_owner,sys_context('userenv', 'current_schema')), a_package_name ); loop @@ -285,10 +285,7 @@ create or replace package body ut_runner is 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 - ); + ut_utils.get_hash( to_char( dbms_utility.get_hash_value( l_item, 1, a_random_seed ) ) ); end if; exit when l_at_end; l_result := l_result || chr(0); diff --git a/source/api/ut_suite_item_info.tps b/source/api/ut_suite_item_info.tps index d37e89b59..807635d1b 100644 --- a/source/api/ut_suite_item_info.tps +++ b/source/api/ut_suite_item_info.tps @@ -18,7 +18,7 @@ create or replace type ut_suite_item_info as object ( object_owner varchar2( 250 ), -- the owner of test suite packages object_name varchar2( 250 ), -- the name of test suite package item_name varchar2( 250 ), -- the name of suite/test - item_description varchar2( 250 ), -- the description of suite/suite item + item_description varchar2( 4000 ), -- the description of suite/suite item item_type varchar2( 250 ), -- the type of item (UT_SUITE/UT_SUITE_CONTEXT/UT_TEST) item_line_no integer, -- line_number where annotation identifying the item exists path varchar2( 4000 ),-- suitepath of the item diff --git a/source/core/annotations/ut_annotation_cache_manager.pkb b/source/core/annotations/ut_annotation_cache_manager.pkb index 21151de8b..eb60ac3dd 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pkb +++ b/source/core/annotations/ut_annotation_cache_manager.pkb @@ -91,12 +91,29 @@ create or replace package body ut_annotation_cache_manager as commit; end; + function get_annotations_objects_info(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info is + l_result ut_annotation_objs_cache_info; + begin + select ut_annotation_obj_cache_info( + object_owner => i.object_owner, + object_name => i.object_name, + object_type => i.object_type, + needs_refresh => 'N', + parse_time => i.parse_time + ) + bulk collect into l_result + from ut_annotation_cache_info i + where i.object_owner = a_object_owner + and i.object_type = a_object_type; + return l_result; + end; + function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info is l_result t_cache_schema_info; begin begin select * - into l_result + into l_result from ut_annotation_cache_schema s where s.object_type = a_object_type and s.object_owner = a_object_owner; exception diff --git a/source/core/annotations/ut_annotation_cache_manager.pks b/source/core/annotations/ut_annotation_cache_manager.pks index 4366cd536..2a1d60f1e 100644 --- a/source/core/annotations/ut_annotation_cache_manager.pks +++ b/source/core/annotations/ut_annotation_cache_manager.pks @@ -34,6 +34,9 @@ create or replace package ut_annotation_cache_manager authid definer as */ function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor; + + function get_annotations_objects_info(a_object_owner varchar2, a_object_type varchar2) return ut_annotation_objs_cache_info; + function get_cache_schema_info(a_object_owner varchar2, a_object_type varchar2) return t_cache_schema_info; /** diff --git a/source/core/annotations/ut_annotation_manager.pkb b/source/core/annotations/ut_annotation_manager.pkb index 009e2741d..fd2997632 100644 --- a/source/core/annotations/ut_annotation_manager.pkb +++ b/source/core/annotations/ut_annotation_manager.pkb @@ -24,29 +24,28 @@ create or replace package body ut_annotation_manager as l_ut_owner varchar2(250) := ut_utils.ut_owner; l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); l_cursor_text varchar2(32767); + l_data ut_annotation_objs_cache_info; l_result ut_annotation_objs_cache_info; + l_card natural; begin + l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type); + l_card := ut_utils.scale_cardinality(cardinality(l_data)); + l_cursor_text := - q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( - object_owner => i.object_owner, - object_name => i.object_name, - object_type => i.object_type, - needs_refresh => null - ) - from ]'||l_ut_owner||q'[.ut_annotation_cache_info i + 'select /*+ cardinality(i '||l_card||') */ + value(i) + from table( cast( :l_data as '||l_ut_owner||'.ut_annotation_objs_cache_info ) ) i where not exists ( - select 1 from ]'||l_objects_view||q'[ o + select 1 from '||l_objects_view||q'[ o where o.owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type - and o.owner = :a_object_owner - and o.object_type = :a_object_type - ) - and i.object_owner = :a_object_owner - and i.object_type = :a_object_type]'; - open l_rows for l_cursor_text using a_object_owner, a_object_type, a_object_owner, a_object_type; - fetch l_rows bulk collect into l_result limit 1000000; + and o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' + )]'; + open l_rows for l_cursor_text using l_data; + fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit; close l_rows; return l_result; end; @@ -61,83 +60,48 @@ create or replace package body ut_annotation_manager as l_ut_owner varchar2(250) := ut_utils.ut_owner; l_objects_view varchar2(200) := ut_metadata.get_objects_view_name(); l_cursor_text varchar2(32767); + l_data ut_annotation_objs_cache_info; l_result ut_annotation_objs_cache_info; - l_object_owner varchar2(250); - l_object_type varchar2(250); begin ut_event_manager.trigger_event( 'get_annotation_objs_info - start ( a_full_scan = ' || ut_utils.to_string(a_full_scan) || ' )' ); + + l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, a_object_type); + if not a_full_scan then - l_cursor_text := - q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( - object_owner => i.object_owner, - object_name => i.object_name, - object_type => i.object_type, - needs_refresh => 'N' - ) - from ]'||l_ut_owner||q'[.ut_annotation_cache_info i - where i.object_owner = :a_object_owner - and i.object_type = :a_object_type]'; - open l_rows for l_cursor_text using a_object_owner, a_object_type; + l_result := l_data; else - if a_object_owner is not null then - l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); - end if; - if a_object_type is not null then - l_object_type := sys.dbms_assert.qualified_sql_name(a_object_type); - end if; l_cursor_text := - q'[select ]'||l_ut_owner||q'[.ut_annotation_obj_cache_info( - object_owner => o.owner, - object_name => o.object_name, - object_type => o.object_type, - needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end - ) - from ]'||l_objects_view||q'[ o - left join ]'||l_ut_owner||q'[.ut_annotation_cache_info i + 'select /*+ cardinality(i '||ut_utils.scale_cardinality(cardinality(l_data))||') */ + '||l_ut_owner||q'[.ut_annotation_obj_cache_info( + object_owner => o.owner, + object_name => o.object_name, + object_type => o.object_type, + needs_refresh => case when o.last_ddl_time < cast(i.parse_time as date) then 'N' else 'Y' end, + parse_time => i.parse_time + ) + from ]'||l_objects_view||' o + left join table( cast(:l_data as '||l_ut_owner||q'[.ut_annotation_objs_cache_info ) ) i on o.owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type - where o.owner = ']'||l_object_owner||q'[' - and o.object_type = ']'||l_object_type||q'[' + where o.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and o.object_type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' and ]' || case when a_parse_date is null then ':a_parse_date is null' else 'o.last_ddl_time >= cast(:a_parse_date as date)' end; - open l_rows for l_cursor_text using a_parse_date; + open l_rows for l_cursor_text using l_data, a_parse_date; + fetch l_rows bulk collect into l_result limit ut_utils.gc_max_objects_fetch_limit; + close l_rows; end if; - fetch l_rows bulk collect into l_result limit 10000000; - close l_rows; ut_event_manager.trigger_event('get_annotation_objs_info - end (count='||l_result.count||')'); return l_result; end; - function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2) return sys_refcursor is - l_result sys_refcursor; - l_sources_view varchar2(200) := ut_metadata.get_source_view_name(); - begin - open l_result for - q'[select s.name, s.text - from (select s.name, s.text, s.line, - max(case when s.text like '%--%\%%' escape '\' - and regexp_like(s.text,'--\s*%') - then 'Y' else 'N' end - ) - over(partition by s.name) is_annotated - from ]'||l_sources_view||q'[ s - where s.type = :a_object_type - and s.owner = :a_object_owner - ) s - where s.is_annotated = 'Y' - order by s.name, s.line]' - using a_object_type, a_object_owner, a_object_type, a_object_owner; - - return l_result; - end; - function get_sources_to_annotate(a_object_owner varchar2, a_object_type varchar2, a_objects_to_refresh ut_annotation_objs_cache_info) return sys_refcursor is l_result sys_refcursor; l_sources_view varchar2(200) := ut_metadata.get_source_view_name(); @@ -158,12 +122,12 @@ create or replace package body ut_annotation_manager as on s.name = r.object_name and s.owner = r.object_owner and s.type = r.object_type - where s.type = :a_object_type - and s.owner = :a_object_owner + where s.owner = ']'||ut_utils.qualified_sql_name(a_object_owner)||q'[' + and s.type = ']'||ut_utils.qualified_sql_name(a_object_type)||q'[' ) s where s.is_annotated = 'Y' order by s.name, s.line]' - using a_objects_to_refresh, a_object_type, a_object_owner; + using a_objects_to_refresh; return l_result; end; @@ -207,7 +171,6 @@ create or replace package body ut_annotation_manager as l_object_lines.delete; end if; close a_sources_cursor; - commit; end; @@ -257,7 +220,6 @@ create or replace package body ut_annotation_manager as procedure trigger_obj_annotation_rebuild is l_sql_text ora_name_list_t; l_parts binary_integer; - l_object_to_parse ut_annotation_obj_cache_info; l_restricted_users ora_name_list_t; function get_source_from_sql_text(a_object_name varchar2, a_sql_text ora_name_list_t, a_parts binary_integer) return sys_refcursor is @@ -312,8 +274,6 @@ create or replace package body ut_annotation_manager as return; end if; - l_object_to_parse := ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y'); - if ora_sysevent = 'CREATE' then l_parts := ORA_SQL_TXT(l_sql_text); build_annot_cache_for_sources( @@ -324,9 +284,13 @@ create or replace package body ut_annotation_manager as build_annot_cache_for_sources( ora_dict_obj_owner, ora_dict_obj_type, get_source_for_object(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type) - ); + ); elsif ora_sysevent = 'DROP' then - ut_annotation_cache_manager.remove_from_cache(ut_annotation_objs_cache_info(l_object_to_parse)); + ut_annotation_cache_manager.remove_from_cache( + ut_annotation_objs_cache_info( + ut_annotation_obj_cache_info(ora_dict_obj_owner, ora_dict_obj_name, ora_dict_obj_type, 'Y', null) + ) + ); end if; end if; end; diff --git a/source/core/annotations/ut_annotation_obj_cache_info.tps b/source/core/annotations/ut_annotation_obj_cache_info.tps index fd0ec51e7..4b8178a9d 100644 --- a/source/core/annotations/ut_annotation_obj_cache_info.tps +++ b/source/core/annotations/ut_annotation_obj_cache_info.tps @@ -18,6 +18,7 @@ create type ut_annotation_obj_cache_info as object( object_owner varchar2(250), object_name varchar2(250), object_type varchar2(250), - needs_refresh varchar2(1) + needs_refresh varchar2(1), + parse_time timestamp ) / diff --git a/source/core/coverage/dbms_plssqlcode.sql b/source/core/coverage/dbms_plssqlcode.sql index 065563ef7..4bba7780c 100644 --- a/source/core/coverage/dbms_plssqlcode.sql +++ b/source/core/coverage/dbms_plssqlcode.sql @@ -7,69 +7,21 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_BLOCKS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create table dbmspcc_blocks ( + create global temporary table dbmspcc_blocks ( run_id number(38, 0), object_id number(38, 0), block number(38, 0), - line number(38, 0), - col number(38, 0), - covered number(1, 0), - not_feasible number(1, 0) - )]'; - execute immediate q'[ - create unique index dbmspcc_blocks_pk on - dbmspcc_blocks ( - run_id, - object_id, - block - )]'; - execute immediate q'[ - alter table dbmspcc_blocks modify ( - line - constraint dbmspcc_blocks_line_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_blocks modify ( - col - constraint dbmspcc_blocks_col_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_blocks modify ( - covered - constraint dbmspcc_blocks_covered_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_blocks modify ( - not_feasible - constraint dbmspcc_blocks_not_feasible_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_covered_ck check ( covered in ( - 0, - 1 - ) ) enable]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( - 0, - 1 - ) ) enable]'; - execute immediate q'[ - alter table dbmspcc_blocks - add constraint dbmspcc_blocks_pk primary key ( run_id, - object_id, - block ) - using index enable]'; + line number(38, 0) constraint dbmspcc_blocks_line_nn not null enable, + col number(38, 0) constraint dbmspcc_blocks_col_nn not null enable, + covered number(1, 0) constraint dbmspcc_blocks_covered_nn not null enable, + not_feasible number(1, 0) constraint dbmspcc_blocks_not_feasible_nn not null enable, + constraint dbmspcc_blocks_block_ck check ( block >= 0 ) enable, + constraint dbmspcc_blocks_line_ck check ( line >= 0 ) enable, + constraint dbmspcc_blocks_col_ck check ( col >= 0 ) enable, + constraint dbmspcc_blocks_covered_ck check ( covered in ( 0, 1 ) ) enable, + constraint dbmspcc_blocks_not_feasible_ck check ( not_feasible in ( 0, 1 ) ) enable, + constraint dbmspcc_blocks_pk primary key ( run_id, object_id, block ) using index + ) on commit preserve rows]'; end if; end; / @@ -82,31 +34,13 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_RUNS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create table dbmspcc_runs ( + create global temporary table dbmspcc_runs ( run_id number(38, 0), run_comment varchar2(4000 byte), - run_owner varchar2(128 byte), - run_timestamp date - )]'; - execute immediate q'[ - create unique index dbmspcc_runs_pk on - dbmspcc_runs ( - run_id - )]'; - execute immediate q'[ - alter table dbmspcc_runs modify ( - run_owner - constraint dbmspcc_runs_run_owner_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_runs modify ( - run_timestamp - constraint dbmspcc_runs_run_timestamp_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_runs - add constraint dbmspcc_runs_pk primary key ( run_id ) - using index enable]'; + run_owner varchar2(128 byte) constraint dbmspcc_runs_run_owner_nn not null enable, + run_timestamp date constraint dbmspcc_runs_run_timestamp_nn not null enable, + constraint dbmspcc_runs_pk primary key ( run_id ) using index enable + ) on commit preserve rows]'; end if; end; / @@ -119,45 +53,15 @@ begin select synonym_name from all_synonyms where synonym_name = 'DBMSPCC_UNITS' and owner = sys_context('USERENV','CURRENT_SCHEMA')); if l_tab_exist = 0 then execute immediate q'[ - create table dbmspcc_units ( + create global temporary table dbmspcc_units ( run_id number(38, 0), object_id number(38, 0), - owner varchar2(128 byte), - name varchar2(128 byte), - type varchar2(12 byte), - last_ddl_time date - )]'; - execute immediate q'[ - create unique index dbmspcc_units_pk on - dbmspcc_units ( - run_id, - object_id - )]'; - execute immediate q'[ - alter table dbmspcc_units modify ( - owner - constraint dbmspcc_units_owner_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_units modify ( - name - constraint dbmspcc_units_name_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_units modify ( - type - constraint dbmspcc_units_type_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_units modify ( - last_ddl_time - constraint dbmspcc_units_last_ddl_time_nn not null enable - )]'; - execute immediate q'[ - alter table dbmspcc_units - add constraint dbmspcc_units_pk primary key ( run_id, - object_id ) - using index enable]'; + owner varchar2(128 byte) constraint dbmspcc_units_owner_nn not null enable, + name varchar2(128 byte) constraint dbmspcc_units_name_nn not null enable, + type varchar2(12 byte) constraint dbmspcc_units_type_nn not null enable, + last_ddl_time date constraint dbmspcc_units_last_ddl_time_nn not null enable, + constraint dbmspcc_units_pk primary key ( run_id, object_id ) using index enable + ) on commit preserve rows]'; end if; end; / diff --git a/source/core/coverage/ut_coverage.pkb b/source/core/coverage/ut_coverage.pkb index 2fc5c4aec..5754cf4e9 100644 --- a/source/core/coverage/ut_coverage.pkb +++ b/source/core/coverage/ut_coverage.pkb @@ -161,9 +161,7 @@ create or replace package body ut_coverage is l_run_comment varchar2(200) := 'utPLSQL Code coverage run '||ut_utils.to_string(systimestamp); begin if not is_develop_mode() and not g_is_started then - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then ut_coverage_helper_block.coverage_start( l_run_comment, g_coverage_id(gc_block_coverage) ); - $end ut_coverage_helper_profiler.coverage_start( l_run_comment, g_coverage_id(gc_proftab_coverage) ); coverage_pause(); g_is_started := true; @@ -200,9 +198,7 @@ create or replace package body ut_coverage is begin if not is_develop_mode() then g_is_started := false; - $if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then ut_coverage_helper_block.coverage_stop(); - $end ut_coverage_helper_profiler.coverage_stop(); g_is_started := false; end if; diff --git a/source/core/coverage/ut_coverage_helper.pkb b/source/core/coverage/ut_coverage_helper.pkb index 1c83606d8..12ee9e1f7 100644 --- a/source/core/coverage/ut_coverage_helper.pkb +++ b/source/core/coverage/ut_coverage_helper.pkb @@ -43,9 +43,7 @@ create or replace package body ut_coverage_helper is procedure cleanup_tmp_table is pragma autonomous_transaction; begin - null; execute immediate 'truncate table ut_coverage_sources_tmp'; - commit; end; function is_tmp_table_populated return boolean is diff --git a/source/core/coverage/ut_coverage_helper_block.pkb b/source/core/coverage/ut_coverage_helper_block.pkb index e8342a105..fc64c507f 100644 --- a/source/core/coverage/ut_coverage_helper_block.pkb +++ b/source/core/coverage/ut_coverage_helper_block.pkb @@ -49,28 +49,24 @@ create or replace package body ut_coverage_helper_block is end; function block_results(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return t_block_rows is - l_raw_coverage sys_refcursor; l_coverage_rows t_block_rows; - l_ut3_owner varchar2(128) := ut_utils.ut_owner(); begin - open l_raw_coverage for 'select ccb.line - ,count(ccb.block) totalblocks - ,sum(ccb.covered) + select ccb.line as line, + count(ccb.block) as blocks, + sum(ccb.covered) as covered_blocks + bulk collect into l_coverage_rows from dbmspcc_units ccu left outer join dbmspcc_blocks ccb on ccu.run_id = ccb.run_id and ccu.object_id = ccb.object_id - where ccu.run_id = :a_coverage_id - and ccu.owner = :a_object_owner - and ccu.name = :a_object_name + where ccu.run_id = a_coverage_id + and ccu.owner = a_object_owner + and ccu.name = a_object_name group by ccb.line - order by 1' using a_coverage_id,a_object_owner,a_object_name; + order by 1; - fetch l_raw_coverage bulk collect into l_coverage_rows; - close l_raw_coverage; - - return l_coverage_rows; + return l_coverage_rows; end; function get_raw_coverage_data(a_object_owner varchar2, a_object_name varchar2, a_coverage_id integer) return ut_coverage_helper.t_unit_line_calls is diff --git a/source/core/types/ut_suite_cache_row.tps b/source/core/types/ut_suite_cache_row.tps new file mode 100644 index 000000000..6817be5ec --- /dev/null +++ b/source/core/types/ut_suite_cache_row.tps @@ -0,0 +1,40 @@ +create type ut_suite_cache_row as object ( + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + id number(22,0), + self_type varchar2(250 byte), + path varchar2(1000 byte), + object_owner varchar2(250 byte), + object_name varchar2(250 byte), + name varchar2(250 byte), + line_no number, + parse_time timestamp (6), + description varchar2(4000 byte), + rollback_type number, + disabled_flag number, + warnings ut_varchar2_rows, + before_all_list ut_executables, + after_all_list ut_executables, + before_each_list ut_executables, + before_test_list ut_executables, + after_each_list ut_executables, + after_test_list ut_executables, + expected_error_codes ut_integer_list, + tags ut_varchar2_rows, + item ut_executable_test +) +/ \ No newline at end of file diff --git a/source/core/types/ut_suite_cache_rows.tps b/source/core/types/ut_suite_cache_rows.tps new file mode 100644 index 000000000..660f934cf --- /dev/null +++ b/source/core/types/ut_suite_cache_rows.tps @@ -0,0 +1,19 @@ +create type ut_suite_cache_rows as + /* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + table of ut_suite_cache_row +/ \ No newline at end of file diff --git a/source/core/ut_metadata.pkb b/source/core/ut_metadata.pkb index a33dfc1eb..7859d6b3f 100644 --- a/source/core/ut_metadata.pkb +++ b/source/core/ut_metadata.pkb @@ -292,7 +292,7 @@ create or replace package body ut_metadata as if not l_result like '"%"' then l_result := upper(l_result); end if; - return sys.dbms_assert.qualified_sql_name(l_result); + return ut_utils.qualified_sql_name(l_result); end; function get_anydata_compound_type(a_data_value anydata) return varchar2 is diff --git a/source/core/ut_suite_cache.sql b/source/core/ut_suite_cache.sql index e4bf52439..a7f998f83 100644 --- a/source/core/ut_suite_cache.sql +++ b/source/core/ut_suite_cache.sql @@ -1,9 +1,4 @@ -create or replace type ut_suite_contexts as table of ut_suite_context -/ -create or replace type ut_tests as table of ut_test -/ - -create table ut_suite_cache ( +create table ut_suite_cache /* utPLSQL - Version 3 Copyright 2016 - 2019 utPLSQL Project @@ -17,28 +12,7 @@ create table ut_suite_cache ( See the License for the specific language governing permissions and limitations under the License. */ - id, - self_type, - path, - object_owner, - object_name, - name, - line_no, - parse_time, - description, - rollback_type, - disabled_flag, - warnings, - before_all_list, - after_all_list, - before_each_list, - before_test_list, - after_each_list, - after_test_list, - expected_error_codes, - tags, - item -) + of ut_suite_cache_row nested table warnings store as ut_suite_cache_warnings nested table before_all_list store as ut_suite_cache_before_all nested table after_all_list store as ut_suite_cache_after_all @@ -48,32 +22,6 @@ create table ut_suite_cache ( nested table after_test_list store as ut_suite_cache_after_test nested table expected_error_codes store as ut_suite_cache_throws nested table tags store as ut_suite_cache_tags return as locator - as - select - cast(null as number(22)) id, - c.self_type, - c.path, - c.object_owner, - c.object_name, - c.name, - c.line_no, - c.parse_time, - c.description, - c.rollback_type, - c.disabled_flag, - c.warnings, - c.before_all_list, - c.after_all_list, - t.before_each_list, - t.before_test_list, - t.after_each_list, - t.after_test_list, - t.expected_error_codes, - t.tags, - t.item - from table(ut_suite_contexts(ut_suite_context(user,'package_name','ctx_name',1))) c - cross join table(ut_tests(ut_test(user,'package_name','test_name',1))) t - where rownum < 0 / alter table ut_suite_cache modify (object_owner not null, path not null, self_type not null, object_name not null, name not null, parse_time not null) @@ -88,9 +36,3 @@ alter table ut_suite_cache add constraint ut_suite_cache_uk2 unique (object_owne alter table ut_suite_cache add constraint ut_suite_cache_schema_fk foreign key (object_owner, object_name) references ut_suite_cache_package(object_owner, object_name) on delete cascade / - -drop type ut_tests -/ - -drop type ut_suite_contexts -/ diff --git a/source/core/ut_suite_cache_manager.pkb b/source/core/ut_suite_cache_manager.pkb index b8b548a4b..f5c472e29 100644 --- a/source/core/ut_suite_cache_manager.pkb +++ b/source/core/ut_suite_cache_manager.pkb @@ -16,6 +16,210 @@ create or replace package body ut_suite_cache_manager is limitations under the License. */ + /* + * Private code + */ + + gc_get_cache_suite_sql constant varchar2(32767) := + q'[with + suite_items as ( + select /*+ cardinality(c 100) */ value(c) as obj + from ut_suite_cache c + where 1 = 1 + and c.object_owner = :l_object_owner + and ( {:path:} + and {:object_name:} + and {:procedure_name:} + ) + ) + ), + {:tags:} + suitepaths as ( + select distinct substr(c.obj.path,1,instr(c.obj.path,'.',-1)-1) as suitepath, + c.obj.path as path, + c.obj.object_owner as object_owner + from {:suite_item_name:} c + where c.obj.self_type = 'UT_SUITE' + ), + gen as ( + select rownum as pos + from xmltable('1 to 20') + ), + suitepath_part AS ( + select distinct + substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, + object_owner + from suitepaths b + join gen g + on g.pos <= regexp_count(b.suitepath, '\w+') + ), + logical_suite_data as ( + select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, + upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, + cast(null as ut_executables) as x, + cast(null as ut_integer_list) as y, + cast(null as ut_executable_test) as z + from suitepath_part p + where p.path + not in (select s.path from suitepaths s) + ), + logical_suites as ( + select ut_suite_cache_row( + null, + s.self_type, s.path, s.object_owner, s.object_name, + s.object_name, null, null, null, null, 0, + ut_varchar2_rows(), + s.x, s.x, s.x, s.x, s.x, s.x, + s.y, null, s.z + ) as obj + from logical_suite_data s + ), + items as ( + select obj from {:suite_item_name:} + union all + select obj from logical_suites + ) + select c.obj + from items c + order by c.obj.object_owner,{:random_seed:}]'; + + function get_missing_cache_objects(a_object_owner varchar2) return ut_varchar2_rows is + l_result ut_varchar2_rows; + l_data ut_annotation_objs_cache_info; + begin + l_data := ut_annotation_cache_manager.get_annotations_objects_info(a_object_owner, 'PACKAGE'); + + select i.object_name + bulk collect into l_result + from ut_suite_cache_package i + where not exists ( + select 1 from table(l_data) o + where o.object_owner = i.object_owner + and o.object_name = i.object_name + and o.object_type = 'PACKAGE' + ) + and i.object_owner = a_object_owner; + return l_result; + end; + + + function get_path_sql(a_path in varchar2) return varchar2 is + begin + return case when a_path is not null then q'[ + :l_path||'.' like c.path || '.%' /*all children and self*/ + or ( c.path||'.' like :l_path || '.%' --all parents + ]' + else ' :l_path is null and ( :l_path is null ' end; + end; + + function get_object_name_sql(a_object_name in varchar2) return varchar2 is + begin + return case when a_object_name is not null + then ' c.object_name = :a_object_name ' + else ' :a_object_name is null' end; + end; + + function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is + begin + return case when a_procedure_name is not null + then ' c.name = :a_procedure_name' + else ' :a_procedure_name is null' end; + end; + + function get_tags_sql(a_tags_count in integer) return varchar2 is + begin + return case when a_tags_count > 0 then + q'[filter_tags as ( + select c.obj.path as path + from suite_items c + where c.obj.tags multiset intersect :a_tag_list is not empty + ), + suite_items_tags as ( + select c.* + from suite_items c + where exists ( + select 1 from filter_tags t + where t.path||'.' like c.obj.path || '.%' /*all children and self*/ + or c.obj.path||'.' like t.path || '.%' --all parents + ) + ),]' + else + q'[dummy as (select 'x' from dual where :a_tag_list is null ),]' + end; + end; + + function get_random_seed_sql(a_random_seed positive) return varchar2 is + begin + return case + when a_random_seed is null then q'[ + replace( + case + when c.obj.self_type in ( 'UT_TEST' ) + then substr(c.obj.path, 1, instr(c.obj.path, '.', -1) ) + else c.obj.path + end, '.', chr(0) + ) desc nulls last, + c.obj.object_name desc, + c.obj.line_no, + :a_random_seed]' + else + ' ut_runner.hash_suite_path( + c.obj.path, :a_random_seed + ) desc nulls last' + end; + end; + + + + /* + * Public code + */ + function get_cached_suite_rows( + a_object_owner varchar2, + a_path varchar2 := null, + a_object_name varchar2 := null, + a_procedure_name varchar2 := null, + a_random_seed positive := null, + a_tags ut_varchar2_rows := null + ) return ut_suite_cache_rows is + l_path varchar2(4000); + l_results ut_suite_cache_rows := ut_suite_cache_rows(); + l_sql varchar2(32767); + l_suite_item_name varchar2(20); + l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows()); + l_object_owner varchar2(250) := ut_utils.qualified_sql_name(a_object_owner); + l_object_name varchar2(250) := ut_utils.qualified_sql_name(a_object_name); + l_procedure_name varchar2(250) := ut_utils.qualified_sql_name(a_procedure_name); + begin + if a_path is null and a_object_name is not null then + select min(c.path) + into l_path + from ut_suite_cache c + where c.object_owner = upper(l_object_owner) + and c.object_name = upper(l_object_name) + and c.name = nvl(upper(l_procedure_name), c.name); + else + l_path := lower(ut_utils.qualified_sql_name(a_path)); + end if; + l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end; + + l_sql := gc_get_cache_suite_sql; + l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name); + l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner)); + l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path)); + l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name)); + l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name)); + l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count)); + l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed)); + + ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); + + execute immediate l_sql + bulk collect into l_results + using upper(l_object_owner), l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_tags, a_random_seed; + return l_results; + end; + function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is l_cache_parse_time timestamp; begin @@ -133,26 +337,95 @@ create or replace package body ut_suite_cache_manager is s.t.expected_error_codes as expected_error_codes, s.t.tags as test_tags, s.t.item as item from tests s; - + end if; end if; commit; end; - procedure remove_from_cache(a_schema_name varchar2, a_objects ut_varchar2_rows) is + procedure remove_missing_objs_from_cache(a_schema_name varchar2) is + l_objects ut_varchar2_rows; pragma autonomous_transaction; begin + l_objects := get_missing_cache_objects(a_schema_name); delete from ut_suite_cache i where i.object_owner = a_schema_name - and i.object_name in ( select column_value from table (a_objects) ); + and i.object_name in ( select column_value from table (l_objects) ); delete from ut_suite_cache_package i where i.object_owner = a_schema_name - and i.object_name in ( select column_value from table (a_objects) ); + and i.object_name in ( select column_value from table (l_objects) ); commit; end; + function get_cached_suite_info( + a_object_owner varchar2, + a_object_name varchar2 + ) return ut_suite_items_info is + l_cache_rows ut_suite_cache_rows; + l_results ut_suite_items_info; + begin + l_cache_rows := get_cached_suite_rows( a_object_owner, a_object_name ); + select ut_suite_item_info( + c.object_owner, c.object_name, c.name, + c.description, c.self_type, c.line_no, + c.path, c.disabled_flag, c.tags + ) + bulk collect into l_results + from table(l_cache_rows) c; + + return l_results; + end; + + function get_cached_packages( + a_schema_names ut_varchar2_rows + ) return ut_object_names is + l_results ut_object_names; + begin + select ut_object_name( c.object_owner, c.object_name ) + bulk collect into l_results + from ut_suite_cache_package c + join table ( a_schema_names ) s + on c.object_owner = upper(s.column_value); + return l_results; + end; + + function suite_item_exists( + a_owner_name varchar2, + a_package_name varchar2, + a_procedure_name varchar2 + ) return boolean is + l_count integer; + begin + if a_procedure_name is not null then + select count( 1 ) into l_count from dual + where exists( + select 1 + from ut_suite_cache c + where c.object_owner = a_owner_name + and c.object_name = a_package_name + and c.name = a_procedure_name + ); + elsif a_package_name is not null then + select count( 1 ) into l_count from dual + where exists( + select 1 + from ut_suite_cache_package c + where c.object_owner = a_owner_name + and c.object_name = a_package_name + ); + else + select count( 1 ) into l_count from dual + where exists( + select 1 + from ut_suite_cache_package c + where c.object_owner = a_owner_name + ); + end if; + + return l_count > 0; + end; end ut_suite_cache_manager; / diff --git a/source/core/ut_suite_cache_manager.pks b/source/core/ut_suite_cache_manager.pks index 03816ee70..d5b31ccee 100644 --- a/source/core/ut_suite_cache_manager.pks +++ b/source/core/ut_suite_cache_manager.pks @@ -20,6 +20,9 @@ create or replace package ut_suite_cache_manager authid definer is * Responsible for storing and retrieving suite data from cache */ + /* + * Saves suite items for individual package in suite cache + */ procedure save_object_cache( a_object_owner varchar2, a_object_name varchar2, @@ -27,9 +30,59 @@ create or replace package ut_suite_cache_manager authid definer is a_suite_items ut_suite_items ); + /* + * Returns time when schema was last saved in cache + */ function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache; - procedure remove_from_cache(a_schema_name varchar2, a_objects ut_varchar2_rows); + /* + * Removes packages that are no longer annotated from cache + */ + procedure remove_missing_objs_from_cache(a_schema_name varchar2); + + /* + * Retrieves suite items data from cache. + * Returned data is not filtered by user access rights. + * Not to be used publicly. Used internally for building suites at runtime. + */ + function get_cached_suite_rows( + a_object_owner varchar2, + a_path varchar2 := null, + a_object_name varchar2 := null, + a_procedure_name varchar2 := null, + a_random_seed positive := null, + a_tags ut_varchar2_rows := null + ) return ut_suite_cache_rows; + + /* + * Retrieves suite item info rows from cache. + * Returned data is not filtered by user access rights. + * Not to be used publicly. Used internally for building suites info. + */ + function get_cached_suite_info( + a_object_owner varchar2, + a_object_name varchar2 + ) return ut_suite_items_info; + + /* + * Retrieves list of cached suite packages. + * Returned data is not filtered by user access rights. + * Not to be used publicly. Used internally. + */ + function get_cached_packages( + a_schema_names ut_varchar2_rows + ) return ut_object_names; + + /* + * Returns true if given suite item exists in cache. + * Returned data is not filtered by user access rights. + * Not to be used publicly. Used internally. + */ + function suite_item_exists( + a_owner_name varchar2, + a_package_name varchar2, + a_procedure_name varchar2 + ) return boolean; end ut_suite_cache_manager; / diff --git a/source/core/ut_suite_manager.pkb b/source/core/ut_suite_manager.pkb index 65cefdc81..e71a51dc8 100644 --- a/source/core/ut_suite_manager.pkb +++ b/source/core/ut_suite_manager.pkb @@ -18,70 +18,6 @@ create or replace package body ut_suite_manager is gc_suitpath_error_message constant varchar2(100) := 'Suitepath exceeds 1000 CHAR on: '; - gc_get_cache_suite_sql constant varchar2(32767) := - q'[with - suite_items as ( - select /*+ cardinality(c 100) */ c.* - from {:owner:}.ut_suite_cache c - where 1 = 1 {:object_list:} - and c.object_owner = '{:object_owner:}' - and ( {:path:} - and {:object_name:} - and {:procedure_name:} - ) - ) - ), - {:tags:}, - suitepaths as ( - select distinct substr(path,1,instr(path,'.',-1)-1) as suitepath, - path, - object_owner - from {:suite_item_name:} - where self_type = 'UT_SUITE' - ), - gen as ( - select rownum as pos - from xmltable('1 to 20') - ), - suitepath_part AS ( - select distinct - substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, - object_owner - from suitepaths b - join gen g - on g.pos <= regexp_count(b.suitepath, '\w+') - ), - logical_suite_data as ( - select 'UT_LOGICAL_SUITE' as self_type, p.path, p.object_owner, - upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name, - cast(null as {:owner:}.ut_executables) as x, - cast(null as {:owner:}.ut_integer_list) as y, - cast(null as {:owner:}.ut_executable_test) as z - from suitepath_part p - where p.path - not in (select s.path from suitepaths s) - ), - logical_suites as ( - select to_number(null) as id, s.self_type, s.path, s.object_owner, s.object_name, - s.object_name as name, null as line_no, null as parse_time, - null as description, null as rollback_type, 0 as disabled_flag, - {:owner:}.ut_varchar2_rows() as warnings, - s.x as before_all_list, s.x as after_all_list, - s.x as before_each_list, s.x as before_test_list, - s.x as after_each_list, s.x as after_test_list, - s.y as expected_error_codes, null as test_tags, - s.z as item - from logical_suite_data s - ), - items as ( - select * from {:suite_item_name:} - union all - select * from logical_suites - ) - select c.* - from items c - order by c.object_owner,{:random_seed:}]'; - type t_path_item is record ( object_name varchar2(250), procedure_name varchar2(250), @@ -90,9 +26,9 @@ create or replace package body ut_suite_manager is type t_path_items is table of t_path_item; type t_schema_paths is table of t_path_items index by varchar2(250 char); - subtype t_cached_suite is ut_suite_cache%rowtype; - type tt_cached_suites is table of t_cached_suite; - type t_cached_suites_cursor is ref cursor return t_cached_suite; + cursor c_cached_suites_cursor is select * from table(ut_suite_cache_rows()); + type tt_cached_suites is table of c_cached_suites_cursor%rowtype; + type t_cached_suites_cursor is ref cursor return c_cached_suites_cursor%rowtype; type t_item_levels is table of ut_suite_items index by binary_integer; ------------------ @@ -395,108 +331,6 @@ create or replace package body ut_suite_manager is close a_suite_data_cursor; end reconstruct_from_cache; - function get_missing_objects(a_object_owner varchar2) return ut_varchar2_rows is - l_rows sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_cursor_text varchar2(32767); - l_result ut_varchar2_rows; - l_object_owner varchar2(250); - begin - l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); - l_cursor_text := - q'[select i.object_name - from ]'||l_ut_owner||q'[.ut_suite_cache_package i - where - not exists ( - select 1 from ]'||l_ut_owner||q'[.ut_annotation_cache_info o - where o.object_owner = i.object_owner - and o.object_name = i.object_name - and o.object_type = 'PACKAGE' - ) - and i.object_owner = ']'||l_object_owner||q'[']'; - open l_rows for l_cursor_text; - fetch l_rows bulk collect into l_result limit 1000000; - close l_rows; - return l_result; - end; - - function get_object_names_sql(a_skip_all_objects boolean ) return varchar2 is - begin - return case when not a_skip_all_objects then q'[ - and exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = '{:object_owner:}' - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - )]' else null end; - end; - - function get_path_sql(a_path in varchar2) return varchar2 is - begin - return case when a_path is not null then q'[ - :l_path||'.' like c.path || '.%' /*all children and self*/ - or ( c.path||'.' like :l_path || '.%' --all parents - ]' - else ' :l_path is null and ( :l_path is null ' end; - end; - - function get_object_name_sql(a_object_name in varchar2) return varchar2 is - begin - return case when a_object_name is not null - then ' c.object_name = :a_object_name ' - else ' :a_object_name is null' end; - end; - - function get_procedure_name_sql(a_procedure_name in varchar2) return varchar2 is - begin - return case when a_procedure_name is not null - then ' c.name = :a_procedure_name' - else ' :a_procedure_name is null' end; - end; - - function get_tags_sql(a_tags_count in integer) return varchar2 is - begin - return case when a_tags_count > 0 then - q'[filter_tags as ( - select c.* - from suite_items c - where c.tags multiset intersect :a_tag_list is not empty - ), - suite_items_tags as ( - select c.* from suite_items c - where exists (select 1 from filter_tags t where - t.path||'.' like c.path || '.%' /*all children and self*/ - or c.path||'.' like t.path || '.%' --all parents - ) - )]' - else - q'[dummy as (select 'x' from dual where :a_tag_list is null )]' - end; - end; - - function get_random_seed_sql(a_random_seed positive) return varchar2 is - begin - return case - when a_random_seed is null then q'[ - replace( - case - when c.self_type in ( 'UT_TEST' ) - then substr(c.path, 1, instr(c.path, '.', -1) ) - else c.path - end, '.', chr(0) - ) desc nulls last, - c.object_name desc, - c.line_no, - :a_random_seed]' - else - ' {:owner:}.ut_runner.hash_suite_path( - c.path, :a_random_seed - ) desc nulls last' - end; - end; - function get_cached_suite_data( a_object_owner varchar2, a_path varchar2 := null, @@ -506,53 +340,32 @@ create or replace package body ut_suite_manager is a_random_seed positive, a_tags ut_varchar2_rows := null ) return t_cached_suites_cursor is - l_path varchar2(4000); - l_result sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_sql varchar2(32767); - l_suite_item_name varchar2(20); - l_tags ut_varchar2_rows := coalesce(a_tags,ut_varchar2_rows()); - l_object_owner varchar2(250); - l_object_name varchar2(250); - l_procedure_name varchar2(250); + l_unfiltered_rows ut_suite_cache_rows; + l_result t_cached_suites_cursor; begin - if a_object_owner is not null then - l_object_owner := sys.dbms_assert.qualified_sql_name(a_object_owner); - end if; - if a_object_name is not null then - l_object_name := sys.dbms_assert.qualified_sql_name(a_object_name); - end if; - if a_procedure_name is not null then - l_procedure_name := sys.dbms_assert.qualified_sql_name(a_procedure_name); - end if; - if a_path is null and a_object_name is not null then - execute immediate 'select min(path) - from '||l_ut_owner||q'[.ut_suite_cache - where object_owner = :a_object_owner - and object_name = :a_object_name - and name = nvl(:a_procedure_name, name)]' - into l_path using upper(l_object_owner), upper(l_object_name), upper(a_procedure_name); + l_unfiltered_rows := ut_suite_cache_manager.get_cached_suite_rows( + a_object_owner, + a_path, + a_object_name, + a_procedure_name, + a_random_seed, + a_tags + ); + if a_skip_all_objects then + open l_result for + select c.* from table(l_unfiltered_rows) c; else - if a_path is not null then - l_path := lower(sys.dbms_assert.qualified_sql_name(a_path)); - end if; + open l_result for + select c.* from table(l_unfiltered_rows) c + where exists + ( select 1 + from all_objects a + where a.object_name = c.object_name + and a.owner = c.object_owner + and a.object_type = 'PACKAGE' + ); end if; - l_suite_item_name := case when l_tags.count > 0 then 'suite_items_tags' else 'suite_items' end; - - l_sql := gc_get_cache_suite_sql; - l_sql := replace(l_sql,'{:suite_item_name:}',l_suite_item_name); - l_sql := replace(l_sql,'{:object_list:}',get_object_names_sql(a_skip_all_objects)); - l_sql := replace(l_sql,'{:object_owner:}',upper(l_object_owner)); - l_sql := replace(l_sql,'{:path:}',get_path_sql(l_path)); - l_sql := replace(l_sql,'{:object_name:}',get_object_name_sql(l_object_name)); - l_sql := replace(l_sql,'{:procedure_name:}',get_procedure_name_sql(l_procedure_name)); - l_sql := replace(l_sql,'{:tags:}',get_tags_sql(l_tags.count)); - l_sql := replace(l_sql,'{:random_seed:}',get_random_seed_sql(a_random_seed)); - l_sql := replace(l_sql,'{:owner:}',l_ut_owner); - - ut_event_manager.trigger_event(ut_event_manager.gc_debug, ut_key_anyvalues().put('l_sql',l_sql) ); - - open l_result for l_sql using l_path, l_path, upper(a_object_name), upper(a_procedure_name), l_tags, a_random_seed; + return l_result; end; @@ -621,7 +434,7 @@ create or replace package body ut_suite_manager is build_and_cache_suites(a_owner_name, l_annotations_cursor); if can_skip_all_objects_scan(a_owner_name) or ut_metadata.is_object_visible( 'dba_objects') then - ut_suite_cache_manager.remove_from_cache( a_owner_name, get_missing_objects(a_owner_name) ); + ut_suite_cache_manager.remove_missing_objs_from_cache( a_owner_name ); end if; ut_event_manager.trigger_event('refresh_cache - end'); @@ -686,41 +499,12 @@ create or replace package body ut_suite_manager is end; function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is - l_results ut_object_names := ut_object_names( ); - l_schema_names ut_varchar2_rows; - l_object_names ut_varchar2_rows; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_need_all_objects_scan boolean := true; begin - -- if current user is the onwer or current user has execute any procedure privilege - if ut_metadata.user_has_execute_any_proc() - or (a_schema_names is not null and a_schema_names.count = 1 - and sys_context('userenv','current_schema') = a_schema_names(1)) - then - l_need_all_objects_scan := false; - end if; - for i in 1 .. a_schema_names.count loop refresh_cache(a_schema_names(i)); end loop; - execute immediate 'select c.object_owner, c.object_name - from '||l_ut_owner||q'[.ut_suite_cache_package c - join table ( :a_schema_names ) s - on c.object_owner = upper(s.column_value)]' - || case when l_need_all_objects_scan then q'[ - where exists - (select 1 from all_objects a - where a.owner = c.object_owner - and a.object_name = c.object_name - and a.object_type = 'PACKAGE') - ]' end - bulk collect into l_schema_names, l_object_names using a_schema_names; - l_results.extend( l_schema_names.count ); - for i in 1 .. l_schema_names.count loop - l_results( i ) := ut_object_name( l_schema_names( i ), l_object_names( i ) ); - end loop; - return l_results; + return ut_suite_cache_manager.get_cached_packages( a_schema_names ); end; function get_schema_names(a_paths ut_varchar2_list) return ut_varchar2_rows is @@ -799,146 +583,64 @@ create or replace package body ut_suite_manager is a_owner_name varchar2, a_package_name varchar2 := null ) return sys_refcursor is - l_result sys_refcursor; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_owner_name varchar2(250); - l_package_name varchar2(250); + l_result sys_refcursor; + l_all_suite_info ut_suite_items_info; + l_owner_name varchar2(250) := ut_utils.qualified_sql_name(a_owner_name); + l_package_name varchar2(250) := ut_utils.qualified_sql_name(a_package_name); begin - if a_owner_name is not null then - l_owner_name := sys.dbms_assert.qualified_sql_name(a_owner_name); - end if; - if a_package_name is not null then - l_package_name := sys.dbms_assert.qualified_sql_name(a_package_name); - end if; refresh_cache(l_owner_name); - - open l_result for - q'[with - suite_items as ( - select /*+ cardinality(c 100) */ c.* - from ]'||l_ut_owner||q'[.ut_suite_cache c - where 1 = 1 ]'||case when can_skip_all_objects_scan(l_owner_name) then q'[ - and exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = ']'||upper(l_owner_name)||q'[' - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - )]' end ||q'[ - and c.object_owner = ']'||upper(l_owner_name)||q'[' - and ]' - || case when l_package_name is not null - then 'c.object_name = :a_package_name' - else ':a_package_name is null' end - || q'[ - ), - suitepaths as ( - select distinct - substr(path,1,instr(path,'.',-1)-1) as suitepath, - path, - object_owner - from suite_items - where self_type = 'UT_SUITE' - ), - gen as ( - select rownum as pos - from xmltable('1 to 20') - ), - suitepath_part AS ( - select distinct - substr(b.suitepath, 1, instr(b.suitepath || '.', '.', 1, g.pos) -1) as path, - object_owner - from suitepaths b - join gen g - on g.pos <= regexp_count(b.suitepath, '\w+') - ), - logical_suites as ( - select 'UT_LOGICAL_SUITE' as item_type, - p.path, p.object_owner, - upper( substr(p.path, instr( p.path, '.', -1 ) + 1 ) ) as object_name - from suitepath_part p - where p.path - not in (select s.path from suitepaths s) - ), - items as ( - select object_owner, object_name, name as item_name, - description as item_description, self_type as item_type, line_no as item_line_no, - path, disabled_flag,tags - from suite_items - union all - select object_owner, object_name, object_name as item_name, - null as item_description, item_type, null as item_line_no, - s.path, 0 as disabled_flag, ]'||l_ut_owner||q'[.ut_varchar2_rows() as tags - from logical_suites s - ) - select ]'||l_ut_owner||q'[.ut_suite_item_info( - object_owner, object_name, item_name, item_description, - item_type, item_line_no, path, disabled_flag, tags - ) - from items c]' using upper(l_package_name); + l_all_suite_info := ut_suite_cache_manager.get_cached_suite_info( l_owner_name, l_package_name ); + if can_skip_all_objects_scan( l_owner_name ) then + open l_result for + select value(c) + from table(l_all_suite_info) c + order by c.object_owner, c.object_name, c.item_line_no; + else + open l_result for + select value(c) + from table(l_all_suite_info) c + where exists + ( select 1 + from all_objects a + where a.object_name = c.object_name + and a.owner = c.object_owner + and a.object_type = 'PACKAGE' + ) + order by c.object_owner, c.object_name, c.item_line_no; + end if; return l_result; end; function suite_item_exists( a_owner_name varchar2, a_package_name varchar2 := null, - a_procedure_name varchar2 := null, - a_item_type varchar2 := null + a_procedure_name varchar2 := null ) return boolean is - l_result integer; - l_ut_owner varchar2(250) := ut_utils.ut_owner; - l_owner_name varchar2(250); - l_package_name varchar2(250); - l_procedure_name varchar2(250); + l_count integer := 1; + l_item_exists boolean; + l_owner_name varchar2(250) := upper(a_owner_name); + l_package_name varchar2(250) := upper(a_package_name); + l_procedure_name varchar2(250) := upper(a_procedure_name); begin - if a_owner_name is not null then - l_owner_name := sys.dbms_assert.qualified_sql_name(a_owner_name); - end if; - if a_package_name is not null then - l_package_name := sys.dbms_assert.qualified_sql_name(a_package_name); - end if; - if a_procedure_name is not null then - l_procedure_name := sys.dbms_assert.qualified_sql_name(a_procedure_name); - end if; refresh_cache(l_owner_name); + l_item_exists := ut_suite_cache_manager.suite_item_exists( l_owner_name, l_package_name, l_procedure_name ); + if not can_skip_all_objects_scan( l_owner_name ) then + select count(1) + into l_count + from dual c + where exists + ( select 1 + from all_objects a + where a.object_name = l_package_name + and a.owner = l_owner_name + and a.object_type = 'PACKAGE' + ); + end if; - execute immediate q'[ - select count(1) from dual - where exists ( - select 1 - from ]'||l_ut_owner||q'[.ut_suite_cache c - where 1 = 1 ]'||case when not can_skip_all_objects_scan(l_owner_name) then q'[ - and exists - ( select 1 - from all_objects a - where a.object_name = c.object_name - and a.owner = :a_owner_name - and a.owner = c.object_owner - and a.object_type = 'PACKAGE' - )]' else q'[ - and :a_owner_name is not null ]' end ||q'[ - and c.object_owner = :a_owner_name - and ]' - || case when l_package_name is not null - then 'c.object_name = :a_package_name' - else ':a_package_name is null' end - || q'[ - and ]' - || case when l_procedure_name is not null - then 'c.name = :a_procedure_name' - else ':a_procedure_name is null' end - || q'[ - )]' - into l_result - using - upper(l_owner_name), upper(l_owner_name), - upper(l_package_name), upper(l_procedure_name); - - return l_result > 0; + return l_count > 0 and l_item_exists; end; end ut_suite_manager; diff --git a/source/core/ut_suite_manager.pks b/source/core/ut_suite_manager.pks index fe492b049..093201b36 100644 --- a/source/core/ut_suite_manager.pks +++ b/source/core/ut_suite_manager.pks @@ -24,6 +24,8 @@ create or replace package ut_suite_manager authid current_user is * @private * * Returns a list of Unit Test packages that exist in a given database schema + * IMPORTANT! The returned list is not filtered by user privileges. + * To be used internally only. * * @param a_schema_names list of schemas to return the information for * @return array containing unit test schema and object names @@ -99,8 +101,7 @@ create or replace package ut_suite_manager authid current_user is function suite_item_exists( a_owner_name varchar2, a_package_name varchar2 := null, - a_procedure_name varchar2 := null, - a_item_type varchar2 := null + a_procedure_name varchar2 := null ) return boolean; diff --git a/source/core/ut_utils.pkb b/source/core/ut_utils.pkb index 1fa128c64..5157278fc 100644 --- a/source/core/ut_utils.pkb +++ b/source/core/ut_utils.pkb @@ -488,11 +488,11 @@ create or replace package body ut_utils is return l_xpath; end; - procedure cleanup_temp_tables is + procedure cleanup_session_temp_tables is begin - execute immediate 'delete from ut_compound_data_tmp'; - execute immediate 'delete from ut_compound_data_diff_tmp'; - execute immediate 'delete from ut_json_data_diff_tmp'; + execute immediate 'truncate table dbmspcc_blocks'; + execute immediate 'truncate table dbmspcc_units'; + execute immediate 'truncate table dbmspcc_runs'; end; function to_version(a_version_no varchar2) return t_version is @@ -543,7 +543,7 @@ create or replace package body ut_utils is procedure read_cache_to_dbms_output is l_lines_data sys_refcursor; l_lines ut_varchar2_rows; - c_lines_limit constant integer := 100; + c_lines_limit constant integer := 1000; pragma autonomous_transaction; begin open l_lines_data for select text from ut_dbms_output_cache order by seq_no; @@ -558,7 +558,7 @@ create or replace package body ut_utils is end loop; exit when l_lines_data%notfound; end loop; - delete from ut_dbms_output_cache; + execute immediate 'truncate table ut_dbms_output_cache'; commit; end; @@ -865,5 +865,24 @@ create or replace package body ut_utils is return regexp_replace(a_item,a_prefix||a_connector); end; + function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is + begin + return dbms_crypto.hash(a_data, a_hash_type); + end; + + function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is + begin + return dbms_crypto.hash(a_data, a_hash_type); + end; + + function qualified_sql_name(a_name varchar2) return varchar2 is + begin + return + case + when a_name is not null + then sys.dbms_assert.qualified_sql_name(a_name) + end; + end; + end ut_utils; / diff --git a/source/core/ut_utils.pks b/source/core/ut_utils.pks index 9858bffac..0ce50d24c 100644 --- a/source/core/ut_utils.pks +++ b/source/core/ut_utils.pks @@ -136,6 +136,8 @@ create or replace package ut_utils authid definer is gc_bc_fetch_limit constant integer := 1000; gc_diff_max_rows constant integer := 20; + gc_max_objects_fetch_limit constant integer := 1000000; + /** * Regexp to validate tag */ @@ -307,7 +309,11 @@ create or replace package ut_utils authid definer is function to_xpath(a_list ut_varchar2_list, a_ancestors varchar2 := '/*/') return varchar2; - procedure cleanup_temp_tables; + /* + * Truncates session-level GTT's (on commit preserve rows) + * IMPORTANT: Procedure will do an implicit commit when called + */ + procedure cleanup_session_temp_tables; /** * Converts version string into version record @@ -420,5 +426,24 @@ create or replace package ut_utils authid definer is function strip_prefix(a_item varchar2, a_prefix varchar2, a_connector varchar2 := '/') return varchar2; - end ut_utils; + + subtype t_hash is raw(128); + + /* + * Wrapper function for calling dbms_crypto.hash + */ + function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; + + /* + * Wrapper function for calling dbms_crypto.hash + */ + function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; + + /* + * Verifies that the input string is a qualified SQL name using sys.dbms_assert.qualified_sql_name + * If null value passed returns null + */ + function qualified_sql_name(a_name varchar2) return varchar2; + +end ut_utils; / diff --git a/source/create_grants.sql b/source/create_grants.sql new file mode 100644 index 000000000..5749d5dac --- /dev/null +++ b/source/create_grants.sql @@ -0,0 +1,133 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework +*/ + +@@define_ut3_owner_param.sql + +column 2 new_value 2 noprint +select null as "2" from dual where 1=0; +spool params.sql.tmp +select + case + when '&&2' is null then q'[ACCEPT ut3_user CHAR DEFAULT 'PUBLIC' PROMPT 'Provide schema which should be granted access to the utPLSQL v3 framework (PUBLIC): ']' + else 'define ut3_user=&&2' + end +from dual; + +spool off +set termout on +@params.sql.tmp +set termout off +/* cleanup temporary sql files */ +--try running on windows +$ del params.sql.tmp +--try running on linux/unix +! rm params.sql.tmp +set termout on + +set echo off +set feedback on +set heading off +set verify off + +prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user + +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set current_schema = &&ut3_owner; + +--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_suite_items_info to &ut3_user; +grant execute on &&ut3_owner..ut_suite_item_info to &ut3_user; +grant execute on &&ut3_owner..ut_run_info 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; +grant execute on &&ut3_owner..ut_key_value_pairs to &ut3_user; +grant execute on &&ut3_owner..ut_key_value_pair to &ut3_user; + +--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; +grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user; +grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user; +grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user; +grant execute on &&ut3_owner..ut_be_less_than to &ut3_user; +grant execute on &&ut3_owner..ut_be_like to &ut3_user; +grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; +grant execute on &&ut3_owner..ut_be_null to &ut3_user; +grant execute on &&ut3_owner..ut_be_true to &ut3_user; +grant execute on &&ut3_owner..ut_contain 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; + +--reporters - test results +grant execute on &&ut3_owner..ut_teamcity_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_xunit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_sonar_test_reporter to &ut3_user; +grant execute on &&ut3_owner..ut_realtime_reporter to &ut3_user; +--reporters - coverage +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; +--reporters - debug +grant execute on &&ut3_owner..ut_debug_reporter to &ut3_user; + +--reporters - base types +grant execute on &&ut3_owner..ut_reporters 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; + +--outputs +grant execute on &&ut3_owner..ut_output_buffer_base to &ut3_user; + +--needed internally for selecting from annotation objects within packages that use invoker rights +grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; +grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user; + +--other grants +grant execute on &&ut3_owner..ut_executables to &ut3_user; +grant execute on &&ut3_owner..ut_executable_test to &ut3_user; +grant execute on &&ut3_owner..ut_suite_cache_row to &ut3_user; +grant execute on &&ut3_owner..ut_suite_cache_rows to &ut3_user; + +grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user; +grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user; +grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user; +grant execute on &&ut3_owner..ut_matcher_options to &ut3_user; +grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user; + diff --git a/source/create_synonyms.sql b/source/create_synonyms.sql new file mode 100644 index 000000000..39d559b20 --- /dev/null +++ b/source/create_synonyms.sql @@ -0,0 +1,133 @@ +/* + utPLSQL - Version 3 + Copyright 2016 - 2019 utPLSQL Project + + Licensed under the Apache License, Version 2.0 (the "License"): + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework +*/ + +@@define_ut3_owner_param.sql + +column 2 new_value 2 noprint +select null as "2" from dual where 1=0; +spool params.sql.tmp +select + case + when '&&2' is null then q'[ACCEPT ut3_user CHAR DEFAULT 'PUBLIC' PROMPT 'Provide schema which should own synonyms for the utPLSQL v3 framework (PUBLIC): ']' + else 'define ut3_user=&&2.' + end +from dual; +spool off +set termout on +@params.sql.tmp +set termout off + +spool params.sql.tmp +select + case + when upper('&&ut3_user') = 'PUBLIC' then q'[define action_type='public' + ]'||q'[define ut3_user='' + ]'||q'[define grantee='PUBLIC']' + else q'[define action_type='or replace' + ]'||q'[define grantee='&&ut3_user'] + ]'||q'[define ut3_user='&&ut3_user..']' + end +from dual; + +spool off +set termout on +@params.sql.tmp +set termout off +/* cleanup temporary sql files */ +--try running on windows +$ del params.sql.tmp +--try running on linux/unix +! rm params.sql.tmp +set termout on + +set echo off +set feedback on +set heading off +set verify off + +whenever sqlerror exit failure rollback +whenever oserror exit failure rollback + +alter session set current_schema = &&ut3_owner; + +prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&grantee + +--public API +create &action_type. synonym &ut3_user.ut for &&ut3_owner..ut; +create &action_type. synonym &ut3_user.ut_runner for &&ut3_owner..ut_runner; +create &action_type. synonym &ut3_user.ut_file_mappings for &&ut3_owner..ut_file_mappings; +create &action_type. synonym &ut3_user.ut_file_mapping for &&ut3_owner..ut_file_mapping; +create &action_type. synonym &ut3_user.ut_file_mapper for &&ut3_owner..ut_file_mapper; +create &action_type. synonym &ut3_user.ut_suite_items_info for &&ut3_owner..ut_suite_items_info; +create &action_type. synonym &ut3_user.ut_suite_item_info for &&ut3_owner..ut_suite_item_info; +create &action_type. synonym &ut3_user.ut_run_info for &&ut3_owner..ut_run_info; + +--generic types +create &action_type. synonym &ut3_user.ut_varchar2_list for &&ut3_owner..ut_varchar2_list; +create &action_type. synonym &ut3_user.ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; +create &action_type. synonym &ut3_user.ut_integer_list for &&ut3_owner..ut_integer_list; +create &action_type. synonym &ut3_user.ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; +create &action_type. synonym &ut3_user.ut_key_value_pair for &&ut3_owner..ut_key_value_pair; + +--expectations +create &action_type. synonym &ut3_user.ut_expectation for &&ut3_owner..ut_expectation; +create &action_type. synonym &ut3_user.ut_expectation_compound for &&ut3_owner..ut_expectation_compound; +create &action_type. synonym &ut3_user.ut_expectation_json for &&ut3_owner..ut_expectation_json; + +--matchers +create &action_type. synonym &ut3_user.be_between for &&ut3_owner..be_between; +create &action_type. synonym &ut3_user.be_empty for &&ut3_owner..be_empty; +create &action_type. synonym &ut3_user.be_false for &&ut3_owner..be_false; +create &action_type. synonym &ut3_user.be_greater_or_equal for &&ut3_owner..be_greater_or_equal; +create &action_type. synonym &ut3_user.be_greater_than for &&ut3_owner..be_greater_than; +create &action_type. synonym &ut3_user.be_less_or_equal for &&ut3_owner..be_less_or_equal; +create &action_type. synonym &ut3_user.be_less_than for &&ut3_owner..be_less_than; +create &action_type. synonym &ut3_user.be_like for &&ut3_owner..be_like; +create &action_type. synonym &ut3_user.be_not_null for &&ut3_owner..be_not_null; +create &action_type. synonym &ut3_user.be_null for &&ut3_owner..be_null; +create &action_type. synonym &ut3_user.be_true for &&ut3_owner..be_true; +create &action_type. synonym &ut3_user.contain for &&ut3_owner..contain; +create &action_type. synonym &ut3_user.equal for &&ut3_owner..equal; +create &action_type. synonym &ut3_user.have_count for &&ut3_owner..have_count; +create &action_type. synonym &ut3_user.match for &&ut3_owner..match; + +--reporters - test results +create &action_type. synonym &ut3_user.ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; +create &action_type. synonym &ut3_user.ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; +create &action_type. synonym &ut3_user.ut_junit_reporter for &&ut3_owner..ut_junit_reporter; +create &action_type. synonym &ut3_user.ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; +create &action_type. synonym &ut3_user.ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; +create &action_type. synonym &ut3_user.ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; +create &action_type. synonym &ut3_user.ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter; +--reporters - coverage +create &action_type. synonym &ut3_user.ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; +create &action_type. synonym &ut3_user.ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; +create &action_type. synonym &ut3_user.ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; +create &action_type. synonym &ut3_user.ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; +--reporters - debug +create &action_type. synonym &ut3_user.ut_debug_reporter for &&ut3_owner..ut_debug_reporter; +--reporters - base types +create &action_type. synonym &ut3_user.ut_reporters for &&ut3_owner..ut_reporters; +create &action_type. synonym &ut3_user.ut_reporter_base for &&ut3_owner..ut_reporter_base; +create &action_type. synonym &ut3_user.ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; + +--other synonyms +create &action_type. synonym &ut3_user.dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks; +create &action_type. synonym &ut3_user.dbmspcc_runs for &&ut3_owner..dbmspcc_runs; +create &action_type. synonym &ut3_user.dbmspcc_units for &&ut3_owner..dbmspcc_units; diff --git a/source/create_synonyms_and_grants_for_public.sql b/source/create_synonyms_and_grants_for_public.sql index c19d86261..6d43c6b7a 100644 --- a/source/create_synonyms_and_grants_for_public.sql +++ b/source/create_synonyms_and_grants_for_public.sql @@ -19,173 +19,5 @@ Create all necessary grant for the user who owns test packages and want to execu @@define_ut3_owner_param.sql -set echo off -set feedback on -set heading off -set verify off - -prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to PUBLIC - -whenever sqlerror exit failure rollback -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; -grant execute on &&ut3_owner..ut_be_greater_or_equal to public; -grant execute on &&ut3_owner..ut_be_greater_than to public; -grant execute on &&ut3_owner..ut_be_less_or_equal to public; -grant execute on &&ut3_owner..ut_be_less_than to public; -grant execute on &&ut3_owner..ut_be_like to public; -grant execute on &&ut3_owner..ut_be_not_null to public; -grant execute on &&ut3_owner..ut_be_null to public; -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; -grant execute on &&ut3_owner..ut_junit_reporter to public; -grant execute on &&ut3_owner..ut_tfs_junit_reporter to public; -grant execute on &&ut3_owner..ut_documentation_reporter to public; -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_reporter_base to public; -grant execute on &&ut3_owner..ut_output_reporter_base 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; - ---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_annotations to public; -grant execute on &&ut3_owner..ut_annotation 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; -grant select on &&ut3_owner..ut_suite_cache_package to public; -grant select on &&ut3_owner..ut_suite_cache_schema to public; -grant execute on &&ut3_owner..ut_annotation_cache_manager to public; -grant execute on &&ut3_owner..ut_annotation_parser to public; -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 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; -grant execute on &&ut3_owner..ut_matcher_options to public; -grant execute on &&ut3_owner..ut_matcher_options_items to public; -grant execute on &&ut3_owner..ut_run_info to public; - -prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC - -create public synonym ut_expectation for &&ut3_owner..ut_expectation; -create public synonym ut_expectation_compound for &&ut3_owner..ut_expectation_compound; -create public synonym ut_expectation_json for &&ut3_owner..ut_expectation_json; - -create public synonym be_between for &&ut3_owner..be_between; -create public synonym be_empty for &&ut3_owner..be_empty; -create public synonym be_false for &&ut3_owner..be_false; -create public synonym be_greater_or_equal for &&ut3_owner..be_greater_or_equal; -create public synonym be_greater_than for &&ut3_owner..be_greater_than; -create public synonym be_less_or_equal for &&ut3_owner..be_less_or_equal; -create public synonym be_less_than for &&ut3_owner..be_less_than; -create public synonym be_like for &&ut3_owner..be_like; -create public synonym be_not_null for &&ut3_owner..be_not_null; -create public synonym be_null for &&ut3_owner..be_null; -create public synonym be_true for &&ut3_owner..be_true; -create public synonym contain for &&ut3_owner..contain; -create public synonym equal for &&ut3_owner..equal; -create public synonym have_count for &&ut3_owner..have_count; -create public synonym match for &&ut3_owner..match; - -create public synonym ut for &&ut3_owner..ut; -create public synonym ut_runner for &&ut3_owner..ut_runner; -create public synonym ut_debug_reporter for &&ut3_owner..ut_debug_reporter; -create public synonym ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; -create public synonym ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; -create public synonym ut_junit_reporter for &&ut3_owner..ut_junit_reporter; -create public synonym ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; -create public synonym ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; -create public synonym ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; -create public synonym ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create public synonym ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; -create public synonym ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; -create public synonym ut_reporters for &&ut3_owner..ut_reporters; -create public synonym ut_varchar2_list for &&ut3_owner..ut_varchar2_list; -create public synonym ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; -create public synonym ut_integer_list for &&ut3_owner..ut_integer_list; -create public synonym ut_reporter_base for &&ut3_owner..ut_reporter_base; -create public synonym ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; -create public synonym ut_output_data_row for &&ut3_owner..ut_output_data_row; -create public synonym ut_output_data_rows for &&ut3_owner..ut_output_data_rows; -create public synonym ut_coverage for &&ut3_owner..ut_coverage; -create public synonym ut_coverage_options for &&ut3_owner..ut_coverage_options; -create public synonym ut_coverage_helper for &&ut3_owner..ut_coverage_helper; -create public synonym ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; -create public synonym ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; -create public synonym ut_output_clob_table_buffer for &&ut3_owner..ut_output_clob_table_buffer; -create public synonym ut_file_mappings for &&ut3_owner..ut_file_mappings; -create public synonym ut_file_mapping for &&ut3_owner..ut_file_mapping; -create public synonym ut_file_mapper for &&ut3_owner..ut_file_mapper; -create public synonym ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; -create public synonym ut_key_value_pair for &&ut3_owner..ut_key_value_pair; -create public synonym ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; -create public synonym ut_suite_items_info for &&ut3_owner..ut_suite_items_info; -create public synonym ut_suite_item_info for &&ut3_owner..ut_suite_item_info; -create public synonym ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter; -create public synonym dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks; -create public synonym dbmspcc_runs for &&ut3_owner..dbmspcc_runs; -create public synonym dbmspcc_units for &&ut3_owner..dbmspcc_units; -create public synonym ut_run_info for &&ut3_owner..ut_run_info; +@@create_grants.sql '&&ut3_owner' 'PUBLIC' +@@create_synonyms.sql '&&ut3_owner' 'PUBLIC' diff --git a/source/create_user_grants.sql b/source/create_user_grants.sql index 9da5ebebb..4ca721cf4 100644 --- a/source/create_user_grants.sql +++ b/source/create_user_grants.sql @@ -17,131 +17,4 @@ Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework */ -@@define_ut3_owner_param.sql - -column 2 new_value 2 noprint -select null as "2" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema to which should be granted the utPLSQL v3 ']' - else 'define ut3_user=&&2' - end -from dual; -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on - -set echo off -set feedback on -set heading off -set verify off - -prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -whenever sqlerror exit failure rollback -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; -grant execute on &&ut3_owner..ut_be_greater_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_greater_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_or_equal to &ut3_user; -grant execute on &&ut3_owner..ut_be_less_than to &ut3_user; -grant execute on &&ut3_owner..ut_be_like to &ut3_user; -grant execute on &&ut3_owner..ut_be_not_null to &ut3_user; -grant execute on &&ut3_owner..ut_be_null to &ut3_user; -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; -grant execute on &&ut3_owner..ut_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_tfs_junit_reporter to &ut3_user; -grant execute on &&ut3_owner..ut_documentation_reporter to &ut3_user; -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_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; - ---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_annotations to &ut3_user; -grant execute on &&ut3_owner..ut_annotation 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 &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; -grant execute on &&ut3_owner..ut_annotation_objs_cache_info to &ut3_user; -grant execute on &&ut3_owner..ut_annotation_obj_cache_info to &ut3_user; -grant execute on &&ut3_owner..ut_realtime_reporter to &ut3_user; -grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user; -grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user; -grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user; -grant execute on &&ut3_owner..ut_matcher_options to &ut3_user; -grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user; -grant execute on &&ut3_owner..ut_run_info to &ut3_user; +@@create_grants.sql diff --git a/source/create_user_synonyms.sql b/source/create_user_synonyms.sql index b564dc6c4..ee9f60fdd 100644 --- a/source/create_user_synonyms.sql +++ b/source/create_user_synonyms.sql @@ -17,97 +17,4 @@ Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework */ -@@define_ut3_owner_param.sql - -column 2 new_value 2 noprint -select null as "2" from dual where 1=0; -spool params.sql.tmp -select - case - when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema name where synonyms for the utPLSQL v3 should be created ']' - else 'define ut3_user=&&2' - end -from dual; -spool off -set termout on -@params.sql.tmp -set termout off -/* cleanup temporary sql files */ ---try running on windows -$ del params.sql.tmp ---try running on linux/unix -! rm params.sql.tmp -set termout on - -set echo off -set feedback on -set heading off -set verify off - -prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set current_schema = &&ut3_owner; - -prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to user &&ut3_user - -create or replace synonym &ut3_user..ut_expectation for &&ut3_owner..ut_expectation; -create or replace synonym &ut3_user..ut_expectation_compound for &&ut3_owner..ut_expectation_compound; -create or replace synonym &ut3_user..ut_expectation_json for &&ut3_owner..ut_expectation_json; - -create or replace synonym &ut3_user..be_between for &&ut3_owner..be_between; -create or replace synonym &ut3_user..be_empty for &&ut3_owner..be_empty; -create or replace synonym &ut3_user..be_false for &&ut3_owner..be_false; -create or replace synonym &ut3_user..be_greater_or_equal for &&ut3_owner..be_greater_or_equal; -create or replace synonym &ut3_user..be_greater_than for &&ut3_owner..be_greater_than; -create or replace synonym &ut3_user..be_less_or_equal for &&ut3_owner..be_less_or_equal; -create or replace synonym &ut3_user..be_less_than for &&ut3_owner..be_less_than; -create or replace synonym &ut3_user..be_like for &&ut3_owner..be_like; -create or replace synonym &ut3_user..be_not_null for &&ut3_owner..be_not_null; -create or replace synonym &ut3_user..be_null for &&ut3_owner..be_null; -create or replace synonym &ut3_user..be_true for &&ut3_owner..be_true; -create or replace synonym &ut3_user..contain for &&ut3_owner..contain; -create or replace synonym &ut3_user..equal for &&ut3_owner..equal; -create or replace synonym &ut3_user..have_count for &&ut3_owner..have_count; -create or replace synonym &ut3_user..match for &&ut3_owner..match; - -create or replace synonym &ut3_user..ut for &&ut3_owner..ut; -create or replace synonym &ut3_user..ut_runner for &&ut3_owner..ut_runner; -create or replace synonym &ut3_user..ut_debug_reporter for &&ut3_owner..ut_debug_reporter; -create or replace synonym &ut3_user..ut_teamcity_reporter for &&ut3_owner..ut_teamcity_reporter; -create or replace synonym &ut3_user..ut_xunit_reporter for &&ut3_owner..ut_xunit_reporter; -create or replace synonym &ut3_user..ut_junit_reporter for &&ut3_owner..ut_junit_reporter; -create or replace synonym &ut3_user..ut_tfs_junit_reporter for &&ut3_owner..ut_tfs_junit_reporter; -create or replace synonym &ut3_user..ut_documentation_reporter for &&ut3_owner..ut_documentation_reporter; -create or replace synonym &ut3_user..ut_coverage_html_reporter for &&ut3_owner..ut_coverage_html_reporter; -create or replace synonym &ut3_user..ut_coverage_sonar_reporter for &&ut3_owner..ut_coverage_sonar_reporter; -create or replace synonym &ut3_user..ut_coveralls_reporter for &&ut3_owner..ut_coveralls_reporter; -create or replace synonym &ut3_user..ut_coverage_cobertura_reporter for &&ut3_owner..ut_coverage_cobertura_reporter; -create or replace synonym &ut3_user..ut_reporters for &&ut3_owner..ut_reporters; -create or replace synonym &ut3_user..ut_varchar2_list for &&ut3_owner..ut_varchar2_list; -create or replace synonym &ut3_user..ut_varchar2_rows for &&ut3_owner..ut_varchar2_rows; -create or replace synonym &ut3_user..ut_integer_list for &&ut3_owner..ut_integer_list; -create or replace synonym &ut3_user..ut_reporter_base for &&ut3_owner..ut_reporter_base; -create or replace synonym &ut3_user..ut_output_reporter_base for &&ut3_owner..ut_output_reporter_base; -create or replace synonym &ut3_user..ut_output_data_row for &&ut3_owner..ut_output_data_row; -create or replace synonym &ut3_user..ut_output_data_rows for &&ut3_owner..ut_output_data_rows; -create or replace synonym &ut3_user..ut_coverage for &&ut3_owner..ut_coverage; -create or replace synonym &ut3_user..ut_coverage_options for &&ut3_owner..ut_coverage_options; -create or replace synonym &ut3_user..ut_coverage_helper for &&ut3_owner..ut_coverage_helper; -create or replace synonym &ut3_user..ut_output_buffer_base for &&ut3_owner..ut_output_buffer_base; -create or replace synonym &ut3_user..ut_output_table_buffer for &&ut3_owner..ut_output_table_buffer; -create or replace synonym &ut3_user..ut_output_clob_table_buffer for &&ut3_owner..ut_output_clob_table_buffer; -create or replace synonym &ut3_user..ut_file_mappings for &&ut3_owner..ut_file_mappings; -create or replace synonym &ut3_user..ut_file_mapping for &&ut3_owner..ut_file_mapping; -create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_mapper; -create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs; -create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair; -create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data; -create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter; -create or replace synonym &ut3_user..ut_realtime_reporter for &&ut3_owner..ut_realtime_reporter; -create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks; -create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs; -create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units; -create or replace synonym &ut3_user..ut_run_info for &&ut3_owner..ut_run_info; +@@create_synonyms.sql diff --git a/source/expectations/data_values/ut_compound_data_diff_tmp.sql b/source/expectations/data_values/ut_compound_data_diff_tmp.sql index 19f2a6bb2..e96d716b5 100644 --- a/source/expectations/data_values/ut_compound_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_diff_tmp.sql @@ -23,4 +23,4 @@ create global temporary table ut_compound_data_diff_tmp( constraint ut_compound_data_diff_tmp_chk check( item_no is not null ) -) on commit preserve rows; +) on commit delete rows; diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index cbfc5ac58..51fa61fbd 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -35,7 +35,7 @@ create or replace package body ut_compound_data_helper is ,x.data_id data_id ,position + x.item_no item_no {:columns:} - from {:ut3_owner:}.ut_compound_data_tmp x, + from ut_compound_data_tmp x, xmltable('/ROWSET/ROW' passing x.item_data columns item_data xmltype path '*' ,position for ordinality @@ -53,7 +53,7 @@ create or replace package body ut_compound_data_helper is ,x.data_id data_id ,position + x.item_no item_no {:columns:} - from {:ut3_owner:}.ut_compound_data_tmp x, + from ut_compound_data_tmp x, xmltable('/ROWSET/ROW' passing x.item_data columns item_data xmltype path '*' ,position for ordinality @@ -207,10 +207,9 @@ create or replace package body ut_compound_data_helper is is l_alias varchar2(10) := a_alias; l_col_syntax varchar2(4000); - l_ut_owner varchar2(250) := ut_utils.ut_owner; - begin + begin if a_data_info.is_sql_diffable = 0 then - l_col_syntax := l_ut_owner ||'.ut_compound_data_helper.get_hash('||l_alias||a_data_info.transformed_name||'.getClobVal()) as '||a_data_info.transformed_name ; + l_col_syntax := 'ut_utils.get_hash('||l_alias||a_data_info.transformed_name||'.getClobVal()) as '||a_data_info.transformed_name ; elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type = 'DATE' then l_col_syntax := 'to_date('||l_alias||a_data_info.transformed_name||') as '|| a_data_info.transformed_name; elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('TIMESTAMP') then @@ -334,7 +333,6 @@ create or replace package body ut_compound_data_helper is l_join_on_stmt clob; l_not_equal_stmt clob; l_where_stmt clob; - l_ut_owner varchar2(250) := ut_utils.ut_owner; l_join_by_list ut_varchar2_list; function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is @@ -379,8 +377,7 @@ create or replace package body ut_compound_data_helper is l_compare_sql := replace(l_compare_sql,'{:duplicate_number:}',l_partition_stmt); l_compare_sql := replace(l_compare_sql,'{:columns:}',l_select_stmt); - l_compare_sql := replace(l_compare_sql,'{:ut3_owner:}',l_ut_owner); - l_compare_sql := replace(l_compare_sql,'{:xml_to_columns:}',l_xmltable_stmt); + l_compare_sql := replace(l_compare_sql,'{:xml_to_columns:}',l_xmltable_stmt); l_compare_sql := replace(l_compare_sql,'{:item_no:}',get_item_no(a_unordered)); l_compare_sql := replace(l_compare_sql,'{:join_type:}',get_join_type(a_inclusion_type,a_is_negated)); l_compare_sql := replace(l_compare_sql,'{:join_condition:}',l_join_on_stmt); @@ -536,16 +533,6 @@ create or replace package body ut_compound_data_helper is return l_results; end; - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is - begin - return dbms_crypto.hash(a_data, a_hash_type); - end; - - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash is - begin - return dbms_crypto.hash(a_data, a_hash_type); - end; - function get_fixed_size_hash(a_string varchar2, a_base integer :=0,a_size integer := 9999999) return number is begin return dbms_utility.get_hash_value(a_string,a_base,a_size); @@ -623,8 +610,28 @@ create or replace package body ut_compound_data_helper is ut_utils.remove_error_from_stack(sqlerrm,ut_utils.gc_xml_processing)||chr(10)|| ut_expectation_processor.who_called_expectation(a_error_stack)|| 'Check the query and data for errors.'; - end; - + end; + + procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype) is + begin + insert into ut_compound_data_tmp (data_id, item_no, item_data) values (a_data_id, a_set_id, a_xml); + end; + + function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab is + l_results ut_utils.t_clob_tab; + begin + select xmlserialize( content ucd.item_data no indent) + bulk collect into l_results + from ut_compound_data_tmp tmp + ,xmltable ( '/ROWSET' passing tmp.item_data + columns item_data xmltype PATH '*' + ) ucd + where tmp.data_id = a_data_id + and rownum <= a_max_rows; + + return l_results; + end; + function type_no_length ( a_type_name varchar2) return boolean is begin return case diff --git a/source/expectations/data_values/ut_compound_data_helper.pks b/source/expectations/data_values/ut_compound_data_helper.pks index 8d763c80c..b39df0039 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pks +++ b/source/expectations/data_values/ut_compound_data_helper.pks @@ -90,12 +90,6 @@ create or replace package ut_compound_data_helper authid definer is a_extract_path varchar2 ) return tt_row_diffs; - subtype t_hash is raw(128); - - function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; - - function get_hash(a_data clob, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash; - function get_fixed_size_hash(a_string varchar2, a_base integer :=0,a_size integer :=9999999) return number; function gen_compare_sql( @@ -121,6 +115,10 @@ create or replace package ut_compound_data_helper authid definer is function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor; function create_err_cursor_msg(a_error_stack varchar2) return varchar2; + + procedure save_cursor_data_for_diff(a_data_id raw, a_set_id integer, a_xml xmltype); + + function get_row_data_as_xml(a_data_id raw, a_max_rows integer) return ut_utils.t_clob_tab; /* * Function to return true or false if the type dont have an length diff --git a/source/expectations/data_values/ut_compound_data_tmp.sql b/source/expectations/data_values/ut_compound_data_tmp.sql index 10a88269e..c860a1872 100644 --- a/source/expectations/data_values/ut_compound_data_tmp.sql +++ b/source/expectations/data_values/ut_compound_data_tmp.sql @@ -19,5 +19,5 @@ create global temporary table ut_compound_data_tmp( pk_hash raw(128), duplicate_no integer, constraint ut_cmp_data_tmp_hash_pk unique (data_id, item_no, duplicate_no) -) on commit preserve rows; +) on commit delete rows; --xmltype column item_data store as binary xml; \ No newline at end of file diff --git a/source/expectations/data_values/ut_compound_data_value.tpb b/source/expectations/data_values/ut_compound_data_value.tpb index 3dbf9431a..5874beef8 100644 --- a/source/expectations/data_values/ut_compound_data_value.tpb +++ b/source/expectations/data_values/ut_compound_data_value.tpb @@ -44,18 +44,10 @@ create or replace type body ut_compound_data_value as if not self.is_null() then dbms_lob.createtemporary(l_result, true); ut_utils.append_to_clob(l_result,'Data:'||chr(10)); - --return first c_max_rows rows - execute immediate ' - select xmlserialize( content ucd.item_data no indent) - from '|| ut_utils.ut_owner ||q'[.ut_compound_data_tmp tmp - ,xmltable ( '/ROWSET' passing tmp.item_data - columns item_data xmltype PATH '*' - ) ucd - where tmp.data_id = :data_id - and rownum <= :max_rows]' - bulk collect into l_results using self.data_id, ut_utils.gc_diff_max_rows; - - ut_utils.append_to_clob(l_result,l_results); + ut_utils.append_to_clob( + l_result, + ut_compound_data_helper.get_row_data_as_xml( self.data_id, ut_utils.gc_diff_max_rows ) + ); l_result_string := ut_utils.to_string(l_result,null); dbms_lob.freetemporary(l_result); diff --git a/source/expectations/data_values/ut_data_value_json.tpb b/source/expectations/data_values/ut_data_value_json.tpb index 0f3f5287b..e1ef4d7e2 100644 --- a/source/expectations/data_values/ut_data_value_json.tpb +++ b/source/expectations/data_values/ut_data_value_json.tpb @@ -53,7 +53,7 @@ create or replace type body ut_data_value_json as l_result_string varchar2(32767); l_other ut_data_value_json; l_self ut_data_value_json := self; - l_diff_id ut_compound_data_helper.t_hash; + l_diff_id ut_utils.t_hash; c_max_rows integer := ut_utils.gc_diff_max_rows; l_diffs ut_compound_data_helper.tt_json_diff_tab; l_message varchar2(32767); @@ -95,7 +95,7 @@ create or replace type body ut_data_value_json as end if; dbms_lob.createtemporary(l_result, true); l_other := treat(a_other as ut_data_value_json); - l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); + l_diff_id := ut_utils.get_hash(self.data_id||l_other.data_id); if not l_self.is_null and not l_other.is_null then l_diffs := ut_compound_data_helper.get_json_diffs_tmp(l_diff_id); @@ -129,13 +129,13 @@ create or replace type body ut_data_value_json as member function compare_implementation(a_other in ut_data_value,a_match_options ut_matcher_options) return integer is - l_result integer; - l_other ut_data_value_json; - l_diff_id ut_compound_data_helper.t_hash; + l_result integer; + l_other ut_data_value_json; + l_diff_id ut_utils.t_hash; begin if a_other is of (ut_data_value_json) then l_other := treat(a_other as ut_data_value_json); - l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id); + l_diff_id := ut_utils.get_hash(self.data_id||l_other.data_id); l_result := case when ut_compound_data_helper.insert_json_diffs( diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index eda5b2cd9..dab76a817 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -58,10 +58,7 @@ create or replace type body ut_data_value_refcursor as null; $end l_elements_count := l_elements_count + dbms_xmlgen.getNumRowsProcessed(l_ctx); - execute immediate - 'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' || - 'values (:self_guid, :self_row_count, :l_xml)' - using in self.data_id, l_set_id, l_xml; + ut_compound_data_helper.save_cursor_data_for_diff( self.data_id, l_set_id, l_xml ); l_set_id := l_set_id + c_bulk_rows; end loop; @@ -149,7 +146,7 @@ create or replace type body ut_data_value_refcursor as l_exp_missing_pk ut_varchar2_list := ut_varchar2_list(); c_max_rows integer := ut_utils.gc_diff_max_rows; - l_diff_id ut_compound_data_helper.t_hash; + l_diff_id ut_utils.t_hash; l_diff_row_count integer; l_row_diffs ut_compound_data_helper.tt_row_diffs; l_message varchar2(32767); @@ -243,7 +240,7 @@ create or replace type body ut_data_value_refcursor as --diff rows and row elements if the pk is not missing if l_act_missing_pk.count + l_exp_missing_pk.count = 0 then - l_diff_id := ut_compound_data_helper.get_hash( l_self.data_id || l_other.data_id ); + l_diff_id := ut_utils.get_hash( l_self.data_id || l_other.data_id ); -- First tell how many rows are different l_diff_row_count := ut_compound_data_helper.get_rows_diff_count; @@ -317,14 +314,14 @@ create or replace type body ut_data_value_refcursor as a_other ut_data_value_refcursor, a_diff_cursor_text clob ) return integer is - l_diff_id ut_compound_data_helper.t_hash; + l_diff_id ut_utils.t_hash; l_result integer; --We will start with number od differences being displayed. l_cursor sys_refcursor; l_diff_tab ut_compound_data_helper.t_diff_tab; l_diif_rowcount integer :=0; begin - l_diff_id := ut_compound_data_helper.get_hash(a_self.data_id||a_other.data_id); + l_diff_id := ut_utils.get_hash(a_self.data_id||a_other.data_id); begin l_cursor := ut_compound_data_helper.get_compare_cursor(a_diff_cursor_text, diff --git a/source/expectations/data_values/ut_json_data_diff_tmp.sql b/source/expectations/data_values/ut_json_data_diff_tmp.sql index 3d77dca8b..bfaaa1b72 100644 --- a/source/expectations/data_values/ut_json_data_diff_tmp.sql +++ b/source/expectations/data_values/ut_json_data_diff_tmp.sql @@ -24,4 +24,4 @@ create global temporary table ut_json_data_diff_tmp( exp_json_type varchar2(2000), exp_access_path varchar2(4000), exp_parent_path varchar2(4000) -) on commit preserve rows; +) on commit delete rows; diff --git a/source/install.sql b/source/install.sql index c8eab658c..0e28fa3ab 100644 --- a/source/install.sql +++ b/source/install.sql @@ -57,6 +57,10 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'reporters/ut_ansiconsole_helper.pks' @@install_component.sql 'reporters/ut_ansiconsole_helper.pkb' +@@install_component.sql 'api/ut_suite_item_info.tps' +@@install_component.sql 'api/ut_suite_item_info.tpb' +@@install_component.sql 'api/ut_suite_items_info.tps' + --event manager objects @@install_component.sql 'core/events/ut_event_item.tps' @@install_component.sql 'core/events/ut_event_listener.tps' @@ -133,10 +137,13 @@ alter session set current_schema = &&ut3_owner; @@install_component.sql 'core/annotations/ut_annotation_manager.pkb' --suite builder +@@install_component.sql 'core/types/ut_suite_cache_row.tps' +@@install_component.sql 'core/types/ut_suite_cache_rows.tps' @@install_component.sql 'core/ut_suite_cache_schema.sql' @@install_component.sql 'core/ut_suite_cache_package.sql' @@install_component.sql 'core/ut_suite_cache_seq.sql' @@install_component.sql 'core/ut_suite_cache.sql' + @@install_component.sql 'core/ut_suite_cache_manager.pks' @@install_component.sql 'core/ut_suite_cache_manager.pkb' @@install_component.sql 'core/ut_suite_builder.pks' @@ -295,9 +302,6 @@ prompt Installing DBMSPLSQL Tables objects into &&ut3_owner schema @@install_component.sql 'reporters/ut_documentation_reporter.tpb' --plugin interface API for running utPLSQL -@@install_component.sql 'api/ut_suite_item_info.tps' -@@install_component.sql 'api/ut_suite_item_info.tpb' -@@install_component.sql 'api/ut_suite_items_info.tps' @@install_component.sql 'api/ut_runner.pks' @@install_component.sql 'api/ut_runner.pkb' diff --git a/source/uninstall_objects.sql b/source/uninstall_objects.sql index 9d2c0d61e..6b98bf19c 100644 --- a/source/uninstall_objects.sql +++ b/source/uninstall_objects.sql @@ -70,6 +70,10 @@ drop package ut_suite_cache_manager; drop table ut_suite_cache purge; +drop type ut_suite_cache_rows force; + +drop type ut_suite_cache_row force; + drop sequence ut_suite_cache_seq; drop table ut_suite_cache_package purge; diff --git a/test/install_tests.sql b/test/install_tests.sql deleted file mode 100644 index 9ce06280d..000000000 --- a/test/install_tests.sql +++ /dev/null @@ -1,156 +0,0 @@ -set define off -whenever sqlerror exit failure rollback -whenever oserror exit failure rollback - -alter session set plsql_optimize_level=0; ---Install helpers -@@helpers/ut_test_table.sql -@@helpers/ut_example_tests.pks -@@helpers/ut_example_tests.pkb -@@helpers/ut_without_body.pks -@@helpers/ut_with_invalid_body.pks -@@helpers/ut_with_invalid_body.pkb -@@helpers/other_dummy_object.tps -@@helpers/test_dummy_object.tps -@@helpers/test_dummy_object_list.tps -@@helpers/test_event_object.tps -@@helpers/test_event_list.tps -@@helpers/test_tab_varchar2.tps -@@helpers/test_tab_varray.tps -@@helpers/ut3user#.test_cursor_grants.pks -@@helpers/ut3user#.test_cursor_grants.pkb - ---Install tests -@@core.pks -@@core/min_grant_user/test_min_grant_user.pks -@@api/test_ut_runner.pks -@@api/test_ut_run.pks -@@core/test_ut_utils.pks -@@core/test_ut_suite.pks -@@core/test_ut_test.pks -@@core/annotations/test_annotation_parser.pks -@@core/annotations/test_annotation_manager.pks -@@core/annotations/test_before_after_annotations.pks -@@core/expectations/test_expectation_processor.pks -@@core/expectations/test_matchers.pks -@@core/test_output_buffer.pks -@@core/test_file_mapper.pks -@@core/test_suite_manager.pks -@@core/test_ut_executable.pks -@@core/test_suite_builder.pks -@@core/reporters.pks -@@core/reporters/test_coverage.pks -set define on -@@install_above_12_1.sql 'core/reporters/test_extended_coverage.pks' -@@install_above_12_1.sql 'core/reporters/test_coverage/test_html_extended_reporter.pks' -set define off -@@core/reporters/test_coverage/test_coverage_sonar_reporter.pks -@@core/reporters/test_coverage/test_coveralls_reporter.pks -@@core/reporters/test_coverage/test_cov_cobertura_reporter.pks -@@core/reporters/test_junit_reporter.pks -@@core/reporters/test_realtime_reporter.pks -@@core/reporters/test_debug_reporter.pks -set define on -@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pks' -set define off -@@core/reporters/test_tfs_junit_reporter.pks -@@core/reporters/test_documentation_reporter.pks -@@core/reporters/test_sonar_test_reporter.pks -@@core/reporters/test_teamcity_reporter.pks -@@core/expectations.pks -@@core/expectations/binary/test_be_greater_or_equal.pks -@@core/expectations/binary/test_be_greater_than.pks -@@core/expectations/binary/test_be_less_or_equal.pks -@@core/expectations/binary/test_equal.pks -@@core/expectations/binary/test_expect_to_be_less_than.pks -@@core/expectations/unary/test_expect_to_be_empty.pks -@@core/expectations/unary/test_expect_to_have_count.pks -@@core/expectations/unary/test_expect_not_to_be_null.pks -@@core/expectations/unary/test_expect_to_be_not_null.pks -@@core/expectations/unary/test_expect_to_be_null.pks -@@core/expectations/unary/test_expect_to_be_true_false.pks -@@core/expectations/test_expectations_cursor.pks -@@core/expectations/test_expectation_anydata.pks -@@core/annotations/test_annot_throws_exception.pks - -@@core.pkb -@@core/min_grant_user/test_min_grant_user.pkb -@@api/test_ut_runner.pkb -@@api/test_ut_run.pkb -@@core/test_ut_utils.pkb -@@core/test_ut_suite.pkb -@@core/test_ut_test.pkb -@@core/annotations/test_annotation_parser.pkb -@@core/annotations/test_annotation_manager.pkb -@@core/expectations/test_expectation_processor.pkb -@@core/expectations/test_matchers.pkb -@@core/annotations/test_before_after_annotations.pkb -@@core/test_output_buffer.pkb -@@core/test_file_mapper.pkb -@@core/test_suite_manager.pkb -@@core/test_ut_executable.pkb -@@core/test_suite_builder.pkb -@@core/reporters.pkb -@@core/reporters/test_coverage.pkb -set define on -@@install_above_12_1.sql 'core/reporters/test_extended_coverage.pkb' -@@install_above_12_1.sql 'core/reporters/test_coverage/test_html_extended_reporter.pkb' -set define off -@@core/reporters/test_coverage/test_coverage_sonar_reporter.pkb -@@core/reporters/test_coverage/test_coveralls_reporter.pkb -@@core/reporters/test_coverage/test_cov_cobertura_reporter.pkb -@@core/reporters/test_junit_reporter.pkb -@@core/reporters/test_realtime_reporter.pkb -@@core/reporters/test_debug_reporter.pkb -set define on -@@install_below_12_2.sql 'core/reporters/test_coverage/test_html_proftab_reporter.pkb' -set define off -@@core/reporters/test_tfs_junit_reporter.pkb -@@core/reporters/test_documentation_reporter.pkb -@@core/reporters/test_sonar_test_reporter.pkb -@@core/reporters/test_teamcity_reporter.pkb -@@core/expectations.pkb -@@core/expectations/binary/test_be_greater_or_equal.pkb -@@core/expectations/binary/test_be_greater_than.pkb -@@core/expectations/binary/test_be_less_or_equal.pkb -@@core/expectations/binary/test_equal.pkb -@@core/expectations/binary/test_expect_to_be_less_than.pkb -@@core/expectations/unary/test_expect_to_be_empty.pkb -@@core/expectations/unary/test_expect_to_have_count.pkb -@@core/expectations/unary/test_expect_not_to_be_null.pkb -@@core/expectations/unary/test_expect_to_be_not_null.pkb -@@core/expectations/unary/test_expect_to_be_null.pkb -@@core/expectations/unary/test_expect_to_be_true_false.pkb -@@core/expectations/test_expectations_cursor.pkb -@@core/expectations/test_expectation_anydata.pkb -@@core/annotations/test_annot_throws_exception.pkb - -set linesize 200 -set define on -set verify off -column text format a100 -column error_count noprint new_value error_count - -prompt Validating installation - -set heading on -select type, name, sequence, line, position, text, count(1) over() error_count - from all_errors - where owner = USER - and name not like 'BIN$%' --not recycled - and name != 'UT_WITH_INVALID_BODY' - -- errors only. ignore warnings - and attribute = 'ERROR' - order by name, type, sequence -/ - -begin - if to_number('&&error_count') > 0 then - raise_application_error(-20000, 'Not all sources were successfully installed.'); - else - dbms_output.put_line('Installation completed successfully'); - end if; -end; -/ - -exit; diff --git a/test/install_ut3_user_tests.sql b/test/install_ut3_user_tests.sql index b7361e4aa..ef50432d1 100644 --- a/test/install_ut3_user_tests.sql +++ b/test/install_ut3_user_tests.sql @@ -8,6 +8,9 @@ alter session set plsql_optimize_level=0; @@common_helper/utplsql.pkb prompt Install user tests +@@ut3_user/helpers/some_item.tps +@@ut3_user/helpers/some_items.tps +@@ut3_user/helpers/some_object.tps @@ut3_user/test_user.pks @@ut3_user/expectations/unary/test_expect_not_to_be_null.pks @@ut3_user/expectations/unary/test_expect_to_be_null.pks diff --git a/test/ut3_tester/core.pkb b/test/ut3_tester/core.pkb index 505388a8f..41b6b10d1 100644 --- a/test/ut3_tester/core.pkb +++ b/test/ut3_tester/core.pkb @@ -2,7 +2,7 @@ create or replace package body core is procedure global_setup is begin - ut3.ut_coverage.set_develop_mode(true); + ut3_tester_helper.coverage_helper.set_develop_mode(); --improve performance of test execution by disabling all compiler optimizations ut3_tester_helper.main_helper.execute_autonomous('ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0'); end; diff --git a/test/ut3_tester/core/annotations/test_annotation_manager.pkb b/test/ut3_tester/core/annotations/test_annotation_manager.pkb index 944f6451d..d564e5d57 100644 --- a/test/ut3_tester/core/annotations/test_annotation_manager.pkb +++ b/test/ut3_tester/core/annotations/test_annotation_manager.pkb @@ -212,6 +212,14 @@ create or replace package body test_annotation_manager is procedure trg_not_add_new_package is l_actual sys_refcursor; begin + --Arrange + open l_actual for + select * + from ut3.ut_annotation_cache_info + where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_PACKAGE'; + + ut.expect(l_actual).to_be_empty(); + --Act create_dummy_package(); --Assert @@ -236,7 +244,6 @@ create or replace package body test_annotation_manager is assert_dummy_test_package(l_start_date); end; - --%test(Removes annotations from cache when object was removed and user can't see whole schema) procedure trg_no_data_for_dropped_object is l_actual sys_refcursor; begin diff --git a/test/ut3_tester_helper/coverage_helper.pkb b/test/ut3_tester_helper/coverage_helper.pkb index feac8000d..74a33da54 100644 --- a/test/ut3_tester_helper/coverage_helper.pkb +++ b/test/ut3_tester_helper/coverage_helper.pkb @@ -1,6 +1,10 @@ create or replace package body coverage_helper is - - function get_mock_run_id return integer is + + g_run_ids ut3.ut_coverage.tt_coverage_id_arr; + g_profiler_run_id integer; + g_block_run_id integer; + + function get_mock_proftab_run_id return integer is v_result integer; begin select nvl(min(runid),0) - 1 into v_result @@ -12,23 +16,53 @@ create or replace package body coverage_helper is v_result integer; begin select nvl(min(run_id),0) - 1 into v_result - from dbmspcc_runs; + from ut3.dbmspcc_runs; return v_result; end; - - procedure mock_coverage_data(a_run_id integer,a_user in varchar2) is + + procedure setup_mock_coverage_id is + begin + g_profiler_run_id := get_mock_proftab_run_id(); + ut3.ut_coverage.mock_coverage_id(g_profiler_run_id, ut3.ut_coverage.gc_proftab_coverage); + end; + + procedure setup_mock_coverage_ids(a_profiler_run_id integer, a_block_run_id integer) is + l_coverage_ids ut3.ut_coverage.tt_coverage_id_arr; + begin + l_coverage_ids(ut3.ut_coverage.gc_proftab_coverage) := a_profiler_run_id; + l_coverage_ids(ut3.ut_coverage.gc_block_coverage) := a_block_run_id; + ut3.ut_coverage.mock_coverage_id(l_coverage_ids); + end; + + procedure setup_dummy_coverage is + pragma autonomous_transaction; + begin + create_dummy_12_2_cov_pck(); + create_dummy_12_2_cov_test(); + grant_exec_on_12_2_cov(); + + g_profiler_run_id := get_mock_proftab_run_id(); + g_block_run_id := get_mock_block_run_id(); + setup_mock_coverage_ids(g_profiler_run_id, g_block_run_id); + + mock_block_coverage_data(g_block_run_id, user); + mock_profiler_coverage_data(g_profiler_run_id, user); + commit; + end; + + procedure mock_coverage_data(a_user in varchar2) is c_unit_id constant integer := 1; begin insert into ut3.plsql_profiler_runs ( runid, run_owner, run_date, run_comment) - values(a_run_id, a_user, sysdate, 'unit testing utPLSQL'); + values(g_profiler_run_id, a_user, sysdate, 'unit testing utPLSQL'); insert into ut3.plsql_profiler_units ( runid, unit_number, unit_type, unit_owner, unit_name) - values(a_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE'); + values(g_profiler_run_id, c_unit_id, 'PACKAGE BODY', 'UT3', 'DUMMY_COVERAGE'); insert into ut3.plsql_profiler_data ( runid, unit_number, line#, total_occur, total_time) - select a_run_id, c_unit_id, 4, 1, 1 from dual union all - select a_run_id, c_unit_id, 5, 0, 0 from dual union all - select a_run_id, c_unit_id, 7, 1, 1 from dual; + select g_profiler_run_id, c_unit_id, 4, 1, 1 from dual union all + select g_profiler_run_id, c_unit_id, 5, 0, 0 from dual union all + select g_profiler_run_id, c_unit_id, 7, 1, 1 from dual; end; procedure cleanup_dummy_coverage(a_run_id in integer) is @@ -39,7 +73,27 @@ create or replace package body coverage_helper is delete from ut3.plsql_profiler_runs where runid = a_run_id; commit; end; - + + procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer) is + pragma autonomous_transaction; + begin + begin execute immediate q'[drop package ut3.test_block_dummy_coverage]'; exception when others then null; end; + begin execute immediate q'[drop package ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long]'; exception when others then null; end; + delete from dbmspcc_blocks where run_id = a_block_id; + delete from dbmspcc_units where run_id = a_block_id; + delete from dbmspcc_runs where run_id = a_block_id; + cleanup_dummy_coverage(a_prof_id); + commit; + end; + + procedure cleanup_dummy_coverage is + begin + cleanup_dummy_coverage( + g_block_run_id, + g_profiler_run_id + ); + end; + procedure create_dummy_coverage_package is pragma autonomous_transaction; begin @@ -151,6 +205,8 @@ create or replace package body coverage_helper is end; end;]'; + execute immediate 'begin UT3.DUMMY_COVERAGE_1.grant_myself(); end;'; + execute immediate 'begin UT3.TEST_DUMMY_COVERAGE_1.grant_myself(); end;'; end; procedure drop_dummy_coverage_test_1 is @@ -160,13 +216,6 @@ create or replace package body coverage_helper is execute immediate q'[drop package UT3.TEST_DUMMY_COVERAGE_1]'; end; - procedure grant_exec_on_cov_1 is - pragma autonomous_transaction; - begin - execute immediate 'begin UT3.DUMMY_COVERAGE_1.grant_myself(); end;'; - execute immediate 'begin UT3.TEST_DUMMY_COVERAGE_1.grant_myself(); end;'; - end; - --12.2 Setup procedure create_dummy_12_2_cov_pck is pragma autonomous_transaction; @@ -253,23 +302,17 @@ create or replace package body coverage_helper is select a_run_id, c_unit_id, 7, 1, 1 from dual; end; - procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer) is - pragma autonomous_transaction; - begin - begin execute immediate q'[drop package ut3.test_block_dummy_coverage]'; exception when others then null; end; - begin execute immediate q'[drop package ut3.dummy_coverage_package_with_an_amazingly_long_name_that_you_would_not_think_of_in_real_life_project_because_its_simply_too_long]'; exception when others then null; end; - delete from dbmspcc_blocks where run_id = a_block_id; - delete from dbmspcc_units where run_id = a_block_id; - delete from dbmspcc_runs where run_id = a_block_id; - cleanup_dummy_coverage(a_prof_id); - commit; - end; - procedure grant_exec_on_12_2_cov is pragma autonomous_transaction; begin execute immediate 'begin UT3.DUMMY_COVERAGE_PACKAGE_WITH_AN_AMAZINGLY_LONG_NAME_THAT_YOU_WOULD_NOT_THINK_OF_IN_REAL_LIFE_PROJECT_BECAUSE_ITS_SIMPLY_TOO_LONG.grant_myself(); end;'; execute immediate 'begin UT3.TEST_BLOCK_DUMMY_COVERAGE.grant_myself(); end;'; end; + + procedure set_develop_mode is + begin + ut3.ut_coverage.set_develop_mode(true); + end; + end; / diff --git a/test/ut3_tester_helper/coverage_helper.pks b/test/ut3_tester_helper/coverage_helper.pks index 73ff7b448..9e152707b 100644 --- a/test/ut3_tester_helper/coverage_helper.pks +++ b/test/ut3_tester_helper/coverage_helper.pks @@ -1,30 +1,34 @@ create or replace package coverage_helper is - g_run_id integer; - type prof_runs_tab is table of ut3.plsql_profiler_runs%rowtype; - function get_mock_run_id return integer; - function get_mock_block_run_id return integer; - procedure cleanup_dummy_coverage(a_run_id in integer); - procedure mock_coverage_data(a_run_id integer,a_user in varchar2); + function get_mock_proftab_run_id return integer; + + procedure setup_mock_coverage_id; + + procedure mock_coverage_data(a_user in varchar2); + + procedure cleanup_dummy_coverage; + + procedure setup_dummy_coverage; - --Profiler coveage + --Profiler coverage procedure create_dummy_coverage_package; procedure create_dummy_coverage_test; procedure grant_exec_on_cov; procedure mock_profiler_coverage_data(a_run_id integer,a_user in varchar2); procedure drop_dummy_coverage_pkg; + procedure create_dummy_coverage_test_1; procedure drop_dummy_coverage_test_1; - procedure grant_exec_on_cov_1; - + --Block coverage procedure create_dummy_12_2_cov_pck; procedure create_dummy_12_2_cov_test; procedure mock_block_coverage_data(a_run_id integer,a_user in varchar2); - procedure cleanup_dummy_coverage(a_block_id in integer, a_prof_id in integer); procedure grant_exec_on_12_2_cov; + + procedure set_develop_mode; end; / diff --git a/test/ut3_tester_helper/main_helper.pkb b/test/ut3_tester_helper/main_helper.pkb index de28083f9..2370f1db6 100644 --- a/test/ut3_tester_helper/main_helper.pkb +++ b/test/ut3_tester_helper/main_helper.pkb @@ -100,7 +100,7 @@ create or replace package body main_helper is pragma autonomous_transaction; begin delete from ut3.ut_annotation_cache_info - where object_owner = user and object_type = 'PACKAGE' and object_name in ('DUMMY_PACKAGE','DUMMY_TEST_PACKAGE'); + where object_owner = 'UT3_TESTER' and object_type = 'PACKAGE' and object_name in ('DUMMY_PACKAGE','DUMMY_TEST_PACKAGE'); commit; end; diff --git a/test/ut3_tester_helper/run_helper.pkb b/test/ut3_tester_helper/run_helper.pkb index 9bc2b7f79..bea89b901 100644 --- a/test/ut3_tester_helper/run_helper.pkb +++ b/test/ut3_tester_helper/run_helper.pkb @@ -627,6 +627,35 @@ create or replace package body run_helper is begin delete from ut3.ut_output_buffer_tmp; end; - + + function get_annotation_cache_info_cur( + a_owner varchar2, + a_type varchar2 + ) return sys_refcursor is + l_result sys_refcursor; + begin + open l_result for + select * from ut3.ut_annotation_cache_info + where object_owner = a_owner and object_type = a_type; + + return l_result; + end; + + function get_annotation_cache_cursor( + a_owner varchar2, + a_type varchar2, + a_name varchar2 := null + ) return sys_refcursor is + l_result sys_refcursor; + begin + open l_result for + select * + from ut3.ut_annotation_cache_info i + join ut3.ut_annotation_cache c on c.cache_id = i.cache_id + where object_owner = a_owner and object_type = a_type and object_name = nvl( a_name, object_name ); + + return l_result; + end; + end; / diff --git a/test/ut3_tester_helper/run_helper.pks b/test/ut3_tester_helper/run_helper.pks index e06401eae..0f5e5a925 100644 --- a/test/ut3_tester_helper/run_helper.pks +++ b/test/ut3_tester_helper/run_helper.pks @@ -63,6 +63,17 @@ create or replace package run_helper is function ut_output_buffer_tmp return t_out_buff_tab pipelined; procedure delete_buffer; - + + function get_annotation_cache_info_cur( + a_owner varchar2, + a_type varchar2 + ) return sys_refcursor; + + function get_annotation_cache_cursor( + a_owner varchar2, + a_type varchar2, + a_name varchar2 := null + ) return sys_refcursor; + end; / diff --git a/test/ut3_user/api/test_ut_runner.pkb b/test/ut3_user/api/test_ut_runner.pkb index 2baf4cbeb..28370ca96 100644 --- a/test/ut3_user/api/test_ut_runner.pkb +++ b/test/ut3_user/api/test_ut_runner.pkb @@ -198,54 +198,64 @@ end;'; procedure test_purge_cache_schema_type is l_actual sys_refcursor; begin + --Arrange + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( + a_owner => sys_context('USERENV', 'CURRENT_USER'), + a_type => 'PROCEDURE' + ); - open l_actual for - select * from ut3.ut_annotation_cache_info - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PROCEDURE'; ut.expect(l_actual).not_to_be_empty(); --Act ut3.ut_runner.purge_cache(sys_context('USERENV', 'CURRENT_USER'),'PROCEDURE'); --Assert - open l_actual for - select * from ut3.ut_annotation_cache_info - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PROCEDURE'; + + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( + a_owner => sys_context('USERENV', 'CURRENT_USER'), + a_type => 'PROCEDURE' + ); --Cache purged for object owner/type ut.expect(l_actual).to_be_empty(); - open l_actual for - select * from ut3.ut_annotation_cache_info - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE'; + + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( + a_owner => sys_context('USERENV', 'CURRENT_USER'), + a_type => 'PACKAGE' + ); --Cache not purged for other types ut.expect(l_actual).not_to_be_empty(); - open l_actual for - select * from ut3.ut_annotation_cache_info - where object_owner = 'UT3_TESTER_HELPER' and object_type = 'PROCEDURE'; + + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_info_cur( + a_owner => 'UT3_TESTER_HELPER', + a_type => 'PROCEDURE' + ); --Cache not purged for other owners ut.expect(l_actual).not_to_be_empty(); end; procedure test_rebuild_cache_schema_type is - l_actual integer; + l_actual sys_refcursor; begin --Act - ut3.ut_runner.rebuild_annotation_cache(sys_context('USERENV', 'CURRENT_USER'),'PACKAGE'); + ut3.ut_runner.rebuild_annotation_cache( sys_context('USERENV', 'CURRENT_USER'), 'PACKAGE' ); --Assert - select count(1) into l_actual - from ut3.ut_annotation_cache_info i - join ut3.ut_annotation_cache c on c.cache_id = i.cache_id - where object_owner = sys_context('USERENV', 'CURRENT_USER') and object_type = 'PACKAGE' and object_name = 'DUMMY_TEST_PACKAGE'; + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_cursor( + a_owner => sys_context('USERENV', 'CURRENT_USER'), + a_type => 'PACKAGE', + a_name => 'DUMMY_TEST_PACKAGE' + ); + --Rebuild cache for sys_context('USERENV', 'CURRENT_USER')/packages - ut.expect(l_actual).to_equal(4); + ut.expect(l_actual).to_have_count(4); - select count(1) into l_actual - from ut3.ut_annotation_cache_info i - join ut3.ut_annotation_cache c on c.cache_id = i.cache_id - where object_owner = 'UT3_TESTER_HELPER' and object_type = 'PROCEDURE'; + l_actual := ut3_tester_helper.run_helper.get_annotation_cache_cursor( + a_owner => sys_context('USERENV', 'CURRENT_USER'), + a_type => 'PACKAGE' + ); --Did not rebuild cache for ut3/procedures - ut.expect(l_actual).to_equal(0); + ut.expect(l_actual).to_have_count(0); end; procedure test_get_suites_info_notag is diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index daa3389bc..4603f9eff 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -1967,23 +1967,15 @@ Diff:% end; procedure compare_rec_colltype_as_cols is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3.ut_annotated_object; - l_expected_tab ut3.ut_annotated_object; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab some_object; + l_expected_tab some_object; begin - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_actual_tab from dual; - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) into l_expected_tab from dual; --Arrange @@ -1999,24 +1991,16 @@ Diff:% end; procedure compare_rec_colltype_as_attr is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3.ut_annotated_object; - l_expected_tab ut3.ut_annotated_object; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab some_object; + l_expected_tab some_object; begin - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_actual_tab from dual; - - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_expected_tab from dual; + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + into l_actual_tab from dual; + + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + into l_expected_tab from dual; --Arrange open l_actual for select l_actual_tab as nested_table from dual; @@ -2031,60 +2015,44 @@ Diff:% end; procedure compare_collection_in_rec is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3.ut_annotated_object; - l_expected_tab ut3.ut_annotated_object; - l_expected_message varchar2(32767); - l_actual_message varchar2(32767); + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab some_object; + l_expected_tab some_object; begin - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_actual_tab from dual; - - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_expected_tab from dual; - + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + into l_actual_tab from dual; + + select some_object( user,'TEST', sysdate, some_items( some_item(1,'test'), some_item(2,'test') ) ) + into l_expected_tab from dual; + --Arrange open l_actual for select l_actual_tab as nested_table from dual; open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS'); + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS'); --Assert ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0); end; procedure compare_rec_coll_as_cols_fl is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3.ut_annotated_object; - l_expected_tab ut3.ut_annotated_object; + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab some_object; + l_expected_tab some_object; l_expected_message varchar2(32767); l_actual_message varchar2(32767); l_date date := sysdate; begin - select ut3.ut_annotated_object('TEST','TEST','TEST', l_date, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_actual_tab - from dual; - - select ut3.ut_annotated_object('TEST','TEST','TEST', l_date, - ut3.ut_annotations(ut3.ut_annotation(1,'1test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_expected_tab - from dual; - + select some_object( 'TEST','TEST', l_date, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) + into l_actual_tab from dual; + + select some_object( 'TEST','TEST', l_date, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) + into l_expected_tab from dual; + --Arrange open l_actual for select rownum rn, l_actual_tab as nested_table from dual; @@ -2099,48 +2067,41 @@ Diff:% l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ] %Diff: %Rows: [ 1 differences ] -%PK TEST - Actual: TESTTESTTEST%1testtesttest2testtesttest% -%PK TEST - Expected: TESTTESTTEST%11testtesttest2testtesttest%]'; +%PK TEST - Actual: TESTTEST%1BAD2test% +%PK TEST - Expected: TESTTEST%1TEST2test%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert ut.expect(l_actual_message).to_be_like(l_expected_message); - --ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); - end; + end; procedure compare_rec_coll_as_join is - l_actual sys_refcursor; - l_expected sys_refcursor; - l_actual_tab ut3.ut_annotated_object; - l_expected_tab ut3.ut_annotated_object; + l_actual sys_refcursor; + l_expected sys_refcursor; + l_actual_tab some_object; + l_expected_tab some_object; l_expected_message varchar2(32767); l_actual_message varchar2(32767); begin - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'1test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_actual_tab from dual; - - select ut3.ut_annotated_object('TEST','TEST','TEST', SYSDATE, - ut3.ut_annotations(ut3.ut_annotation(1,'test','test','test'), - ut3.ut_annotation(2,'test','test','test')) - ) - into l_expected_tab from dual; - + select some_object( 'TEST','TEST', sysdate, some_items( some_item(1,'BAD'), some_item(2,'test') ) ) + into l_actual_tab from dual; + + select some_object( 'TEST','TEST', sysdate, some_items( some_item(1,'TEST'), some_item(2,'test') ) ) + into l_expected_tab from dual; + --Arrange open l_actual for select l_actual_tab as nested_table from dual; open l_expected for select l_expected_tab as nested_table from dual; --Act - ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ANNOTATIONS/TEXT'); + ut3.ut.expect(l_actual).to_equal(l_expected).join_by('NESTED_TABLE/ITEMS/ID'); --Assert - l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]% + l_expected_message := q'[%Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]% %Diff:% %Unable to join sets:% -%Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in expected% -%Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in actual% +%Join key NESTED_TABLE/ITEMS/ID does not exists in expected% +%Join key NESTED_TABLE/ITEMS/ID does not exists in actual% %Please make sure that your join clause is not refferring to collection element%]'; l_actual_message := ut3_tester_helper.main_helper.get_failed_expectations(1); --Assert @@ -2550,7 +2511,7 @@ Diff:% begin l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: ORA-01476: divisor is equal to zero -at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2561 ut3.ut.expect(l_actual).to_equal(l_expected);% +at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2522 ut3.ut.expect(l_actual).to_equal(l_expected);% Check the query and data for errors.'; open l_actual for @@ -2575,7 +2536,7 @@ Check the query and data for errors.'; l_exp_message :='ORA-20218: SQL exception thrown when fetching data from cursor: ORA-01476: divisor is equal to zero -at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2586 ut3.ut.expect(l_actual).to_equal(l_expected);% +at "UT3$USER#.TEST_EXPECTATIONS_CURSOR%", line 2547 ut3.ut.expect(l_actual).to_equal(l_expected);% Check the query and data for errors.'; open l_expected for diff --git a/test/ut3_user/helpers/some_item.tps b/test/ut3_user/helpers/some_item.tps new file mode 100644 index 000000000..336f44d9a --- /dev/null +++ b/test/ut3_user/helpers/some_item.tps @@ -0,0 +1,6 @@ +create or replace type some_item force as object( + item_id number(38), + item_name varchar2(250) +) +/ + diff --git a/test/ut3_user/helpers/some_items.tps b/test/ut3_user/helpers/some_items.tps new file mode 100644 index 000000000..8b984f8a4 --- /dev/null +++ b/test/ut3_user/helpers/some_items.tps @@ -0,0 +1,2 @@ +create or replace type some_items force as table of some_item +/ diff --git a/test/ut3_user/helpers/some_object.tps b/test/ut3_user/helpers/some_object.tps new file mode 100644 index 000000000..024379974 --- /dev/null +++ b/test/ut3_user/helpers/some_object.tps @@ -0,0 +1,7 @@ +create or replace type some_object force as object( + object_owner varchar2(250), + object_name varchar2(250), + create_time timestamp, + items some_items +) +/ diff --git a/test/ut3_user/reporters.pkb b/test/ut3_user/reporters.pkb index d6a104242..6d6d573aa 100644 --- a/test/ut3_user/reporters.pkb +++ b/test/ut3_user/reporters.pkb @@ -148,7 +148,7 @@ end;]'; end; procedure check_xml_encoding_included( - a_reporter ut3.ut_output_reporter_base, + a_reporter ut3.ut_reporter_base, a_client_character_set varchar2 ) is l_results ut3.ut_varchar2_list; @@ -164,7 +164,7 @@ end;]'; end; procedure check_xml_failure_escaped( - a_reporter ut3.ut_output_reporter_base + a_reporter ut3.ut_reporter_base ) is l_results ut3.ut_varchar2_list; l_actual clob; diff --git a/test/ut3_user/reporters.pks b/test/ut3_user/reporters.pks index 54800fa4a..d1ed8635f 100644 --- a/test/ut3_user/reporters.pks +++ b/test/ut3_user/reporters.pks @@ -10,12 +10,12 @@ create or replace package reporters is procedure reporters_cleanup; procedure check_xml_encoding_included( - a_reporter ut3.ut_output_reporter_base, + a_reporter ut3.ut_reporter_base, a_client_character_set varchar2 ); procedure check_xml_failure_escaped( - a_reporter ut3.ut_output_reporter_base + a_reporter ut3.ut_reporter_base ); end reporters; diff --git a/test/ut3_user/reporters/test_coverage.pkb b/test/ut3_user/reporters/test_coverage.pkb index 6b094f2ae..738ce67e4 100644 --- a/test/ut3_user/reporters/test_coverage.pkb +++ b/test/ut3_user/reporters/test_coverage.pkb @@ -1,11 +1,5 @@ create or replace package body test_coverage is - function get_mock_run_id return integer is - v_result integer; - begin - return ut3_tester_helper.coverage_helper.get_mock_run_id(); - end; - procedure create_dummy_coverage_pkg is begin ut3_tester_helper.coverage_helper.create_dummy_coverage_package(); @@ -16,21 +10,10 @@ create or replace package body test_coverage is procedure setup_dummy_coverage is pragma autonomous_transaction; begin - g_run_id := get_mock_run_id(); - ut3.ut_coverage.mock_coverage_id(g_run_id, ut3.ut_coverage.gc_proftab_coverage); - ut3_tester_helper.coverage_helper.mock_coverage_data(g_run_id,user); + ut3_tester_helper.coverage_helper.setup_mock_coverage_id(); + ut3_tester_helper.coverage_helper.mock_coverage_data(user); commit; end; - procedure drop_dummy_coverage_pkg is - begin - ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg(); - end; - - procedure cleanup_dummy_coverage is - begin - ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(g_run_id); - end; - end; / diff --git a/test/ut3_user/reporters/test_coverage.pks b/test/ut3_user/reporters/test_coverage.pks index d56597d11..4c19e125a 100644 --- a/test/ut3_user/reporters/test_coverage.pks +++ b/test/ut3_user/reporters/test_coverage.pks @@ -3,18 +3,15 @@ create or replace package test_coverage is --%suite --%suitepath(utplsql.test_user.reporters) - g_run_id integer; - --%beforeall procedure create_dummy_coverage_pkg; --%beforeall procedure setup_dummy_coverage; - --%afterall - procedure drop_dummy_coverage_pkg; - --%afterall - procedure cleanup_dummy_coverage; + --%afterall(ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg) + + --%afterall(ut3_tester_helper.coverage_helper.cleanup_dummy_coverage) end; / diff --git a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb index b3c0439b4..183492eb7 100644 --- a/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_cov_cobertura_reporter.pkb @@ -79,7 +79,7 @@ create or replace package body test_cov_cobertura_reporter is ]'; - test_coverage.cleanup_dummy_coverage; + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(); --Act select * bulk collect into l_results diff --git a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb index 0be0e8ce3..2d36d45cb 100644 --- a/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb +++ b/test/ut3_user/reporters/test_coverage/test_coveralls_reporter.pkb @@ -66,7 +66,7 @@ null, ]} ]'; - test_coverage.cleanup_dummy_coverage; + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(); --Act select * diff --git a/test/ut3_user/reporters/test_extended_coverage.pkb b/test/ut3_user/reporters/test_extended_coverage.pkb index bb8bd27a6..33d42d9ef 100644 --- a/test/ut3_user/reporters/test_extended_coverage.pkb +++ b/test/ut3_user/reporters/test_extended_coverage.pkb @@ -1,37 +1,5 @@ create or replace package body test_extended_coverage is - g_run_id ut3.ut_coverage.tt_coverage_id_arr; - - function get_mock_block_run_id return integer is - begin - return ut3_tester_helper.coverage_helper.get_mock_block_run_id(); - end; - - function get_mock_proftab_run_id return integer is - begin - return ut3_tester_helper.coverage_helper.get_mock_run_id(); - end; - - procedure setup_dummy_coverage is - pragma autonomous_transaction; - begin - ut3_tester_helper.coverage_helper.create_dummy_12_2_cov_pck(); - ut3_tester_helper.coverage_helper.create_dummy_12_2_cov_test(); - ut3_tester_helper.coverage_helper.grant_exec_on_12_2_cov(); - g_run_id(ut3.ut_coverage.gc_block_coverage) := get_mock_block_run_id(); - g_run_id(ut3.ut_coverage.gc_proftab_coverage) := get_mock_proftab_run_id(); - ut3.ut_coverage.mock_coverage_id(g_run_id); - ut3_tester_helper.coverage_helper.mock_block_coverage_data(g_run_id(ut3.ut_coverage.gc_block_coverage),user); - ut3_tester_helper.coverage_helper.mock_profiler_coverage_data(g_run_id(ut3.ut_coverage.gc_proftab_coverage),user); - commit; - end; - - procedure cleanup_dummy_coverage is - begin - ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(g_run_id(ut3.ut_coverage.gc_block_coverage) - ,g_run_id(ut3.ut_coverage.gc_proftab_coverage)); - end; - procedure coverage_for_object is l_expected clob; l_actual clob; diff --git a/test/ut3_user/reporters/test_extended_coverage.pks b/test/ut3_user/reporters/test_extended_coverage.pks index aaef20877..a8460aa3a 100644 --- a/test/ut3_user/reporters/test_extended_coverage.pks +++ b/test/ut3_user/reporters/test_extended_coverage.pks @@ -3,11 +3,9 @@ create or replace package test_extended_coverage is --%suite --%suitepath(utplsql.test_user.reporters) - --%beforeall - procedure setup_dummy_coverage; + --%beforeall(ut3_tester_helper.coverage_helper.setup_dummy_coverage) - --%afterall - procedure cleanup_dummy_coverage; + --%afterall(ut3_tester_helper.coverage_helper.cleanup_dummy_coverage) --%test(Coverage is gathered for specified object - extended coverage type) procedure coverage_for_object; diff --git a/test/ut3_user/reporters/test_proftab_coverage.pkb b/test/ut3_user/reporters/test_proftab_coverage.pkb index c5ad8c112..74a33772e 100644 --- a/test/ut3_user/reporters/test_proftab_coverage.pkb +++ b/test/ut3_user/reporters/test_proftab_coverage.pkb @@ -1,16 +1,5 @@ create or replace package body test_proftab_coverage is - procedure create_dummy_coverage_test_1 is - begin - ut3_tester_helper.coverage_helper.create_dummy_coverage_test_1(); - ut3_tester_helper.coverage_helper.grant_exec_on_cov_1(); - end; - - procedure drop_dummy_coverage_test_1 is - begin - ut3_tester_helper.coverage_helper.drop_dummy_coverage_test_1(); - end; - procedure coverage_for_object is l_expected clob; l_actual clob; @@ -117,9 +106,9 @@ create or replace package body test_proftab_coverage is a_include_objects => ut3.ut_varchar2_list( 'ut3.dummy_coverage' ) ) ); - ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(test_coverage.g_run_id); + ut3_tester_helper.coverage_helper.cleanup_dummy_coverage(); ut3_tester_helper.coverage_helper.drop_dummy_coverage_pkg(); - create_dummy_coverage_test_1; + ut3_tester_helper.coverage_helper.create_dummy_coverage_test_1(); --Act select * diff --git a/test/ut3_user/reporters/test_proftab_coverage.pks b/test/ut3_user/reporters/test_proftab_coverage.pks index 1bb5c10cd..6f2548158 100644 --- a/test/ut3_user/reporters/test_proftab_coverage.pks +++ b/test/ut3_user/reporters/test_proftab_coverage.pks @@ -18,10 +18,8 @@ create or replace package test_proftab_coverage is --%test(Coverage data is not cached between runs - issue #562 ) --%aftertest(ut3$user#.test_coverage.create_dummy_coverage_pkg) --%aftertest(ut3$user#.test_coverage.setup_dummy_coverage) - --%aftertest(drop_dummy_coverage_test_1) + --%aftertest(ut3_tester_helper.coverage_helper.drop_dummy_coverage_test_1) procedure coverage_tmp_data_refresh; - procedure drop_dummy_coverage_test_1; - end; / diff --git a/test/ut3_user/test_user.pkb b/test/ut3_user/test_user.pkb index ca84a1c69..9fec79d96 100644 --- a/test/ut3_user/test_user.pkb +++ b/test/ut3_user/test_user.pkb @@ -2,7 +2,7 @@ create or replace package body test_user is procedure global_setup is begin - ut3.ut_coverage.set_develop_mode(true); + ut3_tester_helper.coverage_helper.set_develop_mode(); --improve performance of test execution by disabling all compiler optimizations ut3_tester_helper.main_helper.execute_autonomous('ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0'); end;