Last active
October 16, 2019 18:05
-
-
Save johnpmitsch/ec777c75cca3b1939c243f32a57e38bf to your computer and use it in GitHub Desktop.
hammer concurrent requests on centos7-hammer-devel box
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
#!/usr/bin/env ruby | |
# This will send concurrent hammer requests from a centos7-hammer-devel box. Update the commands below to alter the request | |
require 'net/http' | |
hammer="BUNDLE_GEMFILE=~/hammer-cli-foreman/Gemfile bundle exec hammer" | |
# create base command | |
base_command = "repository info " | |
# create an array of flags | |
command_flags = ['--id 1','--id 2','--id 3'] | |
# Create an array to keep track of threads. | |
threads = [] | |
command_flags.each_with_index do |flag, i| | |
# spawn a new thread for each url | |
threads << Thread.new do | |
cmd = `#{hammer} #{base_command} #{flag}` | |
puts "\nRequest #{i+1} Complete: \n#{cmd}\n" | |
end | |
end | |
# wait for threads to finish before ending program. | |
threads.each { |t| t.join } | |
puts "All Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment