Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
86d4d0a
Initial check-in.
lwasylow Mar 18, 2022
f1f6d71
Tidy up code to make sure we got distinct set of expanded tests.
lwasylow Mar 19, 2022
1454221
Adding extra fields.
lwasylow Mar 23, 2022
ce4df28
Stage 3. Fixing error calls.
lwasylow Mar 29, 2022
273962b
Fixing issue with a non visible tests.
lwasylow Mar 29, 2022
a753e66
Fixing ORA-600
lwasylow Mar 30, 2022
0d8d34d
Cleanup Phase1.
lwasylow Mar 30, 2022
95ddec1
Adding tests.
lwasylow Mar 31, 2022
83dbdaa
Updating documentation.
lwasylow Mar 31, 2022
52c0307
Addresing sonar issues
lwasylow Mar 31, 2022
8f8d257
Extra tests and cleanup of old code.
lwasylow Apr 1, 2022
12be123
Adding extra tests
lwasylow Apr 1, 2022
d5ee6ca
Updating SQL to expand paths and extract suites.
lwasylow Apr 1, 2022
2db8d63
Addressing issue with reconstruct_cache knocking off other levels.
lwasylow Apr 6, 2022
d3396fe
Update tests for random order
lwasylow Apr 7, 2022
02d41a6
Removing a hash function from api into utils package which is more su…
lwasylow Apr 7, 2022
274d80a
Fixing ordering
lwasylow Apr 7, 2022
3937737
Fixing a documentation
lwasylow Apr 7, 2022
9296f38
Fixing indent
lwasylow Apr 7, 2022
6ff7f38
Peer review changes
lwasylow Apr 12, 2022
ee7a98b
Moving a SQL to be more readable.
lwasylow Apr 12, 2022
a53cefa
Apply suggestions from code review
jgebal Apr 13, 2022
011970f
Apply suggestions from code review
jgebal Apr 13, 2022
71e07f9
Merge remote-tracking branch 'origin/develop' into feature/call_tests…
jgebal Apr 15, 2022
221c2de
Address issue of not recognizing a correct nested level of suitepath.
lwasylow Apr 16, 2022
870cfe4
Merge branch 'feature/call_tests_by_part_of_name' of https://github.c…
lwasylow Apr 16, 2022
51439d8
Update documentation
lwasylow Apr 16, 2022
0fc7ff6
Fixing issue where parition by only path caused a duplicate level 1 a…
lwasylow Apr 16, 2022
647b830
Fixed issue with suites getting duplicated when running tests across …
jgebal Apr 17, 2022
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
Adding tests.
modifying code to cater for path with wildcard that can result in large item duplication due to parent/child search.
  • Loading branch information
lwasylow committed Mar 31, 2022
commit 95ddec1e535aa720a4383affecdb7ac158cba91e
65 changes: 43 additions & 22 deletions source/core/ut_suite_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ create or replace package body ut_suite_cache_manager is
end;
end;

--Possible move logic to type
function group_paths_by_schema(a_paths ut_varchar2_list) return ut_path_items is
c_package_path_regex constant varchar2(100) := '^([A-Za-z0-9$#_]+)(\.([A-Za-z0-9$#_\*]+))?(\.([A-Za-z0-9$#_\*]+))?$';
l_results ut_path_items := ut_path_items();
Expand All @@ -152,34 +151,41 @@ create or replace package body ut_suite_cache_manager is

function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
l_schema_paths ut_path_items:= ut_path_items();
begin
begin
with paths_to_expand as (
select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(sp.object_name,c.object_name) as object_name,
sp.procedure_name as procedure_name
/*
The object name is populate but suitepath not
We will use that object and try to match.
We can pass also a wildcard this will result in one to many.
*/
select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
nvl2(sp.procedure_name,c.name,null) as procedure_name
from table(a_schema_paths) sp left outer join ut_suite_cache c
on ( c.object_owner = upper(sp.schema_name)
and c.object_name like replace(upper(sp.object_name),'*','%')
and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name))
where sp.suite_path is null
and sp.object_name is not null
group by sp.schema_name,nvl(sp.object_name,c.object_name),sp.procedure_name
where sp.suite_path is null and sp.object_name is not null
group by sp.schema_name,nvl(c.object_name,sp.object_name),nvl2(sp.procedure_name,c.name,null)
union all
select /*+ no_parallel */ c.path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
from
table(a_schema_paths) sp left outer join ut_suite_cache c on
( c.object_owner = upper(sp.schema_name)
and sp.suite_path is not null
and instr(sp.suite_path,'*') > 0)
where c.path like replace(sp.suite_path,'*','%')
( c.object_owner = upper(sp.schema_name)
and c.path like replace(sp.suite_path,'*','%'))
where sp.suite_path is not null and instr(sp.suite_path,'*') > 0
union all
/*
Get all data that do not have an wildcard and not require expanding.
We will take them as they are.
a)suite path is populated
b)suite path and object is empty so schema name is by default ( or passed)
*/
select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
from table(a_schema_paths) sp
where sp.suite_path is not null
and instr(sp.suite_path,'*') = 0
union all
select /*+ no_parallel */ sp.suite_path as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
from table(a_schema_paths) sp
where sp.suite_path is null and sp.object_name is null
where
(sp.suite_path is not null and instr(sp.suite_path,'*') = 0)
or
(sp.suite_path is null and sp.object_name is null)
)
select ut_path_item(schema_name,object_name,procedure_name,suite_path)
bulk collect into l_schema_paths
Expand All @@ -190,14 +196,25 @@ create or replace package body ut_suite_cache_manager is
where r_num = 1 ;
return l_schema_paths;
end;


/*
Get a suite items rows that matching our criteria like
path,object_name etc.
We need to consider also an wildcard character on our procedures and object
names.
Were the path is populated we need to make sure we dont return duplicates
as the wildcard can produce multiple results from same path and
parents and child for each can be same resulting in duplicates
TODO: Verify that this not duplicate with a expand paths.
*/
function get_suite_items (
a_schema_paths ut_path_items
) return ut_suite_cache_rows is
l_suite_items ut_suite_cache_rows := ut_suite_cache_rows();
begin
select /*+ cardinality(c 500) */ value(c) as obj
bulk collect into l_suite_items
select obj bulk collect into l_suite_items
from (
select /*+ cardinality(c 500) */ value(c) as obj,row_number() over ( partition by path order by path asc) r_num
from ut_suite_cache c,
table(a_schema_paths) sp
where c.object_owner = upper(sp.schema_name)
Expand All @@ -212,10 +229,14 @@ create or replace package body ut_suite_cache_manager is
( sp.suite_path is null
and c.object_name like nvl(upper(replace(sp.object_name,'*','%')),c.object_name)
and c.name like nvl(upper(replace(sp.procedure_name,'*','%')),c.name)
));
))) where r_num = 1;
return l_suite_items;
end;

/*
Having a base set of suites we will do a further filter down if there are
any tags defined.
*/
function get_tags_suites (
a_suite_items ut_suite_cache_rows,
a_tags ut_varchar2_rows
Expand Down
1 change: 0 additions & 1 deletion source/core/ut_suite_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ create or replace package ut_suite_manager authid current_user is
* Resposible for building hierarhy of sutes from individual suites created by suite_builder
*/


/**
* @private
*
Expand Down
162 changes: 162 additions & 0 deletions test/ut3_tester/core/test_suite_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,26 @@ end;]';
ut.expect(sqlerrm).to_be_like('%failing_non_existing%');
end;

procedure test_search_nonex_pck_wild is
l_objects_to_run ut3_develop.ut_suite_items;
begin
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop.failing_non_*'));
ut.fail('Non existing package did not raise exception');
exception
when others then
ut.expect(sqlerrm).to_be_like('%failing_non_*%');
end;

procedure test_search_nonex_path_wild is
l_objects_to_run ut3_develop.ut_suite_items;
begin
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list('ut3_develop:failing_non_*'));
ut.fail('Non existing path did not raise exception');
exception
when others then
ut.expect(sqlerrm).to_be_like('%:failing_non_*%');
end;

procedure test_search_nonexist_sch_pck is
l_objects_to_run ut3_develop.ut_suite_items;
begin
Expand Down Expand Up @@ -1560,5 +1580,147 @@ end;]';

end;

procedure test_wild_card_obj_name is
c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_*';
l_objects_to_run ut3_develop.ut_suite_items;
l_test_suite ut3_develop.ut_logical_suite;
l_test1_suite ut3_develop.ut_logical_suite;
l_test2_suite ut3_develop.ut_logical_suite;
l_ctx_suite ut3_develop.ut_logical_suite;
l_test_proc ut3_develop.ut_test;
begin
--Act
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path));

--Assert
ut.expect(l_objects_to_run.count).to_equal(3);


for i in 1 .. 3 loop
l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite);
ut.expect(l_test_suite.name in ('test_package_with_ctx','tests', 'tests2')).to_be_true;

case l_test_suite.name
when 'test_package_with_ctx' then
ut.expect(l_test_suite.items.count).to_equal(1);
l_ctx_suite:= treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite);
ut.expect(l_ctx_suite.name).to_equal('some_context');
ut.expect(l_ctx_suite.description).to_equal('Some context description');
ut.expect(l_ctx_suite.items.count).to_equal(1);
l_test_proc := treat(l_ctx_suite.items(1) as ut3_develop.ut_test);
ut.expect(l_test_proc.name).to_equal('test1');
when 'tests' then
l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_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.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual);
l_test2_suite := treat(l_test1_suite.items(1) as ut3_develop.ut_logical_suite);

ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);
ut.expect(l_test2_suite.rollback_type).to_equal(ut3_develop.ut_utils.gc_rollback_manual);
when 'tests2' then
l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite);
ut.expect(l_test1_suite.name).to_equal('test_package_3');
ut.expect(l_test1_suite.items.count).to_equal(3);
end case;

end loop;

end;

procedure test_wild_card_prc_name is
c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||'.test_package_1.test*';
l_objects_to_run ut3_develop.ut_suite_items;
l_test_suite ut3_develop.ut_logical_suite;
l_test1_suite ut3_develop.ut_logical_suite;
l_test1_proc ut3_develop.ut_test;
l_test2_proc ut3_develop.ut_test;
begin
--Act
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path));

--Assert
ut.expect(l_objects_to_run.count).to_equal(1);
l_test_suite := treat(l_objects_to_run(1) as ut3_develop.ut_logical_suite);
ut.expect(l_test_suite.name).to_equal('tests');

l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite);
ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(2);

l_test1_proc := treat(l_test1_suite.items(1) as ut3_develop.ut_test);
ut.expect(l_test1_proc.name).to_equal('test1');

l_test2_proc := treat(l_test1_suite.items(2) as ut3_develop.ut_test);
ut.expect(l_test2_proc.name).to_equal('test2');
end;

procedure test_wild_card_path_name is
c_path varchar2(100) := sys_context('USERENV', 'CURRENT_USER')||':tests*';
l_objects_to_run ut3_develop.ut_suite_items;
l_test_suite ut3_develop.ut_logical_suite;
l_test1_suite ut3_develop.ut_logical_suite;
l_test2_suite ut3_develop.ut_logical_suite;
l_test3_suite ut3_develop.ut_logical_suite;
l_ctx_suite ut3_develop.ut_logical_suite;
l_test_proc ut3_develop.ut_test;
begin
--Act
l_objects_to_run := ut3_develop.ut_suite_manager.configure_execution_by_path(ut3_develop.ut_varchar2_list(c_path));

--Assert
ut.expect(l_objects_to_run.count).to_equal(2);


for i in 1 .. 2 loop
l_test_suite := treat(l_objects_to_run(i) as ut3_develop.ut_logical_suite);
ut.expect(l_test_suite.name in ('tests', 'tests2')).to_be_true;

case l_test_suite.name
when 'tests' then
l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite);
ut.expect(l_test1_suite.name).to_equal('test_package_1');
ut.expect(l_test1_suite.items.count).to_equal(3);

for i in 1 ..3 loop
--l_test2_suite := treat(l_test1_suite.items(i) as ut3_develop.ut_logical_suite);
--ut.expect(l_test2_suite.name).to_equal('test_package_2');
--ut.expect(l_test2_suite.items.count).to_equal(3);
case l_test1_suite.items(i).self_type
when 'UT_SUITE' then
l_test2_suite := treat(l_test1_suite.items(i) as ut3_develop.ut_logical_suite);
ut.expect(l_test2_suite.name).to_equal('test_package_2');
ut.expect(l_test2_suite.items.count).to_equal(3);

l_test_proc := treat(l_test2_suite.items(1) as ut3_develop.ut_test);
ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true;

l_test_proc := treat(l_test2_suite.items(2) as ut3_develop.ut_test);
ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true;

l_test_proc := treat(l_test2_suite.items(3) as ut3_develop.ut_test);
ut.expect(l_test_proc.name in ('test1', 'test2','context_test')).to_be_true;

when 'UT_TEST' then
l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test);
ut.expect(l_test_proc.name in ('test1', 'test2')).to_be_true;
end case;
end loop;
when 'tests2' then
ut.expect(l_test_suite.items.count).to_equal(1);
l_test1_suite := treat(l_test_suite.items(1) as ut3_develop.ut_logical_suite);
ut.expect(l_test1_suite.name).to_equal('test_package_3');
ut.expect(l_test1_suite.items.count).to_equal(3);
for i in 1 .. 3 loop
l_test_proc := treat(l_test1_suite.items(i) as ut3_develop.ut_test);
ut.expect(l_test_proc.name in ('test1', 'test2','disabled_test')).to_be_true;
end loop;
end case;

end loop;

end;

end test_suite_manager;
/
22 changes: 20 additions & 2 deletions test/ut3_tester/core/test_suite_manager.pks
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ create or replace package test_suite_manager is

--%test(Prepare runner for nonexisting package with schema)
procedure test_search_nonexisting_pck;

--%test(Prepare runner for nonexisting package without schema)

--%test(Prepare runner for nonexisting package using wildcard filter)
procedure test_search_nonex_pck_wild;

--%test(Prepare runner for nonexisting path using wildcard filter)
procedure test_search_nonex_path_wild;

--%test(Prepare runner for nonexisting package without schema)
procedure test_search_nonexist_sch_pck;

--%test(Test description with comma)
Expand Down Expand Up @@ -185,6 +191,18 @@ create or replace package test_suite_manager is
--%aftertest(clean_remove_annot_test)
procedure test_rem_cache_on_crt_anno;

--%context(wildcard_filters)

--%test(Execute test_packages using a object_name with wildcard )
procedure test_wild_card_obj_name;

--%test(Execute test_packages using a procedure name with wildcard )
procedure test_wild_card_prc_name;

--%test(Execute test_packages using a path name with wildcard )
procedure test_wild_card_path_name;

--%endcontext

end test_suite_manager;
/