noah 0.4 → 0.6.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -69
- data/lib/noah/agent.rb +1 -0
- data/lib/noah/agents/base_agent.rb +4 -2
- data/lib/noah/agents/http_agent.rb +1 -1
- data/lib/noah/agents/https_agent.rb +6 -0
- data/lib/noah/app.rb +8 -6
- data/lib/noah/exceptions.rb +0 -0
- data/lib/noah/linkable.rb +21 -0
- data/lib/noah/models/applications.rb +19 -9
- data/lib/noah/models/configurations.rb +32 -13
- data/lib/noah/models/ephemerals.rb +7 -6
- data/lib/noah/models/hosts.rb +11 -5
- data/lib/noah/models/link.rb +70 -29
- data/lib/noah/models/services.rb +11 -2
- data/lib/noah/models/tags.rb +86 -5
- data/lib/noah/models/watchers.rb +0 -1
- data/lib/noah/models.rb +14 -25
- data/lib/noah/{application_routes.rb → routes/applications.rb} +31 -27
- data/lib/noah/routes/configurations.rb +77 -0
- data/lib/noah/{ephemeral_routes.rb → routes/ephemerals.rb} +5 -5
- data/lib/noah/{host_routes.rb → routes/hosts.rb} +16 -1
- data/lib/noah/routes/links.rb +16 -0
- data/lib/noah/{service_routes.rb → routes/services.rb} +28 -12
- data/lib/noah/routes/tags.rb +15 -0
- data/lib/noah/{watcher_routes.rb → routes/watchers.rb} +0 -0
- data/lib/noah/taggable.rb +30 -0
- data/lib/noah/version.rb +1 -1
- data/lib/noah.rb +1 -0
- data/noah.gemspec +5 -4
- data/spec/application_spec.rb +3 -3
- data/spec/configuration_spec.rb +19 -12
- data/spec/host_spec.rb +5 -5
- data/spec/noahapp_application_spec.rb +11 -13
- data/spec/noahapp_configuration_spec.rb +63 -40
- data/spec/noahapp_ephemeral_spec.rb +15 -15
- data/spec/noahapp_host_spec.rb +4 -6
- data/spec/noahapp_service_spec.rb +8 -7
- data/spec/service_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/support/sample_data.rb +87 -0
- data/spec/tag_spec.rb +78 -0
- data/views/index.haml +7 -1
- metadata +23 -16
- data/lib/noah/configuration_routes.rb +0 -81
- data/lib/noah/models/link_member.rb +0 -18
@@ -1,34 +1,61 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
|
3
|
+
SAMPLE_YAML = <<EOY
|
4
|
+
development:
|
5
|
+
database: development_database
|
6
|
+
adapter: mysql
|
7
|
+
username: dev_user
|
8
|
+
password: dev_password
|
9
|
+
EOY
|
10
|
+
|
11
|
+
SAMPLE_JSON = <<EOJ
|
12
|
+
{
|
13
|
+
"id":"hostname",
|
14
|
+
"data":"localhost"
|
15
|
+
}
|
16
|
+
EOJ
|
17
|
+
|
18
|
+
describe "Using the Configuration API", :reset_redis => true, :populate_sample_data => false do
|
4
19
|
describe "calling" do
|
20
|
+
before(:each) do
|
21
|
+
Ohm.redis.flushdb
|
22
|
+
@redis_config = Noah::Configuration.create(:name => 'redis_url', :format => 'string', :body => 'redis://127.0.0.1:6379/0')
|
23
|
+
@json_config = Noah::Configuration.create(:name => 'json_config', :format => 'json', :body => SAMPLE_JSON)
|
24
|
+
@yaml_config = Noah::Configuration.create(:name => 'yaml_config', :format => 'yaml', :body => SAMPLE_YAML)
|
25
|
+
@sample_application = Noah::Application.create(:name => 'rspec_application')
|
26
|
+
end
|
27
|
+
after(:each) do
|
28
|
+
Ohm.redis.flushdb
|
29
|
+
end
|
5
30
|
|
6
31
|
describe "GET" do
|
7
32
|
it "all configurations should work" do
|
8
33
|
get '/configurations'
|
9
34
|
last_response.should be_ok
|
10
|
-
last_response.should return_json
|
11
|
-
end
|
12
|
-
it "named application should work" do
|
13
|
-
get '/configurations/noah'
|
14
|
-
last_response.should be_ok
|
15
35
|
response = last_response.should return_json
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
36
|
+
response.keys.size.should == 3
|
37
|
+
%w[redis_url json_config yaml_config].each do |c|
|
38
|
+
response.keys.member?(c).should == true
|
39
|
+
%w[id tags links format body created_at updated_at].each do |ck|
|
40
|
+
response[c].keys.member?(ck).should == true
|
41
|
+
end
|
42
|
+
end
|
22
43
|
end
|
23
|
-
it "named configuration
|
24
|
-
get '/configurations/
|
44
|
+
it "named configuration should work" do
|
45
|
+
get '/configurations/redis_url'
|
25
46
|
last_response.should be_ok
|
26
|
-
response = last_response.
|
27
|
-
response.should ==
|
47
|
+
response = last_response.should return_json
|
48
|
+
response.is_a?(Hash).should == true
|
49
|
+
response['name'].should == @redis_config.name
|
50
|
+
response['id'].should == @redis_config.id
|
51
|
+
response["format"].should == @redis_config.format
|
52
|
+
response["body"].should == @redis_config.body
|
53
|
+
response["tags"].size.should == 0
|
54
|
+
response["links"].size.should == 0
|
28
55
|
end
|
29
56
|
it "named configuration should work with mime-type" do
|
30
57
|
require 'yaml'
|
31
|
-
get '/configurations/
|
58
|
+
get '/configurations/yaml_config/data'
|
32
59
|
last_response.should be_ok
|
33
60
|
last_response.headers["Content-Type"].should == "text/x-yaml;charset=utf-8"
|
34
61
|
response = YAML.load(last_response.body)
|
@@ -37,12 +64,12 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
|
|
37
64
|
response["development"].keys.sort.should == ["adapter", "database", "password", "username"]
|
38
65
|
response["development"].values.sort.should == ["dev_password", "dev_user", "development_database", "mysql"]
|
39
66
|
end
|
40
|
-
it "invalid
|
41
|
-
get '/configurations/
|
67
|
+
it "invalid configuration should not work" do
|
68
|
+
get '/configurations/badconfig'
|
42
69
|
last_response.should be_missing
|
43
70
|
end
|
44
|
-
it "invalid configuration
|
45
|
-
get '/configurations/
|
71
|
+
it "invalid configuration data should not work" do
|
72
|
+
get '/configurations/badconfig/data'
|
46
73
|
last_response.should be_missing
|
47
74
|
end
|
48
75
|
end
|
@@ -50,60 +77,56 @@ describe "Using the Configuration API", :reset_redis => false, :populate_sample_
|
|
50
77
|
describe "PUT" do
|
51
78
|
it "new configuration should work" do
|
52
79
|
config_data = {:format => "string", :body => "sample_config_entry"}.to_json
|
53
|
-
put '/configurations/
|
80
|
+
put '/configurations/newconfig', config_data, "CONTENT_TYPE" => "application/json"
|
54
81
|
last_response.should be_ok
|
55
82
|
response = last_response.should return_json
|
56
83
|
response["result"].should == "success"
|
57
84
|
response["action"].should == "create"
|
58
|
-
response["dependencies"].should == "created"
|
59
|
-
response["application"].should == "newapp"
|
60
85
|
response["item"].should == "newconfig"
|
61
86
|
end
|
62
87
|
it "existing configuration should work" do
|
63
88
|
config_data = {:format => "string", :body => "sample_config_entry"}.to_json
|
89
|
+
put '/configurations/newconfig', config_data, "CONTENT_TYPE" => "application/json"
|
64
90
|
sleep 3
|
65
|
-
put '/configurations/
|
91
|
+
put '/configurations/newconfig', config_data, "CONTENT_TYPE" => "application/json"
|
66
92
|
last_response.should be_ok
|
67
93
|
response = last_response.should return_json
|
68
94
|
response["result"].should == "success"
|
69
95
|
response["action"].should == "update"
|
70
|
-
response["dependencies"].should == "updated"
|
71
|
-
response["application"].should == "newapp"
|
72
96
|
response["item"].should == "newconfig"
|
73
97
|
end
|
74
98
|
it "new configuration with missing format should not work" do
|
75
99
|
config_data = {:body => "a string"}.to_json
|
76
|
-
put '/configurations/
|
100
|
+
put '/configurations/someconfig', config_data, "CONTENT_TYPE" => "application/json"
|
77
101
|
last_response.should be_invalid
|
78
102
|
end
|
79
103
|
it "new configuration with missing body should not work" do
|
80
104
|
config_data = {:body => "a string"}.to_json
|
81
|
-
put '/configurations/
|
105
|
+
put '/configurations/someconfig', config_data, "CONTENT_TYPE" => "application/json"
|
82
106
|
last_response.should be_invalid
|
83
107
|
end
|
84
108
|
end
|
85
109
|
|
86
110
|
describe "DELETE" do
|
87
|
-
before(:all) do
|
88
|
-
@a = Noah::Application.create(:name => 'delete_test_app')
|
89
|
-
cparms = {:name => 'a', :format => 'string', :body => 'asdf', :application_id => @a.id}
|
90
|
-
@a.configurations << Noah::Configuration.create(cparms)
|
91
|
-
@a.save
|
92
|
-
@c = @a.configurations.first
|
93
|
-
end
|
94
|
-
|
95
111
|
it "existing configuration should work" do
|
96
|
-
|
112
|
+
@a = Noah::Application.create(:name => 'delete_test_app')
|
113
|
+
cparms = {:name => 'asdf', :format => 'string', :body => 'asdf'}
|
114
|
+
@c = Noah::Configuration.create(cparms)
|
115
|
+
@a.configurations << @c
|
116
|
+
get "/configurations/asdf"
|
117
|
+
p last_response
|
118
|
+
delete "/configurations/#{@c.name}"
|
119
|
+
p last_response
|
97
120
|
last_response.should be_ok
|
98
121
|
response = last_response.should return_json
|
99
122
|
response["result"].should == "success"
|
100
123
|
response["id"].should == @c.id
|
101
124
|
response["action"].should == "delete"
|
102
|
-
response["
|
125
|
+
response["affected_applications"].member?(@a.name).should == true
|
103
126
|
response["item"].should == @c.name
|
104
127
|
end
|
105
128
|
it "invalid configuration should not work" do
|
106
|
-
delete "/configurations
|
129
|
+
delete "/configurations/somethingthatshouldnotexist"
|
107
130
|
last_response.should be_missing
|
108
131
|
end
|
109
132
|
end
|
@@ -13,7 +13,7 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
13
13
|
|
14
14
|
describe "GET" do
|
15
15
|
it "all ephemerals should return 404" do
|
16
|
-
get '/
|
16
|
+
get '/ephemerals'
|
17
17
|
last_response.should_not be_ok
|
18
18
|
last_response.status.should == 404
|
19
19
|
response = last_response.should return_json
|
@@ -22,13 +22,13 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "named path with data should work" do
|
25
|
-
get '/
|
25
|
+
get '/ephemerals/foo/bar/baz'
|
26
26
|
last_response.should be_ok
|
27
27
|
last_response.body.should == 'value1'
|
28
28
|
end
|
29
29
|
|
30
30
|
it "named path without data should work" do
|
31
|
-
get '/
|
31
|
+
get '/ephemerals/baz/bar'
|
32
32
|
last_response.status.should == 200
|
33
33
|
last_response.body.should == ""
|
34
34
|
end
|
@@ -45,7 +45,7 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
45
45
|
|
46
46
|
describe "PUT" do
|
47
47
|
it "new ephemeral with data should work" do
|
48
|
-
put '/
|
48
|
+
put '/ephemerals/whiz/bang/', 'value3'
|
49
49
|
last_response.should be_ok
|
50
50
|
response = last_response.should return_json
|
51
51
|
response['result'].should == 'success'
|
@@ -55,7 +55,7 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "new ephemeral without data should work" do
|
58
|
-
put '/
|
58
|
+
put '/ephemerals/bang/whiz'
|
59
59
|
last_response.should be_ok
|
60
60
|
response = last_response.should return_json
|
61
61
|
response['result'].should == 'success'
|
@@ -67,35 +67,35 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
67
67
|
|
68
68
|
it "existing ephemeral with data should work" do
|
69
69
|
Noah::Ephemeral.create(:path => '/new/ephemeral', :data => 'old_value')
|
70
|
-
get '/
|
70
|
+
get '/ephemerals/new/ephemeral'
|
71
71
|
last_response.should be_ok
|
72
72
|
last_response.body.should == 'old_value'
|
73
|
-
put '/
|
73
|
+
put '/ephemerals/new/ephemeral', 'new_value'
|
74
74
|
last_response.should be_ok
|
75
|
-
get '/
|
75
|
+
get '/ephemerals/new/ephemeral'
|
76
76
|
last_response.should be_ok
|
77
77
|
last_response.body.should == 'new_value'
|
78
78
|
end
|
79
79
|
it "existing ephemeral without data should work" do
|
80
80
|
Noah::Ephemeral.create(:path => '/a/random/key')
|
81
|
-
get '/
|
81
|
+
get '/ephemerals/a/random/key'
|
82
82
|
last_response.should be_ok
|
83
83
|
last_response.body.should == ""
|
84
|
-
put '/
|
84
|
+
put '/ephemerals/a/random/key', 'a new value'
|
85
85
|
last_response.should be_ok
|
86
|
-
get '/
|
86
|
+
get '/ephemerals/a/random/key'
|
87
87
|
last_response.should be_ok
|
88
88
|
last_response.body.should == 'a new value'
|
89
89
|
end
|
90
90
|
it "ephemeral with reserved word in subpath should work" do
|
91
91
|
Noah::PROTECTED_PATHS.each do |path|
|
92
|
-
put "/
|
92
|
+
put "/ephemerals/a/valid/path/with/#{path}"
|
93
93
|
last_response.should be_ok
|
94
94
|
end
|
95
95
|
end
|
96
96
|
it "ephemeral with reserved word as path should not work" do
|
97
97
|
Noah::PROTECTED_PATHS.each do |path|
|
98
|
-
put "/
|
98
|
+
put "/ephemerals/#{path}/other/stuff"
|
99
99
|
last_response.should_not be_ok
|
100
100
|
response = last_response.should return_json
|
101
101
|
response['error_message'].should == 'Path is reserved'
|
@@ -108,7 +108,7 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
108
108
|
it "existing path should work" do
|
109
109
|
e = Noah::Ephemeral.new(:path => '/slart/i/bart/fast', :data => 'someddata')
|
110
110
|
e.save
|
111
|
-
delete "/
|
111
|
+
delete "/ephemerals/slart/i/bart/fast"
|
112
112
|
last_response.should be_ok
|
113
113
|
response = last_response.should return_json
|
114
114
|
response['result'].should == 'success'
|
@@ -118,7 +118,7 @@ describe "Using the Ephemeral API", :reset_redis => true do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "invalid path should not work" do
|
121
|
-
delete '/
|
121
|
+
delete '/ephemerals/fork/spoon/knife'
|
122
122
|
last_response.should_not be_ok
|
123
123
|
last_response.status.should == 404
|
124
124
|
response = last_response.should return_json
|
data/spec/noahapp_host_spec.rb
CHANGED
@@ -20,12 +20,10 @@ describe "Using the Host API", :reset_redis => false, :populate_sample_data => t
|
|
20
20
|
response["name"].should == "localhost"
|
21
21
|
response["status"].should == "up"
|
22
22
|
services.size.should == 2
|
23
|
-
services.
|
24
|
-
services.
|
25
|
-
services
|
26
|
-
services
|
27
|
-
services.last["status"].should == "up"
|
28
|
-
services.last["host"].should == "localhost"
|
23
|
+
services.has_key?("redis").should == true
|
24
|
+
services.has_key?("noah").should == true
|
25
|
+
services["redis"].should == "up"
|
26
|
+
services["noah"].should == "up"
|
29
27
|
end
|
30
28
|
|
31
29
|
it "named service for host should work" do
|
@@ -16,18 +16,19 @@ describe "Using the Service API", :reset_redis => false, :populate_sample_data =
|
|
16
16
|
get '/services'
|
17
17
|
last_response.should be_ok
|
18
18
|
response = last_response.should return_json
|
19
|
-
response.is_a?(
|
19
|
+
response.is_a?(Hash).should == true
|
20
20
|
end
|
21
21
|
it "all named services should work" do
|
22
22
|
get "/services/#{@sample_service[:name]}"
|
23
23
|
last_response.should be_ok
|
24
24
|
response = last_response.should return_json
|
25
|
-
response.is_a?(
|
26
|
-
s
|
27
|
-
s
|
28
|
-
s
|
29
|
-
s[
|
30
|
-
s["
|
25
|
+
response.is_a?(Hash).should == true
|
26
|
+
response.has_key?(@s.name).should == true
|
27
|
+
response[@s.name].is_a?(Hash).should == true
|
28
|
+
response[@s.name].has_key?(@h.name).should == true
|
29
|
+
response[@s.name][@h.name].is_a?(Hash).should == true
|
30
|
+
response[@s.name][@h.name]["id"].should == @s.id
|
31
|
+
response[@s.name][@h.name]["status"].should == @s.status
|
31
32
|
end
|
32
33
|
it "named service for host should work" do
|
33
34
|
get "/services/#{@sample_service[:name]}/#{@sample_host[:name]}"
|
data/spec/service_spec.rb
CHANGED
@@ -57,8 +57,8 @@ describe "Noah Service Model", :reset_redis => true do
|
|
57
57
|
h.save
|
58
58
|
end
|
59
59
|
Noah::Services.all.size.should == 2
|
60
|
-
Noah::Services.all.
|
61
|
-
Noah::Services.all.
|
60
|
+
Noah::Services.all.has_key?("s1").should == true
|
61
|
+
Noah::Services.all.has_key?("s2").should == true
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -29,9 +29,9 @@ RSpec.configure do |config|
|
|
29
29
|
|
30
30
|
a = Noah::Application.create(:name => 'noah')
|
31
31
|
if a.save
|
32
|
-
cr = Noah::Configuration.create(:name => 'redis', :format => 'string', :body => 'redis://127.0.0.1:6379/0'
|
33
|
-
ch = Noah::Configuration.create(:name => 'host', :format => 'string', :body => 'localhost'
|
34
|
-
cp = Noah::Configuration.create(:name => 'port', :format => 'string', :body => '9292'
|
32
|
+
cr = Noah::Configuration.create(:name => 'redis', :format => 'string', :body => 'redis://127.0.0.1:6379/0')
|
33
|
+
ch = Noah::Configuration.create(:name => 'host', :format => 'string', :body => 'localhost')
|
34
|
+
cp = Noah::Configuration.create(:name => 'port', :format => 'string', :body => '9292')
|
35
35
|
%w[cr ch cp].each do |c|
|
36
36
|
a.configurations << eval(c)
|
37
37
|
end
|
@@ -53,13 +53,13 @@ EOJ
|
|
53
53
|
|
54
54
|
a1 = Noah::Application.create(:name => 'myrailsapp1')
|
55
55
|
if a1.save
|
56
|
-
c1 = Noah::Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml
|
56
|
+
c1 = Noah::Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml)
|
57
57
|
a1.configurations << c1
|
58
58
|
end
|
59
59
|
|
60
60
|
a2 = Noah::Application.create(:name => 'myrestapp1')
|
61
61
|
if a2.save
|
62
|
-
c2 = Noah::Configuration.create(:name => 'config.json', :format => 'json', :body => my_json
|
62
|
+
c2 = Noah::Configuration.create(:name => 'config.json', :format => 'json', :body => my_json)
|
63
63
|
a2.configurations << c2
|
64
64
|
end
|
65
65
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'noah'
|
2
|
+
|
3
|
+
Ohm::redis.flushdb
|
4
|
+
puts "Creating sample entries - Watchers"
|
5
|
+
Noah::Watcher.create :endpoint => "dummy://applications", :pattern => "//noah/applications"
|
6
|
+
Noah::Watcher.create :endpoint => "dummy://configurations", :pattern => "//noah/configurations"
|
7
|
+
Noah::Watcher.create :endpoint => "dummy://hosts", :pattern => "//noah/hosts"
|
8
|
+
Noah::Watcher.create :endpoint => "dummy://services", :pattern => "//noah/services"
|
9
|
+
Noah::Watcher.create :endpoint => "dummy://ephemerals", :pattern => "//noah/ephemerals"
|
10
|
+
puts "Creating Host entry for 'localhost'"
|
11
|
+
h = Noah::Host.create(:name => 'localhost', :status => "up")
|
12
|
+
if h.save
|
13
|
+
%w[redis noah].each do |service|
|
14
|
+
puts "Create Service entry for #{service}"
|
15
|
+
s = Noah::Service.create(:name => service, :status => "up", :host_id => h.id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Creating Application entry for 'noah'"
|
20
|
+
a = Noah::Application.create(:name => 'noah')
|
21
|
+
if a.save
|
22
|
+
puts "Creating Configuration entry for 'noah'"
|
23
|
+
cr = Noah::Configuration.create(:name => 'redis_url', :format => 'string', :body => 'redis://127.0.0.1:6379/0')
|
24
|
+
ch = Noah::Configuration.create(:name => 'noah_host', :format => 'string', :body => 'localhost')
|
25
|
+
cp = Noah::Configuration.create(:name => 'noah_port', :format => 'string', :body => '9292')
|
26
|
+
[cr,ch,cp].each do |c|
|
27
|
+
a.configurations << c
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "Creating sample entries - Host and Service"
|
32
|
+
%w[host1.domain.com host2.domain.com host3.domain.com].each do |host|
|
33
|
+
h = Noah::Host.create(:name => host, :status => "up")
|
34
|
+
if h.save
|
35
|
+
%w[http https smtp mysql].each do |service|
|
36
|
+
s = Noah::Service.create(:name => service, :status => "pending", :host_id => h.id)
|
37
|
+
h.services << s
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "Creating sample entries - Application and Configuration"
|
43
|
+
my_yaml = <<EOY
|
44
|
+
development:
|
45
|
+
database: development_database
|
46
|
+
adapter: mysql
|
47
|
+
username: dev_user
|
48
|
+
password: dev_password
|
49
|
+
EOY
|
50
|
+
my_json = <<EOJ
|
51
|
+
{
|
52
|
+
"id":"hostname",
|
53
|
+
"data":"localhost"
|
54
|
+
}
|
55
|
+
EOJ
|
56
|
+
|
57
|
+
a1 = Noah::Application.create(:name => 'myrailsapp1')
|
58
|
+
if a1.save
|
59
|
+
c1 = Noah::Configuration.create(:name => 'database.yml', :format => 'yaml', :body => my_yaml)
|
60
|
+
a1.configurations << c1
|
61
|
+
end
|
62
|
+
|
63
|
+
a2 = Noah::Application.create(:name => 'myrestapp1')
|
64
|
+
if a2.save
|
65
|
+
c2 = Noah::Configuration.create(:name => 'config.json', :format => 'json', :body => my_json)
|
66
|
+
a2.configurations << c2
|
67
|
+
end
|
68
|
+
|
69
|
+
puts "Creating sample entries - Ephemerals"
|
70
|
+
e1 = Noah::Ephemeral.create(:path => '/some/random/path/item1', :data => 'some_data')
|
71
|
+
e2 = Noah::Ephemeral.create(:path => '/some/random/path/', :data => '{"children":["item1", "item2"]}')
|
72
|
+
|
73
|
+
puts "Creating sample entries - Links and Tags"
|
74
|
+
l1 = Noah::Link.new
|
75
|
+
l1.path = "/my_sample_organization"
|
76
|
+
l1.save
|
77
|
+
l1.nodes = [a1, c2, Noah::Host.find(:name => 'localhost').first, Noah::Service.find(:name => 'redis').first, e1, e2]
|
78
|
+
a1.tag! ["production", "sample_data"]
|
79
|
+
e2.tag! ["ephemeral", "development"]
|
80
|
+
c1.tag! "development"
|
81
|
+
Noah::Service[1].tag! "development"
|
82
|
+
Noah::Service[2].tag! ["development", "out-of-service"]
|
83
|
+
Noah::Service[2].link! "/my_sample_organization"
|
84
|
+
|
85
|
+
|
86
|
+
puts "Sample data populated!"
|
87
|
+
|
data/spec/tag_spec.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Using the Tag Model", :reset_redis => true do
|
4
|
+
before(:each) do
|
5
|
+
Ohm.redis.flushdb
|
6
|
+
@tags1 = ["production", "databases", "in-service"]
|
7
|
+
@tags2 = "out-of-service"
|
8
|
+
@host = Noah::Host.create(:name => 'tagged_host', :status => 'up')
|
9
|
+
@service = Noah::Service.create(:name => 'tagged_service', :status => 'down', :host_id => @host.id)
|
10
|
+
@application = Noah::Application.create(:name => 'tagged_application')
|
11
|
+
@configuration = Noah::Configuration.create(:name => 'tagged_configuration', :format => 'string', :body => 'some_string')
|
12
|
+
@ephemeral = Noah::Ephemeral.create(:path => '/tagged/ephemeral')
|
13
|
+
end
|
14
|
+
after(:each) do
|
15
|
+
Ohm.redis.flushdb
|
16
|
+
end
|
17
|
+
describe "should" do
|
18
|
+
it "create a new Noah::Tag" do
|
19
|
+
t = Noah::Tag.new(:name => 'some_tag')
|
20
|
+
t.valid?.should == true
|
21
|
+
t.save
|
22
|
+
t.is_new?.should == true
|
23
|
+
b = Noah::Tag.find(:name => 'some_tag').first
|
24
|
+
b.should == t
|
25
|
+
end
|
26
|
+
it "create a new Noah::Tag and add a member" do
|
27
|
+
t = Noah::Tag.create(:name => 'some_tag')
|
28
|
+
t.members = @host
|
29
|
+
@host.tags.member?(t).should == true
|
30
|
+
t.members[:hosts].size.should == 1
|
31
|
+
t.members[:hosts].member?(@host).should == true
|
32
|
+
end
|
33
|
+
it "tag! an existing object with a single tag" do
|
34
|
+
@host.tag! @tags2
|
35
|
+
t = Noah::Tag.find(:name => @tags2).first
|
36
|
+
@host.tags.member?(t).should == true
|
37
|
+
t.members[:hosts].size.should == 1
|
38
|
+
t.members[:hosts].member?(@host).should == true
|
39
|
+
end
|
40
|
+
it "tag! an existing object with an array of tags" do
|
41
|
+
@host.tag! @tags1
|
42
|
+
@tags1.each do |tag|
|
43
|
+
t = Noah::Tag.find(:name => tag).first
|
44
|
+
@host.tags.member?(t).should == true
|
45
|
+
t.members[:hosts].size.should == 1
|
46
|
+
t.members[:hosts].member?(@host).should == true
|
47
|
+
end
|
48
|
+
Noah::Tag.all.size.should == 3
|
49
|
+
end
|
50
|
+
it "tag all object types and find via tagged" do
|
51
|
+
@host.tag! @tags1
|
52
|
+
@ephemeral.tag! @tags1
|
53
|
+
@configuration.tag! @tags1
|
54
|
+
@application.tag! @tags1
|
55
|
+
@service.tag! @tags1
|
56
|
+
@tags1.each do |tag|
|
57
|
+
Noah::Tags.tagged(tag).size.should == 5
|
58
|
+
[@host, @service, @application, @configuration, @ephemeral].each do |o|
|
59
|
+
Noah::Tags.tagged(tag).values.flatten.member?(o).should == true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "should not" do
|
66
|
+
it "create a new Noah::Tag without a name" do
|
67
|
+
a = Noah::Tag.create
|
68
|
+
a.valid?.should == false
|
69
|
+
a.errors.should == [[:name, :not_present]]
|
70
|
+
end
|
71
|
+
it "create a tag with a duplicate name" do
|
72
|
+
a = Noah::Tag.create(:name => 'tag1')
|
73
|
+
b = Noah::Tag.create(:name => 'tag1')
|
74
|
+
b.valid?.should == false
|
75
|
+
b.errors.should == [[:name, :not_unique]]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/views/index.haml
CHANGED
@@ -52,4 +52,10 @@
|
|
52
52
|
%a{:href => "configurations/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
|
53
53
|
%li
|
54
54
|
%a{:href => "configurations/myrestapp1/config.json"} config.json file for myrestapp1
|
55
|
-
|
55
|
+
#header
|
56
|
+
%h2 Links
|
57
|
+
%ul
|
58
|
+
%li
|
59
|
+
%a{:href => "my_sample_organization"} Sample Organization Link
|
60
|
+
%li
|
61
|
+
%a{:href => "my_sample_organization/hosts"} Sample Organization Link - Hosts
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version:
|
4
|
+
prerelease: 4
|
5
|
+
version: 0.6.pre
|
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-
|
13
|
+
date: 2011-04-18 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - "="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
46
|
+
version: 2.2.0
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - "="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.2.
|
68
|
+
version: 1.2.2
|
69
69
|
type: :runtime
|
70
70
|
version_requirements: *id005
|
71
71
|
- !ruby/object:Gem::Dependency
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.2.
|
90
|
+
version: 1.2.3
|
91
91
|
type: :runtime
|
92
92
|
version_requirements: *id007
|
93
93
|
- !ruby/object:Gem::Dependency
|
@@ -270,14 +270,13 @@ files:
|
|
270
270
|
- lib/noah/agents/base_agent.rb
|
271
271
|
- lib/noah/agents/dummy_agent.rb
|
272
272
|
- lib/noah/agents/http_agent.rb
|
273
|
+
- lib/noah/agents/https_agent.rb
|
273
274
|
- lib/noah/app.rb
|
274
|
-
- lib/noah/application_routes.rb
|
275
275
|
- lib/noah/ark.rb
|
276
|
-
- lib/noah/configuration_routes.rb
|
277
276
|
- lib/noah/custom_watcher.rb
|
278
|
-
- lib/noah/
|
277
|
+
- lib/noah/exceptions.rb
|
279
278
|
- lib/noah/helpers.rb
|
280
|
-
- lib/noah/
|
279
|
+
- lib/noah/linkable.rb
|
281
280
|
- lib/noah/log.rb
|
282
281
|
- lib/noah/models.rb
|
283
282
|
- lib/noah/models/applications.rb
|
@@ -285,17 +284,23 @@ files:
|
|
285
284
|
- lib/noah/models/ephemerals.rb
|
286
285
|
- lib/noah/models/hosts.rb
|
287
286
|
- lib/noah/models/link.rb
|
288
|
-
- lib/noah/models/link_member.rb
|
289
287
|
- lib/noah/models/services.rb
|
290
288
|
- lib/noah/models/tags.rb
|
291
289
|
- lib/noah/models/watchers.rb
|
292
290
|
- lib/noah/passthrough.rb
|
293
|
-
- lib/noah/
|
291
|
+
- lib/noah/routes/applications.rb
|
292
|
+
- lib/noah/routes/configurations.rb
|
293
|
+
- lib/noah/routes/ephemerals.rb
|
294
|
+
- lib/noah/routes/hosts.rb
|
295
|
+
- lib/noah/routes/links.rb
|
296
|
+
- lib/noah/routes/services.rb
|
297
|
+
- lib/noah/routes/tags.rb
|
298
|
+
- lib/noah/routes/watchers.rb
|
299
|
+
- lib/noah/taggable.rb
|
294
300
|
- lib/noah/validations.rb
|
295
301
|
- lib/noah/validations/ephemeral_validations.rb
|
296
302
|
- lib/noah/validations/watcher_validations.rb
|
297
303
|
- lib/noah/version.rb
|
298
|
-
- lib/noah/watcher_routes.rb
|
299
304
|
- noah.gemspec
|
300
305
|
- spec/application_spec.rb
|
301
306
|
- spec/configuration_spec.rb
|
@@ -311,7 +316,9 @@ files:
|
|
311
316
|
- spec/service_spec.rb
|
312
317
|
- spec/spec_helper.rb
|
313
318
|
- spec/support/db/.keep
|
319
|
+
- spec/support/sample_data.rb
|
314
320
|
- spec/support/test-redis.conf
|
321
|
+
- spec/tag_spec.rb
|
315
322
|
- spec/watcher_spec.rb
|
316
323
|
- views/200.erb
|
317
324
|
- views/404.erb
|
@@ -321,7 +328,7 @@ has_rdoc: true
|
|
321
328
|
homepage: https://github.com/lusis/noah
|
322
329
|
licenses: []
|
323
330
|
|
324
|
-
post_install_message:
|
331
|
+
post_install_message: This release has backwards incompatible changes to the API. Please watch http://goo.gl/jYqp2 for details
|
325
332
|
rdoc_options: []
|
326
333
|
|
327
334
|
require_paths:
|
@@ -335,9 +342,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
335
342
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
336
343
|
none: false
|
337
344
|
requirements:
|
338
|
-
- - "
|
345
|
+
- - ">"
|
339
346
|
- !ruby/object:Gem::Version
|
340
|
-
version:
|
347
|
+
version: 1.3.1
|
341
348
|
requirements: []
|
342
349
|
|
343
350
|
rubyforge_project: noah
|