Sonar 3.6.1 : Manual metrics and treemap components - sonarqube

I have a problem with SonarQube 3.5.1 / 3.6 / 3.6.1.
I use web API to inject manual metrics values for a project like this :
curl -u user:password -d "resource=<project>&metric=<key of metric>&val=<value>" http://localhost:8081/sonar/api/manual_measures
More over, I use sonar-runner (with a .properties file) to run analysis after injected these values.
One of these metrics is a percentage and this metric is declared as a Percent Unit value in Sonar (in Settings => Manual Metrics menu).
I have a project with components and each project and components have this metric value injected and I can see it in Sonar.
When I want to show this metric as a color metric in a "treemap of components" widget, all the treemap is grey (as if values are not defined).
But if I put mouse on the name of component in treemap, I see the color metric value as a percentage value like this :
myComponent - ncloc: 800 - myMetric: 84,0%
Moreover, scale metric color does not appear in treemap title (after Size ncloc Color <my metric>).
Colors and scale appear if I choose an other metric for color (not a manual metric).

In fact feeding a manual metric is a two steps mechanim:
Define the value of this manual metric as you did by calling for instance the 'manual_measures' web service
Launch a Sonar analysis on this project to 'associate' this manual measure to the latest quality snapshot of this project
Then you should be able to use this manual metric in a treemap.

I finally found a solution for this problem.
In metrics table in database, i realized that my manuals metrics for color treemap don't have worst_value and best_value (value was NULL).
select * from metrics where name like 'sp_violations_density';
Result :
+-----+-----------------------+------------------+-----------+--------+-------------------------------+-------------+----------+--------------+---------+--------+------------------------+--------------------------+----------------------+--------+------------------------+
| id | name | description | direction | domain | short_name | qualitative | val_type | user_managed | enabled | origin | worst_value | best_value | optimized_best_value | hidden | delete_historical_data |
+-----+-----------------------+------------------+-----------+--------+-------------------------------+-------------+----------+--------------+---------+--------+------------------------+--------------------------+----------------------+--------+------------------------+
| 161 | sp_violations_density | Rules compliance | 0 | Issues | SyncPerl Compliance Rules (%) | 1 | PERCENT | 1 | 1 | GUI | NULL | NULL | NULL | NULL | NULL |
+-----+-----------------------+------------------+-----------+--------+-------------------------------+-------------+----------+--------------+---------+--------+------------------------+--------------------------+----------------------+--------+------------------------+
So i set them with 0 and 100.
update metrics set worst_value='0' where name LIKE 'sp_violations_density';
update metrics set best_value='100' where name LIKE 'sp_violations_density';
Need a Tomcat restart, and then it works.
Treemap has colors now.

Related

How to address SpecFlow Scenario Outlines with too many parameters?

We are using SpecFlow for functional tests that suppose to replace manual testing when a human reads generated email and validates that all sections match specification. The problem is that Scenario Outlines become to grow to have too many parameters
Scenario Outline: generate and send confirmation email
Given I have stored itinerary in '<EmbeddedItinerary>'
When Generate confirmation email
Then section1 should have parameters '<Param1_1>', '<Param1_2>', '<Param1_3>',...
Then section2 should have parameters '<Param2_1>', '<Param2_2>', '<Param2_3>',..
Then section3 should have parameters '<Param3_1>', '<Param3_2>', '<Param3_3>',...
....
Examples:
| EmbeddedItinerary | Param1_1| Param1_2| Param1_3| Param2_1| Param2_2| Param2_3| Param3_1| Param3_2| Param3_3|...
| Itinerary_1 | Value1_1 | Value1_2 | Value1_3 | Value2_1 | Value2_2 | Value2_3 |Value3_1 | Value3_2 | Value3_3 |...
| Itinerary_1 | Value1_1 | Value1_2 | Value1_3 | Value2_1 | Value2_2 | Value2_3 |Value3_1 | Value3_2 | Value3_3 |...
But the number of columns in Examples would become unmanageable. I wish to have multi-line examples ( but with different reason then in Multiple Multi-Line Examples in SpecFlow Feature File).
The option that I see is to store all ExpectedResults in embedded xml or json resource file, and have SpecFlow features quite small e.g.
Scenario Outline: generate and send confirmation email with correct email address for flight section
Given I have stored embedded resource '<EmbeddedItinerary>'
When Generate confirmation email
Then sections should be as specified in '<ExpectedResultsFile>'
Examples:
| EmbeddedItinerary | ExpectedResultsFile
| Itinerary_1 | ExpectedResults1 |
| Itinerary_2 | ExpectedResults2 |
...
Is it a good idea?
Can anyone suggest better way ( more SpecFlow style)?
My concern is that moving expected data to separate files I am loosing visibility, that is one of advantages of SpecFlow features.
Update: while writing this question I found commercial product ($AUD 255 per user) Specflow+Excel http://www.specflow.org/plus/excel/getting-started/ , which may satisfy my requirement to maintain many columns.
Is it a mature/reliable product? Should I use it instead of own parsing expected results files in proprietary format?
If I have a lot of parameters in a Scenario Outline, I try to work as much as possible with default parameters or split the Scenario Outline in multiple ones.
I think in your case, it should be possible to split the one 'generate and send confirmation email' Scenario Outline in multiple ones that you have a scenario outline for every section.
This would reduce the amount of needed parameters per scenario and you get faster feedback if an error occurs. You immediately see in which section you have an error.
e.g.:
Scenario Outline: generate and send confirmation email - section 1
Given I have stored itinerary in '<EmbeddedItinerary>'
When Generate confirmation email
Then section1 should have parameters '<Param1_1>', '<Param1_2>', '<Param1_3>',...
Examples:
| EmbeddedItinerary | Param1_1 | Param1_2 | Param1_3 |
| Itinerary_1 | Value1_1 | Value1_2 | Value1_3 |
Scenario Outline: generate and send confirmation email - section 2
Given I have stored itinerary in '<EmbeddedItinerary>'
When Generate confirmation email
Then section2 should have parameters '<Param2_1>', '<Param2_2>', '<Param2_3>',..
Examples:
| EmbeddedItinerary | Param2_1 | Param2_2 | Param2_3 |
| Itinerary_1 | Value2_1 | Value2_2 | Value2_3 |
Scenario Outline: generate and send confirmation email - section 3
Given I have stored itinerary in '<EmbeddedItinerary>'
When Generate confirmation email
Then section3 should have parameters '<Param3_1>', '<Param3_2>', '<Param3_3>',...
Examples:
| EmbeddedItirerary | Param3_1 | Param3_2 | Param3_3 |
| Itinerary_1 | Value3_1 | Value3_2 | Value3_3 |
About SpecFlow+Excel: That is also an option. Maintaining examples in Excel is most of the time easier than in the feature- file. It will at least solve your problem in short term, but you have to be also careful to write scenarios that are still understandable and readable.
You can get a trial license for it from here: http://www.specflow.org/request-your-specflow-trial-license/
Full Disclosure: I am one of the developers of SpecFlow+ (Runner & Excel).

Simple event correlation using Elasticsearch and Kibana

I'm doing some optimization work on some database stuff and the system writes down log files. Basically I want to optimize some stuff then restore the original customer db-dump and re-run the whole thing. My log files look something like that:
2016-05-10 15:43:18,135 DEBUG [WorkerThread#0[127.0.0.1:64181]] d.h.h.h.c.d.m... [1517]: doing thing #2081087 took 26831ms
2016-05-10 15:05:18,135 DEBUG [WorkerThread#0[127.0.0.1:64181]] d.h.h.h.c.d.m... [1517]: doing thing #20887 took 4051ms
2016-05-10 15:02:18,135 DEBUG [WorkerThread#0[127.0.0.1:64181]] d.h.h.h.c.d.m... [1517]: doing thing #1087 took 261ms
I want to correlate these events over the different runs now to have some statistical data which change did what. So, what I want is a result like
| run 1 | run 2 | run 3 | ... |
thing #20887 | 261ms | 900ms | 100ms | ... |
thing #1087 | 4051ms | 9000ms | 2000ms | ... |
How can I correlate these events using Elasticsearch and visualize it with Kibana?

cucumber using multiple example tables dynamically

Is it possible to use different tables based on previous steps?
So suppose I have something like
When I choose from a <list> of things
And I run a <test> from that thing chosen with special <parameter>
Examples:
|list|
| a |
| b |
| a |
| test | parameter |
| mytest1 | myparameter1 |
| mytest2 | myparameter2 |
| b |
| test | parameter|
| mytest1 | myparameter3 |
| mytest2 | myparameter4 |
Is this possible and what would be the correct structure?
No its not, and it is a very bad idea. Generally when you want to do programming in your scenarios, you should do it by
Giving it a name
Pushing the programming down into the step definitions
In this particular case you seem to want to be doing some sort of exhaustive testing, where you try a single operation under a number of different conditions. Cucumber is not appropriate for this sort of testing. Instead find a way to do these sort of tests at a lower level of abstraction e.g. a unit test.
The main reason for not doing exhaustive testing in Cucumber is the runtime cost. As a rough rule of thumb each integration test (Cucumber) has a run time cost of hundreds of unit tests (maybe thousands of good unit tests).

InDesign - how do I know if an image already placed?

I am working on a book with many images, and I want to ensure that I place each picture only once. Is there a way to tell indesign to to check if image exist before placing it? Or a way to define a preflight profile for it?
Thank you,
Omer
You should be able to see a list in the links panel.
It shows the number of times and the page number it appears on.
example:
Name | ! | Pg |
--------------------|---|----|
my-image.psd (2) | | |
my-image.psd | | 1 |
my-image.psd | | 4 |

Octopress: Tables and Definition Lists not showing in rake preview

Hi I dont know if this is the normal behaviour but if possible would like to preview tables and definition lists.
Using latest versions:
I am using the kramdown version of markdown.
I haven't deployed yet which means I only have
a source but no Masters folder.
I use rake generate or rake preview commands only.
I have tried
| First cell|Second cell|Third cell
| First | Second | Third |
First | Second | | Fourth |
size material color
---- ------------ ------------
9 leather brown
10 hemp canvas natural
11 glass transparent
and for definition lists
apples
: Good for making applesauce.
oranges
: Citrus!
tomatoes
: There's no "e" in tomatoe.

Resources