Bug 716233

Summary: XMLRPC: TestCase.get() does not provide product id
Product: [Other] TCMS Reporter: Petr Šplíchal <psplicha>
Component: ApplicationAssignee: Yang Ren <ryang>
Status: NEW --- QA Contact: Nobody <nobody>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.4.1CC: junzhang, ohudlick, ryang, vchen
Target Milestone: ---   
Target Release: 4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Petr Šplíchal 2011-06-23 18:03:55 UTC
Description of problem:

Currently, TestCase.get() does not provide product id in the
result hash. Please, include product id as well. Thanks.

Version-Release number of selected component (if applicable):
Nitrate 3.4.1

Comment 1 Petr Šplíchal 2011-06-23 19:36:05 UTC
Similarly TestRun.get() only provides product_version but no product_id.

Comment 2 Yuguang Wang 2011-07-05 03:30:09 UTC
See following relationships:

            foreignkey
TestCase ---------------> TestCaseCategory
                               /
                              / 
                             /foreignkey
                            /
                           /
                        Product

To obtain product info via TestCase.get(), we need first to get category from an intermediate table 'testcasecategory', then get product info through category.

By calling rpc functions, we could provide the first level foreignkey(name & id) but not any more, or it would be too coupled.
I suggest to get additional information by calling other methods.

What's your opinion?

Comment 3 Petr Šplíchal 2011-07-07 13:48:41 UTC
> By calling rpc functions, we could provide the first level
> foreignkey(name & id) but not any more, or it would be too
> coupled.  I suggest to get additional information by calling
> other methods.

What do you exactly mean by "first level foreign key(name & id)"?
For my use case product_id would be completely sufficient. No need
to provide the product name or anything else.

An example scenario can be updating a test build of a test run: I
would like to be able to fetch test run data (including product):

    hash = TestRun.get(1234)

then get the new build id

    build_id = Build.check_build('SomeBuildName', hash["product_id"])

and then simply update the build using

    TestRun.update(1234, {product: hash["product_id"], build_id})

without need to perform additional xmlrpc call to look up the
actual product id.

Comment 4 Yuguang Wang 2011-07-08 08:34:25 UTC
by saying 'first level foreignkey', see following:

 
             foreignkey
TestRun ------------------> TestBuild
                                /
                               / 
                              /foreignkey
                             /
                            /
                         Product

It's bundled to current db table relationships, to provide product_id via TestRun.get(), need first get the run's build and then fetch product via build.

By calling one function(e.g. TestRun.get) and get all fks and fks' fks and so on would be too coupled, I think.

Comment 5 Yuguang Wang 2011-07-08 08:36:04 UTC
In above graph, For TestRun, 'first level foreignkey' means 'TestBuild' model, and 'Product' is a second level foreignkey(TestBuild's foreignkey)

Comment 6 Petr Šplíchal 2011-07-08 12:52:00 UTC
I see, thanks for making the relations clear. One more question:
Is the default_product_version also a foreign key? I was quite
surprised that TestPlan.get() and TestRun.get() return string
values for the default product version (e.g. '5.7') but update()
functions require version id. If it is a foreign key, could it be
included in the get() results as well?

Comment 7 Yuguang Wang 2011-07-11 03:03:48 UTC
The product_version for a TestRun is not a foreign key, it's a field and will be stored during run's creation, thus by calling TestRun.get() will get product_version but not product.

TCMS's db structure is originated from Testopia and we found a few problems/bugs bundled to db schema, need to refactor/refine codes to fix them.

Comment 8 Petr Šplíchal 2011-07-18 12:46:06 UTC
(In reply to comment #7)
> The product_version for a TestRun is not a foreign key, it's a
> field and will be stored during run's creation, thus by calling
> TestRun.get() will get product_version but not product.

Oh! I see, Testopia legacy... That's sad.

However, I suggest to keep this bug open to track the default
product version cleanup. I suppose TestRun & TestPlan field
product_version should be changed to a foreign key (or a new
product_version_id added) and synced to the "field value".

As far as xmlrpc API is concerned, new product_version_id should
be returned when calling TestRun.get() and TestPlan.get(). Agree?

Comment 9 Yuguang Wang 2011-07-19 01:59:19 UTC
Agreed, versions should be stored as fk instead of static values.