Skip to content

Instantly share code, notes, and snippets.

@cheerfulstoic
Created January 23, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheerfulstoic/1894565afefd29446aa7 to your computer and use it in GitHub Desktop.
Save cheerfulstoic/1894565afefd29446aa7 to your computer and use it in GitHub Desktop.
require 'json'
queries = []
queries << <<QUERY
{
"statements" : [
{
"statement" : "CREATE (n:TransactionTestFoo) RETURN id(n)"
},
{
"statement" : "MATCH (n:TransactionTestFoo) WITH n LIMIT 1 DELETE n"
}
]
}
QUERY
queries << <<QUERY
{
"statements" : [
{
"statement" : "MATCH (n:TransactionTestFoo) RETURN count(n)"
}
]
}
QUERY
queries = queries.map do |query|
query.gsub!('"', '\"').gsub!(/\n/, ' ')
end
threads = queries.map do |query|
Thread.new do
100_000.times do
data = `echo "#{query}" | http POST http://localhost:7777/db/data/transaction "Accept:application/json; charset=UTF-8" "Content-Type:application/json" -b`
puts data
data = JSON.parse(data)
commit_url = data['commit']
sleep(rand(4))
puts `http POST #{commit_url} "Accept:application/json; charset=UTF-8" "Content-Type:application/json"`
end
end
end
threads.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment