How to run while controller a number of times until i get a result code - while-loop

I have the following doubt:
I need to run my test i.e. HTTP sampler until i get a status code >11 and the maximum number of times I need to run while loop is 20. As soon as i get a status code > 11 the loop should end. How do I achieve that.
my while loop has condition
:
${__javaScript(${Status_Code}<"11" && ${Status_Code}!="11",)}

You can use ${__jm__While Controller__idx} pre-defined variable in order to define the maximum number of iterations for the While Controller
Since JMeter 3.1 you should be preferring __groovy() function as Groovy performance is much better than other languages
Assuming above 2 points I would suggest refactoring your While Controller's condition to be:
${__groovy((vars.get('__jm__While Controller__idx') as int) < 20 && (vars.get('Status_Code') as int) < 11 ,)}

Related

Minecraft datapack check if in block (portal)

So this is 100% a minecraft data pack thing... (programming languages are not similar at all)
I have a function to detect if I am in a portal
execute at #a if block ~ ~ ~ blue_stained_glass_pane run say inPortal
Which looks like
So I was wondering if it would be possible to somehow either change this function into a predicate
Or if there is a way to change this into a seperate function and write
execute as #a if function???:inportal run...
A comment on any other ways to detect if they are in the portal would be cool too.
Setting into a predicate is not very practical and will just cause more issues! Doing it this way is simpler and will work fine for you!
Like RoyalQuack, I don't recommend predicate, but if you use execute at #a if block ~ ~ ~ blue_stained_glass_pane run ... you will probably have some issues.
Unless you only have this block in one place on your map, you will probably run portal somewhere else.
I recommend using a positional detection instead:
execute as #a[x=XX,y=YY,z=ZZ,dx=0,dy=1,dz=0] run function sys:yourfunction
(change XX YY ZZ by your location of course)
Using as instead of at allows to use #s in yourfunction which can be convenient. Example of yourfunction:
tp #s 10 25 10 particle flame X Y Z 0 0 0 0.02 force #a title #a [{"selector":#s, "text":" used a portal!", "color": "red"}]
If you have several portals that need to do the same action, instead of using fixed location and having to redo a different command at each portal, you can use an invisible entity to place on each portal and do the detection according to the invisible entity:
execute at #e[type=marker,tag=portal] as #a[dx=0,dy=1,dz=0] run function sys:yourfunction
Here it will run the yourfunction function for all players on the marker entity with the portal tag.

While Controller is not looping all the values in the array from Regex( -1 ) results

Im having the requirement like i need to loop through all the values that are capturing from regex with match No -1
ThreadGroup
---Req1
---Req2
---RegEx: with Match No. -1 (Debug Sampler shows match count : **18** )
---JSR223 Sampler ( Setting the counter value to 1 --**vars.put("counter1","1");**)
---While Controller ( **${__javaScript(parseInt(vars.get("counter1"))<=(${Task_matchNr}),)}** )
----Http req inside While controller
----JSR223 Sampler(Increasing the counter value by 1 everytime till Task_matchNr --**counter = counter+1; vars.put("counter1",Integer.toString(counter));**
Everytime it will execute till 11th value correctly and again it start executing from 1st value without exiting the loop
Could someone please help.
You don't need the counter as While Controller exposes current iteration via ${__jm__While Controller__idx} (since JMeter 5.0)
You're comparing integer to a string, you should do something like parseInt("${Task_matchNr}") `
It's better to use more performing function than JavaScript, for example __jexl3(), the relevant syntax would be something like:
${__jexl3("${Task_matchNr}" != "${__jm__While Controller__idx}",)}
Wouldn't be easier to use ForEach Controller instead?

How to parameterize tests for each iteration in Postman collection?

My GET request goes like this:
<some ip>/search?IW_INDEX={IW_INDEX}&IW_FIELD_WEB_STYLE={IW_FIELD_TEXT}
The data file is as follows:
IW_INDEX,IW_FIELD_TEXT
index1,text1
index2,text2
My test for iteration 1 is as follows:
tests["parameter1"] = responseBody.has("value=\"19\"");
Now this value 19 will change depending upon the iteration and might be 20 in iteration 2.
Is there a way to provide expected test results iteration-wise in Postman?
I think you could do it by adding a column to your CSV file with "expected_result" and in the test, call that value by {{data.expected_result}}, so your test should probably look like:
tests["parameter1"] = responseBody.has("value=\"{{data.expected_result}}\");

twiiter4j when to STOP when no more tweets available?

So, I've figured out how to be able to get more than 100 tweets, thanks to How to retrieve more than 100 results using Twitter4j
However, when do I make the script stop and print stop when maximum results have been reached? For example, I set
int numberOfTweets = 512;
And, it finds just 82 tweets matching my query.
However, because of:
while (tweets.size () < numberOfTweets)
it still continues to keep on querying over and over until I max out my rate limit of 180 requests per 15 seconds.
I'm really a novice at java, so I would really appreciate if you could show me how to resolve this by modifying the first answer script at How to retrieve more than 100 results using Twitter4j
Thanks in advance!
You only need to modify things in the try{} block. One solution is to check whether the ID of the last tweet you found on the previous loop(previousLastID) in the while is the same as the ID of the last tweet (lastID) in the new batch collected (newTweets). If it is, it means the new batch's elements already exist in the previous array, and that that we have reached the end of possible tweets for this hastag.
try {
QueryResult result = twitter.search(query);
List<Status> newTweets = result.getTweets();
long previousLastID = lastID;
for (Status t: newTweets)
if (t.getId() < lastID) lastID = t.getId();
if (previousLastID == lastID) {
println("Last batch (" + tweets.size() + " tweets) was the same as first. Stopping the Gathering process");
break;
}

DQL query to return all files in a Cabinet in Documentum?

I want to retrieve all the files from a cabinet (called 'Wombat Insurance Co'). Currently I am using this DQL query:
select r_object_id, object_name from dm_document(all)
where folder('/Wombat Insurance Co', descend);
This is ok except it only returns a maximum of 100 results. If there are 5000 files in the cabinet I want to get all 5000 results. Is there a way to use pagination to get all the results?
I have tried this query:
select r_object_id, object_name from dm_document(all)
where folder('/Wombat Insurance Co', descend)
ENABLE (RETURN_RANGE 0 100 'r_object_id DESC');
with the intention of getting results in 100 file increments, but this query gives me an error when I try to execute it. The error says this:
com.emc.documentum.fs.services.core.CoreServiceException: "QUERY" action failed.
java.lang.Exception: [DM_QUERY2_E_UNRECOGNIZED_HINT]error:
"RETURN_RANGE is an unknown hint or is being used incorrectly."
I think I am using the RETURN_RANGE hint correctly, but maybe I'm not. Any help would be appreciated!
I have also tried using the hint ENABLE(FETCH_ALL_RESULTS 0) but this still only returns a maximum of 100 results.
To clarify, my question is: how can I get all the files from a cabinet?
You have already accepted an answer which is using DFS.
Since your are playing with DFC, these information might help you.
DFS:
If you are using DFS, you have to aware about the number of concurrent sessions that you can consume with DFS.
I think it is 100 or 150.
DFC:
Actually there is a limit that you can fetch via DFC (I'm not sure with DFS).
Go to your DFC application(webtop or da or anything) and check the dfc.properties file.
# Maximum number of results to retrieve by a query search.
# min value: 1, max value: 10000000
#
dfc.search.max_results = 100
# Maximum number of results to retrieve per source by a query search.
# min value: 1, max value: 10000000
#
dfc.search.max_results_per_source = 400
dfc.properties.full or similar file is there and you can verify these values according to your system.
And I'm talking about the ContentServer side, not the client side dfc.properties file.
If you use ENABLE (RETURN_TOP) hint with DFC, there are 2 ways to fetch the results from the ContentServer.
Object based
Row based
You have to configure this by using the parameter return_top_results_row_based in the server.ini file.
All of these changes for the documentum server side, not for your DFC/DQL client.
Aha, I've figured it out. Using DFS with Java (an abstraction layer on top of DFC) you can set the starting index for query results:
String queryStr = "select r_object_id, object_name from dm_document(all)
where folder('/Wombat Insurance Co', descend);"
PassthroughQuery query = new PassthroughQuery();
query.setQueryString(queryStr);
query.addRepository(repositoryStr);
QueryExecution queryEx = new QueryExecution();
queryEx.setCacheStrategyType(CacheStrategyType.DEFAULT_CACHE_STRATEGY);
queryEx.setStartingIndex(currentIndex); // set start index here
OperationOptions operationOptions = null;
// will return 100 results starting from currentIndex
QueryResult queryResult = queryService.execute(query, queryEx, operationOptions);
You can just increment the currentIndex variable to get all results.
Well, the hint is being used incorrectly. Start with 1, not 0.
There is no built-in limit in DQL itself. All results are returned by default. The reason you get only 100 results must have something to do with the way you're using DFC (or whichever other client you are using). Using IDfCollection in the following way will surely return everything:
IDfQuery query = new DfQuery("SELECT r_object_id, object_name "
+ "FROM dm_document(all) WHERE FOLDER('/System', DESCEND)");
IDfCollection coll = query.execute(session, IDfQuery.DF_READ_QUERY);
int i = 0;
while (coll.next()) i++;
System.out.println("Number of results: " + i);
In a test environment (CS 6.7 SP1 x64, MS SQL), this outputs:
Number of results: 37162
Now, there's proof. Using paging is however a good idea if you want to improve the overall performance in your application. As mentioned, start counting with the number 1:
ENABLE(RETURN_RANGE 1 100 'r_object_id DESC')
This way of paging requires that sorting be specified in the hint rather than as a DQL statement. If all you want is the first 100 records, try this hint instead:
ENABLE(RETURN_TOP 100)
In this case sorting with ORDER BY will work as you'd expect.
Lastly, note that adding (all) will not only find all documents matching the specified qualification, but all versions of every document. If this was your intention, that's fine.
I've worked with DFC API (with Java) for a while but I don't remember any default limit on queries, IIRC we've always got all of the documents, there weren't any limit. Actually (according to my notes) we have to set the limit explicitly with, for example, enable (return_top 2000). (As far I know the syntax might be depend on the DBMS behind EMC Documentum.)
Just a guess: check your dfc.properties file.