eye 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. data/.gitignore +31 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +132 -0
  6. data/Rakefile +18 -0
  7. data/bin/eye +282 -0
  8. data/bin/loader_eye +56 -0
  9. data/examples/processes/em.rb +56 -0
  10. data/examples/processes/forking.rb +20 -0
  11. data/examples/processes/sample.rb +144 -0
  12. data/examples/rbenv.eye +11 -0
  13. data/examples/test.eye +65 -0
  14. data/examples/unicorn.eye +29 -0
  15. data/eye.gemspec +37 -0
  16. data/lib/eye.rb +25 -0
  17. data/lib/eye/application.rb +65 -0
  18. data/lib/eye/checker.rb +118 -0
  19. data/lib/eye/checker/cpu.rb +27 -0
  20. data/lib/eye/checker/file_ctime.rb +29 -0
  21. data/lib/eye/checker/file_size.rb +38 -0
  22. data/lib/eye/checker/http.rb +94 -0
  23. data/lib/eye/checker/memory.rb +27 -0
  24. data/lib/eye/checker/socket.rb +148 -0
  25. data/lib/eye/checker/validation.rb +49 -0
  26. data/lib/eye/child_process.rb +75 -0
  27. data/lib/eye/client.rb +32 -0
  28. data/lib/eye/control.rb +2 -0
  29. data/lib/eye/controller.rb +43 -0
  30. data/lib/eye/controller/commands.rb +64 -0
  31. data/lib/eye/controller/helpers.rb +61 -0
  32. data/lib/eye/controller/load.rb +224 -0
  33. data/lib/eye/controller/send_command.rb +88 -0
  34. data/lib/eye/controller/status.rb +136 -0
  35. data/lib/eye/dsl.rb +52 -0
  36. data/lib/eye/dsl/application_opts.rb +33 -0
  37. data/lib/eye/dsl/chain.rb +12 -0
  38. data/lib/eye/dsl/child_process_opts.rb +7 -0
  39. data/lib/eye/dsl/config_opts.rb +11 -0
  40. data/lib/eye/dsl/group_opts.rb +27 -0
  41. data/lib/eye/dsl/helpers.rb +12 -0
  42. data/lib/eye/dsl/main.rb +58 -0
  43. data/lib/eye/dsl/opts.rb +88 -0
  44. data/lib/eye/dsl/process_opts.rb +21 -0
  45. data/lib/eye/dsl/pure_opts.rb +132 -0
  46. data/lib/eye/dsl/validate.rb +41 -0
  47. data/lib/eye/group.rb +125 -0
  48. data/lib/eye/group/chain.rb +68 -0
  49. data/lib/eye/io/unix_server.rb +44 -0
  50. data/lib/eye/io/unix_socket.rb +39 -0
  51. data/lib/eye/loader.rb +13 -0
  52. data/lib/eye/logger.rb +80 -0
  53. data/lib/eye/process.rb +83 -0
  54. data/lib/eye/process/child.rb +61 -0
  55. data/lib/eye/process/commands.rb +256 -0
  56. data/lib/eye/process/config.rb +70 -0
  57. data/lib/eye/process/controller.rb +72 -0
  58. data/lib/eye/process/data.rb +46 -0
  59. data/lib/eye/process/monitor.rb +97 -0
  60. data/lib/eye/process/notify.rb +17 -0
  61. data/lib/eye/process/scheduler.rb +50 -0
  62. data/lib/eye/process/states.rb +92 -0
  63. data/lib/eye/process/states_history.rb +62 -0
  64. data/lib/eye/process/system.rb +60 -0
  65. data/lib/eye/process/trigger.rb +32 -0
  66. data/lib/eye/process/watchers.rb +67 -0
  67. data/lib/eye/server.rb +51 -0
  68. data/lib/eye/settings.rb +35 -0
  69. data/lib/eye/system.rb +145 -0
  70. data/lib/eye/system_resources.rb +83 -0
  71. data/lib/eye/trigger.rb +53 -0
  72. data/lib/eye/trigger/flapping.rb +24 -0
  73. data/lib/eye/utils.rb +5 -0
  74. data/lib/eye/utils/alive_array.rb +31 -0
  75. data/lib/eye/utils/celluloid_chain.rb +51 -0
  76. data/lib/eye/utils/leak_19.rb +7 -0
  77. data/lib/eye/utils/tail.rb +20 -0
  78. data/spec/checker/cpu_spec.rb +58 -0
  79. data/spec/checker/file_ctime_spec.rb +34 -0
  80. data/spec/checker/file_size_spec.rb +107 -0
  81. data/spec/checker/http_spec.rb +109 -0
  82. data/spec/checker/memory_spec.rb +64 -0
  83. data/spec/checker/socket_spec.rb +116 -0
  84. data/spec/checker_spec.rb +188 -0
  85. data/spec/child_process/child_process_spec.rb +46 -0
  86. data/spec/client_server_spec.rb +34 -0
  87. data/spec/controller/commands_spec.rb +92 -0
  88. data/spec/controller/controller_spec.rb +133 -0
  89. data/spec/controller/find_objects_spec.rb +150 -0
  90. data/spec/controller/group_spec.rb +110 -0
  91. data/spec/controller/intergration_spec.rb +327 -0
  92. data/spec/controller/load_spec.rb +326 -0
  93. data/spec/controller/races_spec.rb +70 -0
  94. data/spec/controller/stop_on_delete_spec.rb +157 -0
  95. data/spec/dsl/chain_spec.rb +140 -0
  96. data/spec/dsl/checks_spec.rb +202 -0
  97. data/spec/dsl/config_spec.rb +44 -0
  98. data/spec/dsl/dsl_spec.rb +73 -0
  99. data/spec/dsl/getter_spec.rb +223 -0
  100. data/spec/dsl/integration_spec.rb +311 -0
  101. data/spec/dsl/load_spec.rb +52 -0
  102. data/spec/dsl/process_spec.rb +330 -0
  103. data/spec/dsl/sub_procs_spec.rb +93 -0
  104. data/spec/dsl/with_server_spec.rb +104 -0
  105. data/spec/example/em.rb +57 -0
  106. data/spec/example/forking.rb +20 -0
  107. data/spec/example/sample.rb +154 -0
  108. data/spec/fixtures/dsl/0.rb +8 -0
  109. data/spec/fixtures/dsl/0a.rb +8 -0
  110. data/spec/fixtures/dsl/0c.rb +8 -0
  111. data/spec/fixtures/dsl/1.rb +5 -0
  112. data/spec/fixtures/dsl/bad.eye +6 -0
  113. data/spec/fixtures/dsl/configs/1.eye +3 -0
  114. data/spec/fixtures/dsl/configs/2.eye +1 -0
  115. data/spec/fixtures/dsl/configs/3.eye +1 -0
  116. data/spec/fixtures/dsl/configs/4.eye +3 -0
  117. data/spec/fixtures/dsl/empty.eye +20 -0
  118. data/spec/fixtures/dsl/include_test.eye +5 -0
  119. data/spec/fixtures/dsl/include_test/1.rb +6 -0
  120. data/spec/fixtures/dsl/include_test/ha.rb +4 -0
  121. data/spec/fixtures/dsl/include_test2.eye +5 -0
  122. data/spec/fixtures/dsl/integration.eye +30 -0
  123. data/spec/fixtures/dsl/integration2.eye +32 -0
  124. data/spec/fixtures/dsl/integration_locks.eye +30 -0
  125. data/spec/fixtures/dsl/integration_sor.eye +32 -0
  126. data/spec/fixtures/dsl/integration_sor2.eye +27 -0
  127. data/spec/fixtures/dsl/integration_sor3.eye +32 -0
  128. data/spec/fixtures/dsl/load.eye +25 -0
  129. data/spec/fixtures/dsl/load2.eye +7 -0
  130. data/spec/fixtures/dsl/load2_dup2.eye +13 -0
  131. data/spec/fixtures/dsl/load2_dup_pid.eye +7 -0
  132. data/spec/fixtures/dsl/load3.eye +10 -0
  133. data/spec/fixtures/dsl/load4.eye +7 -0
  134. data/spec/fixtures/dsl/load5.eye +8 -0
  135. data/spec/fixtures/dsl/load6.eye +17 -0
  136. data/spec/fixtures/dsl/load_dubls.eye +36 -0
  137. data/spec/fixtures/dsl/load_dup_ex_names.eye +15 -0
  138. data/spec/fixtures/dsl/load_error.eye +5 -0
  139. data/spec/fixtures/dsl/load_error_folder/load3.eye +10 -0
  140. data/spec/fixtures/dsl/load_error_folder/load4.eye +7 -0
  141. data/spec/fixtures/dsl/load_folder/load3.eye +10 -0
  142. data/spec/fixtures/dsl/load_folder/load4.eye +7 -0
  143. data/spec/fixtures/dsl/load_int.eye +8 -0
  144. data/spec/fixtures/dsl/load_int2.eye +13 -0
  145. data/spec/fixtures/dsl/load_logger.eye +26 -0
  146. data/spec/fixtures/dsl/load_logger2.eye +3 -0
  147. data/spec/fixtures/dsl/long_load.eye +5 -0
  148. data/spec/fixtures/dsl/subfolder1/proc1.rb +3 -0
  149. data/spec/fixtures/dsl/subfolder2.eye +9 -0
  150. data/spec/fixtures/dsl/subfolder2/common.rb +1 -0
  151. data/spec/fixtures/dsl/subfolder2/proc2.rb +3 -0
  152. data/spec/fixtures/dsl/subfolder2/sub/proc3.rb +6 -0
  153. data/spec/fixtures/dsl/subfolder3.eye +8 -0
  154. data/spec/fixtures/dsl/subfolder3/common.rb +1 -0
  155. data/spec/fixtures/dsl/subfolder3/proc4.rb +3 -0
  156. data/spec/fixtures/dsl/subfolder3/sub/proc5.rb +6 -0
  157. data/spec/fixtures/dsl/subfolder4.eye +6 -0
  158. data/spec/fixtures/dsl/subfolder4/a.rb +2 -0
  159. data/spec/fixtures/dsl/subfolder4/b.rb +1 -0
  160. data/spec/fixtures/dsl/subfolder4/c.rb +1 -0
  161. data/spec/mock_spec.rb +32 -0
  162. data/spec/process/checks/child_checks_spec.rb +79 -0
  163. data/spec/process/checks/cpu_spec.rb +114 -0
  164. data/spec/process/checks/ctime_spec.rb +43 -0
  165. data/spec/process/checks/fsize_spec.rb +22 -0
  166. data/spec/process/checks/http_spec.rb +52 -0
  167. data/spec/process/checks/intergration_spec.rb +32 -0
  168. data/spec/process/checks/memory_spec.rb +113 -0
  169. data/spec/process/child_process_spec.rb +125 -0
  170. data/spec/process/config_spec.rb +75 -0
  171. data/spec/process/controller_spec.rb +173 -0
  172. data/spec/process/monitoring_spec.rb +180 -0
  173. data/spec/process/restart_spec.rb +174 -0
  174. data/spec/process/scheduler_spec.rb +150 -0
  175. data/spec/process/start_spec.rb +261 -0
  176. data/spec/process/states_history_spec.rb +118 -0
  177. data/spec/process/stop_spec.rb +150 -0
  178. data/spec/process/system_spec.rb +100 -0
  179. data/spec/process/triggers/flapping_spec.rb +81 -0
  180. data/spec/process/update_config_spec.rb +63 -0
  181. data/spec/spec_helper.rb +120 -0
  182. data/spec/support/rr_celluloid.rb +36 -0
  183. data/spec/support/scheduler_hack.rb +16 -0
  184. data/spec/support/spec_support.rb +164 -0
  185. data/spec/system_resources_spec.rb +59 -0
  186. data/spec/system_spec.rb +170 -0
  187. data/spec/utils/alive_array_spec.rb +50 -0
  188. data/spec/utils/celluloid_chain_spec.rb +82 -0
  189. data/spec/utils/tail_spec.rb +21 -0
  190. metadata +558 -0
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Eye::ChildProcess" do
4
+
5
+ before :each do
6
+ @pid = Eye::System.daemonize(C.p1[:start_command], C.p1)[:pid]
7
+ Eye::System.pid_alive?(@pid).should == true
8
+ sleep 0.5
9
+ end
10
+
11
+ it "some process was declared by my child" do
12
+ @process = Eye::ChildProcess.new(@pid, {})
13
+ @process.pid.should == @pid
14
+
15
+ @process.watchers.keys.should == []
16
+ end
17
+
18
+ describe "restart" do
19
+
20
+ it "kill by default command" do
21
+ @process = Eye::ChildProcess.new(@pid, {})
22
+ @process.schedule :restart
23
+
24
+ sleep 0.5
25
+ Eye::System.pid_alive?(@pid).should == false
26
+ end
27
+
28
+ it "kill by stop command" do
29
+ @process = Eye::ChildProcess.new(@pid, {:stop_command => "kill -9 {{PID}}"})
30
+ @process.schedule :restart
31
+
32
+ sleep 0.5
33
+ Eye::System.pid_alive?(@pid).should == false
34
+ end
35
+
36
+ it "try to snd URS1" do
37
+ @process = Eye::ChildProcess.new(@pid, {:stop_command => "kill -USR1 {{PID}}"})
38
+ @process.schedule :restart
39
+
40
+ sleep 0.5
41
+ Eye::System.pid_alive?(@pid).should == true
42
+ end
43
+ end
44
+
45
+ end
46
+
@@ -0,0 +1,34 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require File.dirname(__FILE__) + '/spec_helper'
3
+
4
+ describe "Eye::Client, Eye::Server" do
5
+
6
+ before :each do
7
+ @socket_path = C.socket_path
8
+ @client = Eye::Client.new(@socket_path)
9
+ @server = Eye::Server.new(@socket_path)
10
+ end
11
+
12
+ after :each do
13
+ @server.terminate
14
+ end
15
+
16
+ it "client command, should send to controller" do
17
+ mock(Eye::Control).command('restart', 'samples'){ :command_sended }
18
+ mock(Eye::Control).command('stop'){ :command_sended2 }
19
+ @server.run!
20
+ sleep 0.1
21
+
22
+ @client.command('restart', 'samples').should == :command_sended
23
+ @client.command('stop').should == :command_sended2
24
+ end
25
+
26
+ it "another spec works too" do
27
+ mock(Eye::Control).command('stop'){ :command_sended2 }
28
+ @server.run!
29
+ sleep 0.1
30
+
31
+ @client.command('stop').should == :command_sended2
32
+ end
33
+
34
+ end
@@ -0,0 +1,92 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "comamnd spec" do
4
+ subject{ c = Eye::Controller.new; c.load(fixture("dsl/load.eye")); c }
5
+
6
+ before :each do
7
+ @apps = subject.applications
8
+
9
+ @app1 = @apps.first
10
+ @app2 = @apps.last
11
+
12
+ @gr1 = @app1.groups[0]
13
+ @gr2 = @app1.groups[1]
14
+ @gr3 = @app1.groups[2]
15
+ @gr4 = @app2.groups[0]
16
+
17
+ @p1 = @gr1.processes[0]
18
+ @p2 = @gr1.processes[1]
19
+ @p3 = @gr2.processes[0]
20
+ @p4 = @gr3.processes[0]
21
+ @p5 = @gr3.processes[1]
22
+ @p6 = @gr4.processes[0]
23
+ end
24
+
25
+ describe "remove objects" do
26
+ it "remove app" do
27
+ subject.remove_object_from_tree(@app2)
28
+ subject.applications.size.should == 1
29
+ subject.applications.first.should == @app1
30
+ end
31
+
32
+ it "remove group" do
33
+ subject.remove_object_from_tree(@gr1)
34
+ @app1.groups.should_not include(@gr1)
35
+
36
+ subject.remove_object_from_tree(@gr2)
37
+ @app1.groups.should_not include(@gr2)
38
+
39
+ subject.remove_object_from_tree(@gr3)
40
+ @app1.groups.should_not include(@gr3)
41
+
42
+ @app1.groups.should be_empty
43
+ end
44
+
45
+ it "remove process" do
46
+ subject.remove_object_from_tree(@p1)
47
+ @gr1.processes.should_not include(@p1)
48
+
49
+ subject.remove_object_from_tree(@p2)
50
+ @gr1.processes.should_not include(@p2)
51
+
52
+ @gr1.processes.should be_empty
53
+ end
54
+ end
55
+
56
+ describe "send_command" do
57
+ it "nothing" do
58
+ subject.load(fixture("dsl/load.eye")).should include(error: false)
59
+ subject.send_command(:start, "2341234").should == []
60
+ end
61
+
62
+ it "unknown" do
63
+ subject.load(fixture("dsl/load.eye")).should include(error: false)
64
+ subject.send_command(:st33art, "2341234").should == []
65
+ end
66
+
67
+ [:start, :stop, :restart, :unmonitor].each do |cmd|
68
+ it "should send_command #{cmd}" do
69
+ any_instance_of(Eye::Process) do |p|
70
+ dont_allow(p).send_command(cmd)
71
+ end
72
+
73
+ mock(@p1).send_command(cmd)
74
+
75
+ subject.send_command cmd, "p1"
76
+ end
77
+ end
78
+
79
+ it "delete obj" do
80
+ any_instance_of(Eye::Process) do |p|
81
+ dont_allow(p).send_command(:delete)
82
+ end
83
+
84
+ mock(@p1).send_command(:delete)
85
+ subject.send_command :delete, "p1"
86
+
87
+ subject.all_processes.should_not include(@p1)
88
+ subject.all_processes.should include(@p2)
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,133 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ class String
4
+ def clean_info
5
+ self.gsub(%r{\033.*?m}im, '').gsub(%r[\(.*?\)], '')
6
+ end
7
+ end
8
+
9
+ def app_check(app, name, gr_size)
10
+ app.name.should == name
11
+ app.class.should == Eye::Application
12
+ app.groups.size.should == gr_size
13
+ end
14
+
15
+ def gr_check(gr, name, p_size, hidden = false)
16
+ gr.class.should == Eye::Group
17
+ gr.processes.size.should == p_size
18
+ gr.name.should == name
19
+ gr.hidden.should == hidden
20
+ end
21
+
22
+ def p_check(p, name, pid_file)
23
+ p.name.should == name
24
+ p.class.should == Eye::Process
25
+ p[:pid_file].should == "#{pid_file}"
26
+ p[:pid_file_ex].should == "/tmp/#{pid_file}"
27
+ end
28
+
29
+ describe "Eye::Controller" do
30
+ subject{ Eye::Controller.new }
31
+
32
+ it "should ok load config" do
33
+ subject.load(fixture("dsl/load.eye")).should include(error: false)
34
+
35
+ apps = subject.applications
36
+
37
+ app1 = apps.first
38
+ app_check(app1, 'app1', 3)
39
+ app2 = apps.last
40
+ app_check(app2, 'app2', 1)
41
+
42
+ gr1 = app1.groups[0]
43
+ gr_check(gr1, 'gr1', 2, false)
44
+ gr2 = app1.groups[1]
45
+ gr_check(gr2, 'gr2', 1, false)
46
+ gr3 = app1.groups[2]
47
+ gr_check(gr3, '__default__', 2, true)
48
+ gr4 = app2.groups[0]
49
+ gr_check(gr4, '__default__', 1, true)
50
+
51
+ p1 = gr1.processes[0]
52
+ p_check(p1, 'p1', "app1-gr1-p1.pid")
53
+ p2 = gr1.processes[1]
54
+ p_check(p2, 'p2', "app1-gr1-p2.pid")
55
+
56
+ p3 = gr2.processes[0]
57
+ p_check(p3, 'q3', "app1-gr2-q3.pid")
58
+
59
+ p4 = gr3.processes[0]
60
+ p_check(p4, 'g4', "app1-g4.pid")
61
+ p5 = gr3.processes[1]
62
+ p_check(p5, 'g5', "app1-g5.pid")
63
+
64
+ p6 = gr4.processes[0]
65
+ p_check(p6, 'z1', "app2-z1.pid")
66
+ end
67
+
68
+ it "raise when load config" do
69
+ subject.load(fixture("dsl/bad.eye")).should include(:error => true, :message => "blank pid_file for: bad")
70
+ end
71
+
72
+ it "info_string" do
73
+ app1 = <<S
74
+ app1
75
+ gr1 [monitor 1 of 2]
76
+ p1 ............................ unmonitored
77
+ p2 ............................ unmonitored
78
+ gr2
79
+ q3 ............................ unmonitored
80
+ g4 .............................. unmonitored
81
+ g5 .............................. unmonitored
82
+ S
83
+ app2 = <<S
84
+ app2
85
+ z1 .............................. unmonitored
86
+ S
87
+
88
+ subject.load(fixture("dsl/load.eye"))
89
+ subject.info_string.clean_info.strip.should == (app1 + app2).strip
90
+ subject.info_string('app1').clean_info.should == app1.chomp
91
+ subject.info_string('app2').clean_info.strip.should == app2.strip
92
+ subject.info_string('app3').clean_info.should == ''
93
+ end
94
+
95
+ it "info_string_debug should be" do
96
+ subject.load(fixture("dsl/load.eye"))
97
+ subject.info_string_debug.split("\n").size.should > 10
98
+ end
99
+
100
+ it "info_string_short should be" do
101
+ subject.load(fixture("dsl/load.eye"))
102
+ subject.info_string_short.split("\n").size.should == 2
103
+ end
104
+
105
+ describe "command" do
106
+ it "should send_command" do
107
+ mock(Eye::Control).send_command(:restart, 'samples')
108
+ Eye::Control.command('restart', 'samples')
109
+ end
110
+
111
+ it "should send_command" do
112
+ mock(Eye::Control).send_command(:restart)
113
+ Eye::Control.command(:restart)
114
+ end
115
+
116
+ it "load" do
117
+ mock(Eye::Control).load('/tmp/file')
118
+ Eye::Control.command('load', '/tmp/file')
119
+ end
120
+
121
+ it "info" do
122
+ mock(Eye::Control).info_string
123
+ Eye::Control.command('info')
124
+ end
125
+
126
+ it "quit" do
127
+ mock(Eye::Control).quit
128
+ Eye::Control.command('quit')
129
+ end
130
+
131
+ end
132
+
133
+ end
@@ -0,0 +1,150 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "find_objects" do
4
+ subject{ c = Eye::Controller.new; c.load(fixture("dsl/load.eye")); c }
5
+
6
+ it "1 process" do
7
+ objs = subject.find_objects("p1")
8
+ objs.map{|c| c.class}.should == [Eye::Process]
9
+ objs.map{|c| c.name}.sort.should == %w{p1}
10
+ end
11
+
12
+ it "1 group" do
13
+ objs = subject.find_objects("gr2")
14
+ objs.map{|c| c.class}.should == [Eye::Group]
15
+ objs.map{|c| c.name}.sort.should == %w{gr2}
16
+ end
17
+
18
+ it "1 app" do
19
+ objs = subject.find_objects("app2")
20
+ objs.map{|c| c.class}.should == [Eye::Application]
21
+ objs.map{|c| c.name}.sort.should == %w{app2}
22
+ end
23
+
24
+ it "find * processes by mask" do
25
+ objs = subject.find_objects("p*")
26
+ objs.map{|c| c.class}.should == [Eye::Process, Eye::Process]
27
+ objs.map{|c| c.name}.sort.should == %w{p1 p2}
28
+ end
29
+
30
+ it "find * groups by mask" do
31
+ objs = subject.find_objects("gr*")
32
+ objs.map{|c| c.class}.should == [Eye::Group, Eye::Group]
33
+ objs.map{|c| c.name}.sort.should == %w{gr1 gr2}
34
+ end
35
+
36
+ it "find * apps by mask" do
37
+ objs = subject.find_objects("app*")
38
+ objs.map{|c| c.class}.should == [Eye::Application, Eye::Application]
39
+ objs.map{|c| c.name}.sort.should == %w{app1 app2}
40
+ end
41
+
42
+ it "find by ','" do
43
+ objs = subject.find_objects("p1,p2")
44
+ objs.map{|c| c.class}.should == [Eye::Process, Eye::Process]
45
+ objs.map{|c| c.name}.sort.should == %w{p1 p2}
46
+ end
47
+
48
+ it "find by many params" do
49
+ objs = subject.find_objects("p1", "p2")
50
+ objs.map{|c| c.class}.should == [Eye::Process, Eye::Process]
51
+ objs.map{|c| c.name}.sort.should == %w{p1 p2}
52
+ end
53
+
54
+ it "find * apps by mask" do
55
+ objs = subject.find_objects("z*\n")
56
+ objs.map{|c| c.class}.should == [Eye::Process]
57
+ objs.map{|c| c.name}.sort.should == %w{z1}
58
+ end
59
+
60
+ it "empty, find nothing" do
61
+ subject.find_objects("").should == []
62
+ end
63
+
64
+ it "'all', find all projects" do
65
+ objs = subject.find_objects("all")
66
+ objs.map{|c| c.class}.should == [Eye::Application, Eye::Application]
67
+ objs.map{|c| c.name}.sort.should == %w{app1 app2}
68
+ end
69
+
70
+ it "nothing" do
71
+ subject.find_objects("asdfasdf").should == []
72
+ end
73
+
74
+ describe "find by routes" do
75
+ it "group" do
76
+ objs = subject.find_objects("app1:gr2")
77
+ obj = objs.first
78
+ obj.class.should == Eye::Group
79
+ obj.full_name.should == 'app1:gr2'
80
+ end
81
+
82
+ it "group + mask" do
83
+ objs = subject.find_objects("app1:gr*")
84
+ objs.map{|c| c.class}.should == [Eye::Group, Eye::Group]
85
+ objs.map{|c| c.name}.sort.should == %w{gr1 gr2}
86
+ end
87
+
88
+ it "process" do
89
+ objs = subject.find_objects("app1:gr2:q3")
90
+ obj = objs.first
91
+ obj.class.should == Eye::Process
92
+ obj.full_name.should == 'app1:gr2:q3'
93
+ end
94
+
95
+ describe "dubls" do
96
+ subject{ c = Eye::Controller.new; c.load(fixture("dsl/load_dubls.eye")); c }
97
+
98
+ it "not found" do
99
+ subject.find_objects("z").should == []
100
+ end
101
+
102
+ it "found 2 processed" do
103
+ objs = subject.find_objects("z*")
104
+ objs.map{|c| c.class}.should == [Eye::Process, Eye::Process]
105
+ objs.map{|c| c.name}.sort.should == %w{z1 z2}
106
+ end
107
+
108
+ it "find by gr1" do
109
+ objs = subject.find_objects("gr1")
110
+ objs.map{|c| c.class}.should == [Eye::Group, Eye::Group]
111
+ objs.map{|c| c.full_name}.sort.should == %w{app1:gr1 app2:gr1}
112
+ end
113
+
114
+ it "correct by gr*" do
115
+ objs = subject.find_objects("gr*")
116
+ objs.map{|c| c.class}.should == [Eye::Group, Eye::Group, Eye::Group, Eye::Process]
117
+ objs.map{|c| c.full_name}.should == %w{app1:gr1 app1:gr2 app2:gr1 app1:gr2and}
118
+ end
119
+
120
+ it "correct by gr1*" do
121
+ objs = subject.find_objects("gr1*")
122
+ objs.map{|c| c.class}.should == [Eye::Group, Eye::Group]
123
+ objs.map{|c| c.full_name}.sort.should == %w{app1:gr1 app2:gr1}
124
+ end
125
+
126
+ it "correct process" do
127
+ objs = subject.find_objects("gr1and")
128
+ objs.map{|c| c.class}.should == [Eye::Process]
129
+ objs.map{|c| c.full_name}.sort.should == %w{app2:gr1:gr1and}
130
+ end
131
+ end
132
+ end
133
+
134
+ describe "missing" do
135
+ it "should not found" do
136
+ subject.find_objects("app1:gr2:q").should == []
137
+ subject.find_objects("gr1:p1").should == []
138
+ subject.find_objects("pp1").should == []
139
+ subject.find_objects("app1::").should == []
140
+ subject.find_objects("app1:").should == []
141
+ end
142
+ end
143
+
144
+ describe "match" do
145
+ it "should match" do
146
+ subject.match("gr*").should == ["app1:gr1", "app1:gr2"]
147
+ end
148
+ end
149
+
150
+ end