brpm_content_framework 0.2.19 → 0.2.20
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.
- checksums.yaml +8 -8
- data/config.yml +1 -1
- data/lib/brpm_script_executor.rb +18 -17
- data/lib/module_installer.rb +2 -2
- data/tests/brpm_script_executor_spec.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
ZWUyMmVmZGY2NmJjMzIzZTJiNjcyZTJiZTA1NDc0YzMyZTQzMTEzNA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
YmJlZjRhMGM1ZTFiMjY4ZDBjZWU2MjQ5YzkxNGZkNDliYTgzM2Y0Mg==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MjUyNDJmYzJiZDdiODUxNjc0ODVjOGM3ODk5ZGQ4NGY5YTg1MWRiNDcyMjc0
|
|
10
|
+
MjYzNDcxODc0ZWZiNGI3YzY2ZDA1YTNjYjVmODhjZDY1OGI2MTQxMWYwYmRi
|
|
11
|
+
MmJjZjg2MzBhNjQxY2Q4ZTljYWQ1MjBhZDRmYWZlZmVhYTBlOTc=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
OTJhOWMxY2RmMzlkMGU5Nzk5YWRlY2I4NWI4MmEyODYyZjVkZGIwMzBkOGM1
|
|
14
|
+
MjVmYjY0YmJkOWVmNmQxMzNhMGMwZmZkNTE4ODc0OTBhOTEwMDc4YWVlOWFj
|
|
15
|
+
YTMyMTg0MDE1MDFmNjY4MjliN2UyOWM2ZDM4NTdmNDM1NjBkNDM=
|
data/config.yml
CHANGED
data/lib/brpm_script_executor.rb
CHANGED
|
@@ -6,28 +6,19 @@ class BrpmScriptExecutor
|
|
|
6
6
|
private_class_method :new
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
|
-
def
|
|
10
|
-
|
|
9
|
+
def execute_automation_script_in_separate_process(modul, name, params)
|
|
10
|
+
execute_automation_script_in_separate_process_internal(modul, name, params, "automation")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def
|
|
14
|
-
|
|
13
|
+
def execute_resource_automation_script_in_separate_process(modul, name, params, parent_id, offset, max_records)
|
|
14
|
+
execute_automation_script_in_separate_process_internal(modul, name, params, "resource_automation", parent_id, offset, max_records)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
def
|
|
17
|
+
def execute_automation_script_in_separate_process_internal(modul, name, params, automation_type, parent_id = nil, offset = nil, max_records = nil)
|
|
18
18
|
BrpmAuto.setup(params)
|
|
19
19
|
BrpmAuto.log ""
|
|
20
|
+
BrpmAuto.log "Executing #{automation_type} '#{name}' from module '#{modul}' in a separate process..."
|
|
20
21
|
|
|
21
|
-
if in_separate_process || BrpmAuto.params["execute_automations_in_separate_process"]
|
|
22
|
-
BrpmAuto.log "Executing #{automation_type} '#{name}' from module '#{modul}' in a separate process..."
|
|
23
|
-
execute_automation_script_in_separate_process_internal(modul, name, params, automation_type, parent_id, offset, max_records)
|
|
24
|
-
else
|
|
25
|
-
BrpmAuto.log "Executing #{automation_type} '#{name}' from module '#{modul}' in-process..."
|
|
26
|
-
execute_automation_script_in_same_process_internal(modul, name, params, automation_type, parent_id, offset, max_records)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def execute_automation_script_in_separate_process_internal(modul, name, params, automation_type, parent_id = nil, offset = nil, max_records = nil)
|
|
31
22
|
env_vars = {}
|
|
32
23
|
env_vars["JRUBY_OPTS"] = "-Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF" # improve jvm startup time (see http://rexchung.com/2013/08/02/speed-up-jruby-rails-startup-time/)
|
|
33
24
|
env_vars["GEM_HOME"] = ENV["BRPM_CONTENT_HOME"] || "#{ENV["BRPM_HOME"]}/modules"
|
|
@@ -108,7 +99,7 @@ class BrpmScriptExecutor
|
|
|
108
99
|
load File.expand_path("#{File.dirname(__FILE__)}/../infrastructure/create_output_file.rb")
|
|
109
100
|
end
|
|
110
101
|
|
|
111
|
-
result =
|
|
102
|
+
result = execute_automation_script_internal(modul, name, params, automation_type, parent_id, offset, max_records)
|
|
112
103
|
if automation_type == "resource_automation"
|
|
113
104
|
result_file = "#{File.dirname(params_file)}/result_#{Process.pid}.yml"
|
|
114
105
|
BrpmAuto.log " Temporarily storing the result to #{result_file}..."
|
|
@@ -119,8 +110,18 @@ class BrpmScriptExecutor
|
|
|
119
110
|
end
|
|
120
111
|
end
|
|
121
112
|
|
|
122
|
-
def
|
|
113
|
+
def execute_automation_script(modul, name, params)
|
|
114
|
+
execute_automation_script_internal(modul, name, params, "automation")
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def execute_resource_automation_script(modul, name, params, parent_id, offset, max_records)
|
|
118
|
+
execute_automation_script_internal(modul, name, params, "resource_automation", parent_id, offset, max_records)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def execute_automation_script_internal(modul, name, params, automation_type, parent_id = nil, offset = nil, max_records = nil)
|
|
123
122
|
begin
|
|
123
|
+
BrpmAuto.setup(params)
|
|
124
|
+
|
|
124
125
|
BrpmAuto.log ""
|
|
125
126
|
BrpmAuto.log ">>>>>>>>>>>>>> START #{automation_type} #{modul} #{name}"
|
|
126
127
|
start_time = Time.now
|
data/lib/module_installer.rb
CHANGED
|
@@ -539,7 +539,7 @@ EOR
|
|
|
539
539
|
template += <<EOR
|
|
540
540
|
require "\#{ENV["BRPM_CONTENT_HOME"] || "\#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content_framework-\#{params["framework_version"] || "latest"}/lib/brpm_script_executor.rb"
|
|
541
541
|
|
|
542
|
-
BrpmScriptExecutor.
|
|
542
|
+
BrpmScriptExecutor.execute_automation_script_in_separate_process("#{module_name}", "#{auto_script_name}", params)
|
|
543
543
|
EOR
|
|
544
544
|
|
|
545
545
|
elsif automation_type == "ResourceAutomation"
|
|
@@ -548,7 +548,7 @@ EOR
|
|
|
548
548
|
load "\#{ENV["BRPM_CONTENT_HOME"] || "\#{ENV["BRPM_HOME"]}/modules"}/gems/brpm_content_framework-\#{params["framework_version"] || "latest"}/lib/brpm_script_executor.rb"
|
|
549
549
|
|
|
550
550
|
def execute(script_params, parent_id, offset, max_records)
|
|
551
|
-
BrpmScriptExecutor.
|
|
551
|
+
BrpmScriptExecutor.execute_resource_automation_script_in_separate_process("#{module_name}", "#{auto_script_name}", script_params, parent_id, offset, max_records)
|
|
552
552
|
end
|
|
553
553
|
EOR
|
|
554
554
|
end
|
|
@@ -35,7 +35,7 @@ describe 'BRPM Script Executor' do
|
|
|
35
35
|
# Note: the following tests will run the automation scripts in a separate process and will therefore use an already installed brpm_content_framework module,
|
|
36
36
|
# either the version from their Gemfile/Gemfile.lock or the latest, but not the one from source code
|
|
37
37
|
it "should execute an automation script in a separate process inside a bundler context" do
|
|
38
|
-
result = BrpmScriptExecutor.
|
|
38
|
+
result = BrpmScriptExecutor.execute_automation_script_in_separate_process("brpm_module_test", "test_ruby", get_default_params)
|
|
39
39
|
|
|
40
40
|
expect(result).to be_truthy
|
|
41
41
|
end
|
|
@@ -46,22 +46,22 @@ describe 'BRPM Script Executor' do
|
|
|
46
46
|
gemfile_path = "#{module_gem_path}/Gemfile"
|
|
47
47
|
|
|
48
48
|
FileUtils.move(gemfile_path, "#{gemfile_path}_tmp")
|
|
49
|
-
result = BrpmScriptExecutor.
|
|
49
|
+
result = BrpmScriptExecutor.execute_automation_script_in_separate_process(@module_name, "test_ruby", get_default_params)
|
|
50
50
|
FileUtils.move("#{gemfile_path}_tmp", gemfile_path)
|
|
51
51
|
|
|
52
52
|
expect(result).to be_truthy
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should return false when executing an non-existing automation script in a separate process" do
|
|
56
|
-
expect{BrpmScriptExecutor.
|
|
56
|
+
expect{BrpmScriptExecutor.execute_automation_script_in_separate_process(@module_name, "xxx", get_default_params)}.to raise_exception
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
it "should return false when executing an erroneous automation script in a separate process" do
|
|
60
|
-
expect{BrpmScriptExecutor.
|
|
60
|
+
expect{BrpmScriptExecutor.execute_automation_script_in_separate_process(@module_name, "test_ruby_raises_error", get_default_params)}.to raise_exception
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "should execute a resource automation script in a separate process" do
|
|
64
|
-
result = BrpmScriptExecutor.
|
|
64
|
+
result = BrpmScriptExecutor.execute_resource_automation_script_in_separate_process(@module_name, "test_resource", get_default_params, nil, 0, 10)
|
|
65
65
|
|
|
66
66
|
expect(result.count).to eql(3)
|
|
67
67
|
end
|