Created
December 28, 2011 08:43
-
-
Save brujoand/1527138 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
#!/usr/bin/env ruby | |
## coding:utf-8 | |
def process_message(message) | |
puts ' Sending message: ' + message | |
end | |
def generate_ical() | |
uid = 'UID' | |
dtstart = '20100130T042210Z' | |
summary = 'SUMMARY' | |
location = 'LOCATION' | |
return format_ical(uid, dtstart, summary, location) | |
end | |
def format_ical(uid, dtstart, summary, location) | |
dtend = last_modified = dtstart | |
ical = '&ical=BEGIN%3AVEVENT%0D%0AUID%3A' | |
+ uid | |
+ '%0D%0ADTSTART%3A' | |
+ dtstart | |
+ '%0D%0ADTEND%3A' | |
+ dtend | |
+ '%0D%0ALAST-MODIFIED%3A' | |
+ last-modified | |
+ '%0D%0ASUMMARY%3A' | |
+ summary | |
+ '%0D%0ALOCATION%3A' | |
+ location | |
+ '%0D%0AEND%3AVEVENT%0D%0A&method=POST' | |
return ical | |
end | |
def handle_messages(number_of_messages) | |
for counter in (1..number_of_messages) | |
ical = generate_ical() | |
process_message(ical) | |
end | |
end | |
def print_usage() | |
puts '\nStress test for the calendar routing system\n\n' | |
puts 'Usage: routingBeast.rb <number of messages>' | |
end | |
unless ARGV.length == 1 | |
print_usage() | |
exit 1 | |
end | |
number_of_messages = ARGV[0].to_i | |
handle_messages(number_of_messages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment