I have a test data in CSV and reading data from CSV to XML request. In one of the section of this request I would like to validation written and built on fly request. For example.
CSV- col1, col2, col3, col4.....
If co11 is not null do one line of code in XML(line1)
if col1 and col2 is not null do two lines of code(line1 code + line2 code)
Can someone please help in getting the code/process
building XML on the fly based on the column values with condition
It's possible but I don't think that you can use ForEach Controller and If Controller for this because if you're iterating values from CSV you will have one value per each loop of each thread and my expectation is that you want to have all the values at once.
If my assumption is correct I would rather recommend creating the request body in JSR223 PreProcessor using Groovy language
See Creating XML chapter of Groovy documentation for more information
Related
I'm still new in NiFi. What I want to achieve is to pass a parameter from a different source.
Scenario:
I have 2 datasource which is Json data and record id (from oracle function). I declared record id using extract text as "${recid}" and json string default is "$1" .
How to insert into table using sql statement insert into table1 (json,recid) value ('$1','${recid}')
After I run the processor. I'm not able to get both attribute into one insert statement.
Please help.
Nifi flowfile
Flowfile after mergecontent
you should merge these 2 flowfiles to make one.
Use mergeFlowfile processor with Attribute Strategy set to Keep All Unique Attributes
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.6.0/org.apache.nifi.processors.standard.MergeContent/index.html
Take a look at LookupAttribute with a SimpleDatabaseLookupService. You can pass your JSON flow file into that, look up the recid into an attribute, then do the ExtractText -> ReplaceText to get it into SQL form.
I'm using grafana, influxdb and jmeter. I have this table.
I need to add a column that says "Base Line" with a value different for each request name. I have tried the following:
- Grafana does not seem to have a way to add static values for columns, or a query equivalent of sql for "select 'value' as 'columnName'"
- I tried creating a new time series for static data (base lines) and do a join of the results from jmeter with the series I created, but I get this error:
error parsing query: found AS, expected ;
I'm having a hard time trying to create an extra column with fixed data for each request... my last resort is to modify or create a jmeter plugin for that matter, but before going for that, there might be something I could be missing.
The easiest solution I can think of is adding a Dummy Sampler which will be doing nothing but "sleeping" for specified amount of time which is your "baseline".
JMeter's Backend Listener will collect this sampler metrics and you will either see a straight horizontal line identifying your baseline in the chart or the baseline value in the table or will be able to aggregate as a vertical column.
You can install Dummy Sampler using JMeter Plugins Manager
I want to use Unique once setting in JMeter as used in load runner for a project.
The data are provided through a CSV file and are parameterized.
If the script is ran with multiple users then also the data should be unique, meaning one data can be used only once.
Users in JMeter equal Threads so just use CSV Data Set Config to read your CSV
Sharing mode All threads - (the default) the file is shared between all the threads.
You can consider using HTTP Simple Table Server plugin, it has KEEP option, if you set it to FALSE once record is read from the source file it will be removed guaranteeing uniqueness even if you run your tests in Distributed Mode.
You can install HTTP Simple Table Server plugin using JMeter Plugins Manager
I have come up with the solution for "Unique Once Vuser setting in jMeter"
1) Create excel and insert data in excel column wise i.e. horizontally insert all the data.
2) Use below code in place of your unique parameter.
${__CSVRead(filePath,${__threadNum})}
So it will pick unique data for each thread.
Thread_1 Iteration_1 --- Data from col 1
Thread_1 Iteration_2 --- Data from col 1
Thread_1 Iteration_3 --- Data from col 1
Thread_2 Iteration_1 --- Data from col 2
Thread_2 Iteration_2 --- Data from col 2
Thread_2 Iteration_3 --- Data from col 2
Although every answer works perfectly fine, but just a different way using if control.
CSV Data Set Config settings :
if controller validation code : ${__groovy(${__jm__Thread Group__idx} == 0,)}
In this if controller we keep a JSR223 sampler and in that we can have one or more line of following code : vars.put("VarName",vars.get("CSV_input"))
where we replace VarName : with the variable name we want to use in the script and CSV_input with the the variable name from CSV Data Set Config input
I am using jdbc request in jmeter. I want to use result of select query as a variable so i can perform some operation in beanshell postprocessor. My sql query is-
select * from table where id = 11111 and number = ${num} order by id desc limit 1;
I used ResultSet as a Result variable name. How can i use it in beanshell processor.
And can i use this variable in other sampler?
Plz help. Thanks in advance.
You can access it as simple as vars.getObject("ResultSet"); which will return an ArrayList with query results.
vars is a shorthand to JMeterVariables class. See JavaDoc on above classes to see what you can do with them and what is the most useful in your case. Also it worth checking out How to use BeanShell: JMeter's favorite built-in component guide.
Another option is defining "Variable Names" field as
column1,column2,column3
So you will be able to access row values as:
vars.get("column1_1"); //for first row of column1
vars.get("column2_1"); //for first row of column2
vars.get("column1_2"); //for second row of column 1
etc.
Hope this helps.
I want to send a dynamic arraylist as POST request by using JMeter. For example the request will be like :
<ArrayOfEmp>
<Emp>
<name>emp1</name>
<dept>dept1</dept>
</Emp>
...
<Emp>
<name>empN</name>
<dept>deptN</dept>
</Emp>
</ArrayOfEmp>
I have a .csv file with Emp name and department. My script should be able to read the data from .csv file and pass to the request. Also each row of the .csv file will be a Emp object. The no of row will be dynamic.
Can anyone help me write the BeanShell PreProcessor for this issue.
Thanks.
I believe that you don't need to use Beanshell here.
Given your CSV file has the following structure:
emp1,dpt1
emp2,dpt2
emp3,dpt3
....
and you have the following CSV Data Set Config:
You should be able to refer ${empName} and ${empDpt} directly in HTTP Request body as follows:
If you add a View Results Tree listener you'll be able to see request and response details
For step-by-step configuration details and more tips refer to Using CSV DATA SET CONFIG guide.
However if you need to generate XML on the fly rather than using template update your question and notify me via comments.