Gatling and variations in csv-file (feeder) - csv

Having this exec in Gatling:
.exec(http("Sykdomsinfo")
.get("https://xxx/contentapi/v1/xxx")
.headers(headers_1)
.queryParam("Sykdomtilstand","${sykdomtilstand}")
.queryParam("Maalgruppe","${maalgruppe}")
.check(status.is(expected = 200)))
and using feeder like this:
.feed(csv("magnus/ContentAPI.csv").circular)
and the csv-file looking like this:
sykdomtilstand,maalgruppe
35489007,133936004
11381005,
363354003
I weant to run a simulation that for some users execute the request using two parameters (the first line in csv-file) while other users only execute wit one parameter. I want to simulate different and randomly.
What would be the best approach to accomplish this? I understand that it wont work as it stands now because of the unbalanced csv-file structure.

May be a csv like below can help. As passing & does not make any change in the URL.
sykdomtilstand,maalgruppe
35489007,133936004
11381005,&
363354003,&

Related

PHP Running/GET Statements

I need help with Get Statements and Running on a site on PHP
I have this a my PHP code
This is how I save it but it only saves username ...
http://example.com/NC0.php?U=namehere
I have tried this below but it doesn't work
http://example.com/NC0.php?U=namehere?P=passhere
How can I make it like........ NC0.php?U=namehere?P=passhere
or something similar thanks!!!
You are using the ? multiple times. It is meant to start the query! To have multiple parameters in the URL you use the & symbol to differentiate the parameters.
For example,
http://example.com/NC0.php?U=namehere&P=passhere

Is it possible to perform a MySQL query using Phing and set the value as a property?

I'm new to Phing.
I'd like to query a value in a MySQL database table, and have the value set as a property so that I can echo it out nicely to the screen.
I can see that there is a PDOSQLExecTask which would allow me to run some SQL, but I can't see how to set the returned value into a property?
The query I want to run is:
SELECT MAX(change_number)
FROM changelog;
I'd like it set into a property:
Can anyone shed any light please?
Thanks,
Chris
I have access to MySQL at command line, I went with the following solution. I'm sure it's not the best, if someone else can improve it please do!
<!-- What's the latest delta that's been applied to this deployment? -->
<exec
command="${progs.mysql} -h${db.host} -u${db.user} -p${db.pass} -e 'USE ${db.main_db}; SELECT MAX(`change_number`) FROM `changelog`;'"
dir="."
checkreturn="false"
passthru="false"
outputProperty="latest_version_output"
/>
<php expression="preg_replace('/[^0-9]|\r|\n/si', '', '${latest_version_output}');" returnProperty="latest_version_applied" />
<echo msg="Latest delta applied was: ${latest_version_applied}" />
The PDOSQLExecTask comes with two default formatters, which will send their output to a file. To change this, you'd probably have to implement your own formatter. On the other hand, the task appears to read its SQL commands from a separate file with SQL commands, not the build file.
So on the whole, It seems to me like you might be better of writing your own task, probably using some code from the implementation of PDOSQLExecTask but with your own command input and result output. Unless calling the mysql command line binary is an alternative for you, in which case you could wrap up that call to redirect its output to a property using the outputProperty attribute to the ExecTask.

Rails - update directly in SQL

Delving into the documentation and the api, I seem to be missing how to update one field in multiple rows at once.
Something like
Table.select(:field).update("update to this").where(id: 4,5,6)
would be nice.
Does something like this exist? It would be much better than having to store everything in an array, set it to a value, and calling save every time.
You can use the update_all method, for example:
Table.update_all("field = 'update to this'", ["id in (?)", ids])

Ruby On Rails map 2 database columns to 2D JSON array

I am trying to grab two columns of data out of a database, using Ruby on Rails ActiveRecord calls and put them into a 2D JSON array for passing to the client.
I have it working for one column. Now I need to get it working for 2 columns.
This is what I have so far for the database call:
select("TOTAL").map{|x| x.TOTAL.ceil}
This is what I have for the controller:
#results = JSON.dump({ :totals => PerformanceResults.find_totals })
This gives me something like this:
{"totals" [145,132,863,693,372,74,838,91,18,172,84,90,373,161,160,173,1910,210,513,14,79,21,84,41,2630,0,93,150,2971]}
To get two columns, this is how I'm starting out, but it's not going well:
Database call:
select("TOTAL, time_stamp ").map{|x| x.attributes.slice(:x.TOTAL.ceil, x.time_stamp)}
Its telling me "undefined method `TOTAL' for :x:Symbol", which I understand, but since I'm new to Ruby on Rails and also JSON, I thought I'd ask for some help in doing this...
My goal is to get this passed to the client: {"totals" [['timestamp', data], ['timestamp', data], etc.... ]}
I have solved this on my own using the following for anyone looking for this solution in the future.
select("TOTAL, time_stamp ").map{|x| [x.TOTAL.ceil, x.time_stamp]}
In rails console, to fetch multiple columns, you could also use the following method. Suppose you have a User table and you wish to print the id's and email's of the users, You have to do it as shown below:
User.all.map{|user| "#{user.id},#{user.email}"}
This is an alternative to what was already explained above.

Get Redmine custom field value to a file

I'm trying to create a text file that contains the value of a custom field I added on redmine. I tried to get it from an SQL query in the create method of the project_controller.rb (at line 80 on redmine 1.2.0) as follows :
sql = Mysql.new('localhost','root','pass','bitnami_redmine')
rq = sql.query("SELECT value
FROM custom_values
INNER JOIN projects
ON custom_values.customized_id=projects.id
WHERE custom_values.custom_field_id=7
AND projects.name='#{#project.name}'")
rq.each_hash { |h|
File.open('pleasework.txt', 'w') { |myfile|
myfile.write(h['value'])
}
}
sql.close
This works fine if I test it in a separate file (with an existing project name instead of #project.name) so it may be a syntax issue but I can't find what it is. I'd also be glad to hear any other solution to get that value.
Thanks !
(there's a very similar post here but none of the solutions actually worked)
First, you could use Project.connection.query instead of your own Mysql instance. Second, I would try to log the SQL RAILS_DEFAULT_LOGGER.info "SELECT ..." and check if it's ok... And the third, I would use identifier instead of name.
I ended up simply using params["project"]["custom_field_values"]["x"] where x is the custom field's id. I still don't know why the sql query didn't work but well, this is much simpler and faster.