statsd_test_harness 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08c0f573234a6427b552505f7263328dda399ac0
4
- data.tar.gz: 5ac82919bf432182ec0a3923c403bc9bf7e53100
3
+ metadata.gz: fb076d5a472dc9b47e680b5d800f69d0bf9d2068
4
+ data.tar.gz: 01d1a1b26c113be200a12198c86e2ea4342438bc
5
5
  SHA512:
6
- metadata.gz: 0b8947e992c4c75fffc310c98be4978a4ab365e68a082c28063ecfaee9030c0312eb6cd5d6bdb4f5fb2eab3278099fe56d06411385b5120cf1d52ecc6f39fd49
7
- data.tar.gz: 97b3f9ea52ce516f61c58d28d63da1f0190052c312c1c218c3e9df21e3dfc8699299c5306ec66e11933b8bafd0a008d5d5ada30249af7c495baaa54303ff689d
6
+ metadata.gz: e35b0f593d8bd4b4561b5358ac326f42000109da1a64b13f39d34e1c42058f476eca62321f94f9405def9914c2f8a7381a073d5819fd4a1ad926d992276d7c8c
7
+ data.tar.gz: 59cc9da579d16e4515a0872850e20e4bb74f28d0990f48629584ffea1de5128377428288c4d43449d4fb8180bfe19de8c7c84dd16751b0994bedfc6e417394f3
data/README.md CHANGED
@@ -24,18 +24,16 @@ Set the following environment variables for statsd integration:
24
24
 
25
25
  STATSD_HOST=192.168.42.10
26
26
  STATSD_PORT=2003
27
- APP_NAME=my_app_name
27
+ STATSD_APP_NAME=my_app_name
28
28
 
29
29
  ## Usage
30
30
 
31
- Run at command line:
32
-
33
- wrap run_suite
34
-
35
- If you don't have a configuration in config/config.rb, you can specify a config file at runtime:
31
+ You must specify a config file at runtime:
36
32
 
37
33
  wrap run_suite --config path/to/config/file.rb
38
34
 
35
+ For an example of what the config file should look like, refer to config/sample_config.rb
36
+
39
37
  ## Development
40
38
 
41
39
  To add support for a new test suite, create a file in statsd_test_harness/postprocessors/ that will extract the duration output
@@ -2,9 +2,9 @@ require 'dotenv'
2
2
  Dotenv.load
3
3
 
4
4
  StatsdTestHarness.configure do |config|
5
- config.statsd_host = ENV['STATSD_HOST']
6
- config.statsd_port = ENV['STATSD_PORT']
7
- config.app_name = ENV['APP_NAME']
5
+ config.statsd_host = ENV['STATSD_HOST']
6
+ config.statsd_port = ENV['STATSD_PORT']
7
+ config.statsd_app_name = ENV['STATSD_APP_NAME']
8
8
 
9
9
  config.tools = [
10
10
  {
@@ -21,7 +21,7 @@ module StatsdTestHarness
21
21
  end
22
22
 
23
23
  class Configuration
24
- attr_accessor :tools, :statsd_host, :statsd_port, :app_name
24
+ attr_accessor :tools, :statsd_host, :statsd_port, :statsd_app_name
25
25
  end
26
26
 
27
27
  end
@@ -6,7 +6,7 @@ module StatsdTestHarness
6
6
 
7
7
  attr_reader :path_to_config
8
8
 
9
- def initialize(path_to_config=nil)
9
+ def initialize(path_to_config)
10
10
  @path_to_config = path_to_config
11
11
  end
12
12
 
@@ -25,18 +25,19 @@ module StatsdTestHarness
25
25
  private
26
26
 
27
27
  def load_external_config
28
- return if self.path_to_config.empty?
29
28
  begin
30
29
  load self.path_to_config
30
+ validate_path_to_config
31
+ validate_env_variables
31
32
  rescue Exception => e
32
- puts "-- Unable to read custom config file: #{e}"
33
+ puts "-- Unable to read config file: #{e}"
33
34
  end
34
35
  end
35
36
 
36
37
  def post_to_statsd(data, label)
37
- puts "Sending test data from #{label} suite for app #{StatsdTestHarness.config.app_name}..."
38
+ puts "Sending test data from #{label} suite for app #{StatsdTestHarness.config.statsd_app_name}..."
38
39
  GraphiteAPI.new(graphite: endpoint).metrics(
39
- {"stats.timers.#{StatsdTestHarness.config.app_name}.#{label}.duration" => data.duration},
40
+ {"stats.timers.#{StatsdTestHarness.config.statsd_app_name}.#{label}.duration" => data.duration},
40
41
  Time.now
41
42
  )
42
43
  end
@@ -45,6 +46,19 @@ module StatsdTestHarness
45
46
  "http://#{StatsdTestHarness.config.statsd_host}:#{StatsdTestHarness.config.statsd_port}"
46
47
  end
47
48
 
49
+ def validate_path_to_config
50
+ if self.path_to_config.empty?
51
+ puts "No config file specified, exiting"
52
+ exit
53
+ end
54
+ end
55
+
56
+ def validate_env_variables
57
+ unless StatsdTestHarness.config.statsd_host && StatsdTestHarness.config.statsd_port
58
+ puts "No statsd environment variables defined, exiting"
59
+ exit
60
+ end
61
+ end
48
62
  end
49
63
 
50
64
  end
@@ -1,3 +1,3 @@
1
1
  module StatsdTestHarness
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsd_test_harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - CoralineAda
@@ -127,8 +127,7 @@ files:
127
127
  - bin/console
128
128
  - bin/setup
129
129
  - bin/wrap
130
- - config/canvas_config.rb
131
- - config/config.rb
130
+ - config/sample_config.rb
132
131
  - lib/statsd_test_harness.rb
133
132
  - lib/statsd_test_harness/cli.rb
134
133
  - lib/statsd_test_harness/postprocessors/rspec.rb
@@ -1,20 +0,0 @@
1
- require 'dotenv'
2
- Dotenv.load
3
-
4
- StatsdTestHarness.configure do |config|
5
- config.statsd_host = ENV['STATSD_HOST']
6
- config.statsd_port = ENV['STATSD_PORT']
7
- config.app_name = "canvas-lms"
8
-
9
- config.tools = [
10
- {
11
- name: 'rspec',
12
- command: 'rspec',
13
- label: 'rspec',
14
- options: './spec/selenium/wiki_pages_spec.rb',
15
- ignore_return_value: true,
16
- postprocessor: StatsdTestHarness::Postprocessors::RSpec
17
- }
18
- ]
19
-
20
- end