Skip to content

Instantly share code, notes, and snippets.

@jturel
Created March 26, 2020 02:44
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 jturel/1dd1ad2ae688569421044e3f2a7db57c to your computer and use it in GitHub Desktop.
Save jturel/1dd1ad2ae688569421044e3f2a7db57c to your computer and use it in GitHub Desktop.
Tracer benchmark
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