JMeter - random currency from list - jmeter

I've got a JMeter test plan that creates a subscription record for a customer. At the moment I need to specify the exact currency to be used, but i'd like to replace this with a variable to automatically pick a currency from a list. We currently use GBP, EUR and USD. I don't know enough about JMeter at the moment to find an easy answer so I do apologise if this is really simple.

I think that the easiest way is using User Defined Variables
Just add User Defined Variables config element to your Thread Group and populate it as follows:
currency1 USD
currency2 EUR
currency3 GBP
So these are being stored as JMeter Variables.
After somewhere in your test where you need to select a currency you can use following combination:
currency${__Random(1,3,)}
Where currency is a static prefix and ${__Random(1,3,)} is JMeter Random Function which returns a random number from 1 to 3.

Related

Variable value reset to default when new user iteration starts in Jmeter

i am using JMeter BeanShell Preprocessor to generate unique date value in each iteration. I am using two (2) users for my load test on database . for user 1 the date value generating as expected but when the user change to 2 then date variable value reset to default. what should i do to prevent the reset of date variable value as on insertion i am facing violation of unique key constraint error.[enter image description here](https://i.stack.imgur.com/euEc9.png)
i have mentioned in the screen shot what I tried . I need help to solve my problem
Don't post code as images
Don't use Beanshell, since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting
Your problem is that both users are adding 1 day to the date and if the database is configured that way it doesn't allow the same dates - the insert or update will fail.
I don't know the details of your test scenario but you could consider adding current iteration number and/or current virtual user number to the date from the User Defined Variables, the relevant functions are:
vars.getIteration() - for the iteration number
ctx.getThreadNum() - for the user number
However the best option would be pre-generating the list of dates somewhere in setUp Thread Group
Example Groovy code:
def now = new Date()
1.upto(200000,{index ->
def date = now.plus(index)
new File('dates.csv') << date.format('yyyy-MM-dd') << System.getProperty('line.separator')
})
And then use CSV Data Set Config to read the generated dates from the dates.csv file in your main Thread Group
Given you have 2 users and 100k iterations which means that the last date would be 2570-08-11 so make sure it matches your requirements and the database is capable of accepting the date such far in the future

PBCS: Custom rules to aggregate Period members

I have an input account (never share) in which the user types a parameter for each month, I want that into aggregate members of Period dimension, for example on YearTotal, the value will be the weighted average between two other accounts representing the cost and the quantity.
With the account properties I can rollup my account in addition or as simple average between months, obviously in this way I get wrong data in both cases.
Anyone know a solution to my question?
Thanks a lot,
Daniele
Not sure exactly what you are asking. But I assume the following in my answer:
data entry for user on account Parameter (from the context, I think it is a price)
data entry for user on level0 Period, i.e. the months
you want Essbase to show the Parameter value as typed in at the month level (Jan .. Dec)
you want Essbase to show Costs / Quantity for Q1/2/3/4 and the YearTotal
the Account and Period dimension are of density: dense
You did not specify if you are also reporting on YTD values and how you have implemented this in Essbase. I assume you do, but the preferred solution depends on how you have implemented this, so I take the "safe" solution here:
solution 1
This is the most straightforward solution:
Implement a "parameter_inp" account on which the user keys in the data. Set the account to "never consolidate".
Create a new "parameter" account, dynamic calc, and give it the formula "Costs/Quantity;".
Refer to "parameter" in your reports, and to "parameter_inp" for user entry
solution 2 - alternative
If you have a lot of these parameters, you'll end up with a system making it unpleasant for data entry and reporting for the end-users. To solve it using data entry and reporting on the same "parameter" account, you need to tune your implementation for Quarter and YearTotal calculation, including the YTD calculation. I see no way of getting this correct if you are using DTS.
This is the way to go forward:
Make use of a new dimension called "View", data entry on PER (= periodic), additional dynamic calc member "YTD", density: dense, place it after Period (so Account, Period, View)
Add a UDA to the "parameter", for example "WA"
Set custom dynamic calculations on Quarter and YearTotal level, something like: IF (#ISUDA("WA")) THEN ELSIF <check on FLOW/BALANCE> ... logic for regular aggregation of FLOW and BALANCE items hereby overriding Essbase's native time logic)
Set custom dynamic calculations for YTD (overiding DTS), and make an exception for UDA "WA"

How do I add a Parameter for Multiple Customer Numbers?

I have a cube with Account Numbers stored as text strings. I need to create a report with a parameter that users can enter a list of Account Numbers.
I've created my query and in the filter I have "Account Number". The Operator is "equals" and I have ticked the Parameter check box.
If I run the report now, I can select multiple Account Numbers, but we have over 40,000 accounts so it can take a while to find and tick all the ones I want to report on. I want to be able to type or paste a list of Accounts.
If I go in to the Parameter Properties and set Available Values to "none" I can enter my list of accounts, but when I try to view the report I get this error.
The restrictions imposed by the CONSTRAINED flag in the STRTOSET function were violated.
I'm guessing I have to go in to the Dataset Properties and do something to the Account Number parameter to format the list of accounts in the correct way, but I have no idea how to do it.
Does anyone have any ideas?
Thanks
David
I finally figured out how to do this.
Create your query with Account Number as a parameter.
In the #CustomerAccountNumber parameter, make sure its type is Text and tick Allow multiple values. Set Available Values to None and set Default Values to No default value.
Go to the properties of your dataset and go to Parameters. In the CustomerAccountNumber parameter set the Parameter Value to this:
=Split(“[Customer].[Account Number].&["+Replace(Join(Parameters!CustomerAccountNumber.Value,"],”)+”]”,”,”,”,[Customer].[Account Number].&["),",")
Now run your report and you should be able to type in a list of account numbers and get results for just those accounts.
I found my answer here.

JMeter and simulating the real users

I am wondering if there is something I could use to create a simulator using JMeter that would pick the users from my "user list" based on some kind of pattern. In fact, even simpler: imagine I have the users from 0 to N. Some of them are active, some of them are not. I would like to have some simulated users that are active during certain period (say, hour), then they go dormant, others become active etc. So, out of total N users I would have something like X unique active users per hour, Y unique active users per day, Z unique active users per week etc.
I think I could write some kind of generator like this but I am wondering if something already exists - as JMeter plugin or just a library/class that I could use.
See the following test elements which can help you to implement scenario requested:
Ultimate Thread Group - to control virtual users arrival rate and time to hold the load
Constant Throughput Timer - to control virtual users activity in "requests per minute" which can be converted to "requests per second" or "requests per day" by simple arithmetic calculations
Provide uniqueness of virtual users via:
CSV Data Set Config configuration element or __CSVRead() function - for pre-defined users list
__Random or __RandomString function for dynamic unique parameters.

Random product selection using Jmeter

I have to performance test an e-commerce web-application using Jmeter.
One flow is like Search > select any product > Add to Cart.
Here I have to select any random product from the search results and proceed.
Can you please guide me on how to select any random product and proceed?
I am using Jmeter 2.11.
You can follow below sequence,
(If you know how many products are there then)
1. add random variable with values 1-no. of products. this will generate random values for each user/iteration
2. use values from random variable (var1) in regular expression extractor for random occurance (var1 occurance which is random every time)
(If you dont know how many products are present and if your response contains no. of products count then)
1. In first regular expression extract count of products in a variable
2. add random variable with values 1-value for first regex. this will generate random values for each user/iteration
3. use values from random variable (var1) in regular expression extractor for random occurance
I have used similar technique in my assgn. attaching snapshots for reference.
Random selector
first regex for count
random variable
2nd regex for random oocurance
you can modify regex as per your requirement.

Resources