noah 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,13 +5,13 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
5
5
 
6
6
  describe "GET" do
7
7
  it "all hosts should work" do
8
- get '/h'
8
+ get '/hosts'
9
9
  last_response.should be_ok
10
10
  last_response.should return_json
11
11
  end
12
12
 
13
13
  it "existing host should work" do
14
- get '/h/localhost'
14
+ get '/hosts/localhost'
15
15
  last_response.should be_ok
16
16
  response = last_response.should return_json
17
17
 
@@ -29,7 +29,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
29
29
  end
30
30
 
31
31
  it "named service for host should work" do
32
- get '/h/localhost/noah'
32
+ get '/hosts/localhost/noah'
33
33
  last_response.should be_ok
34
34
  response = last_response.should return_json
35
35
 
@@ -42,7 +42,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
42
42
  describe "PUT" do
43
43
  it "new host should work" do
44
44
  host_data = {:name => "host99.domain.com", :status => "down"}.to_json
45
- put '/h/host99.domain.com', host_data, "CONTENT_TYPE" => "application/json"
45
+ put '/hosts/host99.domain.com', host_data, "CONTENT_TYPE" => "application/json"
46
46
  last_response.should be_ok
47
47
  response = last_response.should return_json
48
48
 
@@ -56,7 +56,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
56
56
  it "existing host should work" do
57
57
  sleep 3
58
58
  host_data = {:name => "host99.domain.com", :status => "pending"}.to_json
59
- put '/h/host99.domain.com', host_data, "CONTENT_TYPE" => "application/json"
59
+ put '/hosts/host99.domain.com', host_data, "CONTENT_TYPE" => "application/json"
60
60
  last_response.should be_ok
61
61
  response = last_response.should return_json
62
62
 
@@ -65,19 +65,19 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
65
65
 
66
66
  it "host missing name parameter should not work" do
67
67
  host_data = {:status => "pending"}.to_json
68
- put '/h/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
68
+ put '/hosts/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
69
69
  last_response.should be_invalid
70
70
  end
71
71
 
72
72
  it "host missing status parameter should not work" do
73
73
  host_data = {:name => "host100.domain.com"}.to_json
74
- put '/h/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
74
+ put '/hosts/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
75
75
  last_response.should be_invalid
76
76
  end
77
77
 
78
78
  it "host with invalid status parameter should not work" do
79
79
  host_data = {:name => "host100.domain.com", :status => "fscked"}.to_json
80
- put '/h/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
80
+ put '/hosts/host100.domain.com', host_data, "CONTENT_TYPE" => "application/json"
81
81
  last_response.should_not be_ok
82
82
  response = last_response.should return_json
83
83
 
@@ -96,7 +96,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
96
96
  end
97
97
  it "existing host should work" do
98
98
  svc_size = @h.services.size
99
- delete "/h/#{@h.name}"
99
+ delete "/hosts/#{@h.name}"
100
100
  last_response.should be_ok
101
101
  response = last_response.should return_json
102
102
 
@@ -107,7 +107,7 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
107
107
  end
108
108
 
109
109
  it "invalid host should not work" do
110
- delete "/h/#{@h.name}"
110
+ delete "/hosts/#{@h.name}"
111
111
  last_response.should be_missing
112
112
  end
113
113
  end
@@ -13,13 +13,13 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
13
13
 
14
14
  describe "GET" do
15
15
  it "all services should work" do
16
- get '/s'
16
+ get '/services'
17
17
  last_response.should be_ok
18
18
  response = last_response.should return_json
19
19
  response.is_a?(Array).should == true
20
20
  end
21
21
  it "all named services should work" do
22
- get "/s/#{@sample_service[:name]}"
22
+ get "/services/#{@sample_service[:name]}"
23
23
  last_response.should be_ok
24
24
  response = last_response.should return_json
25
25
  response.is_a?(Array).should == true
@@ -30,7 +30,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
30
30
  s["host"].should == @h.name
31
31
  end
32
32
  it "named service for host should work" do
33
- get "/s/#{@sample_service[:name]}/#{@sample_host[:name]}"
33
+ get "/services/#{@sample_service[:name]}/#{@sample_host[:name]}"
34
34
  last_response.should be_ok
35
35
  response = last_response.should return_json
36
36
  response["id"].should == @s.id
@@ -39,7 +39,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
39
39
  response["host"].should == @h.name
40
40
  end
41
41
  it "missing service for host should not work" do
42
- get '/s/foobar/baz'
42
+ get '/services/foobar/baz'
43
43
  last_response.should be_missing
44
44
  end
45
45
  end
@@ -49,7 +49,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
49
49
  @payload = {:name => 'another_rspec_service', :status => 'up', :host => @h.name}
50
50
  end
51
51
  it "new service should work" do
52
- put "/s/#{@payload[:name]}/", @payload.to_json, "CONTENT_TYPE" => "application/json"
52
+ put "/services/#{@payload[:name]}/", @payload.to_json, "CONTENT_TYPE" => "application/json"
53
53
  last_response.should be_ok
54
54
  response = last_response.should return_json
55
55
  response["result"].should == "success"
@@ -61,26 +61,26 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
61
61
  Noah::Service.find(:name => @payload[:name]).first.is_new?.should == true
62
62
  end
63
63
  it "new service without host should not work" do
64
- put "/s/foobar", {:name => "foobar", :status => "up"}.to_json, "CONTENT_TYPE" => "application/json"
64
+ put "/services/foobar", {:name => "foobar", :status => "up"}.to_json, "CONTENT_TYPE" => "application/json"
65
65
  last_response.should be_invalid
66
66
  end
67
67
  it "new service with invalid status should not work" do
68
- put "/s/foobar", {:name => "foobar", :status => "fsck", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
68
+ put "/services/foobar", {:name => "foobar", :status => "fsck", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
69
69
  last_response.should_not be_ok
70
70
  response = last_response.should return_json
71
71
  response["error_message"].should == "Status must be up, down or pending"
72
72
  end
73
73
  it "new service with missing name should not work" do
74
- put "/s/foobar", {:status => "fsck", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
74
+ put "/services/foobar", {:status => "fsck", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
75
75
  last_response.should be_invalid
76
76
  end
77
77
  it "new service with missing status should not work" do
78
- put "/s/foobar", {:name => "foobar", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
78
+ put "/services/foobar", {:name => "foobar", :host => @h.name}.to_json, "CONTENT_TYPE" => "application/json"
79
79
  last_response.should be_invalid
80
80
  end
81
81
  it "existing service should work" do
82
82
  sleep 3
83
- put "/s/#{@payload[:name]}", {:name => @payload[:name], :status => "down", :host => @payload[:host]}.to_json, "CONTENT_TYPE" => "application/json"
83
+ put "/services/#{@payload[:name]}", {:name => @payload[:name], :status => "down", :host => @payload[:host]}.to_json, "CONTENT_TYPE" => "application/json"
84
84
  last_response.should be_ok
85
85
  response = last_response.should return_json
86
86
  response["result"].should == "success"
@@ -101,7 +101,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
101
101
  @s = @h.services.first
102
102
  end
103
103
  it "existing host should work" do
104
- delete "/s/#{@s.name}/#{@h.name}"
104
+ delete "/services/#{@s.name}/#{@h.name}"
105
105
  last_response.should be_ok
106
106
  response = last_response.should return_json
107
107
 
@@ -112,7 +112,7 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
112
112
  response["service"].should == @s.name
113
113
  end
114
114
  it "invalid host should not work" do
115
- delete "/s/#{@s.name}/#{@h.name}"
115
+ delete "/services/#{@s.name}/#{@h.name}"
116
116
  last_response.should be_missing
117
117
  end
118
118
  end
@@ -22,7 +22,7 @@ describe "Using the Watcher API", :reset_redis => true do
22
22
 
23
23
  describe "GET" do
24
24
  it "all watches should work" do
25
- get '/w'
25
+ get '/watches'
26
26
  last_response.should be_ok
27
27
  response = last_response.should return_json
28
28
  response.is_a?(Array).should == true
@@ -30,8 +30,8 @@ describe "Using the Watcher API", :reset_redis => true do
30
30
  end
31
31
 
32
32
  it "named watch should work" do
33
- w = Noah::Watcher.create(:pattern => '//noah/application/myapp', :endpoint => 'http://localhost/webhook')
34
- get "/w/#{w.name}"
33
+ w = Noah::Watcher.create(:pattern => '//noah/application/myapp', :endpoint => 'http://localhost/watchersebhook')
34
+ get "/watches/#{w.name}"
35
35
  last_response.should be_ok
36
36
  response = last_response.should return_json
37
37
  response['pattern'].should == w.pattern
@@ -39,15 +39,15 @@ describe "Using the Watcher API", :reset_redis => true do
39
39
  end
40
40
 
41
41
  it "invalid watch should not work" do
42
- get '/w/asdfasdfasdfasdfasdfsdf'
42
+ get '/watches/asdfasdfasdfasdfasdfsdf'
43
43
  last_response.should be_missing
44
44
  end
45
45
  end
46
46
 
47
47
  describe "PUT" do
48
48
  it "new watch should work" do
49
- data = {:pattern => "//noah/application", :endpoint => "http://myendpoint/webhook"}
50
- put '/w', data.to_json, "CONTENT_TYPE" => "application/json"
49
+ data = {:pattern => "//noah/application", :endpoint => "http://myendpoint/watchersebhook"}
50
+ put '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
51
51
  last_response.should be_ok
52
52
  response = last_response.should return_json
53
53
  response['pattern'].should == data[:pattern]
@@ -58,30 +58,30 @@ describe "Using the Watcher API", :reset_redis => true do
58
58
  end
59
59
 
60
60
  it "new watch without pattern should not work" do
61
- data = {:endpoint => "http://myendpoint/webhook"}
62
- put '/w', data.to_json, "CONTENT_TYPE" => "application/json"
61
+ data = {:endpoint => "http://myendpoint/watchersebhook"}
62
+ put '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
63
63
  last_response.should be_invalid
64
64
  end
65
65
 
66
66
  it "new watch without endpoint should not work" do
67
67
  data = {:pattern => "//noah/application"}
68
- put '/w', data.to_json, "CONTENT_TYPE" => "application/json"
68
+ put '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
69
69
  last_response.should be_invalid
70
70
  end
71
71
 
72
72
  it "new watch that supercedes existing should not work" do
73
- Noah::Watcher.create(:endpoint => 'http://myendpoint/webhook', :pattern => '//noah/application/foo')
74
- data = {:endpoint => "http://myendpoint/webhook", :pattern => '//noah/application'}
75
- put '/w', data.to_json, "CONTENT_TYPE" => "application/json"
73
+ Noah::Watcher.create(:endpoint => 'http://myendpoint/watchersebhook', :pattern => '//noah/application/foo')
74
+ data = {:endpoint => "http://myendpoint/watchersebhook", :pattern => '//noah/application'}
75
+ put '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
76
76
  last_response.should_not be_ok
77
77
  response = last_response.should return_json
78
78
  response['error_message'].should == 'Pattern would overwrite existing'
79
79
  end
80
80
 
81
81
  it "new watch that subsets an existing should not work" do
82
- Noah::Watcher.create(:endpoint => 'http://myendpoint/webhook', :pattern => '//noah/application')
83
- data = {:endpoint => "http://myendpoint/webhook", :pattern => '//noah/application/foo'}
84
- put '/w', data.to_json, "CONTENT_TYPE" => "application/json"
82
+ Noah::Watcher.create(:endpoint => 'http://myendpoint/watchersebhook', :pattern => '//noah/application')
83
+ data = {:endpoint => "http://myendpoint/watchersebhook", :pattern => '//noah/application/foo'}
84
+ put '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
85
85
  last_response.should_not be_ok
86
86
  response = last_response.should return_json
87
87
  response['error_message'].should == 'Pattern is already provided'
@@ -90,9 +90,9 @@ describe "Using the Watcher API", :reset_redis => true do
90
90
 
91
91
  describe "DELETE" do
92
92
  it "delete an existing watch should work" do
93
- data = {:endpoint => "http://myendpoint/webhookd", :pattern => '//noah/application/d'}
93
+ data = {:endpoint => "http://myendpoint/watchersebhookd", :pattern => '//noah/application/d'}
94
94
  w = Noah::Watcher.create(data)
95
- delete '/w', data.to_json, "CONTENT_TYPE" => "application/json"
95
+ delete '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
96
96
  last_response.should be_ok
97
97
  response = last_response.should return_json
98
98
  response['pattern'].should == data[:pattern]
@@ -103,19 +103,19 @@ describe "Using the Watcher API", :reset_redis => true do
103
103
 
104
104
  it "delete an invalid watch should not work" do
105
105
  data = {:endpoint => 'missing', :pattern => '//noah/application/dag'}
106
- delete '/w', data.to_json, "CONTENT_TYPE" => "application/json"
106
+ delete '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
107
107
  last_response.should be_missing
108
108
  end
109
109
 
110
110
  it "delete without pattern should not work" do
111
111
  data = {:endpoint => "invalid"}
112
- delete '/w', data.to_json, "CONTENT_TYPE" => "application/json"
112
+ delete '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
113
113
  last_response.should be_invalid
114
114
  end
115
115
 
116
116
  it "delete without endpoint should not work" do
117
117
  data = {:pattern => "//noah/invalid"}
118
- delete '/w', data.to_json, "CONTENT_TYPE" => "application/json"
118
+ delete '/watches', data.to_json, "CONTENT_TYPE" => "application/json"
119
119
  last_response.should be_invalid
120
120
  end
121
121
  end
data/spec/spec_helper.rb CHANGED
@@ -14,6 +14,11 @@ RSpec.configure do |config|
14
14
  config.after(:all, :populate_sample_data => true) {Ohm::redis.flushdb }
15
15
  config.before(:all, :populate_sample_data => true) do
16
16
  Ohm::redis.flushdb
17
+ Noah::Watcher.create :endpoint => "dummy://applications", :pattern => "//noah/applications"
18
+ Noah::Watcher.create :endpoint => "dummy://configurations", :pattern => "//noah/configurations"
19
+ Noah::Watcher.create :endpoint => "dummy://hosts", :pattern => "//noah/hosts"
20
+ Noah::Watcher.create :endpoint => "dummy://services", :pattern => "//noah/services"
21
+ Noah::Watcher.create :endpoint => "dummy://ephemerals", :pattern => "//noah/ephemerals"
17
22
  h = Noah::Host.create(:name => 'localhost', :status => "up")
18
23
  if h.save
19
24
  %w[redis noah].each do |service|
data/views/index.haml CHANGED
@@ -14,42 +14,42 @@
14
14
  %h2 Hosts
15
15
  %ul
16
16
  %li
17
- %a{:href => "h/"} All registered Hosts
17
+ %a{:href => "hosts/"} All registered Hosts
18
18
  %li
19
- %a{:href => "h/localhost"} localhost (this server)
19
+ %a{:href => "hosts/localhost"} localhost (this server)
20
20
  %li
21
- %a{:href => "h/localhost/noah"} localhost noah service
21
+ %a{:href => "hosts/localhost/noah"} localhost noah service
22
22
  #header
23
23
  %h2 Services
24
24
  %ul
25
25
  %li
26
- %a{:href => "s/"} All registered Services
26
+ %a{:href => "services/"} All registered Services
27
27
  %li
28
- %a{:href => "s/http"} All hosts providing 'http'
28
+ %a{:href => "services/http"} All hosts providing 'http'
29
29
  %li
30
- %a{:href => "s/noah/localhost"} localhost noah service
30
+ %a{:href => "services/noah/localhost"} localhost noah service
31
31
  #header
32
32
  %h2 Applications
33
33
  %ul
34
34
  %li
35
- %a{:href => "a/"} All registered Applications
35
+ %a{:href => "applications/"} All registered Applications
36
36
  %li
37
- %a{:href => "a/noah"} Noah Application entry
37
+ %a{:href => "applications/noah"} Noah Application entry
38
38
  %li
39
- %a{:href => "a/noah/redis"} Noah Redis configuration entry
39
+ %a{:href => "applications/noah/redis"} Noah Redis configuration entry
40
40
  #header
41
41
  %h2 Configurations
42
42
  %ul
43
43
  %li
44
- %a{:href => "c/"} All registered Configurations
44
+ %a{:href => "configurations/"} All registered Configurations
45
45
  %li
46
- %a{:href => "c/noah"} Noah Configuration entry
46
+ %a{:href => "configurations/noah"} Noah Configuration entry
47
47
  %li
48
- %a{:href => "c/myrailsapp1"} myrailsapp1 Configuration entry
48
+ %a{:href => "configurations/myrailsapp1"} myrailsapp1 Configuration entry
49
49
  %li
50
- %a{:href => "c/myrestapp1"} myrestapp1 Configuration entry
50
+ %a{:href => "configurations/myrestapp1"} myrestapp1 Configuration entry
51
51
  %li
52
- %a{:href => "c/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
52
+ %a{:href => "configurations/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
53
53
  %li
54
- %a{:href => "c/myrestapp1/config.json"} config.json file for myrestapp1
54
+ %a{:href => "configurations/myrestapp1/config.json"} config.json file for myrestapp1
55
55
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: noah
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: "0.3"
6
6
  platform: ruby
7
7
  authors:
8
8
  - John E. Vincent
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-16 00:00:00 -04:00
13
+ date: 2011-03-25 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -87,7 +87,7 @@ dependencies:
87
87
  requirements:
88
88
  - - "="
89
89
  - !ruby/object:Gem::Version
90
- version: 1.1.2
90
+ version: 1.2.0
91
91
  type: :runtime
92
92
  version_requirements: *id007
93
93
  - !ruby/object:Gem::Dependency
@@ -275,16 +275,21 @@ files:
275
275
  - lib/noah/ephemeral_routes.rb
276
276
  - lib/noah/helpers.rb
277
277
  - lib/noah/host_routes.rb
278
+ - lib/noah/log.rb
278
279
  - lib/noah/models.rb
279
280
  - lib/noah/models/applications.rb
280
281
  - lib/noah/models/configurations.rb
281
282
  - lib/noah/models/ephemerals.rb
282
283
  - lib/noah/models/hosts.rb
284
+ - lib/noah/models/link.rb
285
+ - lib/noah/models/link_member.rb
283
286
  - lib/noah/models/services.rb
287
+ - lib/noah/models/tags.rb
284
288
  - lib/noah/models/watchers.rb
285
289
  - lib/noah/passthrough.rb
286
290
  - lib/noah/service_routes.rb
287
291
  - lib/noah/validations.rb
292
+ - lib/noah/validations/ephemeral_validations.rb
288
293
  - lib/noah/validations/watcher_validations.rb
289
294
  - lib/noah/version.rb
290
295
  - lib/noah/watcher_routes.rb