Created
February 20, 2014 19:41
-
-
Save kbarber/9121614 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'net/http' | |
| require 'uri' | |
| require 'json' | |
| require 'facter' | |
| uri = URI.parse("http://localhost:8080/v3/commands/") | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| facts = {} | |
| Facter.to_hash.each do |k,v| | |
| facts[k] = v.to_s | |
| end | |
| def random_string | |
| (0...50).map{ ('a'..'z').to_a[rand(26)] }.join | |
| end | |
| 10000.times do | |
| # Stringify to make sure RHS is a string | |
| request = Net::HTTP::Post.new(uri.request_uri) | |
| request.set_form_data( | |
| { | |
| "payload" => { | |
| "command" => "replace facts", | |
| "version" => 1, | |
| "payload" => { | |
| "name" => random_string, | |
| "values" => facts, | |
| }.to_json, | |
| }.to_json | |
| } | |
| ) | |
| response = http.request(request) | |
| puts response.body | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment