Bug 796983

Summary: Database plugin: Improve discovery and use of column formatted metrics
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: PluginsAssignee: Heiko W. Rupp <hrupp>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 4.3CC: hrupp
Target Milestone: ---   
Target Release: RHQ 4.5.0   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-01 06:11:30 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Description Flags
based on commit 53715248896279279af299e56cdf6d7918a7dcb9
unit tests for database plugin using H2 Database
Heiko's diff none

Description Elias Ross 2012-02-23 19:34:44 EST
We use the RHQ database plugin to query for various metrics. However, it's missing some functionality and does not work against some specialty databases like Hive (for example) where 'count(*)' can take a long time.

1. Don't use count(*) for table discovery. It is much better to discover a table using a select statement that only considers the first row.
2. If a table name is not configured avoid discovery entirely.
3. Support for column data, where metrics can appear in a column format such as:

metric1  m2    m3
------- ---  ----
      2  42   9.0

4. Availability checks are skipped if the table name is not set.

This is a placeholder for a patch.
Comment 1 Mike Foley 2012-02-27 12:12:57 EST
triage 2/27/2012 mfoley, asantos, crouch, loleary
Comment 2 Elias Ross 2012-03-16 13:29:21 EDT
Created attachment 570666 [details]
based on commit 53715248896279279af299e56cdf6d7918a7dcb9
Comment 3 Elias Ross 2012-03-16 13:31:12 EDT
Created attachment 570667 [details]
unit tests for database plugin using H2 Database

This is another patch in a series of two.

You want to change the tests to use the new Arquillian setup. I would be curious to see how well Arquillian works compared to my test class.
Comment 4 Heiko W. Rupp 2012-07-04 10:00:09 EDT

I have applied the patches to my local repo. As you wrote the patch some time ago, the code diverged and the patch did not apply cleanly. Can you please
have a look at the code committed 

In the ComponentTest you shut down the PC in after()

    protected void after() throws Exception {
        for (ResourceComponent c : components.keySet())
        PluginContainer.getInstance().shutdown();  <<--- here

This makes the PC throw a NPE on next invocation of PC.shutdown(), as the PC_internal configuration object gets nulled out. When I disable above call, the test runs fine, but I fear this will only work as long as there is only one test. Could you have a look too?

I've attached my diff - check it?
Comment 5 Heiko W. Rupp 2012-07-04 10:01:02 EDT
Created attachment 596229 [details]
Heiko's diff
Comment 6 Elias Ross 2012-07-05 13:01:07 EDT
Looks great. I wrote this "ComponentTest" back when the Arquillian stuff wasn't available, so if you wanted to port it to that it might be better.
Comment 7 Heiko W. Rupp 2012-07-05 16:20:43 EDT
I committed above patch to master as rev 26959a31d8

Rewriting to Arquillian isn't in for me right now.

Thanks Elias!
Comment 8 Heiko W. Rupp 2013-09-01 06:11:30 EDT
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.