How to retrieve all rules of a quality profile using the web api? - sonarqube

I have run a analysis on Sonarqube with Codescan. The number of issues returned, is way above the 10000 web api limit. Therefore, within my client/code I wanted to loop through all of the rules within a quality profile and return all the issues per rule.
How can I get a list of rules using the web api from java?

You can use api/qualityprofiles/backup. It takes a quality profile key as parameter and returns an xml containing all "active rules".

Newer SonarQube versions do not have the 10K issues limitation.
You have to loop n-times to collect all results.
For example:
Consider a project with 44K issues.
You have to discover first how many issues you have to read, call one time the /api/issues/search with only you project key and the parameter ps ( pagesize ) equal to 100
http:///api/issues/search?componentKeys=&ps=100
You could receive an answer like this
{"total":44130,"p":1,"ps":100,"paging":{"pageIndex":1,"pageSize":100,"total":44130},"issues":[{"key":"AVtoCSNP6OwvnmtEJjae","ru..........
So we have to claim 44130 issues, using a pagesize of 100 then you must call (44130 / 100 ) + 1 times the /api/issues/search for your project and for every request remember to increase by 1 the p ( page ) parameter ( so you can point the right portion of results )
Your sequence of command will be like this
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=1
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=2
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=3
....
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=442
Parse the result of every call and you will be obtained the list of your issues.
Cheers
Massimo

Related

How do I use "maxPageSize" with the new Xrm.API?

Edit 2
It was a Microsoft bug. My CRM updated recently and the query is now executing as expected
Server version: 9.1.0000.21041
Client version: 1.4.1144-2007.3
Edit
If it is a Microsoft bug, which looks likely thanks to Arun's research, then for future reference, my CRM versions are
Server version: 9.1.0000.20151
Client version: 1.4.1077-2007.1
Original question below
I followed the example as described in the MSDN Documentation here.
Specify a positive number that indicates the number of entity records to be returned per page. If you do not specify this parameter, the value is defaulted to the maximum limit of 5000 records.
If the number of records being retrieved is more than the specified maxPageSize value or 5000 records, nextLink attribute in the returned promise object will contain a link to retrieve the next set of entities.
However, it doesn't appear to be working for me. Here's my sample JavaScript code:
Xrm.WebApi.retrieveMultipleRecords('account', '?$select=name', 20).then
(
result => console.log(result.entities.length),
error => console.error(error.message)
);
You can see that my query doesn't include any complex filter or expand expressions
maxPageSize is 20
When I run this code, it's returning the full set of results, not limiting the page size at all:
I noticed this too, but this happens only in UCI. Whereas this issue wont be reproduced when you run the same code in classic web UI.
Probably this is a bug in MS side, pls create a ticket so they can fix it.
UCI
Classic

JMeter and random variable along with if controller

i want to control my sampler execution by using a random variable . I have a sequence of hits login,welcome,Bla,log out . i want the log out to be performed for 6/10 requests and let others do not login(so to speak 6 requests will perform the whole sequence including log out, 4 of them will perform will not perform log out ).How to achieve the same in JMETER
I have added a random variable rand and set it between 1-10 at the beginning of the thread group .Then just above Logout sampler i placed an IF controller were i check ${rand}>4 . How ever i always get all sequence executed . Please suggest what am i doing wrong
Your approach is a little bit weird, my expectation is that the problem is in the following areas:
Your IF Controller condition is wrong (check jmeter.log file for any suspicious entries)
Your random variable setting is wrong, i.e. it has the same value for all virtual users (threads) so they will either be executed all or none
So I would recommend using Throughput Controller or Switch Controller in order to set up this 60/40 distribution.
See Running JMeter Samplers with Defined Percentage Probability article for more details.
Random Variable in Jmeter is saved in long format be default so
${rand} > 4 won't work. You need to change
Condition to ${rand} > 4.0
or change Random Variable Output format to 00 (2 digits)
see Manual
This was accomplished by creating a combination of config element- random variable and an IF controller
1) a random variable was created with Minim and maxim value to meet above condition
2) and IF controller was able to check ${myrand}>4;
This had derived the desired result - thank you all

Alternatives to using CSV in JMeter (for generating usernames)

I have a JMeter Test Plan with following structure
Test Plan
**ThreadGroup1**
--CSV Data Config-001
----SimpleController
--------------LoginRequest
--------------Action-abc-Request
**ThreadGroup2**
--CSV Data Config-002
----SimpleController
--------------LoginRequest
--------------Action-xyz-Request
I have two CSV files which contain list of users like this..
**CSV-001**
Username1
Username2
.. ..
Username50
**CSV-002**
Username51
Username52
.. ..
Username100
In my scenario, I need to run a load test with say 100 users. 50 users login from ThreadGroup1 and other 50 users login from ThreadGroup2. Users from both threadgroups login simultaneously.
Currently, I have to go through process of manually creating/editing these CSV files whenever I change the number of total users.
Please suggest if there are any alternative time-saving & performance-efficient approaches through I which can fulfill my scenario requirements (without using CSV files).
I will appreciate, if you can explain the alternative solution with some details as I am quite new to JMeter stuff. Thanks.
Another idea is to use
Username${__threadNum}
for the first thread group and
Username${__BeanShell(ctx.getThreadNum()+Z+1)}
for the second, where Z equals the total number of threads in thread group 1. You also need to add 1 since ctx.getThreadNum() returns a thread number using a 0 based index, whereas the __threadNum function is 1 based.
You can use a counter in each thread. The start value for the counter in the first thread would be 1, in the second 51. Be sure the 'Track counter independently for each user' check box is unchecked.
If you set the reference names to thread1Count and thread2Count respectively, you can use
Username${thread1Count}
for the first thread and
Username${thread2Count}
for the second.

administrative limit exceeded, REST

Using rest I got this exception
http://localhost:8080/customgroups?_queryFilter=(members/uid+co+%22test%22)
{"code":413,"reason":"Request Entity Too Large","message":"Administrative Limit Exceeded"}
I turned all limits off:
ds-cfg-lookthrough-limit: 0
ds-cfg-size-limit: 0
Is there another constrain? The result should be 1-3 entries. Other requests like get all customGroups = 83 or users = 1300 works fine, so why does the query_filter making problems?
Thank You
There are a few things you might try out:
can you check the ds-rlim-lookthrough-limit operational attribute is correctly set? Especially for cn=Directory Manager if you are using it to make requests.
I can see there is a special config for collective attributes ds-rlim-lookthrough-limit;collective: 0. Maybe does it apply to your request?
References:
http://ludopoitou.com/2012/04/10/tips-resource-limits-in-opendj/
http://opendj.forgerock.org/opendj-server/configref/global.html#lookthrough-limit
http://docs.forgerock.org/en/opendj/2.6.0/admin-guide/index/chap-resource-limits.html

Can Cube (js metrics framework) return more than 1000 events?

The Cube software (https://github.com/square/cube) allows you to retrieve events.
I want to retrieve a lot of events. But it appears that I am capped at 1000. There are well over 9000 in mongodb in the collection and time range I am querying
Example http GET queries I issue:
# 1000 results
http://1.2.3.4:1081/1.0/event?expression=my_event_type
# 1000 results
http://1.2.3.4:1081/1.0/event?expression=my_event_type&start=2012-02-02&stop=2013-07-03
# 7 results
http://1.2.3.4:1081/1.0/event?expression=my_event_type&limit=7
# 1000 results
http://1.2.3.4:1081/1.0/event?expression=my_event_type&limit=9999
It appears that the limit is pinned:
https://github.com/square/cube/blob/28dad4af27a6680deb46077b16952590f2c21cad/lib/cube/event.js
Line 166
based on the 'batchSize=1000'
Is it possible that you can 'page' through the data in some way? Or is this just a hard limit?
Looks like there is a hard cap on results in three places that need to be updated for large domains:
event.js - line 166
metric.js - line 11
metric.js - line 12
In addition, I was unable to find any query-string apis for the parameters. Ideally, we can leave the cap at 1000 (to avoid server bloat for people not tuning their queries correctly) and allow the consumer to define override behavior.

Resources