tengine_core 0.5.39 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/Gemfile +1 -37
  2. data/Gemfile.lock +59 -61
  3. data/README.md +8 -6
  4. data/bin/create_indexes_for_tengine_core +18 -0
  5. data/bin/tengined +3 -3
  6. data/examples/list.txt +36 -0
  7. data/examples/uc08_if_both_a_and_b_occurs.rb +7 -1
  8. data/examples/uc20_fire_with_properties.rb +19 -0
  9. data/examples/uc21_fire_with_same_key.rb +23 -0
  10. data/examples/uc22_fire_with_source_name.rb +17 -0
  11. data/examples/uc23_fire_with_level.rb +19 -0
  12. data/examples/uc24_fire_with_level_key.rb +19 -0
  13. data/examples/uc30_local_variables.rb +28 -0
  14. data/examples/uc31_instance_variables.rb +35 -0
  15. data/examples/uc32_class_variables.rb +20 -0
  16. data/examples/uc33_statics.rb +20 -0
  17. data/examples2/uc30_local_variables.rb +55 -0
  18. data/examples2/uc31_instance_variables.rb +46 -0
  19. data/examples2/uc32_class_variables.rb +22 -0
  20. data/examples2/uc33_statics.rb +23 -0
  21. data/lib/tengine/core/bootstrap.rb +1 -1
  22. data/lib/tengine/core/config/atd.rb +0 -3
  23. data/lib/tengine/core/config/core.rb +21 -20
  24. data/lib/tengine/core/config/heartbeat_watcher.rb +0 -3
  25. data/lib/tengine/core/driveable.rb +34 -12
  26. data/lib/tengine/core/driver.rb +22 -9
  27. data/lib/tengine/core/dsl_evaluator.rb +2 -15
  28. data/lib/tengine/core/dsl_filter_def.rb +40 -0
  29. data/lib/tengine/core/dsl_loader.rb +1 -1
  30. data/lib/tengine/core/event.rb +44 -29
  31. data/lib/tengine/core/event/finder.rb +1 -1
  32. data/lib/tengine/core/event_exception_reportable.rb +7 -10
  33. data/lib/tengine/core/event_wrapper.rb +1 -1
  34. data/lib/tengine/core/find_by_name.rb +1 -1
  35. data/lib/tengine/core/handler.rb +14 -4
  36. data/lib/tengine/core/handler_path.rb +1 -1
  37. data/lib/tengine/core/heartbeat_watcher.rb +3 -2
  38. data/lib/tengine/core/kernel.rb +22 -6
  39. data/lib/tengine/core/mongoid_fix.rb +2 -1
  40. data/lib/tengine/core/mutex.rb +22 -8
  41. data/lib/tengine/core/optimistic_lock.rb +6 -6
  42. data/lib/tengine/core/safe_updatable.rb +24 -26
  43. data/lib/tengine/core/schedule.rb +2 -2
  44. data/lib/tengine/core/scheduler.rb +5 -4
  45. data/lib/tengine/core/session.rb +14 -0
  46. data/lib/tengine/core/session_wrapper.rb +20 -4
  47. data/lib/tengine/core/setting.rb +3 -3
  48. data/lib/tengine/rspec/extension.rb +6 -8
  49. metadata +156 -171
  50. data/.document +0 -5
  51. data/.rspec +0 -1
  52. data/Rakefile +0 -44
  53. data/VERSION +0 -1
  54. data/lib/tengine/core/connection_test/.gitignore +0 -1
  55. data/spec/factories/tengine_core_drivers.rb +0 -10
  56. data/spec/factories/tengine_core_events.rb +0 -14
  57. data/spec/factories/tengine_core_handler_paths.rb +0 -9
  58. data/spec/factories/tengine_core_handlers.rb +0 -9
  59. data/spec/factories/tengine_core_sessions.rb +0 -9
  60. data/spec/mongoid.yml +0 -35
  61. data/spec/spec_helper.rb +0 -48
  62. data/spec/support/mongo_index_key_log.rb +0 -91
  63. data/spec/tengine/core/bootstrap_spec.rb +0 -278
  64. data/spec/tengine/core/bugfix/bind_dsl_file_in_multi_byte_dir_spec.rb +0 -21
  65. data/spec/tengine/core/bugfix/enabled_on_activation_spec.rb +0 -112
  66. data/spec/tengine/core/bugfix/receive_event_spec.rb +0 -133
  67. data/spec/tengine/core/bugfix/use_dsl_version_method.rb +0 -12
  68. data/spec/tengine/core/bugfix/use_dsl_version_method_spec.rb +0 -28
  69. data/spec/tengine/core/bugfix/use_event_in_handler_dsl.rb +0 -11
  70. data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/206/343/202/231/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215/source_location_encoding.rb +0 -35
  71. data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/206/343/202/231/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215//351/235/236ASCII/343/201/256/343/203/225/343/202/241/343/202/244/343/203/253/345/220/215_dsl.rb +0 -38
  72. data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/207/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215/source_location_encoding.rb +0 -35
  73. data/spec/tengine/core/bugfix//351/235/236ACSII/343/201/256/343/203/207/343/202/243/343/203/254/343/202/257/343/203/210/343/203/252/345/220/215//351/235/236ASCII/343/201/256/343/203/225/343/202/241/343/202/244/343/203/253/345/220/215_dsl.rb +0 -38
  74. data/spec/tengine/core/config/atd_spec.rb +0 -62
  75. data/spec/tengine/core/config/core_spec.rb +0 -479
  76. data/spec/tengine/core/config/heartbeat_watcher_spec.rb +0 -62
  77. data/spec/tengine/core/config/syntax_error_in_erb.yml.erb +0 -13
  78. data/spec/tengine/core/config/wrong_category_name.yml.erb +0 -13
  79. data/spec/tengine/core/config/wrong_field_name.yml.erb +0 -12
  80. data/spec/tengine/core/config/wrong_yaml.yml.erb +0 -13
  81. data/spec/tengine/core/config_spec/another_port.yml +0 -54
  82. data/spec/tengine/core/config_spec/config_with_dir_absolute_load_path.yml +0 -16
  83. data/spec/tengine/core/config_spec/config_with_dir_relative_load_path.yml +0 -16
  84. data/spec/tengine/core/config_spec/config_with_file_absolute_load_path.yml +0 -16
  85. data/spec/tengine/core/config_spec/config_with_file_relative_load_path.yml +0 -16
  86. data/spec/tengine/core/config_spec/log_config_spec.rb +0 -245
  87. data/spec/tengine/core/driveable_spec.rb +0 -240
  88. data/spec/tengine/core/driver_spec.rb +0 -159
  89. data/spec/tengine/core/dsl_loader_spec.rb +0 -172
  90. data/spec/tengine/core/dsls/uc08_if_both_a_and_b_occurs_spec.rb +0 -35
  91. data/spec/tengine/core/dsls/uc10_if_the_event_occurs_at_the_server_spec.rb +0 -58
  92. data/spec/tengine/core/dsls/uc50_commit_event_at_first_spec.rb +0 -29
  93. data/spec/tengine/core/dsls/uc52_commit_event_after_all_handler_submit_spec.rb +0 -33
  94. data/spec/tengine/core/dsls/uc52_never_commit_event_unless_all_handler_submit_spec.rb +0 -38
  95. data/spec/tengine/core/dsls/uc53_submit_outside_of_handler_spec.rb +0 -37
  96. data/spec/tengine/core/dsls/uc60_event_in_handler_spec.rb +0 -31
  97. data/spec/tengine/core/dsls/uc61_event_outside_of_handler_spec.rb +0 -37
  98. data/spec/tengine/core/dsls/uc62_session_in_driver_spec.rb +0 -36
  99. data/spec/tengine/core/dsls/uc63_session_outside_of_driver_spec.rb +0 -35
  100. data/spec/tengine/core/dsls/uc64_safety_countup_spec.rb +0 -134
  101. data/spec/tengine/core/dsls/uc70_driver_enabled_on_activation_spec.rb +0 -39
  102. data/spec/tengine/core/dsls/uc71_driver_disabled_on_activation_spec.rb +0 -36
  103. data/spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb +0 -39
  104. data/spec/tengine/core/dsls/uc80_raise_io_error_spec.rb +0 -53
  105. data/spec/tengine/core/dsls/uc81_raise_runtime_error_spec.rb +0 -49
  106. data/spec/tengine/core/event/finder_spec.rb +0 -136
  107. data/spec/tengine/core/event_exception_reportable_spec.rb +0 -33
  108. data/spec/tengine/core/event_spec.rb +0 -161
  109. data/spec/tengine/core/event_wrapper_spec.rb +0 -35
  110. data/spec/tengine/core/handler_path_spec.rb +0 -87
  111. data/spec/tengine/core/handler_spec.rb +0 -190
  112. data/spec/tengine/core/heartbeat_watcher_spec.rb +0 -131
  113. data/spec/tengine/core/io_to_logger_spec.rb +0 -30
  114. data/spec/tengine/core/kernel_spec.rb +0 -902
  115. data/spec/tengine/core/mongodb_spec.rb +0 -12
  116. data/spec/tengine/core/mongoid_fix_spec.rb +0 -52
  117. data/spec/tengine/core/mutex_spec.rb +0 -201
  118. data/spec/tengine/core/optimistic_lock_spec.rb +0 -55
  119. data/spec/tengine/core/scheculer_spec.rb +0 -121
  120. data/spec/tengine/core/selectable_attr_spec.rb +0 -30
  121. data/spec/tengine/core/session_spec.rb +0 -104
  122. data/spec/tengine/core/setting_spec.rb +0 -79
  123. data/spec/tengine/core_spec.rb +0 -13
  124. data/spec/tengine_spec.rb +0 -14
  125. data/tengine_core.gemspec +0 -251
  126. data/tmp/log/.gitignore +0 -1
  127. data/tmp/tengined_status/.gitignore +0 -1
@@ -1,62 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- require 'tengine/event'
5
-
6
- describe Tengine::Core::Config::HeartbeatWatcher do
7
-
8
- describe :[] do
9
- it "should convert a Hash to a Tengine::Core::Config::HeartbeatWatcher" do
10
- converted = Tengine::Core::Config::HeartbeatWatcher[{:process => {:daemon => true}}]
11
- converted.should be_a(Tengine::Core::Config::HeartbeatWatcher)
12
- converted[:process][:daemon].should be_true
13
- end
14
-
15
- it "should return same Tengine::Core::Config::HeartbeatWatcher" do
16
- converted = Tengine::Core::Config::HeartbeatWatcher.new(:process => {:daemon => true})
17
- Tengine::Core::Config::HeartbeatWatcher[converted].should == converted
18
- end
19
- end
20
-
21
- context "デフォルト" do
22
- subject do
23
- Tengine::Core::Config::HeartbeatWatcher.new
24
- end
25
- its(:db){ should == {
26
- 'host' => 'localhost',
27
- 'port' => 27017,
28
- 'username' => nil,
29
- 'password' => nil,
30
- 'database' => 'tengine_production',
31
- }}
32
-
33
- it "db" do
34
- subject.db.should == {
35
- 'host' => 'localhost',
36
- 'port' => 27017,
37
- 'username' => nil,
38
- 'password' => nil,
39
- 'database' => 'tengine_production',
40
- }
41
- end
42
-
43
- it "process_daemon" do
44
- subject[:process][:daemon].should be_false
45
- end
46
-
47
- it "heartbeat_hbw" do
48
- subject[:heartbeat][:hbw][:interval].should == 0
49
- end
50
-
51
- end
52
-
53
- context "指定した設定ファイルが存在しない場合" do
54
- it "例外を生成します" do
55
- config_path = File.expand_path("../config_spec/unexist_config.yml", File.dirname(__FILE__))
56
- expect{
57
- Tengine::Core::Config::HeartbeatWatcher.new(:config => config_path)
58
- }.to raise_error(Tengine::Core::ConfigError, /No such file or directory - #{config_path}/)
59
- end
60
- end
61
-
62
- end
@@ -1,13 +0,0 @@
1
- --
2
- process:
3
- daemon: true
4
- pid_dir: "/var/run/tengined_pids"
5
- tengined:
6
- load_path: "/var/lib/tengine"
7
- status_dir: "/var/run/tengined_status"
8
- activation_dir: "/var/run/tengined_activations"
9
- heartbeat_period: <%= 10 * 60 - %>
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
@@ -1,13 +0,0 @@
1
- ---
2
- process_configs:
3
- daemon: true
4
- pid_dir: "/var/run/tengined_pids"
5
- tengined:
6
- load_path: "/var/lib/tengine"
7
- status_dir: "/var/run/tengined_status"
8
- activation_dir: "/var/run/tengined_activations"
9
- heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
@@ -1,12 +0,0 @@
1
- ---
2
- process:
3
- daemon: true
4
- pid_dir: "/var/run/tengined_pids"
5
- load_path: "/var/lib/tengine"
6
- status_dir: "/var/run/tengined_status"
7
- activation_dir: "/var/run/tengined_activations"
8
- heartbeat_period: 600
9
- confirmation_threshold: "warn"
10
- event_queue:
11
- queue:
12
- name: tengine_event_queue2
@@ -1,13 +0,0 @@
1
- ---
2
- process:
3
- daemon: true
4
- pid_dir: "/var/run/tengined_pids"
5
- tengined:
6
- load_path: "/var/lib/tengine"
7
- - status_dir: "/var/run/tengined_status"
8
- activation_dir: "/var/run/tengined_activations"
9
- heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
@@ -1,54 +0,0 @@
1
- process:
2
- daemon: false
3
- pid_dir: "./tmp/tengined_pids" # 本番環境での例 "/var/run/tengined_pids"
4
-
5
- tengined:
6
- activation_timeout: 300,
7
- load_path: "./spec_dsl/"
8
- activation_dir: "./tmp/tengined_activations" # 本番環境での例 "/var/run/tengined_activations"
9
-
10
- db:
11
- host: 'localhost'
12
- port: 21039
13
- username:
14
- password:
15
- database: 'tengine_production'
16
-
17
- event_queue:
18
- connection:
19
- host: 'localhost'
20
- port: 5672
21
- # vhost:
22
- # user:
23
- # pass:
24
- exchange:
25
- name: 'tengine_event_exchange'
26
- type: 'direct'
27
- durable: true
28
- queue:
29
- name: 'tengine_event_queue'
30
- durable: true
31
-
32
- log_common:
33
- output: # file path or "STDOUT" / "STDERR"
34
- rotation: 3 # rotation file count or daily,weekly,monthly. default: 3
35
- rotation_size: 1024 * 1024 # number of max log file size. default: 1048576 (10MB)
36
- level: 'debug' # debug/info/warn/error/fatal. default: info
37
-
38
- application_log:
39
- output: # file path or "STDOUT" / "STDERR". default: if daemon process then "./log/application.log" else "STDOUT"
40
- rotation: # rotation file count or daily,weekly,monthly. default: value of --log-common-rotation
41
- rotation_size: # number of max log file size. default: value of --log-common-rotation-size
42
- level: # debug/info/warn/error/fatal. default: value of --log-common-level
43
-
44
- process_stdout_log:
45
- output: # file path or "STDOUT" / "STDERR". default: if daemon process then "./log/#{$PROGRAM_NAME}_#{Process.pid}_stdout.log" else "STDOUT"
46
- rotation: # rotation file count or daily,weekly,monthly. default: value of --log-common-rotation
47
- rotation_size: # number of max log file size. default: value of --log-common-rotation-size
48
- level: # debug/info/warn/error/fatal. default: value of --log-common-level
49
-
50
- process_stderr_log:
51
- output: # file path or "STDOUT" / "STDERR". default: if daemon process then "./log/#{$PROGRAM_NAME}_#{Process.pid}_stderr.log" else "STDERR"
52
- rotation: # rotation file count or daily,weekly,monthly. default: value of --log-common-rotation
53
- rotation_size: # number of max log file size. default: value of --log-common-rotation-size
54
- level: # debug/info/warn/error/fatal. default: value of --log-common-level
@@ -1,16 +0,0 @@
1
- process:
2
- daemon: true
3
- pid_dir: "/var/run/tengined_pids"
4
-
5
- tengined:
6
- load_path: "/var/lib/tengine"
7
- status_dir: "/var/run/tengined_status"
8
- activation_dir: "/var/run/tengined_activations"
9
- # heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
14
- heartbeat:
15
- core:
16
- interval: 600
@@ -1,16 +0,0 @@
1
- process:
2
- daemon: true
3
- pid_dir: "tmp/tengined_pids"
4
-
5
- tengined:
6
- load_path: "tengine_dsls"
7
- status_dir: "tmp/tengined_status"
8
- activation_dir: "tmp/tengined_activations"
9
- # heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
14
- heartbeat:
15
- core:
16
- interval: 600
@@ -1,16 +0,0 @@
1
- process:
2
- daemon: true
3
- pid_dir: "/var/run/tengined_pids"
4
-
5
- tengined:
6
- load_path: "/var/lib/tengine/init.rb"
7
- status_dir: "/var/run/tengined_status"
8
- activation_dir: "/var/run/tengined_activations"
9
- # heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
14
- heartbeat:
15
- core:
16
- interval: 600
@@ -1,16 +0,0 @@
1
- process:
2
- daemon: true
3
- pid_dir: "tmp/tengined_pids"
4
-
5
- tengined:
6
- load_path: "tengine_dsls/init.rb"
7
- status_dir: "tmp/tengined_status"
8
- activation_dir: "tmp/tengined_activations"
9
- # heartbeat_period: 600
10
- confirmation_threshold: "warn"
11
- event_queue:
12
- queue:
13
- name: tengine_event_queue2
14
- heartbeat:
15
- core:
16
- interval: 600
@@ -1,245 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe Tengine::Core::Config::Core do
5
-
6
- context "ログの設定なし" do
7
- {
8
- true => "デーモン起動",
9
- false => "非デーモン起動",
10
- }.each do |daemon_process, context_name|
11
- context(context_name) do
12
- before{ @config = Tengine::Core::Config::Core.new(:process => {:daemon => daemon_process})}
13
-
14
- context "正しい設定の場合" do
15
-
16
- context :application_log do
17
- it do
18
- @config[:process][:daemon].should == daemon_process
19
-
20
- mock_logger = mock(:logger)
21
- Logger.should_receive(:new).
22
- with(daemon_process ? "./log/application.log" : STDOUT, 3, 1024 * 1024).
23
- and_return(mock_logger)
24
- mock_logger.should_receive(:level=).with(Logger::INFO)
25
- mock_logger.should_receive(:formatter=).with(nil)
26
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
27
- @config.application_log.new_logger
28
- end
29
- end
30
-
31
- context :process_stdout_log do
32
- it do
33
- mock_logger = mock(:logger)
34
- Logger.should_receive(:new).
35
- with(daemon_process ? %r{^\./log/.*_stdout\.log} : STDOUT, 3, 1024 * 1024).
36
- and_return(mock_logger)
37
- mock_logger.should_receive(:level=).with(Logger::INFO)
38
- mock_logger.should_receive(:formatter=).with(nil)
39
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
40
- @config.process_stdout_log.new_logger
41
- end
42
- end
43
-
44
- context :process_stderr_log do
45
- it do
46
- mock_logger = mock(:logger)
47
- Logger.should_receive(:new).
48
- with(daemon_process ? %r{^\./log/.*_stderr\.log} : STDERR, 3, 1024 * 1024).
49
- and_return(mock_logger)
50
- mock_logger.should_receive(:level=).with(Logger::INFO)
51
- mock_logger.should_receive(:formatter=).with(nil)
52
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
53
- @config.process_stderr_log.new_logger
54
- end
55
- end
56
- end
57
-
58
- context :invalid_log_type_name do
59
- it "should raise ArgumentError"do
60
- expect{
61
- @config.invalid_log_type_name
62
- }.to raise_error(NoMethodError)
63
- end
64
- end
65
-
66
-
67
- end
68
- end
69
- end
70
-
71
- context "共通設定なし各ログの設定あり" do
72
- {
73
- true => "デーモン起動の場合",
74
- false => "非デーモン起動の場合",
75
- }.each do |daemon_process, context_name|
76
- context(context_name) do
77
- before do
78
- @config = Tengine::Core::Config::Core.new({
79
- :process => {:daemon => daemon_process},
80
- :application_log => {
81
- :output => "/var/log/tengined/application.log",
82
- :rotation => "daily",
83
- :level => "error",
84
- },
85
- :process_stdout_log => {
86
- :output => "/var/log/tengined/process_stdout.log",
87
- :rotation => "weekly",
88
- :level => "info",
89
- },
90
- :process_stderr_log => {
91
- :output => "/var/log/tengined/process_stderr.log",
92
- :rotation => "monthly",
93
- :level => "info",
94
- },
95
- })
96
- end
97
-
98
- context :application_log do
99
- it do
100
- mock_logger = mock(:logger)
101
- Logger.should_receive(:new).
102
- with("/var/log/tengined/application.log", "daily", 1048576).
103
- and_return(mock_logger)
104
- mock_logger.should_receive(:level=).with(Logger::ERROR)
105
- mock_logger.should_receive(:formatter=).with(nil)
106
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
107
- @config.application_log.new_logger
108
- end
109
- end
110
-
111
- context :process_stdout_log do
112
- it do
113
- mock_logger = mock(:logger)
114
- Logger.should_receive(:new).
115
- with("/var/log/tengined/process_stdout.log", "weekly", 1048576).
116
- and_return(mock_logger)
117
- mock_logger.should_receive(:level=).with(Logger::INFO)
118
- mock_logger.should_receive(:formatter=).with(nil)
119
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
120
- @config.process_stdout_log.new_logger
121
- end
122
- end
123
-
124
- context :process_stderr_log do
125
- it do
126
- mock_logger = mock(:logger)
127
- Logger.should_receive(:new).
128
- with("/var/log/tengined/process_stderr.log", "monthly", 1048576).
129
- and_return(mock_logger)
130
- mock_logger.should_receive(:level=).with(Logger::INFO)
131
- mock_logger.should_receive(:formatter=).with(nil)
132
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
133
- @config.process_stderr_log.new_logger
134
- end
135
- end
136
-
137
- end
138
- end
139
- end
140
-
141
- context "共通設定あり各ログの設定あり" do
142
- {
143
- true => "デーモン起動の場合",
144
- false => "非デーモン起動の場合",
145
- }.each do |daemon_process, context_name|
146
- context(context_name) do
147
- before do
148
- @config = Tengine::Core::Config::Core.new({
149
- :process => {:daemon => daemon_process},
150
- :log_common => {
151
- :rotation => "daily",
152
- :level => "info",
153
- },
154
- :application_log => {
155
- :output => "/var/log/tengined/application.log",
156
- },
157
- :process_stdout_log => {
158
- :output => "/var/log/tengined/process_stdout.log",
159
- },
160
- :process_stderr_log => {
161
- :output => "/var/log/tengined/process_stderr.log",
162
- :rotation => "monthly",
163
- },
164
- })
165
- end
166
-
167
- context :application_log do
168
- it do
169
- mock_logger = mock(:logger)
170
- Logger.should_receive(:new).
171
- with("/var/log/tengined/application.log", "daily", 1048576).
172
- and_return(mock_logger)
173
- mock_logger.should_receive(:level=).with(Logger::INFO)
174
- mock_logger.should_receive(:formatter=).with(nil)
175
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
176
- @config.application_log.new_logger
177
- end
178
- end
179
-
180
- context :process_stdout_log do
181
- it do
182
- mock_logger = mock(:logger)
183
- Logger.should_receive(:new).
184
- with("/var/log/tengined/process_stdout.log", "daily", 1048576).
185
- and_return(mock_logger)
186
- mock_logger.should_receive(:level=).with(Logger::INFO)
187
- mock_logger.should_receive(:formatter=).with(nil)
188
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
189
- @config.process_stdout_log.new_logger
190
- end
191
- end
192
-
193
- context :process_stderr_log do
194
- it do
195
- mock_logger = mock(:logger)
196
- Logger.should_receive(:new).
197
- with("/var/log/tengined/process_stderr.log", "monthly", 1048576).
198
- and_return(mock_logger)
199
- mock_logger.should_receive(:level=).with(Logger::INFO)
200
- mock_logger.should_receive(:formatter=).with(nil)
201
- mock_logger.should_receive(:formatter=).with(an_instance_of(Proc))
202
- @config.process_stderr_log.new_logger
203
- end
204
- end
205
-
206
- describe :setup_loggers do
207
- before do
208
- @tengine_logger_bak = Tengine.logger
209
- @tengine_core_stdout_logger_bak = Tengine::Core.stdout_logger
210
- @tengine_core_stderr_logger_bak = Tengine::Core.stderr_logger
211
- @stdout_bak = $stdout
212
- @stderr_bak = $stderr
213
- end
214
- after do
215
- Tengine.logger = @tengine_logger_bak
216
- Tengine::Core.stdout_logger = @tengine_core_stdout_logger_bak
217
- Tengine::Core.stderr_logger = @tengine_core_stderr_logger_bak
218
- $stdout = @stdout_bak
219
- $stderr = @stderr_bak
220
- end
221
- it do
222
- mock_logger1 = mock(:logger1)
223
- mock_logger2 = mock(:logger2)
224
- mock_logger3 = mock(:logger3)
225
- mock_loggers = [mock_logger1, mock_logger2, mock_logger3]
226
- mock_loggers.each{|m| m.should_receive(:level=) }
227
- mock_loggers.each{|m| m.should_receive(:formatter=).twice}
228
- mock_logger2.should_receive(:info).with("Tengine::Core::Config::Core#setup_loggers complete")
229
- # mock_logger3.should_receive(:info).with("Tengine::Core::Config::Core#setup_loggers failure")
230
- Logger.should_receive(:new).with("/var/log/tengined/application.log", "daily", 1024 * 1024).and_return(mock_logger1)
231
- Logger.should_receive(:new).with("/var/log/tengined/process_stdout.log", "daily", 1024 * 1024).and_return(mock_logger2)
232
- Logger.should_receive(:new).with("/var/log/tengined/process_stderr.log", "monthly", 1024 * 1024).and_return(mock_logger3)
233
- @config.setup_loggers
234
- Tengine.logger.should == mock_logger1
235
- Tengine::Core.stdout_logger.should == mock_logger2
236
- Tengine::Core.stderr_logger.should == mock_logger3
237
- end
238
-
239
- end
240
-
241
- end
242
- end
243
- end
244
-
245
- end