test_driven_lighting 1.1.0 → 1.2.0

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: dc6f69380759dd4d59c80930267af0c18f178681
4
- data.tar.gz: 79440ded3b44ec566717140e33ac5eee0590d0e5
3
+ metadata.gz: 3058006900e99ccb62674522418df7c4c34c035c
4
+ data.tar.gz: 32d021767ed1ecd5a91b471113bafcad050c5b34
5
5
  SHA512:
6
- metadata.gz: 9b13767c30cff3f54b54cfa26b350f471dc2ae73177b38d873426791cbd8b3ebf3c15a4809444e05d009dc689a11eed460afc2215657d5609e2c8cef2ec57814
7
- data.tar.gz: c77372f8a5f07fd0970aad4dfc9ada857c9d4232a124b5253eb082893dcef04f1ece43a89d3f8049943da9b4f8774a1ab18087ee79a184e7af627ebd3334db34
6
+ metadata.gz: 72b61eb74f2844d6efe233b7fe602affe648ed2a55be07bd7a54fe55a27d278e69d178c4690afb4e1b3b57d6bfe607daaedcecff1faaca5c86fce776230c4341
7
+ data.tar.gz: 1d51a4cab429827969ea14c46bed16fcd9d2890508895880647514db4597244d750a481a15763de93d3831f5e27251dd410a53d77425f00d13473c078a3c19ee
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  config.rb
4
4
  .rfg_project_name
5
5
  coverage
6
+ test_driven_lighting-*.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test_driven_lighting (1.0.2)
4
+ test_driven_lighting (1.1.0)
5
5
  bunny (~> 2.7)
6
6
  faraday (~> 0.12.2)
7
7
  json (~> 2.1)
@@ -9,16 +9,21 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
12
14
  amq-protocol (2.2.0)
13
15
  ast (2.3.0)
14
16
  bunny (2.7.2)
15
17
  amq-protocol (>= 2.2.0)
16
18
  byebug (9.0.6)
17
19
  coderay (1.1.2)
20
+ crack (0.4.3)
21
+ safe_yaml (~> 1.0.0)
18
22
  diff-lcs (1.3)
19
23
  docile (1.1.5)
20
24
  faraday (0.12.2)
21
25
  multipart-post (>= 1.2, < 3)
26
+ hashdiff (0.3.7)
22
27
  json (2.1.0)
23
28
  method_source (0.9.0)
24
29
  multipart-post (2.0.0)
@@ -29,6 +34,7 @@ GEM
29
34
  pry (0.11.3)
30
35
  coderay (~> 1.1.0)
31
36
  method_source (~> 0.9.0)
37
+ public_suffix (3.0.1)
32
38
  rainbow (2.2.2)
33
39
  rake
34
40
  rake (12.3.0)
@@ -53,12 +59,17 @@ GEM
53
59
  ruby-progressbar (~> 1.7)
54
60
  unicode-display_width (~> 1.0, >= 1.0.1)
55
61
  ruby-progressbar (1.9.0)
62
+ safe_yaml (1.0.4)
56
63
  simplecov (0.15.1)
57
64
  docile (~> 1.1.0)
58
65
  json (>= 1.8, < 3)
59
66
  simplecov-html (~> 0.10.0)
60
67
  simplecov-html (0.10.2)
61
68
  unicode-display_width (1.3.0)
69
+ webmock (3.1.1)
70
+ addressable (>= 2.3.6)
71
+ crack (>= 0.3.2)
72
+ hashdiff
62
73
 
63
74
  PLATFORMS
64
75
  ruby
@@ -71,6 +82,7 @@ DEPENDENCIES
71
82
  rubocop (~> 0.51.0)
72
83
  simplecov (~> 0.15.1)
73
84
  test_driven_lighting!
85
+ webmock (~> 3.1.1)
74
86
 
75
87
  BUNDLED WITH
76
88
  1.15.4
data/README.md CHANGED
@@ -1,7 +1,58 @@
1
1
  # Test Driven Lighting
2
- hue bulb test driven lighting
3
2
 
4
- Running Tests:
3
+ ## Overview
4
+ Red / Green / _Refractor!_ Share and control HUE lights with your remote pairing
5
+ partner as you run your tests.
6
+
7
+ ![green_light](https://user-images.githubusercontent.com/28605/33732794-8fb979e6-db55-11e7-9228-adb195e2aac3.jpg)
8
+
9
+ Philips HUE lights can be controlled over wifi. It's pretty trivial to make your
10
+ test suite change your lights to be red or green (or blue or yellow or anything)
11
+ ...as long as you controlling your own lights over your own wifi.
12
+
13
+ ![red_light](https://user-images.githubusercontent.com/28605/33732797-91ecf72e-db55-11e7-83af-088091ef926e.jpg)
14
+
15
+ But what if you are remote pairing, and you run your tests on your partner's
16
+ machine? Wouldn't you want your lights to still update?
17
+
18
+ What if you _both_ had HUE lights for watching your tests run?
19
+
20
+ ## Installation
21
+
22
+ `#glhf`
23
+
24
+ TL;DR Grab Dave or Ashton or DJ or Brian and we can help you. Or just see how
25
+ far you get with this:
26
+
27
+ * **Prerequisites**
28
+ * If you have HUE lights, you need them set up and working, and you'll need to
29
+ know your HUE API id and the IP address of your HUE hub.
30
+ * You'll need a RabbitMQ server running somewhere, and you'll need the host,
31
+ username and password to connect to that.
32
+ * **1. Get Stuff**. Clone this repo and `bundle install`. You could ALSO just
33
+ `gem install test_driven_lighting`, but you won't have an example config file
34
+ to start from. Your call.
35
+ * **2: Set Up Your Config File**. Clone this repo and copy
36
+ examples/example_config.yml to ~/.test_driven_lighting.conf. Edit the file and
37
+ fill in your HUE settings and your RabbitMQ settings in the bunny config
38
+ section.
39
+ * **3: Start the Listener**. _If your partner has HUE lights and you do not, you
40
+ can skip this step._ Just run `tdl-pairing-start` in its own terminal
41
+ window. Leave this window open and leave the program running. If all is set up
42
+ correctly, it will listen for events from the RabbitMQ server and change your
43
+ light(s) accordingly.
44
+ * **4: Test Your Listener**. Run `tdl-test-lighting` while you have the listener
45
+ running. (And/or after your pair has their listener running.) It will go
46
+ through the run/fail/pending/pass light stages and leave the lights green.
47
+ * **5: Run Your Specs With -f LightingFormatter**. That's it--you're all set!
48
+
49
+ ```bash
50
+ gem install test_driven_lighting
51
+
52
+ ```
53
+
54
+
55
+ ## Running Tests
5
56
 
6
57
  ```bash
7
58
  bundle exec rspec spec -f LightingFormatter
@@ -58,3 +109,21 @@ sender.message_send("pass","test")
58
109
  sender.message_send("fail","suite")
59
110
  sender.close_connection
60
111
  ```
112
+
113
+ # TODO:
114
+
115
+ - [ ] MiniTest Formatter
116
+ - [ ] MiniTest Pride Formatter - Photosensitive Epilepsy FTW
117
+ - [ ] Test::Unit Formatter
118
+
119
+ # Database
120
+
121
+ Test Driven Lighting does not require any database, but of course we recommend
122
+ using a SQL Light database. If you've got a magic marker it only takes about ten
123
+ seconds to set up.
124
+
125
+ ![sqlite_database](https://user-images.githubusercontent.com/28605/33732394-5e9ded84-db54-11e7-8851-a3bb214baba5.jpg)
126
+
127
+ Just make sure it's the right color--[I hear mauve has the most RAM.](http://dilbert.com/strip/1995-11-17)
128
+
129
+ ![See? More RAM.](https://user-images.githubusercontent.com/28605/33732397-60ef1e28-db54-11e7-8abd-8efe5a9f093c.jpg)
@@ -30,6 +30,8 @@ receiver.listen(`whoami`) do |payload|
30
30
  puts "Receiving message with #{payload}"
31
31
 
32
32
  case payload['status']
33
+ when 'run'
34
+ lamp.color = 'blue'
33
35
  when 'fail'
34
36
  lamp.color = 'red'
35
37
  when 'pending'
@@ -4,23 +4,24 @@ require 'yaml'
4
4
  require 'test_driven_lighting'
5
5
  include TestDrivenLighting
6
6
 
7
- puts "Sending test messages to your lights..."
8
- puts "Loading config..."
7
+ puts 'Sending test messages to your lights...'
8
+ puts 'Loading config...'
9
9
  config = YAML::load_file(File.expand_path('~/.test_driven_lighting.conf'))
10
10
  bunny_config = config[:bunny]
11
11
 
12
- puts "Connecting to message queue..."
12
+ puts 'Connecting to message queue...'
13
13
  sender = Sender.new bunny_config
14
14
 
15
- puts "Sending test failed message..."
16
- sender.message_send "fail", "test"
17
- sleep 0.5
18
-
19
- puts "Sending test pending message..."
20
- sender.message_send "pending", "test"
21
- sleep 0.5
22
-
23
- puts "Sending suite passed message..."
24
- sender.message_send "pass", "suite"
15
+ [
16
+ ['suite', 'run'],
17
+ ['test', 'fail'],
18
+ ['test', 'pending'],
19
+ ['test', 'pass'],
20
+ ['suite', 'pass']
21
+ ].each do |type, status|
22
+ puts "Sending #{type} #{status} message..."
23
+ sender.message_send status, type
24
+ sleep 0.5
25
+ end
25
26
 
26
27
  puts "All done!"
data/demo_notes.md ADDED
@@ -0,0 +1,139 @@
1
+ # Test Driven Lighting Notes
2
+
3
+ ## TODO for MVP
4
+
5
+ * Get multicast/fanout working
6
+
7
+ ## Bridges to ~~Burn~~Cross When We Get To Them
8
+ * App versioning and/or per-message versioning
9
+ * Per-message versioning: instead of saying "you need version X.Y.Z of the app
10
+ to even talk to me" we say "Here's a TestSuiteStart message version
11
+ 2.1". The client can say "Hey, I have a TestSuiteStart message handler
12
+ class, but it's version 2.0, so I may miss out on some extended
13
+ functionality." or the client could say "I only have version 1.3 of
14
+ TestSuiteStart, so I cannot handle this message."
15
+ * Performance testing - how many ms (or us?) do we lose per message call? If
16
+ it's more than some number, say 1-10ms, we probably don't want it to block
17
+ example execution or it will slow down fast test suites.
18
+ * Performance testing - how many messages can we drive at the lights? Do we want
19
+ the light client to throttle messages to the lights to something like
20
+ 2-10/sec?
21
+ * Client Configuration
22
+ - I have these Light objects
23
+ - On this Message, do this to this Light
24
+
25
+ ## Nicetohaves / Wannados / Coolifs
26
+ * Message classes
27
+ * Message handler/parser/dispatcher (IRC client, anyone?)
28
+ * Light class
29
+ - knows state of light (can query REST interface)
30
+ - can delegate/collaborate with throttling messages to the lights
31
+ * Animations
32
+ - "blink light at 2Hz for 10 seconds"
33
+ - "change light randomly as quickly as possible for 3 seconds"
34
+ - "do the colorloop... only faster (or slower)"
35
+ - "flash the light's brightness"
36
+ * Change multiple lights with a single call - is this possible in the API?
37
+ Perhaps if we make a light group?
38
+ * huepair cli scripts, like hueclear or hueoff or huereset or hueblink. E.g. if
39
+ we hit Ctrl-C during a test run, don't leave the lights blue.
40
+
41
+ ## Stuff We Need For The Demo
42
+ 1. Explain the setup:
43
+ 1. David Presenting, with TMate sessions to Ashton, Brian, and DJ.
44
+ 1. Ashton and Brian are in Columbus on the LAN. They have a HUE hub and each
45
+ have a light.
46
+ 1. I am in Utah with my HUE lights and my HUE hub. I am on the VPN.
47
+ 1. DJ is in Pittsburgh with his HUE light and his HUE hub. He is on the VPN.
48
+ 1. Handwaving: For the sake of this demonstration and for not blowing our
49
+ budget, we are all in the same room and doing this demonstration with a
50
+ single HUE hub, be we are ONLY sharing the hardware. Each of our laptops
51
+ has a separate connection to the hub and none of us will be manipulating
52
+ any lights other than our own.
53
+ 1. So to be clear, I can turn my light on and off (toggle light), and Ashton
54
+ can turn his light on and off, and so can Brian, and so can DJ. (Each
55
+ toggle their light)
56
+ 1. Pair Test Lamps
57
+ 1. I share screens with Ashton via TMate and/or screenhero.
58
+ 1. Ashton and I sit down and start up our test monitors, our lights go green.
59
+ 1. Ashton writes a failing test, runs it on his machine, both our lights go
60
+ blue, the test runs, the lights turn red.
61
+ 1. I write code to make the test pass, run it, both our lights go green.
62
+ 1. TA-DAA!
63
+ 1. Explanation of Technology
64
+ 1. Pretty lights are fun but they're not really distributable.
65
+ 1. What makes this all possible is a messaging exchange server sitting out
66
+ where we can hit it. Ideally this would be some hardware in-house running
67
+ AMQP, but it doesn't have to be. There's no PHI or sensitive data going
68
+ through here. Just tiny little messages like "Ashton started a test run" or
69
+ "Dave's test suite finished, but there were failures."
70
+ 1. Each of us has told this messaging server what kinds of messages we're
71
+ interested in providing, or maybe just listening to. Ashton and I were both
72
+ providing messages about our test suites, and we were both listening for
73
+ messages from either of our test suites.
74
+ 1. Alerting
75
+ 1. Presenter plus Brian. (Consider buying an ambiance lamp for this?)
76
+ 1. This is Brian. He's about to have a bad day, but the important thing is he
77
+ knows it and he's prepared. Brian's light is a dim yellow-orange.
78
+ 1. Show Grafana mockup with line trending upward. This poor test server is
79
+ running out of disk space.
80
+ 1. Brian's light starts getting redder and brighter.
81
+ 1. The good news is, Brian has configured this Grafana dashboard to send
82
+ server alerts to the message server. Again, no PHI or sensitive data, just
83
+ tiny little messages like "disk space alert at 90%". He's also told the
84
+ message server that he's interested in any messages from Grafana, and if
85
+ there's a disk space alert, turn on steady at a brightness and redness
86
+ value relative to the scarcity of the disk space. Wanna go ahead and free
87
+ up some disk space there, Brian?
88
+ 1. Brian fiddles with a thing and the line drops off.
89
+ 1. Brian's light fades back to green and then turns off.
90
+ 1. [Jenkins](https://ci.cmmint.net/view/Testing%20Tools/job/test_driven_lighting/job/send_lighting_message/)
91
+ 1. Presenter plus DJ.
92
+ 1. This is DJ. He wants to deploy some code, but our deploy process has gotten
93
+ more and more cumbersome and asynchronous over time. He's got a PR waiting
94
+ on Jenkins to be deployed, but he's discovered a wafer-thin change he needs
95
+ to make. What could possibly go wrong?
96
+ 1. DJ pushes the commit.
97
+ 1. Jenkins starts running its checks; at the same time, DJ's light turns on.
98
+ 1. DJ has told the messaging server that he's interested in indicators-api
99
+ builds, but only for this PR.
100
+ 1. DJ's light turns red.
101
+ 1. Uh-oh. Jenkins has a problem. This isn't exactly news, of course; but it's
102
+ nice to not have to watch the build and still know it right away
103
+ 1. DJ fixes the build and pushes up the new commit.
104
+ 1. Jenkins fires back up, DJ's light turns on, the tests run, and the light
105
+ turns green.
106
+ 1. Of course we also had to configure Jenkins to send out the message about
107
+ the build of the PR, and to send out the message that the build was
108
+ finished and whether or not it succeeded.
109
+
110
+ 1. So... pretty lights are pretty, but... why is any of this important?
111
+ 1. Pretty lights ARE pretty, but they're really not the point.
112
+ 1. These are Active Information Radiators.
113
+ 1. We don't have to watch a system as closely now when we know the system will
114
+ come find us if there's a problem. (I'm not suggesting you kick off a
115
+ high-risk deploy and close your laptop; this is an additional layer of
116
+ assurance, not an unvetted replacement.)
117
+ 1. Having the light on your desk is a real-time, physical space, active
118
+ information indicator in both space AND time. If my test suite takes 2
119
+ seconds, I already know my tests are fast. If it takes 15 minutes, I
120
+ already know my tests are too slow. But if this light is blue for 45
121
+ seconds or 90 seconds, I am presented with gentle, nag-free, real-time
122
+ sensory input about the duration of my testing cycles. Test suite
123
+ performance becomes observed, not just monitored. That's not something
124
+ PagerDuty or email alerts can do, and it's not something we're honestly
125
+ willing to do by just sitting and watching an ajax spinner. It's there, in
126
+ the corner of our eye, letting us work on and think about other things.
127
+ 1. Red alerts can literally be red alerts, even if you have HipChat minimized
128
+ and Outlook shut down.
129
+ 1. We're working on a Pomodoro timer for it, too.
130
+ 1. And with this clear sticker applied... (put SQL on bulb), it become a tiny
131
+ database. See? It's SQL Lite. It doesn't store very much information, but
132
+ check it out, you can easily upgrade the memory capacity: (Turn light
133
+ mauve.)
134
+
135
+ (Mauve is 276deg, 31% sat, 100% val. Not sure what that would be in HSB space.)
136
+
137
+ HSL Convert says 100 Sat, 84% Lum. Normalizing H to 64k and S/L to 256 is about:
138
+
139
+ --hue 50244 --sat 255 --bri 214
@@ -1,5 +1,5 @@
1
1
  require 'rspec'
2
- require_relative '../../config'
2
+ require 'yaml'
3
3
  require_relative '../../lib/test_driven_lighting'
4
4
 
5
5
  class LightingFormatter
@@ -11,13 +11,8 @@ class LightingFormatter
11
11
  :close
12
12
 
13
13
  def initialize data
14
- bunny_config = {
15
- :bunny_username => BUNNY_USERNAME,
16
- :bunny_password => BUNNY_PASSWORD,
17
- :bunny_host => BUNNY_HOST
18
- }
19
-
20
- @sender = Sender.new bunny_config
14
+ config = YAML::load_file(File.expand_path('~/.test_driven_lighting.conf'))
15
+ @sender = Sender.new config[:bunny]
21
16
  end
22
17
 
23
18
  def example_passed test_data
@@ -11,7 +11,7 @@ class Lamp
11
11
  @id = lamp_id
12
12
  @hue = 0
13
13
  @saturation = 254
14
- @brightness = 10
14
+ @brightness = 254
15
15
  @transition_time = 0
16
16
  @colors = DEFAULT_COLORS
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module TestDrivenLighting
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency 'rspec', '~> 3.5'
28
28
  s.add_development_dependency 'rubocop', '~> 0.51.0'
29
29
  s.add_development_dependency 'simplecov', '~> 0.15.1'
30
+ s.add_development_dependency 'webmock', '~> 3.1.1'
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_driven_lighting
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashton Freidenberger
@@ -139,6 +139,20 @@ dependencies:
139
139
  - - "~>"
140
140
  - !ruby/object:Gem::Version
141
141
  version: 0.15.1
142
+ - !ruby/object:Gem::Dependency
143
+ name: webmock
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: 3.1.1
149
+ type: :development
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: 3.1.1
142
156
  description: provides sender and receiver classes for entities that want to change
143
157
  the bulbs, and the entities that have bulbs to change
144
158
  email: afreidenberger@covermymeds.com
@@ -155,6 +169,7 @@ files:
155
169
  - README.md
156
170
  - bin/tdl-pairing-start
157
171
  - bin/tdl-test-lighting
172
+ - demo_notes.md
158
173
  - examples/example_config.yml
159
174
  - examples/lighting_client.rb
160
175
  - examples/spec/lighting_formatter.rb