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
Added suite_cache.
Refactored lots of code for suite parsing/building.
(Acceptance) tests need rework due to changes in test execution ordering.
  • Loading branch information
jgebal committed Nov 4, 2018
commit f475b7cfea9d7e080b937c31ef88c9c2074ea566
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotated_object.tps
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ create type ut_annotated_object as object(
object_owner varchar2(250),
object_name varchar2(250),
object_type varchar2(50),
parse_time date,
parse_time timestamp,
annotations ut_annotations
)
/
Expand Down
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_cache_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ create table ut_annotation_cache_info (
object_owner varchar2(250) not null,
object_name varchar2(250) not null,
object_type varchar2(250) not null,
parse_time date not null,
parse_time timestamp not null,
constraint ut_annotation_cache_info_pk primary key(cache_id),
constraint ut_annotation_cache_info_uk unique (object_owner, object_name, object_type)
) organization index;
Expand Down
14 changes: 7 additions & 7 deletions source/core/annotations/ut_annotation_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ create or replace package body ut_annotation_cache_manager as
pragma autonomous_transaction;
begin
update ut_annotation_cache_info i
set i.parse_time = sysdate
set i.parse_time = systimestamp
where (i.object_owner, i.object_name, i.object_type)
in ((a_object.object_owner, a_object.object_name, a_object.object_type))
returning cache_id into l_cache_id;
if sql%rowcount = 0 then
insert into ut_annotation_cache_info
(cache_id, object_owner, object_name, object_type, parse_time)
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, sysdate)
values (ut_annotation_cache_seq.nextval, a_object.object_owner, a_object.object_name, a_object.object_type, systimestamp)
returning cache_id into l_cache_id;
end if;

Expand Down Expand Up @@ -66,15 +66,15 @@ create or replace package body ut_annotation_cache_manager as
on (o.object_name = i.object_name
and o.object_type = i.object_type
and o.object_owner = i.object_owner)
when matched then update set parse_time = sysdate
when matched then update set parse_time = systimestamp
when not matched then insert
(cache_id, object_owner, object_name, object_type, parse_time)
values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, sysdate);
values (ut_annotation_cache_seq.nextval, o.object_owner, o.object_name, o.object_type, systimestamp);

commit;
end;

function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor is
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor is
l_results sys_refcursor;
begin
open l_results for q'[
Expand All @@ -92,9 +92,9 @@ 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_date is null then ':a_parse_date is null' else 'i.parse_time > :a_parse_date' 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_date;
using a_cached_objects, a_parse_time;
return l_results;
end;

Expand Down
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_cache_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create or replace package ut_annotation_cache_manager authid definer as
*
* @param a_cached_objects a `ut_annotation_objs_cache_info` list with information about objects to get from cache
*/
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_date date) return sys_refcursor;
function get_annotations_for_objects(a_cached_objects ut_annotation_objs_cache_info, a_parse_time timestamp) return sys_refcursor;

/**
* Removes cached information about annotations for objects on the list and updates parse_time in cache info table.
Expand Down
38 changes: 9 additions & 29 deletions source/core/annotations/ut_annotation_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ create or replace package body ut_annotation_manager as
------------------------------
--private definitions

function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotation_objs_cache_info is
function get_annotation_objs_info(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotation_objs_cache_info is
l_rows sys_refcursor;
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_objects_view varchar2(200) := ut_metadata.get_dba_view('dba_objects');
Expand All @@ -31,7 +31,7 @@ create or replace package body ut_annotation_manager as
object_owner => o.owner,
object_name => o.object_name,
object_type => o.object_type,
needs_refresh => case when o.last_ddl_time < i.parse_time then 'N' else 'Y' end
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
Expand All @@ -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 > :a_parse_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 Expand Up @@ -148,37 +148,17 @@ create or replace package body ut_annotation_manager as


procedure rebuild_annotation_cache( a_object_owner varchar2, a_object_type varchar2, a_info_rows ut_annotation_objs_cache_info) is
l_objects_in_cache_count integer;
l_objects_to_parse ut_annotation_objs_cache_info := ut_annotation_objs_cache_info();
begin
--get list of objects in cache
select count(1) into l_objects_in_cache_count
from table(a_info_rows) x where x.needs_refresh = 'N';

--if cache is empty and there are objects to parse
if l_objects_in_cache_count = 0 and a_info_rows.count > 0 then
select value(x)bulk collect into l_objects_to_parse from table(a_info_rows) x where x.needs_refresh = 'Y';

--if some source needs parsing and putting into cache
if l_objects_to_parse.count > 0 then
build_annot_cache_for_sources(
a_object_owner, a_object_type,
--all schema objects
get_sources_to_annotate(a_object_owner, a_object_type),
a_info_rows
get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_parse),
l_objects_to_parse
);

--if not all in cache, get list of objects to rebuild cache for
elsif l_objects_in_cache_count < a_info_rows.count then

select value(x)bulk collect into l_objects_to_parse from table(a_info_rows) x where x.needs_refresh = 'Y';

--if some source needs parsing and putting into cache
if l_objects_to_parse.count > 0 then
build_annot_cache_for_sources(
a_object_owner, a_object_type,
get_sources_to_annotate(a_object_owner, a_object_type, l_objects_to_parse),
l_objects_to_parse
);
end if;

end if;
end;

Expand All @@ -194,7 +174,7 @@ create or replace package body ut_annotation_manager as
);
end;

function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined is
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined is
l_info_rows ut_annotation_objs_cache_info;
l_cursor sys_refcursor;
l_results ut_annotated_objects;
Expand Down
2 changes: 1 addition & 1 deletion source/core/annotations/ut_annotation_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ create or replace package ut_annotation_manager authid current_user as
* @param a_parse_date date when object was last parsed
* @return array containing annotated objects along with annotations for each object (nested)
*/
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date date := null) return ut_annotated_objects pipelined;
function get_annotated_objects(a_object_owner varchar2, a_object_type varchar2, a_parse_date timestamp := null) return ut_annotated_objects pipelined;

/**
* Rebuilds annotation cache for a specified schema and object type.
Expand Down
24 changes: 20 additions & 4 deletions source/core/types/ut_logical_suite.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ create or replace type body ut_logical_suite as
) return self as result is
begin
self.self_type := $$plsql_unit;
self.init(a_object_owner, a_object_name, a_name, 0);
self.init(a_object_owner, a_object_name, a_name, null);
self.path := a_path;
self.disabled_flag := ut_utils.boolean_to_int(false);
self.items := ut_suite_items();
Expand All @@ -33,10 +33,26 @@ create or replace type body ut_logical_suite as
return true;
end;

member procedure add_item(self in out nocopy ut_logical_suite, a_item ut_suite_item) is
overriding member procedure add_item(
self in out nocopy ut_logical_suite,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
) is
begin
self.items.extend;
self.items(self.items.last) := a_item;
if a_expected_level > a_current_level then
if self.items.last is not null then
self.items(self.items.last).add_item(a_item, a_expected_level, a_current_level+1);
else
raise_application_error(-20000, 'cannot add suite item to sub suite at level '||a_expected_level||'. suite items at level '||a_current_level||' are empty');
end if;
else
if self.items is null then
self.items := ut_suite_items();
end if;
self.items.extend;
self.items(self.items.last) := a_item;
end if;
end;

overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite) is
Expand Down
7 changes: 6 additions & 1 deletion source/core/types/ut_logical_suite.tps
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ create or replace type ut_logical_suite under ut_suite_item (
self in out nocopy ut_logical_suite, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_path varchar2
) return self as result,
member function is_valid(self in out nocopy ut_logical_suite) return boolean,
member procedure add_item(self in out nocopy ut_logical_suite, a_item ut_suite_item),
overriding member procedure add_item(
self in out nocopy ut_logical_suite,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
),
overriding member procedure mark_as_skipped(self in out nocopy ut_logical_suite),
overriding member procedure set_rollback_type(self in out nocopy ut_logical_suite, a_rollback_type integer),
overriding member function do_execute(self in out nocopy ut_logical_suite) return boolean,
Expand Down
10 changes: 10 additions & 0 deletions source/core/types/ut_run.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ create or replace type body ut_run as
null;
end;

overriding member procedure add_item(
self in out nocopy ut_run,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
) is
begin
raise_application_error(-20000, 'Cannot add a suite item to ut_run');
end;

overriding member function do_execute(self in out nocopy ut_run) return boolean is
l_completed_without_errors boolean;
begin
Expand Down
6 changes: 6 additions & 0 deletions source/core/types/ut_run.tps
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ create or replace type ut_run under ut_suite_item (
a_client_character_set varchar2 := null
) return self as result,
overriding member procedure mark_as_skipped(self in out nocopy ut_run),
overriding member procedure add_item(
self in out nocopy ut_run,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
),
overriding member function do_execute(self in out nocopy ut_run) return boolean,
overriding member procedure calc_execution_result(self in out nocopy ut_run),
overriding member procedure mark_as_errored(self in out nocopy ut_run, a_error_stack_trace varchar2),
Expand Down
8 changes: 7 additions & 1 deletion source/core/types/ut_suite_item.tps
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ create or replace type ut_suite_item force under ut_event_item (
/**
* Time when the suite item was last parsed from package source
*/
parse_time date,
parse_time timestamp,
--execution result fields
start_time timestamp with time zone,
end_time timestamp with time zone,
Expand All @@ -63,6 +63,12 @@ create or replace type ut_suite_item force under ut_event_item (
member procedure init(self in out nocopy ut_suite_item, a_object_owner varchar2, a_object_name varchar2, a_name varchar2, a_line_no integer),
member function get_disabled_flag return boolean,
not instantiable member procedure mark_as_skipped(self in out nocopy ut_suite_item),
not instantiable member procedure add_item(
self in out nocopy ut_suite_item,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
),
member procedure set_rollback_type(self in out nocopy ut_suite_item, a_rollback_type integer),
member function get_rollback_type return integer,
member function create_savepoint_if_needed return varchar2,
Expand Down
10 changes: 10 additions & 0 deletions source/core/types/ut_test.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ create or replace type body ut_test as
return;
end;

overriding member procedure add_item(
self in out nocopy ut_test,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
) is
begin
raise_application_error(-20000, 'Cannot add a suite item to ut_test');
end;

overriding member procedure mark_as_skipped(self in out nocopy ut_test) is
begin
ut_event_manager.trigger_event(ut_utils.gc_before_test, self);
Expand Down
6 changes: 6 additions & 0 deletions source/core/types/ut_test.tps
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ create or replace type ut_test under ut_suite_item (
a_line_no integer, a_expected_error_codes ut_integer_list := null
) return self as result,
overriding member procedure mark_as_skipped(self in out nocopy ut_test),
overriding member procedure add_item(
self in out nocopy ut_test,
a_item ut_suite_item,
a_expected_level integer := 1,
a_current_level integer :=1
),
overriding member function do_execute(self in out nocopy ut_test) return boolean,
overriding member procedure calc_execution_result(self in out nocopy ut_test),
overriding member procedure mark_as_errored(self in out nocopy ut_test, a_error_stack_trace varchar2),
Expand Down
Loading