Created
March 26, 2020 02:44
-
-
Save jturel/1dd1ad2ae688569421044e3f2a7db57c to your computer and use it in GitHub Desktop.
Tracer benchmark
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 'faraday' | |
require 'json' | |
require 'securerandom' | |
connection = Faraday.new( | |
url: 'https://sat-6-7-qa-rhel7.strangeways.example.com', | |
headers: { | |
'Content-Type' => 'application/json', | |
'Accept' => 'application/json', | |
}, | |
ssl: { verify: false } | |
) | |
connection.basic_auth('admin', 'changeme') | |
response = connection.get('/api/v2/hosts') do |req| | |
req.params['per_page'] = 500 | |
end | |
hosts = JSON.parse(response.body)['results'] | |
tracer_profile = {traces: {}} | |
100.times do |x| | |
tracer_profile[:traces][SecureRandom.uuid] = { type: 'session', helper: 'restart your computer' } | |
end | |
threads = [] | |
start = Time.now | |
hosts.each do |host| | |
uuid = host.dig('subscription_facet_attributes', 'uuid') | |
next unless uuid | |
puts uuid | |
threads << Thread.new do | |
connection.put("/rhsm/consumers/#{uuid}/tracer", tracer_profile.to_json) | |
end | |
end | |
threads.each(&:join) | |
puts "total time: #{Time.now - start}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment