Sha256: 915057828ef06a81a05681b4febe9ddda98e41b375bc5fcf161f12830d601e76
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
module RubyJmeter class ExtendedDSL < DSL def flood(token, params = {}) RestClient.proxy = params[:proxy] if params[:proxy] begin file = Tempfile.new(['ruby-jmeter', '.jmx']) file.write(doc.to_xml(indent: 2)) file.rewind flood_files = { file: File.new("#{file.path}", 'rb') } if params[:files] flood_files.merge!(Hash[params[:files].map.with_index { |value, index| [index, File.new(value, 'rb')] }]) params.delete(:files) end post_params = { flood: { tool: 'jmeter', name: params[:name], notes: params[:notes], tag_list: params[:tag_list], project: params[:project], threads: params[:threads], rampup: params[:rampup], duration: params[:duration], override_parameters: params[:override_parameters], started: params[:started], stopped: params[:stopped], privacy_flag: params[:privacy] || 'private', grids: params[:grids] }.select { |_, value| !value.nil? }, flood_files: flood_files, region: params[:region], multipart: true, content_type: 'application/octet-stream' }.merge(params).select { |_, value| !value.nil? } response = RestClient.post "#{params[:endpoint] ? params[:endpoint] : 'https://api.flood.io'}/floods?auth_token=#{token}", post_params if response.code == 201 logger.info "Flood results at: #{JSON.parse(response)["permalink"]}" else logger.fatal "Sorry there was an error: #{JSON.parse(response)["error"]}" end rescue => e logger.fatal "Sorry there was an error: #{e}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-jmeter-3.0.12 | lib/ruby-jmeter/extend/misc/flood.rb |
ruby-jmeter-3.0.11 | lib/ruby-jmeter/extend/misc/flood.rb |
ruby-jmeter-3.0.10 | lib/ruby-jmeter/extend/misc/flood.rb |