Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e41d6f9
Interim commit with lots of dirty code - got to a place where I get t…
jgebal Oct 30, 2018
f475b7c
Added `suite_cache`.
jgebal Nov 2, 2018
4dc48e6
Interim commit - performance check on Travis.
jgebal Nov 4, 2018
1611e09
Interim commit some fixes to old tests, examples and code itself.
jgebal Nov 4, 2018
15163a8
Resolved issue with sorting of nested-tables.
jgebal Nov 4, 2018
1b14bb5
Fixing re-enabled test.
jgebal Nov 4, 2018
3bc8da5
Adding missing items to uninstall.
jgebal Nov 4, 2018
8911f97
Small improvements and cleanup.
jgebal Nov 5, 2018
a1f6b34
Removing duplicate with block.
jgebal Nov 6, 2018
59f7738
Adding cache cleanup and "intelligent" join to all_source, only when …
jgebal Nov 11, 2018
cb9cf97
Resolving some sonar violations.
jgebal Nov 11, 2018
8779025
Moving away from full outer join.
jgebal Nov 11, 2018
b3e98be
Reorganizing code a bit.
jgebal Nov 11, 2018
64dfb41
Output buffer&reporters performance improvements
jgebal Nov 12, 2018
9ea805b
Increased fetch size for coverage sources tmp seeding.
jgebal Nov 12, 2018
248bf8c
Small refactoring.
jgebal Nov 13, 2018
8fc2ea6
Further optimizations to suite parsing.
jgebal Nov 15, 2018
3543e3d
Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing
jgebal Nov 15, 2018
23c0557
Fixed formal parameter names
jgebal Nov 15, 2018
f7f6811
Revert "Disabled `PLSQL_OPTIMIZE_LEVEL=0` for testing"
jgebal Nov 15, 2018
d002d18
Refactored procedure `get_unit_test_info` to return more relevant inf…
jgebal Nov 16, 2018
e1f1eec
Renamed `get_unit_test_info` to `get_suites_info` - the latter one wa…
jgebal Nov 16, 2018
d8d251f
Improved automation of `refresh_sources.sh`
jgebal Nov 16, 2018
eb3df21
Fixing failing test.
jgebal Nov 16, 2018
d211348
Added control over rollback behavior in `ut_runner.run`
jgebal Nov 17, 2018
f342195
Reverting rollback changes - they should go as a separate PR.
jgebal Nov 17, 2018
eeae79b
Added documentation for new functionality.
jgebal Nov 17, 2018
74ec9a1
Removed unused code.
jgebal Nov 18, 2018
44d61d9
Recovering exception handlers as they are needed for handling invalid…
jgebal Nov 18, 2018
360a889
Moved some of old tests into new tests.
jgebal Nov 18, 2018
0ee3ce2
Added missing endcontext in `test_ut_test`
jgebal Nov 18, 2018
48aa338
Removed unused constants.
jgebal Nov 18, 2018
b33aaae
Added additional test for display of parser warnings.
jgebal Nov 18, 2018
e8ea644
Merge branch 'develop' into feature/suite_query_api
jgebal Nov 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Interim commit - performance check on Travis.
  • Loading branch information
jgebal committed Nov 4, 2018
commit 4dc48e676f14bae492c5c511f2ac500afa6a2674
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ create or replace package body ut_annotation_cache_manager as
join ut_annotation_cache_info i
on o.object_owner = i.object_owner and o.object_name = i.object_name and o.object_type = i.object_type
join ut_annotation_cache c on i.cache_id = c.cache_id
where ]'|| case when a_parse_time is null then ':a_parse_date is null' else 'i.parse_time > :a_parse_time' end ||q'[
where ]'|| case when a_parse_time is null then ':a_parse_date is null' else 'i.parse_time >= :a_parse_time' end ||q'[
group by i.object_owner, i.object_name, i.object_type, i.parse_time]'
using a_cached_objects, a_parse_time;
return l_results;
Expand Down
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ create or replace package body ut_annotation_manager as
|| case
when a_parse_date is null
then ':a_parse_date is null'
else 'o.last_ddl_time > cast(:a_parse_date as date)'
else 'o.last_ddl_time >= cast(:a_parse_date as date)'
end;
open l_rows for l_cursor_text using a_object_owner, a_object_type, a_parse_date;
fetch l_rows bulk collect into l_result limit 1000000;
Expand Down
244 changes: 192 additions & 52 deletions source/core/ut_suite_builder.pkb

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion source/core/ut_suite_builder.pks
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ create or replace package ut_suite_builder authid current_user is
a_procedure_name varchar2 := null
) return ut_suite_items;

function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names;

function build_suites_from_annotations(
a_owner_name varchar2,
a_annotated_objects sys_refcursor,
a_path varchar2 := null,
a_object_name varchar2 := null,
a_procedure_name varchar2 := null
a_procedure_name varchar2 := null,
a_skip_all_objects boolean := false
) return ut_suite_items;

end ut_suite_builder;
Expand Down
81 changes: 10 additions & 71 deletions source/core/ut_suite_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,6 @@ create or replace package body ut_suite_cache_manager is
limitations under the License.
*/

function get_cached_suite_data(
a_schema_name varchar2,
a_path varchar2 := null,
a_object_name varchar2 := null,
a_procedure_name varchar2 := null
) return t_cached_suites_cursor is
l_path varchar2( 4000 );
l_result sys_refcursor;
begin
if a_path is null and a_object_name is not null then
select min(path) into l_path
from ut_suite_cache
where object_owner = upper(a_schema_name) and object_name = lower(a_object_name) and
name = nvl(lower(a_procedure_name), name);
else
l_path := lower( a_path );
end if;


open l_result for
select c.*
from ut_suite_cache c
-- join all_objects a
-- on a.owner = x.object_owner
-- and a.object_name = x.object_name
-- and a.object_type = 'PACKAGE'
where ( l_path like c.path || '.' || '%'
or ( c.path like l_path || '%'
and c.object_name = nvl(lower(a_object_name), c.object_name)
and c.name = nvl(lower(a_procedure_name), c.name)
)
) and c.object_owner = upper(a_schema_name)
order by c.object_owner,
replace(case
when c.self_type in ( 'UT_TEST' )
then substr(c.path, 1, instr(c.path, '.', -1) - 1)
else c.path
end, '.', chr(0)) desc nulls last,
c.object_name desc,
c.line_no desc;

return l_result;
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;
begin
select distinct c.object_owner, c.object_name
bulk collect into l_schema_names, l_object_names
from ut_suite_cache c
-- join all_objects a
-- on a.owner = c.object_owner
-- and a.object_name = c.object_name
-- and a.object_type = 'PACKAGE'
join table ( a_schema_names ) s on c.object_owner = upper(s.column_value);
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;
end;

function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache is
l_cache_parse_time timestamp;
begin
Expand All @@ -95,6 +30,7 @@ create or replace package body ut_suite_cache_manager is
pragma autonomous_transaction;
l_parse_time timestamp;
l_cached_parse_time timestamp;
l_object_owner varchar2(250) := upper(a_object_owner);
begin
if a_suite_items.count = 0 then
return;
Expand All @@ -115,17 +51,20 @@ create or replace package body ut_suite_cache_manager is

update ut_suite_cache_schema t
set t.parse_time = l_parse_time
where object_owner = a_object_owner;
where object_owner = l_object_owner;

if sql%rowcount = 0 then
insert into ut_suite_cache_schema
(object_owner, parse_time)
values (a_object_owner, l_parse_time);
values (l_object_owner, l_parse_time);
end if;

delete from ut_suite_cache t
where (t.object_name, t.object_owner)
in (select s.object_name, s.object_owner from table(a_suite_items) s where s.self_type != 'UT_LOGICAL_SUITE');
in (
select upper(s.object_name), upper(s.object_owner)
from table(a_suite_items) s where s.self_type != 'UT_LOGICAL_SUITE'
);


insert into ut_suite_cache t
Expand All @@ -134,7 +73,7 @@ create or replace package body ut_suite_cache_manager is
line_no, parse_time, description,
rollback_type, disabled_flag, warnings
)
select self_type, path, object_owner, object_name, name,
select self_type, path, upper(object_owner), upper(object_name), upper(name),
line_no, parse_time, description,
rollback_type, disabled_flag, warnings
from table(a_suite_items) s
Expand All @@ -155,7 +94,7 @@ create or replace package body ut_suite_cache_manager is
from table(a_suite_items) x
where x.self_type in( 'UT_SUITE', 'UT_SUITE_CONTEXT' ) )
select s.i.self_type as self_type, s.i.path as path,
s.i.object_owner as object_owner, s.i.object_name as object_name, s.i.name as name,
upper(s.i.object_owner) as object_owner, upper(s.i.object_name) as object_name, upper(s.i.name) as name,
s.i.line_no as line_no, s.i.parse_time as parse_time, s.i.description as description,
s.i.rollback_type as rollback_type, s.i.disabled_flag as disabled_flag, s.i.warnings as warnings,
s.i.before_all_list as before_all_list, s.i.after_all_list as after_all_list,
Expand All @@ -178,7 +117,7 @@ create or replace package body ut_suite_cache_manager is
from table ( a_suite_items ) x
where x.self_type in ( 'UT_TEST' ) )
select s.t.self_type as self_type, s.t.path as path,
s.t.object_owner as object_owner, s.t.object_name as object_name, s.t.name as name,
upper(s.t.object_owner) as object_owner, upper(s.t.object_name) as object_name, upper(s.t.name) as name,
s.t.line_no as line_no, s.t.parse_time as parse_time, s.t.description as description,
s.t.rollback_type as rollback_type, s.t.disabled_flag as disabled_flag, s.t.warnings as warnings,
null before_all_list, null after_all_list,
Expand Down
12 changes: 0 additions & 12 deletions source/core/ut_suite_cache_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,9 @@ create or replace package ut_suite_cache_manager authid definer is
/**
* Responsible for storing and retrieving suite data from cache
*/
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;

procedure save_cache(a_object_owner varchar2, a_suite_items ut_suite_items);

function get_cached_suite_data(
a_schema_name varchar2,
a_path varchar2 := null,
a_object_name varchar2 := null,
a_procedure_name varchar2 := null
) return t_cached_suites_cursor;

function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names;

function get_schema_parse_time(a_schema_name varchar2) return timestamp result_cache;

end ut_suite_cache_manager;
Expand Down
11 changes: 10 additions & 1 deletion source/core/ut_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ create or replace package body ut_suite_manager is

function get_schema_ut_packages(a_schema_names ut_varchar2_rows) return ut_object_names is
begin
return ut_suite_cache_manager.get_schema_ut_packages(a_schema_names);
return ut_suite_builder.get_schema_ut_packages(a_schema_names);
end;

procedure validate_paths(a_paths in ut_varchar2_list) is
Expand Down Expand Up @@ -170,6 +170,15 @@ create or replace package body ut_suite_manager is
l_path_item.object_name,
l_path_item.procedure_name
);
if l_suites.count = 0 then
if l_path_item.suite_path is not null then
raise_application_error(ut_utils.gc_suite_package_not_found,'No suite packages found for path '||l_schema||':'||l_path_item.suite_path|| '.');
elsif l_path_item.procedure_name is not null then
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite test '||l_schema||'.'||l_path_item.object_name|| '.'||l_path_item.procedure_name||' does not exist');
else
raise_application_error(ut_utils.gc_suite_package_not_found,'Suite package '||l_schema||'.'||l_path_item.object_name|| ' does not exist');
end if;
end if;
l_index := l_suites.first;
while l_index is not null loop
l_objects_to_run.extend;
Expand Down
4 changes: 4 additions & 0 deletions source/create_synonyms_and_grants_for_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ 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_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;
Expand Down
4 changes: 4 additions & 0 deletions source/create_user_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ 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_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;
Expand Down
11 changes: 6 additions & 5 deletions test/core/test_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ create or replace package body test_suite_builder is
a_owner_name => 'UT3_TESTER',
a_annotated_objects => l_cursor,
a_path => null,
a_object_name => a_package_name
a_object_name => a_package_name,
a_skip_all_objects => true
);
l_suite := treat( l_suites(l_suites.first) as ut3.ut_logical_suite);

Expand Down Expand Up @@ -395,7 +396,7 @@ create or replace package body test_suite_builder is
ut3.ut_annotation(1, 'suite','Cool', null),
ut3.ut_annotation(2, 'beforeall',null, 'first_before_all'),
ut3.ut_annotation(3, 'beforeall',null, 'another_before_all'),
ut3.ut_annotation(4, 'beforeeach',null, 'first_bfore_each'),
ut3.ut_annotation(4, 'beforeeach',null, 'first_before_each'),
ut3.ut_annotation(5, 'beforeeach',null, 'another_before_each'),
ut3.ut_annotation(6, 'aftereach',null, 'first_after_each'),
ut3.ut_annotation(7, 'aftereach',null, 'another_after_each'),
Expand Down Expand Up @@ -640,9 +641,6 @@ create or replace package body test_suite_builder is
'%<UT_LOGICAL_SUITE>' ||
'%<WARNINGS/>' ||
'%<ITEMS>' ||
'<UT_SUITE_ITEM>' ||
'%<NAME>suite_level_test</NAME><DESCRIPTION>In suite</DESCRIPTION><PATH>some_package.suite_level_test</PATH>' ||
'%</UT_SUITE_ITEM>' ||
'<UT_SUITE_ITEM>' ||
'%<NAME>a_context</NAME><DESCRIPTION>A context</DESCRIPTION><PATH>some_package.a_context</PATH>' ||
'%<ITEMS>' ||
Expand All @@ -655,6 +653,9 @@ create or replace package body test_suite_builder is
'%</BEFORE_ALL_LIST>' ||
'<AFTER_ALL_LIST/>' ||
'</UT_SUITE_ITEM>' ||
'<UT_SUITE_ITEM>' ||
'%<NAME>suite_level_test</NAME><DESCRIPTION>In suite</DESCRIPTION><PATH>some_package.suite_level_test</PATH>' ||
'%</UT_SUITE_ITEM>' ||
'</ITEMS>' ||
'<BEFORE_ALL_LIST>' ||
'%<OBJECT_NAME>some_package</OBJECT_NAME><PROCEDURE_NAME>suite_level_beforeall</PROCEDURE_NAME>' ||
Expand Down
37 changes: 12 additions & 25 deletions test/core/test_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ end test_package_with_ctx;]';
ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);
ut.expect(l_test1_suite.rollback_type).to_equal(ut3.ut_utils.gc_rollback_manual);
l_test2_suite := treat(l_test1_suite.items(3) as ut3.ut_logical_suite);
l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
Expand Down Expand Up @@ -515,7 +515,6 @@ end test_package_with_ctx;]';

l_test0_suite ut3.ut_logical_suite;
l_test1_suite ut3.ut_suite;
l_test2_suite ut3.ut_suite;
begin
--Act
l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list(c_path));
Expand All @@ -529,7 +528,7 @@ end test_package_with_ctx;]';
l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_suite);

ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);
ut.expect(l_test1_suite.items.count).to_equal(2);

ut.expect(l_test1_suite.items(1).name).to_equal('test1');
ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1');
Expand All @@ -545,12 +544,6 @@ end test_package_with_ctx;]';
ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_each_list.count).to_be_greater_than(0);
ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).disabled_flag).to_equal(0);

-- temporary behavior.
-- decided that when executed by package, not path, only that package has to execute
l_test2_suite := treat(l_test1_suite.items(3) as ut3.ut_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
end;

procedure test_top_pack_by_name_cu is
Expand All @@ -573,7 +566,7 @@ end test_package_with_ctx;]';
l_test1_suite := treat(l_test0_suite.items(1) as ut3.ut_suite);

ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);
ut.expect(l_test1_suite.items.count).to_equal(2);

ut.expect(l_test1_suite.items(1).name).to_equal('test1');
ut.expect(l_test1_suite.items(1).description).to_equal('Test1 from test package 1');
Expand All @@ -589,12 +582,6 @@ end test_package_with_ctx;]';
ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).before_each_list.count).to_be_greater_than(0);
ut.expect(treat(l_test1_suite.items(2) as ut3.ut_test).disabled_flag).to_equal(0);

-- temporary behavior.
-- decided that when executed by package, not path, only that package has to execute
l_test2_suite := treat(l_test1_suite.items(3) as ut3.ut_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
end;

procedure test_top_pack_by_path is
Expand All @@ -618,7 +605,7 @@ end test_package_with_ctx;]';

ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);
l_test2_suite := treat(l_test1_suite.items(3) as ut3.ut_logical_suite);
l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
Expand All @@ -645,7 +632,7 @@ end test_package_with_ctx;]';

ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);
l_test2_suite := treat(l_test1_suite.items(3) as ut3.ut_logical_suite);
l_test2_suite := treat(l_test1_suite.items(1) as ut3.ut_logical_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
Expand Down Expand Up @@ -942,7 +929,7 @@ end;]';
l_objects_to_run ut3.ut_suite_items;
begin
l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('ut3.failing_non_existing'));
ut.fail('Non existing package didnt raised exception');
ut.fail('Non existing package did not raise exception');
exception
when others then
ut.expect(sqlerrm).to_be_like('%failing_non_existing%');
Expand All @@ -952,7 +939,7 @@ end;]';
l_objects_to_run ut3.ut_suite_items;
begin
l_objects_to_run := ut3.ut_suite_manager.configure_execution_by_path(ut3.ut_varchar2_list('failing_non_existing'));
ut.fail('Non existing package without schema didnt raised exception');
ut.fail('Non existing package without schema did not raise exception');
exception
when others then
ut.expect(sqlerrm).to_be_like('%ORA-44001: invalid schema%');
Expand All @@ -979,10 +966,10 @@ end;]';
ut.expect(l_test.name).to_equal('test1');
ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager');

l_test := treat(l_suite.items(2) as ut3.ut_test);

ut.expect(l_test.name).to_equal('test2');
ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager');
-- l_test := treat(l_suite.items(2) as ut3.ut_test);
--
-- ut.expect(l_test.name).to_equal('test2');
-- ut.expect(l_test.description).to_equal('A test description, though with comma, is assigned by suite_manager');

end;
procedure setup_desc_with_comma is
Expand Down Expand Up @@ -1029,7 +1016,7 @@ end;';
ut.fail('Cache not invalidated on package drop');
exception
when others then
ut.expect(sqlerrm).to_be_like('%tst_package_to_be_dropped%not found%');
ut.expect(sqlerrm).to_be_like('%tst_package_to_be_dropped%does not exist%');
end;

end;
Expand Down