Created
January 23, 2015 18:59
-
-
Save cheerfulstoic/1894565afefd29446aa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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