fluentd-server 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bdb2c370dae1201863b40f1c52925dd7b7faf9c
4
- data.tar.gz: 123bb993f7412ed3401680b766e675ee1ffa5874
3
+ metadata.gz: d24dfc4f888469d4cd08a0a60a5963c15b1e7cb1
4
+ data.tar.gz: cc9acfe2cfbe34e3607ff72ab5a1c3ec455a430d
5
5
  SHA512:
6
- metadata.gz: 9ce9d5de9c3f5237a703c5987a0eb49762233fa6140ae8fa074486206840c404b2f22bb42a6182501e3eae889e05d2ca22d48303d9286b776b84d689857f63e4
7
- data.tar.gz: 4a173696a16bf08097d2771761d511f123d4918b6d07986b48c9bb3a0b05c6b731aa8181cd62f1f72c38a6d43ad2ea2ad72efabb03727854fe5eb42177c72aee
6
+ metadata.gz: 40d9a520d3492776c34f167c70c2273851adb0928c7860ef3e95a0b832e4485657f7e103b11d16085d1b295ba8719d8b11b6655a9a1166815f2e9fe8deaed99a
7
+ data.tar.gz: 2e4254a5f50df4c377771eeda77d05502ae9a39f0715403235e932c589b93c381379864b085679821ea7515811433dd121d75ce9b08c3590ec01646cfcd45697
data/.env CHANGED
@@ -6,6 +6,6 @@ HOST=0.0.0.0
6
6
  # LOG_LEVEL=debug
7
7
  # LOG_SHIFT_AGE=0
8
8
  # LOG_SHIFT_SIZE=1048576
9
- # LOCAL_STORAGE=false
9
+ # FILE_STORAGE=false
10
10
  # DATA_DIR=data
11
11
  # SYNC_INTERVAL=60
@@ -4,5 +4,5 @@ rvm:
4
4
  gemfile:
5
5
  - Gemfile
6
6
  env:
7
- - LOCAL_STORAGE=false
8
- - LOCAL_STORAGE=true DATA_DIR=spec/tmp
7
+ - FILE_STORAGE=false
8
+ - FILE_STORAGE=true DATA_DIR=spec/tmp
@@ -1,3 +1,9 @@
1
+ # 0.3.2 (2014/06/08)
2
+
3
+ Changes:
4
+
5
+ * Rename `LOCAL_STORAGE` to `FILE_STORAGE`
6
+
1
7
  # 0.3.1
2
8
 
3
9
  Enhancements:
data/README.md CHANGED
@@ -108,26 +108,29 @@ See [API.md](API.md).
108
108
 
109
109
  ### Use Fluentd Server from Command Line
110
110
 
111
- For the case you want to edit Fluentd configuration files from your favorite editors rather than from the Web UI, `LOCAL STORAGE` feature is available.
111
+ For the case you want to edit Fluentd configuration files from your favorite editors rather than from the Web UI, `FILE STORAGE` feature is available.
112
112
  With this feature, you should also be able to manage your configuration files with git (or any VCS).
113
113
 
114
- To use this feature, enable `LOCAL_STORAGE` in `.env` file as:
114
+ To use this feature, enable `FILE_STORAGE` in `.env` file as:
115
115
 
116
116
  ```
117
- LOCAL_STORAGE=true
117
+ FILE_STORAGE=true
118
118
  DATA_DIR=data
119
119
  SYNC_INTERVAL=60
120
120
  ```
121
121
 
122
122
  where the `DATA_DIR` is the location to place your configuration files locally, and the `SYNC_INTERVAL` is the interval where a synchronization worker works.
123
123
 
124
- Putting any files whose name ends with `.erb` in `DATA_DIR` is automatically synchronized with DB by the synchronization worker. Removing `.erb` files is also synchronized with DB.
125
- For the case you want to synchronize immediately, `sync` command is also available.
124
+ Place your `erb` files in the `DATA_DIR` directory, and please execute `sync` command to synchronize the file existence information with DB
125
+ when you newly add or remove the configuration files.
126
126
 
127
127
  ```
128
128
  $ fluentd-server sync
129
129
  ```
130
130
 
131
+ Or, you may just wait `SYNC_INTERVAL` senconds until a synchronization worker automatically synchronizes the information.
132
+ Please note that modifying the file content does not require to synchronize because the content is read from the local file directly.
133
+
131
134
  NOTE: Enabling this feature disables to edit the Fluentd configuration from the Web UI.
132
135
 
133
136
  ### CLI (Command Line Interface)
@@ -159,6 +162,9 @@ Commands:
159
162
 
160
163
  * Automatic deployment (restart) support like the one of chef-server
161
164
 
165
+ * Need a notification function for when configtest or restart failed
166
+ * Pipe the resulted json to a command (I may prepare email.rb as an example).
167
+
162
168
  ## ChangeLog
163
169
 
164
170
  See [CHANGELOG.md](CHANGELOG.md) for details.
@@ -23,7 +23,7 @@ LOG_PATH=#{LOG_FILE}
23
23
  LOG_LEVEL=warn
24
24
  LOG_SHIFT_AGE=0
25
25
  LOG_SHIFT_SIZE=1048576
26
- LOCAL_STORAGE=false
26
+ FILE_STORAGE=false
27
27
  DATA_DIR=#{DATA_DIR}
28
28
  SYNC_INTERVAL=60
29
29
  EOS
@@ -33,8 +33,8 @@ module FluentdServer::Config
33
33
  ENV.fetch('TASK_MAX_NUM', '20').to_i
34
34
  end
35
35
 
36
- def self.local_storage
37
- ENV.fetch('LOCAL_STORAGE', 'false') == 'true' ? true : false
36
+ def self.file_storage
37
+ ENV.fetch('FILE_STORAGE', 'false') == 'true' ? true : false
38
38
  end
39
39
 
40
40
  def self.data_dir
@@ -12,7 +12,7 @@ class Post < ActiveRecord::Base
12
12
 
13
13
  validates :name, presence: true
14
14
 
15
- if FluentdServer::Config.local_storage
15
+ if FluentdServer::Config.file_storage
16
16
  include ActsAsFile
17
17
 
18
18
  def filename
@@ -13,14 +13,14 @@ class FluentdServer::SyncRunner
13
13
 
14
14
  def run
15
15
  logger.debug "[sync] sync runner started"
16
- return nil unless FluentdServer::Config.local_storage
16
+ return nil unless FluentdServer::Config.file_storage
17
17
  plus, minus = find_diff
18
18
  create(plus)
19
19
  delete(minus)
20
20
  end
21
21
 
22
22
  def find_locals
23
- return [] unless FluentdServer::Config.local_storage
23
+ return [] unless FluentdServer::Config.file_storage
24
24
  names = []
25
25
  Dir.chdir(FluentdServer::Config.data_dir) do
26
26
  Dir.glob("*.erb") do |filename|
@@ -1,3 +1,3 @@
1
1
  module FluentdServer
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -14,6 +14,10 @@ require 'sinatra/activerecord/rake'
14
14
  Rake::Task['db:schema:load'].invoke
15
15
 
16
16
  if ENV['TRAVIS']
17
+ require 'simplecov'
17
18
  require 'coveralls'
18
- Coveralls.wear!
19
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
20
+ SimpleCov.start do
21
+ add_filter 'spec'
22
+ end
19
23
  end
@@ -1,25 +1,26 @@
1
1
  require_relative 'spec_helper'
2
2
  require 'fluentd_server/sync_runner'
3
3
 
4
- if FluentdServer::Config.local_storage
4
+ if FluentdServer::Config.file_storage
5
5
  describe 'SyncRunner' do
6
- around {
6
+ def clean
7
7
  filenames = File.join(FluentdServer::Config.data_dir, '*.erb')
8
8
  Dir.glob(filenames).each { |f| File.delete(f) rescue nil }
9
9
  Post.delete_all
10
- }
10
+ end
11
+ around {|example| clean; example.run; clean }
11
12
  let(:runner) { FluentdServer::SyncRunner.new }
12
13
 
13
14
  context '#find_locals' do
14
- before { Post.create(name: 'post1') }
15
- before { Post.create(name: 'post2') }
15
+ before { Post.create(name: 'post1', body: 'a') }
16
+ before { Post.create(name: 'post2', body: 'a') }
16
17
  let(:subject) { runner.find_locals }
17
18
  it { should =~ ['post1', 'post2' ] }
18
19
  end
19
20
 
20
21
  context '#find_diff' do
21
22
  before { Post.new(name: 'post1').save_without_file }
22
- before { Post.create(name: 'post2') }
23
+ before { Post.create(name: 'post2', body: 'a') }
23
24
  before { File.open(Post.new(name: 'post3').filename, "w") {} }
24
25
  it {
25
26
  plus, minus = runner.find_diff
@@ -29,7 +30,7 @@ if FluentdServer::Config.local_storage
29
30
  end
30
31
 
31
32
  context '#create' do
32
- before { Post.create(name: 'post1') }
33
+ before { Post.create(name: 'post1', body: 'a') }
33
34
  before { runner.create(%w[post1 post2]) }
34
35
  it {
35
36
  expect(Post.find_by(name: 'post1').body).not_to be_nil
@@ -39,8 +40,8 @@ if FluentdServer::Config.local_storage
39
40
 
40
41
  context '#delete' do
41
42
  before {
42
- post1 = Post.create(name: 'post1')
43
- post2 = Post.create(name: 'post2')
43
+ post1 = Post.create(name: 'post1', body: 'a')
44
+ post2 = Post.create(name: 'post2', body: 'a')
44
45
  runner.delete(%w[post1])
45
46
  }
46
47
  it {
@@ -51,7 +52,7 @@ if FluentdServer::Config.local_storage
51
52
 
52
53
  context '#run' do
53
54
  before { Post.new(name: 'post1').save_without_file }
54
- before { Post.create(name: 'post2') }
55
+ before { Post.create(name: 'post2', body: 'a') }
55
56
  before { File.open(Post.new(name: 'post3').filename, "w") {} }
56
57
  it {
57
58
  runner.run
@@ -68,8 +69,8 @@ else
68
69
  it { should be_nil }
69
70
  end
70
71
  context '#find_locals' do
71
- before { Post.create(name: 'post1') }
72
- before { Post.create(name: 'post2') }
72
+ before { Post.create(name: 'post1', body: 'a') }
73
+ before { Post.create(name: 'post2', body: 'a') }
73
74
  let(:subject) { FluentdServer::SyncRunner.new.find_locals }
74
75
  it { should == [] }
75
76
  end
@@ -30,6 +30,14 @@ describe 'Post' do
30
30
  click_button('Submit')
31
31
  }.to change(Post, :count).by(1)
32
32
  end
33
+
34
+ it 'fails to create' do
35
+ expect {
36
+ fill_in "post[name]", with: ''
37
+ fill_in "post[body]", with: ''
38
+ click_button('Submit')
39
+ }.to change(Post, :count).by(0)
40
+ end
33
41
  end
34
42
 
35
43
  context 'edit post' do
@@ -50,6 +58,15 @@ describe 'Post' do
50
58
  expect(edit.body).to eql('bbbb')
51
59
  end
52
60
 
61
+ it 'fails to edit' do
62
+ fill_in "post[name]", with: ''
63
+ fill_in "post[body]", with: ''
64
+ click_button('Submit')
65
+ edit = Post.find(post.id)
66
+ expect(edit.name).not_to eql('')
67
+ expect(edit.body).not_to eql('')
68
+ end
69
+
53
70
  # javascript click for `Really?` is required
54
71
  #it 'delete' do
55
72
  # click_link('Delete')
@@ -93,6 +110,21 @@ describe 'Task' do
93
110
  end
94
111
  end
95
112
 
113
+ context '/json/tasks/:id/body' do
114
+ include Rack::Test::Methods
115
+ def app; FluentdServer::Web; end
116
+
117
+ before { @task = Task.create }
118
+ it 'visit' do
119
+ get "/json/tasks/#{@task.id}/body"
120
+ expect(last_response.status).to eql(200)
121
+ body = JSON.parse(last_response.body)
122
+ expect(body).to be_has_key('body')
123
+ expect(body).to be_has_key('bytes')
124
+ expect(body).to be_has_key('moreData')
125
+ end
126
+ end
127
+
96
128
  context 'task button' do
97
129
  include Rack::Test::Methods
98
130
  def app; FluentdServer::Web; end
@@ -152,6 +184,3 @@ describe 'API' do
152
184
  end
153
185
  end
154
186
  end
155
-
156
-
157
-
@@ -28,7 +28,7 @@ javascript:
28
28
  form.submit();
29
29
  return false;
30
30
  });
31
- - if FluentdServer::Config.local_storage
31
+ - if FluentdServer::Config.file_storage
32
32
  javascript:
33
33
  $('#post_name').attr("disabled", "disabled");
34
34
  $('#post_body').attr("disabled", "disabled");
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler