pione 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Rakefile +13 -0
- data/bin/pione +5 -0
- data/bin/pione-compiler +5 -0
- data/example/ScoreAggregation/ScoreAggregation.pione +2 -0
- data/example/ScoreAggregation/bin/apply-template.rb +1 -1
- data/example/ScoreAggregation/bin/mean-summary.rb +1 -1
- data/example/ScoreAggregation/bin/total-mean.rb +1 -1
- data/example/ScoreAggregation/bin/total-statistics.rb +3 -3
- data/example/ScoreAggregation/pione-package.json +21 -0
- data/example/ScoreAggregation/scenario/case1/Scenario.pione +1 -0
- data/example/ScoreAggregation/scenario/case1/pione-scenario.json +36 -0
- data/lib/pione.rb +15 -2
- data/lib/pione/agent/basic-agent.rb +0 -1
- data/lib/pione/agent/job-terminator.rb +8 -3
- data/lib/pione/agent/task-worker.rb +9 -2
- data/lib/pione/command.rb +2 -0
- data/lib/pione/command/basic-command.rb +4 -0
- data/lib/pione/command/option.rb +4 -1
- data/lib/pione/command/pione-clean.rb +104 -17
- data/lib/pione/command/pione-client.rb +16 -3
- data/lib/pione/command/pione-command.rb +45 -0
- data/lib/pione/command/pione-compiler.rb +39 -0
- data/lib/pione/command/pione-log.rb +1 -0
- data/lib/pione/command/pione-task-worker.rb +6 -2
- data/lib/pione/command/pione-val.rb +1 -0
- data/lib/pione/front.rb +1 -0
- data/lib/pione/front/basic-front.rb +1 -1
- data/lib/pione/front/front-exception.rb +5 -1
- data/lib/pione/global.rb +3 -118
- data/lib/pione/global/broker-variable.rb +21 -8
- data/lib/pione/global/client-variable.rb +16 -8
- data/lib/pione/{system → global}/config.rb +2 -2
- data/lib/pione/global/global-exception.rb +40 -0
- data/lib/pione/global/input-generator-variable.rb +4 -1
- data/lib/pione/global/item.rb +168 -0
- data/lib/pione/global/log-variable.rb +64 -13
- data/lib/pione/global/network-variable.rb +4 -1
- data/lib/pione/global/package-variable.rb +25 -10
- data/lib/pione/global/path-variable.rb +62 -26
- data/lib/pione/global/relay-variable.rb +101 -36
- data/lib/pione/global/system-variable.rb +26 -9
- data/lib/pione/global/task-worker-variable.rb +19 -7
- data/lib/pione/global/tuple-space-notifier-variable.rb +60 -20
- data/lib/pione/lang.rb +0 -2
- data/lib/pione/lang/data-expr.rb +8 -0
- data/lib/pione/package/package-exception.rb +1 -1
- data/lib/pione/rule-engine/action-handler.rb +14 -12
- data/lib/pione/rule-engine/engine-exception.rb +11 -0
- data/lib/pione/rule-engine/flow-handler.rb +20 -11
- data/lib/pione/system.rb +1 -1
- data/lib/pione/system/file-cache.rb +1 -1
- data/lib/pione/system/init.rb +13 -15
- data/lib/pione/system/status.rb +30 -0
- data/lib/pione/system/system-exception.rb +0 -24
- data/lib/pione/test-helper.rb +8 -1
- data/lib/pione/test-helper/command-helper.rb +42 -15
- data/lib/pione/util.rb +1 -0
- data/lib/pione/util/embeded-expr-expander.rb +5 -11
- data/lib/pione/util/pnml-compiler.rb +97 -0
- data/lib/pione/util/profiler.rb +107 -0
- data/lib/pione/version.rb +1 -1
- data/man/pione-clean.1 +76 -0
- data/pione.gemspec +5 -2
- data/test/agent/spec_job-terminator.rb +41 -3
- data/test/command/data/pione-client/ActionError.pione +5 -0
- data/test/command/data/pione-compiler/Sequence.pnml +137 -0
- data/test/command/spec_pione-clean.rb +250 -5
- data/test/command/spec_pione-client.rb +57 -46
- data/test/command/spec_pione-command.rb +18 -0
- data/test/command/spec_pione-compiler.rb +13 -0
- data/test/global/spec_item.rb +77 -0
- data/test/lang/data/data-expr.yml +5 -0
- data/test/rule-engine/{spec_action-handler.pione → data/action-handler/BasicAction.pione} +0 -0
- data/test/rule-engine/data/action-handler/UsePackageScript.pione +17 -0
- data/test/rule-engine/spec_action-handler.rb +143 -80
- data/test/system/spec_status.rb +13 -0
- data/test/{tuple → tuple-space}/spec_basic-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_data-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_finished-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_message-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_task-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_touch-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_working-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/tuple-behavior.rb +0 -0
- data/test/util/data/pnml/Sequence.pnml +137 -0
- data/test/util/spec_pnml-compiler.rb +21 -0
- data/test/util/spec_profiler.rb +53 -0
- metadata +75 -32
- data/example/ScoreAggregation/package.yml +0 -5
- data/example/ScoreAggregation/scenario/case1/scenario.yml +0 -29
- data/lib/pione/lang/interpolator-parser.rb +0 -44
- data/lib/pione/lang/interpolator-transformer.rb +0 -13
- data/test/lang/spec_interpolator-parser.rb +0 -5
- data/test/lang/spec_interpolator-transformer.rb +0 -15
@@ -1,56 +1,67 @@
|
|
1
1
|
require 'pione/test-helper'
|
2
2
|
require_relative 'command-behavior'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
it "should execute a PIONE document with stand alone mode" do
|
19
|
-
path = Temppath.create
|
20
|
-
args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s, "--stand-alone"]
|
21
|
-
res = TestHelper::Command.succeed do
|
22
|
-
Pione::Command::PioneClient.run args
|
4
|
+
TestHelper.scope do |this|
|
5
|
+
this::DIR = Location[File.dirname(__FILE__)] + "data" + "pione-client"
|
6
|
+
|
7
|
+
describe "Pione::Command::PioneClient" do
|
8
|
+
behaves_like "command"
|
9
|
+
|
10
|
+
it "should execute a PIONE document" do
|
11
|
+
path = Temppath.create
|
12
|
+
args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s]
|
13
|
+
res = TestHelper::Command.succeed do
|
14
|
+
Pione::Command::PioneClient.run(args)
|
15
|
+
end
|
16
|
+
Location[path + "message.txt"].should.exist
|
17
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
23
18
|
end
|
24
|
-
Location[path + "message.txt"].should.exist
|
25
|
-
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
26
|
-
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
20
|
+
it "should execute a PIONE document with stand alone mode" do
|
21
|
+
path = Temppath.create
|
22
|
+
args = ["example/HelloWorld/HelloWorld.pione", "-o", path.to_s, "--stand-alone"]
|
23
|
+
TestHelper::Command.succeed do
|
24
|
+
Pione::Command::PioneClient.run(args)
|
25
|
+
end
|
26
|
+
Location[path + "message.txt"].should.exist
|
27
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should execute a PIONE package" do
|
31
|
+
path = Temppath.create
|
32
|
+
args = ["example/HelloWorld/", "-o", path.to_s]
|
33
|
+
TestHelper::Command.succeed do
|
34
|
+
Pione::Command::PioneClient.run(args)
|
35
|
+
end
|
36
|
+
Location[path + "message.txt"].should.exist
|
37
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
43
38
|
end
|
44
|
-
Location[path + "message.txt"].should.exist
|
45
|
-
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
46
|
-
end
|
47
39
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
40
|
+
it "should execute a PIONE package with stand alone mode" do
|
41
|
+
path = Temppath.create
|
42
|
+
args = ["example/HelloWorld/", "-o", path.to_s, "--stand-alone"]
|
43
|
+
TestHelper::Command.succeed do
|
44
|
+
Pione::Command::PioneClient.run(args)
|
45
|
+
end
|
46
|
+
Location[path + "message.txt"].should.exist
|
47
|
+
Location[path + "message.txt"].read.should.start_with "Hello, world!"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should fail with action error" do
|
51
|
+
doc = (this::DIR + "ActionError.pione").path.to_s
|
52
|
+
path = Temppath.create
|
53
|
+
args = [doc, "-o", path.to_s, "--stand-alone"]
|
54
|
+
TestHelper::Command.fail do
|
55
|
+
Pione::Command::PioneClient.run(args)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should show parameters list of package" do
|
60
|
+
args = ["example/HelloWorld/HelloWorld.pione", "--list-params"]
|
61
|
+
res = TestHelper::Command.succeed do
|
62
|
+
Pione::Command::PioneClient.run(args)
|
63
|
+
end
|
64
|
+
res.stdout.string.size.should > 0
|
52
65
|
end
|
53
|
-
res.stdout.string.size.should > 0
|
54
66
|
end
|
55
67
|
end
|
56
|
-
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pione/test-helper'
|
2
|
+
require_relative 'command-behavior'
|
3
|
+
|
4
|
+
describe Pione::Command::PioneCommand do
|
5
|
+
behaves_like "command"
|
6
|
+
|
7
|
+
it "should call subcommand" do
|
8
|
+
TestHelper::Command.succeed do
|
9
|
+
Command::PioneCommand.run(["val", "1 + 1"])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should fail with unknown subcommand name" do
|
14
|
+
TestHelper::Command.fail do
|
15
|
+
Command::PioneCommand.run(["abcdefghijk"])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pione/test-helper'
|
2
|
+
|
3
|
+
TestHelper.scope do |this|
|
4
|
+
this::PNML1 = Location[File.dirname(__FILE__)] + "data" + "pione-compiler" + "Sequence.pnml"
|
5
|
+
|
6
|
+
describe Pione::Command::PioneCompiler do
|
7
|
+
it "should compile from PNML to PIONE document" do
|
8
|
+
res = TestHelper::Command.succeed do
|
9
|
+
Command::PioneCompiler.run [this::PNML1.path.to_s]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "pione/test-helper"
|
2
|
+
|
3
|
+
describe do
|
4
|
+
it "should define an external item" do
|
5
|
+
item = Global.define_external_item(:test_external_item) do |item|
|
6
|
+
item.desc = "test external item"
|
7
|
+
item.init = 1
|
8
|
+
item.define_updater do |val|
|
9
|
+
"value is %s" % val
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Global.test_external_item.should == "value is 1"
|
14
|
+
Global.test_external_item = 2
|
15
|
+
Global.test_external_item.should == "value is 2"
|
16
|
+
|
17
|
+
item.unregister
|
18
|
+
|
19
|
+
should.raise(NoMethodError) {Global.test_external_item}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should define an internal item" do
|
23
|
+
item = Global.define_internal_item(:test_internal_item) do |item|
|
24
|
+
item.desc = "test internal item"
|
25
|
+
item.init = 1
|
26
|
+
item.define_updater do |val|
|
27
|
+
"value is %s" % val
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Global.test_internal_item.should == "value is 1"
|
32
|
+
Global.test_internal_item = 2
|
33
|
+
Global.test_internal_item.should == "value is 2"
|
34
|
+
|
35
|
+
item.unregister
|
36
|
+
|
37
|
+
should.raise(NoMethodError) {item.test_internal_item}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should define a computed item" do
|
41
|
+
item1 = Global.define_external_item(:test_external_item) do |item|
|
42
|
+
item.desc = "test external item"
|
43
|
+
item.type = :integer
|
44
|
+
item.init = 1
|
45
|
+
item.define_updater {|val| "external: %s" % val}
|
46
|
+
end
|
47
|
+
|
48
|
+
item2 = Global.define_internal_item(:test_internal_item) do |item|
|
49
|
+
item.desc = "test internal item"
|
50
|
+
item.type = :integer
|
51
|
+
item.init = 2
|
52
|
+
item.define_updater {|val| "internal: %s" % val}
|
53
|
+
end
|
54
|
+
|
55
|
+
item3 = item = Global.define_computed_item(:test_computed_item, [:test_external_item, :test_internal_item]) do |item|
|
56
|
+
item.desc = "test computed item"
|
57
|
+
item.define_updater do
|
58
|
+
"%s, %s" % [Global.test_external_item, Global.test_internal_item]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Global.test_computed_item.should == "external: 1, internal: 2"
|
63
|
+
Global.test_external_item = 2
|
64
|
+
Global.test_computed_item.should == "external: 2, internal: 2"
|
65
|
+
Global.test_internal_item = 1
|
66
|
+
Global.test_computed_item.should == "external: 2, internal: 1"
|
67
|
+
Global.test_external_item = 3
|
68
|
+
Global.test_internal_item = 4
|
69
|
+
Global.test_computed_item.should == "external: 3, internal: 4"
|
70
|
+
|
71
|
+
item1.unregister
|
72
|
+
item2.unregister
|
73
|
+
item3.unregister
|
74
|
+
|
75
|
+
should.raise(NoMethodError) {item.test_computed_item}
|
76
|
+
end
|
77
|
+
end
|
@@ -91,3 +91,8 @@
|
|
91
91
|
- "'*.x' | '*.y' | '*.z' | '*.x' | '*.y' | '*.z' | '*.x' | '*.y' | '*.z'" :
|
92
92
|
"('*.a' | '*.b' | '*.c').suffix('x' | 'y' | 'z')"
|
93
93
|
|
94
|
+
"#join" :
|
95
|
+
- '"a"' : "'a'.join"
|
96
|
+
- '"a"' : "'a'.join(\":\")"
|
97
|
+
- '"a b c"' : "('a' | 'b' | 'c').join"
|
98
|
+
- '"a:b:c"' : "('a' | 'b' | 'c').join(\":\")"
|
File without changes
|
@@ -1,94 +1,157 @@
|
|
1
1
|
require 'pione/test-helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
describe 'Pione::RuleHandler::ActionHandler' do
|
9
|
-
before do
|
10
|
-
@ts = TestHelper::TupleSpace.create(self)
|
11
|
-
|
12
|
-
location = Location[Temppath.create]
|
13
|
-
location_a = location + "1.a"
|
14
|
-
location_b = location + "1.b"
|
15
|
-
location_a.create("1")
|
16
|
-
location_b.create("2")
|
17
|
-
|
18
|
-
param_set = Lang::ParameterSet.new(table: {
|
19
|
-
"*" => Lang::StringSequence.of("1"),
|
20
|
-
"INPUT" => Lang::Variable.new("I"),
|
21
|
-
"I" => Lang::KeyedSequence.new
|
22
|
-
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.a"))
|
23
|
-
.put(Lang::IntegerSequence.of(2), Lang::DataExprSequence.of("1.b")),
|
24
|
-
"OUTPUT" => Lang::Variable.new("O"),
|
25
|
-
"O" => Lang::KeyedSequence.new
|
26
|
-
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.c"))
|
27
|
-
})
|
28
|
-
|
29
|
-
tuple_a = TupleSpace::DataTuple.new(name: '1.a', location: location_a, time: Time.now)
|
30
|
-
tuple_b = TupleSpace::DataTuple.new(name: '1.b', location: location_b, time: Time.now)
|
31
|
-
inputs = [tuple_a, tuple_b]
|
32
|
-
|
33
|
-
domain_id = Util::DomainID.generate(package_id, @rule_name, inputs, param_set)
|
34
|
-
tuple_a.domain = domain_id
|
35
|
-
tuple_b.domain = domain_id
|
36
|
-
inputs.each {|t| write(t) }
|
37
|
-
|
38
|
-
@handler_sh1 = RuleEngine.make(@ts, env, package_id, 'Shell1', inputs, param_set, domain_id, 'root')
|
39
|
-
@handler_sh2 = RuleEngine.make(@ts, env, package_id, 'Shell2', inputs, param_set, domain_id, 'root')
|
40
|
-
@handler_ruby = RuleEngine.make(@ts, env, package_id, 'Ruby', inputs, param_set, domain_id, 'root')
|
41
|
-
end
|
3
|
+
TestHelper.scope do |this|
|
4
|
+
this::DIR = Location[File.dirname(__FILE__)] + "data" + "action-handler"
|
5
|
+
this::BASIC_ACTION = this::DIR + "BasicAction.pione"
|
6
|
+
this::USE_PACKAGE_SCRIPT = this::DIR + "UsePackageScript.pione"
|
42
7
|
|
43
|
-
|
44
|
-
|
45
|
-
|
8
|
+
describe 'Pione::RuleHandler::ActionHandler' do
|
9
|
+
describe "basic actions" do
|
10
|
+
before do
|
11
|
+
env = Lang::Environment.new.setup_new_package("BasicAction")
|
12
|
+
package_id = "BasicAction"
|
13
|
+
Package::Document.load(env, this::BASIC_ACTION, package_id, nil, nil, "BasicAction.pione")
|
46
14
|
|
47
|
-
|
48
|
-
@handler_sh1.should.be.kind_of(RuleEngine::ActionHandler)
|
49
|
-
@handler_sh2.should.be.kind_of(RuleEngine::ActionHandler)
|
50
|
-
@handler_ruby.should.be.kind_of(RuleEngine::ActionHandler)
|
51
|
-
end
|
15
|
+
@ts = TestHelper::TupleSpace.create(self)
|
52
16
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
17
|
+
location = Location[Temppath.create]
|
18
|
+
location_a = location + "1.a"
|
19
|
+
location_b = location + "1.b"
|
20
|
+
location_a.create("1")
|
21
|
+
location_b.create("2")
|
58
22
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
23
|
+
param_set = Lang::ParameterSet.new(table: {
|
24
|
+
"*" => Lang::StringSequence.of("1"),
|
25
|
+
"INPUT" => Lang::Variable.new("I"),
|
26
|
+
"I" => Lang::KeyedSequence.new
|
27
|
+
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.a"))
|
28
|
+
.put(Lang::IntegerSequence.of(2), Lang::DataExprSequence.of("1.b")),
|
29
|
+
"OUTPUT" => Lang::Variable.new("O"),
|
30
|
+
"O" => Lang::KeyedSequence.new
|
31
|
+
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.c"))
|
32
|
+
})
|
64
33
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
34
|
+
tuple_a = TupleSpace::DataTuple.new(name: '1.a', location: location_a, time: Time.now)
|
35
|
+
tuple_b = TupleSpace::DataTuple.new(name: '1.b', location: location_b, time: Time.now)
|
36
|
+
inputs = [tuple_a, tuple_b]
|
37
|
+
|
38
|
+
domain_id = Util::DomainID.generate(package_id, @rule_name, inputs, param_set)
|
39
|
+
tuple_a.domain = domain_id
|
40
|
+
tuple_b.domain = domain_id
|
41
|
+
inputs.each {|t| write(t) }
|
42
|
+
|
43
|
+
@handler_sh1 = RuleEngine.make(@ts, env, package_id, 'Shell1', inputs, param_set, domain_id, 'root')
|
44
|
+
@handler_sh2 = RuleEngine.make(@ts, env, package_id, 'Shell2', inputs, param_set, domain_id, 'root')
|
45
|
+
@handler_ruby = RuleEngine.make(@ts, env, package_id, 'Ruby', inputs, param_set, domain_id, 'root')
|
46
|
+
end
|
47
|
+
|
48
|
+
after do
|
49
|
+
@ts.terminate
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should be action handler' do
|
53
|
+
@handler_sh1.should.be.kind_of(RuleEngine::ActionHandler)
|
54
|
+
@handler_sh2.should.be.kind_of(RuleEngine::ActionHandler)
|
55
|
+
@handler_ruby.should.be.kind_of(RuleEngine::ActionHandler)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should have working directory' do
|
59
|
+
@handler_sh1.working_directory.should.exist
|
60
|
+
@handler_sh2.working_directory.should.exist
|
61
|
+
@handler_ruby.working_directory.should.exist
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should make different working directories' do
|
65
|
+
@handler_sh1.working_directory.should != @handler_sh2.working_directory
|
66
|
+
@handler_sh2.working_directory.should != @handler_ruby.working_directory
|
67
|
+
@handler_ruby.working_directory.should != @handler_sh1.working_directory
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should write a shell script' do
|
71
|
+
@handler_sh1.write_shell_script do |path|
|
72
|
+
File.should.exist(path)
|
73
|
+
File.should.executable(path)
|
74
|
+
File.read(path).should == "VAL1=`cat 1.a`;\nVAL2=`cat 1.b`;\nexpr $VAL1 + $VAL2 > 1.c\n"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should call shell script' do
|
79
|
+
@handler_sh1.setup_working_directory
|
80
|
+
@handler_sh1.write_shell_script do |path|
|
81
|
+
@handler_sh1.call_shell_script(path)
|
82
|
+
(@handler_sh1.working_directory + "1.b").should.exist
|
83
|
+
end
|
84
|
+
end
|
72
85
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
86
|
+
[:sh1, :sh2, :ruby].each do |sym|
|
87
|
+
it "should execute an action: #{sym}" do
|
88
|
+
# execute and get result
|
89
|
+
handler = eval("@handler_#{sym}")
|
90
|
+
outputs = handler.execute
|
91
|
+
outputs[0][0].name.should == '1.c'
|
92
|
+
outputs[0][0].location.read.chomp.should == "3"
|
93
|
+
should.not.raise do
|
94
|
+
read(TupleSpace::DataTuple.new(name: '1.c', domain: handler.domain_id))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
78
98
|
end
|
79
|
-
end
|
80
99
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
100
|
+
describe "use package script" do
|
101
|
+
before do
|
102
|
+
env = Lang::Environment.new.setup_new_package("UsePackageScript")
|
103
|
+
package_id = "UsePackageScript"
|
104
|
+
Package::Document.load(env, this::USE_PACKAGE_SCRIPT, package_id, nil, nil, "UsePackageScript.pione")
|
105
|
+
|
106
|
+
@ts = TestHelper::TupleSpace.create(self)
|
107
|
+
|
108
|
+
location = Location[Temppath.create]
|
109
|
+
location_a = location + "1.a"
|
110
|
+
location_a.create("1")
|
111
|
+
|
112
|
+
param_set = Lang::ParameterSet.new(table: {
|
113
|
+
"*" => Lang::StringSequence.of("1"),
|
114
|
+
"INPUT" => Lang::Variable.new("I"),
|
115
|
+
"I" => Lang::KeyedSequence.new
|
116
|
+
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.a")),
|
117
|
+
"OUTPUT" => Lang::Variable.new("O"),
|
118
|
+
"O" => Lang::KeyedSequence.new
|
119
|
+
.put(Lang::IntegerSequence.of(1), Lang::DataExprSequence.of("1.b"))
|
120
|
+
})
|
121
|
+
|
122
|
+
tuple_a = TupleSpace::DataTuple.new(name: '1.a', location: location_a, time: Time.now)
|
123
|
+
inputs = [tuple_a]
|
124
|
+
|
125
|
+
sh = (@ts.base_location + "package" + "bin" + "test.sh")
|
126
|
+
sh.write("echo abc > 1.b")
|
127
|
+
sh.path.chmod(0700)
|
128
|
+
|
129
|
+
domain_id = Util::DomainID.generate(package_id, @rule_name, inputs, param_set)
|
130
|
+
tuple_a.domain = domain_id
|
131
|
+
inputs.each {|t| write(t) }
|
132
|
+
|
133
|
+
@handler1 = RuleEngine.make(@ts, env, package_id, 'R1', inputs, param_set, domain_id, 'root')
|
134
|
+
@handler2 = RuleEngine.make(@ts, env, package_id, 'R2', inputs, param_set, domain_id, 'root')
|
135
|
+
end
|
136
|
+
|
137
|
+
after do
|
138
|
+
@ts.terminate
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should call package script" do
|
142
|
+
outputs = @handler1.execute
|
143
|
+
outputs[0][0].name.should == '1.b'
|
144
|
+
outputs[0][0].location.read.chomp.should == "abc"
|
145
|
+
should.not.raise do
|
146
|
+
read(TupleSpace::DataTuple.new(name: '1.b', domain: @handler1.domain_id))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should raise action error because the script not found" do
|
151
|
+
should.raise(RuleEngine::ActionError) do
|
152
|
+
outputs = @handler2.execute
|
153
|
+
end
|
90
154
|
end
|
91
155
|
end
|
92
156
|
end
|
93
157
|
end
|
94
|
-
|