Mantis Bugtracker          
testlink.org

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007738TestLinkTest Spec. - Search Test Casespublic2016-11-10 15:512017-01-22 08:06
ReporterabIng 
Assigned Tofman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version1.9.14 (2015 Q3) 
Fixed in Version1.9.16 (2016 Q4) 
Summary0007738: Missing test cases while applying a filter on a test suite created as another test suite copy
DescriptionAfter copying a testsuite containing testcases with multiple versions some test cases are lost in a filter.
The steps to reproduce and detailed analysis are in the following sections.

The problem can be fixed in two ways:
- respect order while copying a test suite
- modify SQL query while applying the filter

The second way is preferable since our database already contains a lot of copied test suites.
Steps To Reproduce- Create a new project, then a new test suite
- Create three test cases.
- The first one put in the state Obsolete
- Create a new version for the second test, and then make it Obsolete
- Keep the last test case in Draft state
- Filter Obsolete test cases - there are two (1 and 2)
- Copy the test suite - now we have 6 test cases, four of them are Obsolete
- Filter Obsolete test case - only three are filtered (1,2 and 4 that is the copy of 1); the test 5 that should be present is missing

The attache screen copy demostrates the fulls set of test cases, and shows the test case that will be lost in the filter: test 000-5 with two versions in the Obsolete state.
Additional InformationExplanation.

The query
SELECT [id]
      ,[tc_external_id]
      ,[version]
      ,[status]
      ,[summary]
      ,[author_id]
      ,[creation_ts]
      ,[updater_id]
      ,[modification_ts]
  FROM [CODBTLK_AB].[dbo].[tcversions]
  WHERE id > 1142040

Gives the following result:
id tc_external_id version status summary author_id creation_ts updater_id modification_ts
1142050 1 1 5

AB TC 002

180 2016-11-10 13:48:09.000 180 2016-11-10 13:49:08.000
1142052 2 1 1

AB TC 003

180 2016-11-10 13:48:29.000 NULL NULL
1142054 3 1 1

AB TC 004

180 2016-11-10 13:48:54.000 NULL NULL
1142055 2 2 5

AB TC 003

180 2016-11-10 13:49:48.000 180 2016-11-10 13:51:02.000
1142058 4 1 5

AB TC 002

180 2016-11-10 14:59:42.000 NULL NULL
1142060 5 2 5

AB TC 003

180 2016-11-10 14:59:42.000 NULL NULL
1142061 5 1 1

AB TC 003

180 2016-11-10 14:59:42.000 NULL NULL
1142063 6 1 1

AB TC 004

180 2016-11-10 14:59:42.000 NULL NULL

Here the records corresponding to the two versions of the test 5 are:
id= 1142060, version= 2
id= 1142061, version= 1

Thus, id of the version 2 is less than id of the version 1, that is unnatural and is due to the fact that the test suite was copied.

When processed in PHP the following request $ssx is generated in the file testproject.class.php , function _get_subtree_rec:

/* Get LATEST ACTIVE tcversion MAIN ATTRIBUTES */ SELECT TCV.id AS tcversion_id, TCV.tc_external_id AS external_id, SQ.tc_id FROM tcversions TCV JOIN ( /* Get LATEST ACTIVE tcversion ID */ SELECT MAX(TCVX.id) AS tcversion_id, NHTCX.parent_id AS tc_id FROM tcversions TCVX JOIN nodes_hierarchy NHTCX ON NHTCX.id = TCVX.id AND TCVX.active = 1 WHERE NHTCX.parent_id IN (1142057,1142059,1142062) GROUP BY NHTCX.parent_id,TCVX.tc_external_id ) SQ ON TCV.id = SQ.tcversion_id WHERE TCV.status IN (5)

Here we select MAX(TCVX.id) that works fine in normal condition (the greater the version the greater the id), but fails in our case when the test suite is copied.
The query retrieves the first version that is not Obsolete instead of retrieving the most recent version.



TagsNo tags attached.
Database (MySQL,Postgres,etc)MS SQL
Browser
PHP Version
TestCaseID
QA Team - Task Workflow StatusREADY FOR TESTING
Attached Filespng file icon testlink-filter.PNG [^] (38,129 bytes) 2016-11-10 15:51


? file icon testplan.class.php [^] (282,372 bytes) 2016-11-16 10:41
? file icon testproject.class.php [^] (107,718 bytes) 2016-11-16 10:46

- Relationships
related to 0007749closedfman Copy/paste of testsuites 

-  Notes
(0025569)
abIng (reporter)
2016-11-15 14:08

If I modify the PHP file in the following way (file testproject.class.php , function _get_subtree_rec):

// $glav = " /* Get LATEST ACTIVE tcversion ID */ " .
// " SELECT MAX(TCVX.id) AS tcversion_id, NHTCX.parent_id AS tc_id " .
// " FROM {$this->tables['tcversions']} TCVX " .
// " JOIN {$this->tables['nodes_hierarchy']} NHTCX " .
// " ON NHTCX.id = TCVX.id AND TCVX.active = 1 " .
// " WHERE NHTCX.parent_id IN (" . implode($tclist,',') . ")" .
// " GROUP BY NHTCX.parent_id,TCVX.tc_external_id ";

    $glav = " SELECT TCVX.id AS tcversion_id, NHTCX.parent_id AS tc_id " .
            " FROM {$this->tables['tcversions']} TCVX " .
            " JOIN {$this->tables['nodes_hierarchy']} NHTCX " .
            " ON NHTCX.id = TCVX.id AND TCVX.active = 1 " .
            " WHERE NHTCX.parent_id IN (" . implode($tclist,',') . ")" .
            " GROUP BY NHTCX.parent_id,TCVX.tc_external_id,TCVX.id ";

I retrieve all the lost records.
However, the test cases will be included where one of its versions is Obsolete (not only the most recent one).
(0025572)
abIng (reporter)
2016-11-16 10:46

I fixed the problem in the file testproject.class.php attached.
Here I made three modifications:
- in $glav I select all tcversions.id instead of looking for max
- in internal select I get version and max_verison for a given tc_id
- in external select I get the records where version = max_version

In this way I select only the most recent version even if the identifiers increment does'not follow the version increment (that happens in case of copy/paste).

I don't believe that the query is optimal, but it works properly.
(0025573)
abIng (reporter)
2016-11-16 10:47

The file testplan.class.php was not modified - it was uploaded by mistake.

However, the problem is generic - it can happen in other parts of code also.
(0025608)
fman (administrator)
2016-11-19 12:08

https://github.com/TestLinkOpenSourceTRMS/testlink-code/commit/0c3a515fc93b40fb7087671eb58c6ddb117334fa [^]
(0025609)
fman (administrator)
2016-11-19 12:08

please get fix, apply, retest and provide feedback
(0025619)
abIng (reporter)
2016-11-22 11:00

I confirm that it is OK now.
Thanx.
(0025887)
fman (administrator)
2017-01-22 08:06

1.9.16 released

- Issue History
Date Modified Username Field Change
2016-11-10 15:51 abIng New Issue
2016-11-10 15:51 abIng File Added: testlink-filter.PNG
2016-11-15 14:08 abIng Note Added: 0025569
2016-11-16 10:41 abIng File Added: testplan.class.php
2016-11-16 10:46 abIng Note Added: 0025572
2016-11-16 10:46 abIng File Added: testproject.class.php
2016-11-16 10:47 abIng Note Added: 0025573
2016-11-19 11:35 fman Relationship added related to 0007749
2016-11-19 12:06 fman QA Team - Task Workflow Status => TBD
2016-11-19 12:06 fman Summary Missing test cases while applying a filter => Missing test cases while applying a filter on a test suite created as another test suite copy
2016-11-19 12:08 fman Note Added: 0025608
2016-11-19 12:08 fman Note Added: 0025609
2016-11-19 12:08 fman Assigned To => fman
2016-11-19 12:08 fman Status new => feedback
2016-11-22 11:00 abIng Note Added: 0025619
2016-11-22 11:00 abIng Status feedback => assigned
2016-11-22 19:44 fman QA Team - Task Workflow Status TBD => READY FOR TESTING
2016-11-22 19:44 fman Status assigned => resolved
2016-11-22 19:44 fman Fixed in Version => 1.9.16 (2016 Q4)
2016-11-22 19:44 fman Resolution open => fixed
2017-01-22 08:06 fman Note Added: 0025887
2017-01-22 08:06 fman Status resolved => closed



Copyright © 2000 - 2018 MantisBT Team
Powered by Mantis Bugtracker