1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 11:36:51 +00:00

add vendoring with go dep

This commit is contained in:
Adrian Todorov
2017-10-25 20:52:40 +00:00
parent 704f4d20d1
commit a59409f16b
1627 changed files with 489673 additions and 0 deletions

View File

@@ -0,0 +1 @@
rvm use ruby-2.1.0@burn-in --create

View File

@@ -0,0 +1,4 @@
source 'https://rubygems.org'
gem "colorize"
gem "influxdb"

View File

@@ -0,0 +1,14 @@
GEM
remote: https://rubygems.org/
specs:
colorize (0.6.0)
influxdb (0.0.16)
json
json (1.8.1)
PLATFORMS
ruby
DEPENDENCIES
colorize
influxdb

View File

@@ -0,0 +1,79 @@
require "influxdb"
require "colorize"
require "benchmark"
require_relative "log"
require_relative "random_gaussian"
BATCH_SIZE = 10_000
Log.info "Starting burn-in suite"
master = InfluxDB::Client.new
master.delete_database("burn-in") rescue nil
master.create_database("burn-in")
master.create_database_user("burn-in", "user", "pass")
master.database = "burn-in"
# master.query "select * from test1 into test2;"
# master.query "select count(value) from test1 group by time(1m) into test2;"
influxdb = InfluxDB::Client.new "burn-in", username: "user", password: "pass"
Log.success "Connected to server #{influxdb.host}:#{influxdb.port}"
Log.log "Creating RandomGaussian(500, 25)"
gaussian = RandomGaussian.new(500, 25)
point_count = 0
while true
Log.log "Generating 10,000 points.."
points = []
BATCH_SIZE.times do |n|
points << {value: gaussian.rand.to_i.abs}
end
point_count += points.length
Log.info "Sending points to server.."
begin
st = Time.now
foo = influxdb.write_point("test1", points)
et = Time.now
Log.log foo.inspect
Log.log "#{et-st} seconds elapsed"
Log.success "Write successful."
rescue => e
Log.failure "Write failed:"
Log.log e
end
sleep 0.5
Log.info "Checking regular points"
st = Time.now
response = influxdb.query("select count(value) from test1;")
et = Time.now
Log.log "#{et-st} seconds elapsed"
response_count = response["test1"].first["count"]
if point_count == response_count
Log.success "Point counts match: #{point_count} == #{response_count}"
else
Log.failure "Point counts don't match: #{point_count} != #{response_count}"
end
# Log.info "Checking continuous query points for test2"
# st = Time.now
# response = influxdb.query("select count(value) from test2;")
# et = Time.now
# Log.log "#{et-st} seconds elapsed"
# response_count = response["test2"].first["count"]
# if point_count == response_count
# Log.success "Point counts match: #{point_count} == #{response_count}"
# else
# Log.failure "Point counts don't match: #{point_count} != #{response_count}"
# end
end

View File

@@ -0,0 +1,23 @@
module Log
def self.info(msg)
print Time.now.strftime("%r") + " | "
puts msg.to_s.colorize(:yellow)
end
def self.success(msg)
print Time.now.strftime("%r") + " | "
puts msg.to_s.colorize(:green)
end
def self.failure(msg)
print Time.now.strftime("%r") + " | "
puts msg.to_s.colorize(:red)
end
def self.log(msg)
print Time.now.strftime("%r") + " | "
puts msg.to_s
end
end

View File

@@ -0,0 +1,31 @@
class RandomGaussian
def initialize(mean, stddev, rand_helper = lambda { Kernel.rand })
@rand_helper = rand_helper
@mean = mean
@stddev = stddev
@valid = false
@next = 0
end
def rand
if @valid then
@valid = false
return @next
else
@valid = true
x, y = self.class.gaussian(@mean, @stddev, @rand_helper)
@next = y
return x
end
end
private
def self.gaussian(mean, stddev, rand)
theta = 2 * Math::PI * rand.call
rho = Math.sqrt(-2 * Math.log(1 - rand.call))
scale = stddev * rho
x = mean + scale * Math.cos(theta)
y = mean + scale * Math.sin(theta)
return x, y
end
end

View File

@@ -0,0 +1,29 @@
require "influxdb"
ONE_WEEK_IN_SECONDS = 7*24*60*60
NUM_POINTS = 10_000
BATCHES = 100
master = InfluxDB::Client.new
master.delete_database("ctx") rescue nil
master.create_database("ctx")
influxdb = InfluxDB::Client.new "ctx"
influxdb.time_precision = "s"
names = ["foo", "bar", "baz", "quu", "qux"]
st = Time.now
BATCHES.times do |m|
points = []
puts "Writing #{NUM_POINTS} points, time ##{m}.."
NUM_POINTS.times do |n|
timestamp = Time.now.to_i - rand(ONE_WEEK_IN_SECONDS)
points << {value: names.sample, time: timestamp}
end
influxdb.write_point("ct1", points)
end
puts st
puts Time.now