eye 0.2.4 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/bin/eye +7 -0
- data/bin/loader_eye +7 -5
- data/examples/notify.eye +1 -1
- data/eye.gemspec +4 -4
- data/lib/eye.rb +1 -3
- data/lib/eye/controller.rb +4 -0
- data/lib/eye/controller/status.rb +1 -1
- data/lib/eye/dsl.rb +1 -1
- data/lib/eye/dsl/main.rb +0 -13
- data/lib/eye/dsl/opts.rb +4 -2
- data/lib/eye/loader.rb +2 -3
- data/lib/eye/notify.rb +3 -3
- data/lib/eye/process/monitor.rb +5 -3
- data/lib/eye/process/notify.rb +5 -5
- data/lib/eye/process/scheduler.rb +4 -4
- data/lib/eye/process/system.rb +3 -10
- data/lib/eye/process/trigger.rb +1 -1
- data/lib/eye/process/watchers.rb +1 -1
- data/lib/eye/server.rb +9 -8
- data/lib/eye/system.rb +2 -7
- data/lib/eye/system_resources.rb +3 -3
- data/lib/eye/utils/celluloid_chain.rb +2 -2
- metadata +7 -241
- data/lib/eye/io/unix_server.rb +0 -44
- data/lib/eye/io/unix_socket.rb +0 -39
- data/spec/checker/cpu_spec.rb +0 -58
- data/spec/checker/file_ctime_spec.rb +0 -34
- data/spec/checker/file_size_spec.rb +0 -107
- data/spec/checker/http_spec.rb +0 -114
- data/spec/checker/memory_spec.rb +0 -64
- data/spec/checker/socket_spec.rb +0 -116
- data/spec/checker_spec.rb +0 -187
- data/spec/child_process/child_process_spec.rb +0 -46
- data/spec/client_server_spec.rb +0 -33
- data/spec/controller/commands_spec.rb +0 -92
- data/spec/controller/controller_spec.rb +0 -157
- data/spec/controller/find_objects_spec.rb +0 -176
- data/spec/controller/group_spec.rb +0 -110
- data/spec/controller/intergration_spec.rb +0 -366
- data/spec/controller/load_spec.rb +0 -371
- data/spec/controller/races_spec.rb +0 -70
- data/spec/controller/stop_on_delete_spec.rb +0 -157
- data/spec/dsl/chain_spec.rb +0 -146
- data/spec/dsl/checks_spec.rb +0 -219
- data/spec/dsl/config_spec.rb +0 -44
- data/spec/dsl/dsl_spec.rb +0 -73
- data/spec/dsl/getter_spec.rb +0 -223
- data/spec/dsl/integration_spec.rb +0 -376
- data/spec/dsl/load_spec.rb +0 -52
- data/spec/dsl/notify_spec.rb +0 -114
- data/spec/dsl/process_spec.rb +0 -380
- data/spec/dsl/sub_procs_spec.rb +0 -93
- data/spec/dsl/with_server_spec.rb +0 -128
- data/spec/example/em.rb +0 -57
- data/spec/example/forking.rb +0 -20
- data/spec/example/sample.rb +0 -154
- data/spec/fixtures/dsl/0.rb +0 -8
- data/spec/fixtures/dsl/0a.rb +0 -8
- data/spec/fixtures/dsl/0c.rb +0 -8
- data/spec/fixtures/dsl/1.rb +0 -5
- data/spec/fixtures/dsl/bad.eye +0 -6
- data/spec/fixtures/dsl/configs/1.eye +0 -3
- data/spec/fixtures/dsl/configs/2.eye +0 -1
- data/spec/fixtures/dsl/configs/3.eye +0 -1
- data/spec/fixtures/dsl/configs/4.eye +0 -3
- data/spec/fixtures/dsl/empty.eye +0 -20
- data/spec/fixtures/dsl/include_test.eye +0 -5
- data/spec/fixtures/dsl/include_test/1.rb +0 -6
- data/spec/fixtures/dsl/include_test/ha.rb +0 -4
- data/spec/fixtures/dsl/include_test2.eye +0 -5
- data/spec/fixtures/dsl/integration.eye +0 -30
- data/spec/fixtures/dsl/integration2.eye +0 -32
- data/spec/fixtures/dsl/integration_locks.eye +0 -30
- data/spec/fixtures/dsl/integration_sor.eye +0 -32
- data/spec/fixtures/dsl/integration_sor2.eye +0 -27
- data/spec/fixtures/dsl/integration_sor3.eye +0 -32
- data/spec/fixtures/dsl/load.eye +0 -25
- data/spec/fixtures/dsl/load2.eye +0 -7
- data/spec/fixtures/dsl/load2_dup2.eye +0 -13
- data/spec/fixtures/dsl/load2_dup_pid.eye +0 -7
- data/spec/fixtures/dsl/load3.eye +0 -10
- data/spec/fixtures/dsl/load4.eye +0 -7
- data/spec/fixtures/dsl/load5.eye +0 -8
- data/spec/fixtures/dsl/load6.eye +0 -17
- data/spec/fixtures/dsl/load_dubls.eye +0 -36
- data/spec/fixtures/dsl/load_dup_ex_names.eye +0 -15
- data/spec/fixtures/dsl/load_error.eye +0 -5
- data/spec/fixtures/dsl/load_error_folder/load3.eye +0 -10
- data/spec/fixtures/dsl/load_error_folder/load4.eye +0 -7
- data/spec/fixtures/dsl/load_folder/load3.eye +0 -10
- data/spec/fixtures/dsl/load_folder/load4.eye +0 -7
- data/spec/fixtures/dsl/load_int.eye +0 -8
- data/spec/fixtures/dsl/load_int2.eye +0 -13
- data/spec/fixtures/dsl/load_logger.eye +0 -26
- data/spec/fixtures/dsl/load_logger2.eye +0 -3
- data/spec/fixtures/dsl/long_load.eye +0 -5
- data/spec/fixtures/dsl/subfolder1/proc1.rb +0 -3
- data/spec/fixtures/dsl/subfolder2.eye +0 -9
- data/spec/fixtures/dsl/subfolder2/common.rb +0 -1
- data/spec/fixtures/dsl/subfolder2/proc2.rb +0 -3
- data/spec/fixtures/dsl/subfolder2/sub/proc3.rb +0 -6
- data/spec/fixtures/dsl/subfolder3.eye +0 -8
- data/spec/fixtures/dsl/subfolder3/common.rb +0 -1
- data/spec/fixtures/dsl/subfolder3/proc4.rb +0 -3
- data/spec/fixtures/dsl/subfolder3/sub/proc5.rb +0 -6
- data/spec/fixtures/dsl/subfolder4.eye +0 -6
- data/spec/fixtures/dsl/subfolder4/a.rb +0 -2
- data/spec/fixtures/dsl/subfolder4/b.rb +0 -1
- data/spec/fixtures/dsl/subfolder4/c.rb +0 -1
- data/spec/mock_spec.rb +0 -31
- data/spec/notify/jabber_spec.rb +0 -25
- data/spec/notify/mail_spec.rb +0 -26
- data/spec/notify_spec.rb +0 -90
- data/spec/process/checks/child_checks_spec.rb +0 -79
- data/spec/process/checks/cpu_spec.rb +0 -114
- data/spec/process/checks/ctime_spec.rb +0 -43
- data/spec/process/checks/fsize_spec.rb +0 -22
- data/spec/process/checks/http_spec.rb +0 -52
- data/spec/process/checks/intergration_spec.rb +0 -32
- data/spec/process/checks/memory_spec.rb +0 -127
- data/spec/process/child_process_spec.rb +0 -125
- data/spec/process/config_spec.rb +0 -74
- data/spec/process/controller_spec.rb +0 -173
- data/spec/process/monitoring_spec.rb +0 -180
- data/spec/process/notify_spec.rb +0 -27
- data/spec/process/restart_spec.rb +0 -186
- data/spec/process/scheduler_spec.rb +0 -178
- data/spec/process/start_spec.rb +0 -261
- data/spec/process/states_history_spec.rb +0 -123
- data/spec/process/stop_spec.rb +0 -156
- data/spec/process/system_spec.rb +0 -136
- data/spec/process/triggers/flapping_spec.rb +0 -242
- data/spec/process/update_config_spec.rb +0 -62
- data/spec/spec_helper.rb +0 -128
- data/spec/support/rr_celluloid.rb +0 -15
- data/spec/support/spec_support.rb +0 -163
- data/spec/system_resources_spec.rb +0 -56
- data/spec/system_spec.rb +0 -174
- data/spec/utils/alive_array_spec.rb +0 -49
- data/spec/utils/celluloid_chain_spec.rb +0 -89
- data/spec/utils/tail_spec.rb +0 -20
data/lib/eye/io/unix_server.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
|
3
|
-
module Celluloid
|
4
|
-
module IO
|
5
|
-
# UNIXServer with combined blocking and evented support
|
6
|
-
class UNIXServer
|
7
|
-
extend Forwardable
|
8
|
-
def_delegators :@server, :listen, :sysaccept, :close, :closed?
|
9
|
-
|
10
|
-
def self.open(socket_path)
|
11
|
-
self.new(socket_path)
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(socket_path)
|
15
|
-
@server = ::UNIXServer.new(socket_path)
|
16
|
-
end
|
17
|
-
|
18
|
-
def accept
|
19
|
-
actor = Thread.current[:actor]
|
20
|
-
|
21
|
-
if evented?
|
22
|
-
Celluloid.current_actor.wait_readable @server
|
23
|
-
accept_nonblock
|
24
|
-
else
|
25
|
-
Celluloid::IO::UNIXSocket.from_ruby_socket @server.accept
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def accept_nonblock
|
30
|
-
Celluloid::IO::UNIXSocket.from_ruby_socket @server.accept_nonblock
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_io
|
34
|
-
@server
|
35
|
-
end
|
36
|
-
|
37
|
-
# Are we inside a Celluloid ::IO actor?
|
38
|
-
def evented?
|
39
|
-
actor = Thread.current[:actor]
|
40
|
-
actor && actor.mailbox.is_a?(Celluloid::IO::Mailbox)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/eye/io/unix_socket.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
|
3
|
-
module Celluloid
|
4
|
-
module IO
|
5
|
-
# UNIXSocket with combined blocking and evented support
|
6
|
-
class UNIXSocket
|
7
|
-
include CommonMethods
|
8
|
-
extend Forwardable
|
9
|
-
|
10
|
-
def_delegators :@socket, :read_nonblock, :write_nonblock, :close, :closed?, :readline, :puts, :addr
|
11
|
-
|
12
|
-
# Convert a Ruby UNIXSocket into a Celluloid::IO::UNIXSocket
|
13
|
-
def self.from_ruby_socket(ruby_socket)
|
14
|
-
# Some hax here, but whatever ;)
|
15
|
-
socket = allocate
|
16
|
-
socket.instance_variable_set(:@socket, ruby_socket)
|
17
|
-
socket
|
18
|
-
end
|
19
|
-
|
20
|
-
# Open a UNIX connection.
|
21
|
-
def self.open(socket_path, &block)
|
22
|
-
self.new(socket_path, &block)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Open a UNIX connection.
|
26
|
-
def initialize(socket_path, &block)
|
27
|
-
@socket = if block
|
28
|
-
::UNIXSocket.open(socket_path, &block)
|
29
|
-
else
|
30
|
-
::UNIXSocket.new(socket_path)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_io
|
35
|
-
@socket
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/spec/checker/cpu_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
def chcpu(cfg = {})
|
4
|
-
Eye::Checker.create(123, {:type => :cpu, :every => 5.seconds,
|
5
|
-
:times => 1}.merge(cfg))
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Eye::Checker::Cpu" do
|
9
|
-
|
10
|
-
describe "without below" do
|
11
|
-
subject{ chcpu }
|
12
|
-
|
13
|
-
it "get_value" do
|
14
|
-
mock(Eye::SystemResources).cpu(123){ 65 }
|
15
|
-
subject.get_value.should == 65
|
16
|
-
end
|
17
|
-
|
18
|
-
it "without below always true" do
|
19
|
-
stub(subject).get_value{ 15 }
|
20
|
-
subject.check.should == true
|
21
|
-
|
22
|
-
stub(subject).get_value{ 20 }
|
23
|
-
subject.check.should == true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "with below" do
|
28
|
-
subject{ chcpu(:below => 30) }
|
29
|
-
|
30
|
-
it "good" do
|
31
|
-
stub(subject).get_value{ 20 }
|
32
|
-
subject.check.should == true
|
33
|
-
|
34
|
-
stub(subject).get_value{ 25 }
|
35
|
-
subject.check.should == true
|
36
|
-
end
|
37
|
-
|
38
|
-
it "good" do
|
39
|
-
stub(subject).get_value{ 25 }
|
40
|
-
subject.check.should == true
|
41
|
-
|
42
|
-
stub(subject).get_value{ 35 }
|
43
|
-
subject.check.should == false
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "validates" do
|
49
|
-
it "ok" do
|
50
|
-
Eye::Checker.validate!({:type => :cpu, :every => 5.seconds, :times => 1, :below => 100})
|
51
|
-
end
|
52
|
-
|
53
|
-
it "bad param below" do
|
54
|
-
expect{ Eye::Checker.validate!({:type => :cpu, :every => 5.seconds, :times => 1, :below => {1 => 2}}) }.to raise_error(Eye::Dsl::Validation::Error)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
def chctime(cfg = {})
|
4
|
-
Eye::Checker.create(nil, {:type => :ctime, :every => 5.seconds,
|
5
|
-
:file => $logger_path, :times => 1}.merge(cfg))
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Eye::Checker::FileCTime" do
|
9
|
-
|
10
|
-
describe "" do
|
11
|
-
subject{ chctime }
|
12
|
-
|
13
|
-
it "get_value" do
|
14
|
-
subject.get_value.should == File.ctime($logger_path)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "not good if size equal prevous" do
|
18
|
-
stub(subject).get_value{ Time.parse('00:00:01') }
|
19
|
-
subject.check.should == true
|
20
|
-
|
21
|
-
stub(subject).get_value{ Time.parse('00:00:01') }
|
22
|
-
subject.check.should == false
|
23
|
-
end
|
24
|
-
|
25
|
-
it "good when little different with previous" do
|
26
|
-
stub(subject).get_value{ Time.parse('00:00:01') }
|
27
|
-
subject.check.should == true
|
28
|
-
|
29
|
-
stub(subject).get_value{ Time.parse('00:00:02') }
|
30
|
-
subject.check.should == true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
def chfsize(cfg = {})
|
4
|
-
Eye::Checker.create(nil, {:type => :fsize, :every => 5.seconds,
|
5
|
-
:file => $logger_path, :times => 1}.merge(cfg))
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Eye::Checker::FileSize" do
|
9
|
-
|
10
|
-
describe "" do
|
11
|
-
subject{ chfsize }
|
12
|
-
|
13
|
-
it "get_value" do
|
14
|
-
subject.get_value.should be_within(10).of(File.size($logger_path))
|
15
|
-
end
|
16
|
-
|
17
|
-
it "not good if size equal prevous" do
|
18
|
-
stub(subject).get_value{1001}
|
19
|
-
subject.check.should == true
|
20
|
-
|
21
|
-
stub(subject).get_value{1001}
|
22
|
-
subject.check.should == false
|
23
|
-
end
|
24
|
-
|
25
|
-
it "good when little different with previous" do
|
26
|
-
stub(subject).get_value{1001}
|
27
|
-
subject.check.should == true
|
28
|
-
|
29
|
-
stub(subject).get_value{1002}
|
30
|
-
subject.check.should == true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "below" do
|
35
|
-
subject{ chfsize(:below => 10) }
|
36
|
-
|
37
|
-
it "good" do
|
38
|
-
stub(subject).get_value{1001}
|
39
|
-
subject.check.should == true
|
40
|
-
|
41
|
-
stub(subject).get_value{1005}
|
42
|
-
subject.check.should == true
|
43
|
-
end
|
44
|
-
|
45
|
-
it "bad" do
|
46
|
-
stub(subject).get_value{1001}
|
47
|
-
subject.check.should == true
|
48
|
-
|
49
|
-
stub(subject).get_value{1015}
|
50
|
-
subject.check.should == false
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "above" do
|
56
|
-
subject{ chfsize(:above => 10) }
|
57
|
-
|
58
|
-
it "good" do
|
59
|
-
stub(subject).get_value{1001}
|
60
|
-
subject.check.should == true
|
61
|
-
|
62
|
-
stub(subject).get_value{1005}
|
63
|
-
subject.check.should == false
|
64
|
-
end
|
65
|
-
|
66
|
-
it "bad" do
|
67
|
-
stub(subject).get_value{1001}
|
68
|
-
subject.check.should == true
|
69
|
-
|
70
|
-
stub(subject).get_value{1015}
|
71
|
-
subject.check.should == true
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
describe "above and below" do
|
78
|
-
subject{ chfsize(:above => 10, :below => 30) }
|
79
|
-
|
80
|
-
it "bad" do
|
81
|
-
stub(subject).get_value{1001}
|
82
|
-
subject.check.should == true
|
83
|
-
|
84
|
-
stub(subject).get_value{1005}
|
85
|
-
subject.check.should == false
|
86
|
-
end
|
87
|
-
|
88
|
-
it "good" do
|
89
|
-
stub(subject).get_value{1001}
|
90
|
-
subject.check.should == true
|
91
|
-
|
92
|
-
stub(subject).get_value{1021}
|
93
|
-
subject.check.should == true
|
94
|
-
end
|
95
|
-
|
96
|
-
it "bad" do
|
97
|
-
stub(subject).get_value{1001}
|
98
|
-
subject.check.should == true
|
99
|
-
|
100
|
-
stub(subject).get_value{1045}
|
101
|
-
subject.check.should == false
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
end
|
data/spec/checker/http_spec.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
def chhttp(cfg = {})
|
4
|
-
Eye::Checker.create(nil, {:type => :http, :every => 5.seconds,
|
5
|
-
:times => 1, :url => "http://localhost:3000/", :kind => :success,
|
6
|
-
:pattern => /OK/, :timeout => 2}.merge(cfg))
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "Eye::Checker::Http" do
|
10
|
-
|
11
|
-
after :each do
|
12
|
-
FakeWeb.clean_registry
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "get_value" do
|
16
|
-
subject{ chhttp }
|
17
|
-
|
18
|
-
it "initialize" do
|
19
|
-
subject.instance_variable_get(:@kind).should == Net::HTTPSuccess
|
20
|
-
subject.instance_variable_get(:@pattern).should == /OK/
|
21
|
-
subject.instance_variable_get(:@open_timeout).should == 3
|
22
|
-
subject.instance_variable_get(:@read_timeout).should == 2
|
23
|
-
end
|
24
|
-
|
25
|
-
it "without url" do
|
26
|
-
chhttp(:url => nil).uri.should == URI.parse('http://127.0.0.1')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "get_value" do
|
30
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody OK")
|
31
|
-
subject.get_value[:result].body.should == "Somebody OK"
|
32
|
-
|
33
|
-
subject.human_value(subject.get_value).should == "200=0Kb"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "get_value exception" do
|
37
|
-
a = ""
|
38
|
-
stub(subject).session{ a }
|
39
|
-
stub(subject.session).start{ raise Timeout::Error, "timeout" }
|
40
|
-
mes = RUBY_VERSION < '2.0' ? "Timeout<3.0,2.0>" : "ReadTimeout<2.0>"
|
41
|
-
|
42
|
-
subject.get_value.should == {:exception => mes}
|
43
|
-
subject.human_value(subject.get_value).should == mes
|
44
|
-
end
|
45
|
-
|
46
|
-
it "get_value raised" do
|
47
|
-
a = ""
|
48
|
-
stub(subject).session{ a }
|
49
|
-
stub(subject.session).start{ raise "something" }
|
50
|
-
subject.get_value.should == {:exception => "Error<something>"}
|
51
|
-
|
52
|
-
subject.human_value(subject.get_value).should == "Error<something>"
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "good?" do
|
58
|
-
subject{ chhttp }
|
59
|
-
|
60
|
-
it "good" do
|
61
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody OK")
|
62
|
-
subject.check.should == true
|
63
|
-
end
|
64
|
-
|
65
|
-
it "good pattern is string" do
|
66
|
-
subject = chhttp(:pattern => "OK")
|
67
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody OK")
|
68
|
-
subject.check.should == true
|
69
|
-
end
|
70
|
-
|
71
|
-
it "bad pattern" do
|
72
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody bad")
|
73
|
-
subject.check.should == false
|
74
|
-
end
|
75
|
-
|
76
|
-
it "bad pattern string" do
|
77
|
-
subject = chhttp(:pattern => "OK")
|
78
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody bad")
|
79
|
-
subject.check.should == false
|
80
|
-
end
|
81
|
-
|
82
|
-
it "not 200" do
|
83
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/bla", :body => "Somebody OK", :status => [500, 'err'])
|
84
|
-
subject.check.should == false
|
85
|
-
end
|
86
|
-
|
87
|
-
it "without patter its ok" do
|
88
|
-
subject = chhttp(:pattern => nil)
|
89
|
-
FakeWeb.register_uri(:get, "http://localhost:3000/", :body => "Somebody OK")
|
90
|
-
subject.check.should == true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "validates" do
|
95
|
-
it "ok" do
|
96
|
-
Eye::Checker.validate!({:type => :http, :every => 5.seconds,
|
97
|
-
:times => 1, :url => "http://localhost:3000/", :kind => :success,
|
98
|
-
:pattern => /OK/, :timeout => 2})
|
99
|
-
end
|
100
|
-
|
101
|
-
it "without param url" do
|
102
|
-
expect{ Eye::Checker.validate!({:type => :http, :every => 5.seconds,
|
103
|
-
:times => 1, :kind => :success,
|
104
|
-
:pattern => /OK/, :timeout => 2}) }.to raise_error(Eye::Dsl::Validation::Error)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "bad param timeout" do
|
108
|
-
expect{ Eye::Checker.validate!({:type => :http, :every => 5.seconds,
|
109
|
-
:times => 1, :kind => :success, :url => "http://localhost:3000/",
|
110
|
-
:pattern => /OK/, :timeout => :fix}) }.to raise_error(Eye::Dsl::Validation::Error)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
data/spec/checker/memory_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
def chmem(cfg = {})
|
4
|
-
Eye::Checker.create(123, {:type => :memory, :every => 5.seconds,
|
5
|
-
:times => 1}.merge(cfg))
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "Eye::Checker::Memory" do
|
9
|
-
|
10
|
-
describe "without below" do
|
11
|
-
subject{ chmem }
|
12
|
-
|
13
|
-
it "get_value" do
|
14
|
-
mock(Eye::SystemResources).memory(123){ 65 }
|
15
|
-
subject.get_value.should == 66560
|
16
|
-
end
|
17
|
-
|
18
|
-
it "without below always true" do
|
19
|
-
stub(subject).get_value{ 315 }
|
20
|
-
subject.check.should == true
|
21
|
-
|
22
|
-
stub(subject).get_value{ 320 }
|
23
|
-
subject.check.should == true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "with below" do
|
28
|
-
subject{ chmem(:below => 300.megabytes) }
|
29
|
-
|
30
|
-
it "good" do
|
31
|
-
stub(subject).get_value{ 200.megabytes }
|
32
|
-
subject.check.should == true
|
33
|
-
|
34
|
-
stub(subject).get_value{ 250.megabytes }
|
35
|
-
subject.check.should == true
|
36
|
-
end
|
37
|
-
|
38
|
-
it "good" do
|
39
|
-
stub(subject).get_value{ 250.megabytes }
|
40
|
-
subject.check.should == true
|
41
|
-
|
42
|
-
stub(subject).get_value{ 350.megabytes }
|
43
|
-
subject.check.should == false
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "validates" do
|
49
|
-
it "ok" do
|
50
|
-
Eye::Checker.validate!({:type => :memory, :every => 5.seconds, :times => 1, :below => 10.0.bytes})
|
51
|
-
end
|
52
|
-
|
53
|
-
it "bad param below" do
|
54
|
-
expect{ Eye::Checker.validate!({:type => :memory, :every => 5.seconds, :times => 1, :below => {1 => 2}}) }.to raise_error(Eye::Dsl::Validation::Error)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "unknown params" do
|
58
|
-
expect{ Eye::Checker.validate!({:hello => true, :type => :memory, :every => 5.seconds, :times => 1, :below => 10.0.bytes})}.to raise_error(Eye::Dsl::Validation::Error)
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
end
|