katte 0.0.1.3
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/.gitignore +17 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +107 -0
- data/Rakefile +1 -0
- data/bin/katte +7 -0
- data/katte.gemspec +19 -0
- data/lib/katte.rb +50 -0
- data/lib/katte/command.rb +33 -0
- data/lib/katte/config.rb +21 -0
- data/lib/katte/driver.rb +71 -0
- data/lib/katte/environment.rb +14 -0
- data/lib/katte/filter.rb +22 -0
- data/lib/katte/node.rb +5 -0
- data/lib/katte/node/base.rb +48 -0
- data/lib/katte/node/collection.rb +47 -0
- data/lib/katte/plugins.rb +11 -0
- data/lib/katte/plugins/base.rb +38 -0
- data/lib/katte/plugins/file_type.rb +47 -0
- data/lib/katte/plugins/file_type/bash.rb +9 -0
- data/lib/katte/plugins/file_type/debug.rb +14 -0
- data/lib/katte/plugins/file_type/hive.rb +9 -0
- data/lib/katte/plugins/file_type/r.rb +9 -0
- data/lib/katte/plugins/file_type/ruby.rb +9 -0
- data/lib/katte/plugins/node.rb +6 -0
- data/lib/katte/plugins/node/debug.rb +11 -0
- data/lib/katte/plugins/node/file.rb +45 -0
- data/lib/katte/plugins/output.rb +13 -0
- data/lib/katte/plugins/output/debug.rb +14 -0
- data/lib/katte/plugins/output/file.rb +31 -0
- data/lib/katte/plugins/output/stderr.rb +9 -0
- data/lib/katte/plugins/output/stdoe.rb +14 -0
- data/lib/katte/recipe.rb +8 -0
- data/lib/katte/recipe/file_type.rb +29 -0
- data/lib/katte/recipe/node.rb +71 -0
- data/lib/katte/recipe/node_factory.rb +57 -0
- data/lib/katte/runner.rb +66 -0
- data/lib/katte/runner/callback.rb +36 -0
- data/lib/katte/thread_pool.rb +41 -0
- data/lib/katte/version.rb +3 -0
- data/spec/katte/config_spec.rb +16 -0
- data/spec/katte/driver_spec.rb +58 -0
- data/spec/katte/filter_spec.rb +19 -0
- data/spec/katte/node/base_spec.rb +20 -0
- data/spec/katte/node/collection_spec.rb +36 -0
- data/spec/katte/plugins/file_type_spec.rb +59 -0
- data/spec/katte/plugins/output_spec.rb +31 -0
- data/spec/katte/recipe/node_factory_spec.rb +20 -0
- data/spec/katte/runner_spec.rb +34 -0
- data/spec/katte/thread_pool_spec.rb +47 -0
- data/spec/recipes/custom/sample_1.sh +3 -0
- data/spec/recipes/custom/sample_2.sh +3 -0
- data/spec/recipes/test/sample.sh +5 -0
- data/spec/recipes/test/sample/sub.sh +3 -0
- data/spec/spec_helper.rb +7 -0
- metadata +117 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Katte::Recipe
|
4
|
+
describe NodeFactory do
|
5
|
+
before :all do
|
6
|
+
@recipe_path = File.join(Katte.app.config.recipes_root, 'test/sample.sh')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#load" do
|
10
|
+
it "returns node object" do
|
11
|
+
factory = Katte::Recipe::NodeFactory.new
|
12
|
+
|
13
|
+
node = factory.load(@recipe_path)
|
14
|
+
expect(node.name).to eq 'test/sample'
|
15
|
+
expect(node.file_type).to be_respond_to :execute
|
16
|
+
expect(node.period).to eq 'day'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
class Katte
|
5
|
+
describe Runner do
|
6
|
+
describe "#run" do
|
7
|
+
before(:each) {
|
8
|
+
Katte::Plugins::Output.find(:debug).history.clear
|
9
|
+
}
|
10
|
+
|
11
|
+
it "execute whole node" do
|
12
|
+
nodes_count = nil
|
13
|
+
Katte::Runner.after(:load_nodes) do |nodes|
|
14
|
+
nodes_count = nodes.all.length
|
15
|
+
end
|
16
|
+
|
17
|
+
runner = Katte::Runner.new
|
18
|
+
runner.run
|
19
|
+
|
20
|
+
result = []
|
21
|
+
debug_plugin = Katte::Plugins::Output.find(:debug)
|
22
|
+
result << debug_plugin.history.pop[:out] until debug_plugin.history.empty?
|
23
|
+
|
24
|
+
today = Date.today.strftime("%Y-%m-%d")
|
25
|
+
["#{today}\n", "0\n", "custom:1\n", "custom:2\n"].all? do |line|
|
26
|
+
expect(result).to include line
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
expect(nodes_count).not_to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'logger'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
class Katte
|
6
|
+
describe ThreadPool do
|
7
|
+
class Spy
|
8
|
+
attr_reader :num_called
|
9
|
+
def initialize
|
10
|
+
@num_called = 0
|
11
|
+
@mutex = Mutex.new
|
12
|
+
end
|
13
|
+
def call
|
14
|
+
@mutex.synchronize { @num_called += 1 }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "execute procedures concurrently" do
|
19
|
+
thread_pool = ThreadPool.new
|
20
|
+
spy = Spy.new
|
21
|
+
|
22
|
+
threads = thread_pool.run
|
23
|
+
4.times { thread_pool.push { spy.call } }
|
24
|
+
sleep 0.1
|
25
|
+
|
26
|
+
expect(spy.num_called).to eq 4
|
27
|
+
end
|
28
|
+
|
29
|
+
it "ignores all exceptions" do
|
30
|
+
logio = StringIO.new
|
31
|
+
logger = Logger.new(logio)
|
32
|
+
|
33
|
+
thread_pool = ThreadPool.new(4, logger)
|
34
|
+
spy = Spy.new
|
35
|
+
|
36
|
+
threads = thread_pool.run
|
37
|
+
4.times { thread_pool.push { raise "Test thread_pool_spec" } }
|
38
|
+
sleep 0.1
|
39
|
+
|
40
|
+
expect(threads.count(&:alive?)).to eq 4
|
41
|
+
|
42
|
+
logio.rewind
|
43
|
+
logstr = logio.readlines.join
|
44
|
+
expect(logstr).to match(/Test thread_pool_spec/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: katte
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ojima Hikaru
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Batch job management tool.
|
15
|
+
email:
|
16
|
+
- ojiam.h@gmail.com
|
17
|
+
executables:
|
18
|
+
- katte
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .ruby-version
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/katte
|
29
|
+
- katte.gemspec
|
30
|
+
- lib/katte.rb
|
31
|
+
- lib/katte/command.rb
|
32
|
+
- lib/katte/config.rb
|
33
|
+
- lib/katte/driver.rb
|
34
|
+
- lib/katte/environment.rb
|
35
|
+
- lib/katte/filter.rb
|
36
|
+
- lib/katte/node.rb
|
37
|
+
- lib/katte/node/base.rb
|
38
|
+
- lib/katte/node/collection.rb
|
39
|
+
- lib/katte/plugins.rb
|
40
|
+
- lib/katte/plugins/base.rb
|
41
|
+
- lib/katte/plugins/file_type.rb
|
42
|
+
- lib/katte/plugins/file_type/bash.rb
|
43
|
+
- lib/katte/plugins/file_type/debug.rb
|
44
|
+
- lib/katte/plugins/file_type/hive.rb
|
45
|
+
- lib/katte/plugins/file_type/r.rb
|
46
|
+
- lib/katte/plugins/file_type/ruby.rb
|
47
|
+
- lib/katte/plugins/node.rb
|
48
|
+
- lib/katte/plugins/node/debug.rb
|
49
|
+
- lib/katte/plugins/node/file.rb
|
50
|
+
- lib/katte/plugins/output.rb
|
51
|
+
- lib/katte/plugins/output/debug.rb
|
52
|
+
- lib/katte/plugins/output/file.rb
|
53
|
+
- lib/katte/plugins/output/stderr.rb
|
54
|
+
- lib/katte/plugins/output/stdoe.rb
|
55
|
+
- lib/katte/recipe.rb
|
56
|
+
- lib/katte/recipe/file_type.rb
|
57
|
+
- lib/katte/recipe/node.rb
|
58
|
+
- lib/katte/recipe/node_factory.rb
|
59
|
+
- lib/katte/runner.rb
|
60
|
+
- lib/katte/runner/callback.rb
|
61
|
+
- lib/katte/thread_pool.rb
|
62
|
+
- lib/katte/version.rb
|
63
|
+
- spec/katte/config_spec.rb
|
64
|
+
- spec/katte/driver_spec.rb
|
65
|
+
- spec/katte/filter_spec.rb
|
66
|
+
- spec/katte/node/base_spec.rb
|
67
|
+
- spec/katte/node/collection_spec.rb
|
68
|
+
- spec/katte/plugins/file_type_spec.rb
|
69
|
+
- spec/katte/plugins/output_spec.rb
|
70
|
+
- spec/katte/recipe/node_factory_spec.rb
|
71
|
+
- spec/katte/runner_spec.rb
|
72
|
+
- spec/katte/thread_pool_spec.rb
|
73
|
+
- spec/recipes/custom/sample_1.sh
|
74
|
+
- spec/recipes/custom/sample_2.sh
|
75
|
+
- spec/recipes/test/sample.sh
|
76
|
+
- spec/recipes/test/sample/sub.sh
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/ojima-h/katte
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.23
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Batch job management tool.
|
102
|
+
test_files:
|
103
|
+
- spec/katte/config_spec.rb
|
104
|
+
- spec/katte/driver_spec.rb
|
105
|
+
- spec/katte/filter_spec.rb
|
106
|
+
- spec/katte/node/base_spec.rb
|
107
|
+
- spec/katte/node/collection_spec.rb
|
108
|
+
- spec/katte/plugins/file_type_spec.rb
|
109
|
+
- spec/katte/plugins/output_spec.rb
|
110
|
+
- spec/katte/recipe/node_factory_spec.rb
|
111
|
+
- spec/katte/runner_spec.rb
|
112
|
+
- spec/katte/thread_pool_spec.rb
|
113
|
+
- spec/recipes/custom/sample_1.sh
|
114
|
+
- spec/recipes/custom/sample_2.sh
|
115
|
+
- spec/recipes/test/sample.sh
|
116
|
+
- spec/recipes/test/sample/sub.sh
|
117
|
+
- spec/spec_helper.rb
|