masamune 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/Rakefile +37 -0
- data/bin/masamune-dump +22 -0
- data/bin/masamune-elastic-mapreduce +22 -0
- data/bin/masamune-hive +22 -0
- data/bin/masamune-psql +22 -0
- data/bin/masamune-shell +22 -0
- data/lib/masamune/cached_filesystem.rb +1 -1
- data/lib/masamune/commands/shell.rb +1 -1
- data/lib/masamune/configuration.rb +5 -7
- data/lib/masamune/data_plan/elem.rb +15 -7
- data/lib/masamune/data_plan/engine.rb +2 -0
- data/lib/masamune/data_plan/rule.rb +16 -5
- data/lib/masamune/data_plan/set.rb +8 -8
- data/lib/masamune/filesystem.rb +12 -6
- data/lib/masamune/schema/catalog.rb +6 -6
- data/lib/masamune/schema/column.rb +1 -1
- data/lib/masamune/schema/map.rb +6 -2
- data/lib/masamune/schema/store.rb +31 -3
- data/lib/masamune/tasks/shell_thor.rb +1 -1
- data/lib/masamune/thor.rb +12 -4
- data/lib/masamune/version.rb +1 -1
- data/lib/masamune.rb +0 -1
- data/spec/masamune/actions/elastic_mapreduce_spec.rb +0 -2
- data/spec/masamune/actions/execute_spec.rb +0 -2
- data/spec/masamune/actions/hadoop_filesystem_spec.rb +0 -2
- data/spec/masamune/actions/hadoop_streaming_spec.rb +0 -2
- data/spec/masamune/actions/hive_spec.rb +0 -2
- data/spec/masamune/actions/invoke_parallel_spec.rb +0 -2
- data/spec/masamune/actions/postgres_admin_spec.rb +0 -2
- data/spec/masamune/actions/postgres_spec.rb +0 -2
- data/spec/masamune/actions/s3cmd_spec.rb +0 -2
- data/spec/masamune/actions/transform_spec.rb +0 -2
- data/spec/masamune/after_initialization_callbacks_spec.rb +0 -2
- data/spec/masamune/cached_filesystem_spec.rb +0 -2
- data/spec/masamune/commands/hadoop_filesystem_spec.rb +0 -2
- data/spec/masamune/commands/hadoop_streaming_spec.rb +0 -2
- data/spec/masamune/commands/hive_spec.rb +0 -2
- data/spec/masamune/commands/postgres_admin_spec.rb +0 -2
- data/spec/masamune/commands/postgres_spec.rb +0 -2
- data/spec/masamune/commands/retry_with_backoff_spec.rb +0 -2
- data/spec/masamune/commands/s3cmd_spec.rb +0 -2
- data/spec/masamune/commands/shell_spec.rb +0 -2
- data/spec/masamune/configuration_spec.rb +12 -2
- data/spec/masamune/data_plan/builder_spec.rb +0 -2
- data/spec/masamune/data_plan/elem_spec.rb +73 -5
- data/spec/masamune/data_plan/engine_spec.rb +0 -2
- data/spec/masamune/data_plan/rule_spec.rb +51 -6
- data/spec/masamune/data_plan/set_spec.rb +2 -5
- data/spec/masamune/environment_spec.rb +0 -2
- data/spec/masamune/filesystem_spec.rb +33 -4
- data/spec/masamune/helpers/postgres_spec.rb +0 -2
- data/spec/masamune/rspec/job_fixture_spec.rb +365 -0
- data/spec/masamune/rspec/shared_example_group_spec.rb +73 -0
- data/spec/masamune/schema/catalog_spec.rb +14 -2
- data/spec/masamune/schema/column_spec.rb +0 -2
- data/spec/masamune/schema/dimension_spec.rb +0 -2
- data/spec/masamune/schema/fact_spec.rb +0 -2
- data/spec/masamune/schema/map_spec.rb +51 -2
- data/spec/masamune/schema/row_spec.rb +0 -2
- data/spec/masamune/schema/store_spec.rb +23 -2
- data/spec/masamune/schema/table_spec.rb +0 -2
- data/spec/masamune/string_format_spec.rb +0 -2
- data/spec/masamune/tasks/dump_thor_spec.rb +0 -3
- data/spec/masamune/tasks/elastic_mapreduce_thor_spec.rb +0 -3
- data/spec/masamune/tasks/hive_thor_spec.rb +0 -3
- data/spec/masamune/tasks/postgres_thor_spec.rb +0 -3
- data/spec/masamune/tasks/shell_thor_spec.rb +0 -3
- data/spec/masamune/template_spec.rb +0 -2
- data/spec/masamune/thor_spec.rb +53 -8
- data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +0 -2
- data/spec/masamune/transform/consolidate_dimension_spec.rb +0 -2
- data/spec/masamune/transform/deduplicate_dimension_spec.rb +0 -2
- data/spec/masamune/transform/define_schema_spec.rb +0 -2
- data/spec/masamune/transform/define_table.dimension_spec.rb +0 -2
- data/spec/masamune/transform/define_table.fact_spec.rb +0 -2
- data/spec/masamune/transform/define_table.table_spec.rb +0 -2
- data/spec/masamune/transform/denormalize_table_spec.rb +0 -2
- data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +0 -2
- data/spec/masamune/transform/insert_reference_values.fact_spec.rb +0 -2
- data/spec/masamune/transform/load_dimension_spec.rb +0 -2
- data/spec/masamune/transform/load_fact_spec.rb +0 -2
- data/spec/masamune/transform/relabel_dimension_spec.rb +0 -2
- data/spec/masamune/transform/rollup_fact_spec.rb +0 -2
- data/spec/masamune/transform/snapshot_dimension_spec.rb +0 -2
- data/spec/masamune/transform/stage_dimension_spec.rb +0 -2
- data/spec/masamune/transform/stage_fact_spec.rb +0 -2
- data/spec/masamune_spec.rb +0 -2
- data/spec/spec_helper.rb +2 -0
- data/spec/support/masamune/job_example_group.rb +62 -0
- data/spec/support/masamune/job_fixture.rb +137 -0
- data/spec/support/masamune/shared_example_group.rb +203 -0
- data/spec/support/masamune/step_example_group.rb +68 -0
- data/spec/support/masamune/step_fixture.rb +91 -0
- data/{lib/masamune/thor_loader.rb → spec/support/masamune/task_example_group.rb} +33 -10
- data/spec/support/rspec/example/action_example_group.rb +1 -1
- metadata +32 -3
@@ -0,0 +1,203 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Masamune::SharedExampleGroup
|
24
|
+
extend ActiveSupport::Concern
|
25
|
+
|
26
|
+
def capture_popen(cmd, stdin)
|
27
|
+
stdout = StringIO.new
|
28
|
+
IO.popen(cmd, 'r+') do |io|
|
29
|
+
io.sync = true
|
30
|
+
io.write stdin
|
31
|
+
io.close_write
|
32
|
+
while !io.eof?
|
33
|
+
stdout << io.read
|
34
|
+
end
|
35
|
+
end
|
36
|
+
stdout.string
|
37
|
+
end
|
38
|
+
|
39
|
+
def capture_output
|
40
|
+
@stdout, @stderr = StringIO.new, StringIO.new
|
41
|
+
tmp_stdout, $stdout = $stdout, @stdout
|
42
|
+
tmp_stderr, $stderr = $stderr, @stderr
|
43
|
+
yield
|
44
|
+
rescue SystemExit => e
|
45
|
+
@status = e.status
|
46
|
+
ensure
|
47
|
+
$stdout, $stderr = tmp_stdout, tmp_stderr
|
48
|
+
end
|
49
|
+
|
50
|
+
def capture(enable = true)
|
51
|
+
if enable
|
52
|
+
capture_output do
|
53
|
+
yield
|
54
|
+
end
|
55
|
+
else
|
56
|
+
yield
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def with_delim(data, delim = nil)
|
61
|
+
return data unless delim
|
62
|
+
case delim
|
63
|
+
when Hash
|
64
|
+
delim.each do |from, to|
|
65
|
+
data.gsub!(from, to)
|
66
|
+
end
|
67
|
+
when Array
|
68
|
+
data.gsub!(*delim)
|
69
|
+
end
|
70
|
+
data
|
71
|
+
end
|
72
|
+
|
73
|
+
def load_example_config!
|
74
|
+
filesystem.add_path(:current_dir, self.class.example_current_dir) if self.class.example_current_dir
|
75
|
+
environment.configuration.load(self.class.example_default_config) if self.class.example_default_config
|
76
|
+
end
|
77
|
+
|
78
|
+
# TODO: iterate over databases
|
79
|
+
def clean_example_run!
|
80
|
+
if configuration.postgres[:clean]
|
81
|
+
postgres_admin(action: :drop, database: configuration.postgres[:database])
|
82
|
+
postgres_admin(action: :create, database: configuration.postgres[:database])
|
83
|
+
postgres(file: define_schema(catalog, :postgres).to_file, retries: 0)
|
84
|
+
end
|
85
|
+
filesystem.paths.each do |_, (path, options)|
|
86
|
+
filesystem.remove_dir(path) if options[:clean]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# TODO encapsulate commands as runners
|
91
|
+
def setup_example_input!(fixture)
|
92
|
+
fixture.inputs.each do |input|
|
93
|
+
if input['file']
|
94
|
+
filesystem.write(with_delim(input['data'], input['delim']), input['file'])
|
95
|
+
end
|
96
|
+
|
97
|
+
if input['hive']
|
98
|
+
hive(exec: input['hive'])
|
99
|
+
end
|
100
|
+
|
101
|
+
if input['psql']
|
102
|
+
Tempfile.open('etl') do |tmp|
|
103
|
+
tmp.write(input['psql'])
|
104
|
+
tmp.flush
|
105
|
+
postgres(file: tmp.path)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def gather_example_output(fixture)
|
112
|
+
fail "No outputs defined for #{fixture.file_name}" if fixture.outputs.none?
|
113
|
+
fixture.outputs.each do |output|
|
114
|
+
output_file = output['file'] || Tempfile.new('masamune').path
|
115
|
+
|
116
|
+
execute_output_command(output, output_file)
|
117
|
+
next unless output['data']
|
118
|
+
actual_data = File.read(output_file).strip
|
119
|
+
expect_data = with_delim(output['data'].strip, output['delim']).strip
|
120
|
+
if output['order'] == 'random'
|
121
|
+
actual_data = actual_data.split("\n").sort.join("\n")
|
122
|
+
expect_data = expect_data.split("\n").sort.join("\n")
|
123
|
+
end
|
124
|
+
yield [actual_data, output_file, expect_data]
|
125
|
+
FileUtils.rm(output_file) if File.exists?(output_file)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def execute_output_command(output, output_file)
|
130
|
+
if output['hive'] && output['hive'].is_a?(String)
|
131
|
+
# FIXME: Replace with exec once SBI-530 is fixed
|
132
|
+
Tempfile.open('etl') do |tmp|
|
133
|
+
tmp.write(output['hive'])
|
134
|
+
tmp.flush
|
135
|
+
hive(file: tmp.path, output: output_file)
|
136
|
+
end
|
137
|
+
elsif output['table']
|
138
|
+
table = eval "catalog.#{output['table']}"
|
139
|
+
query = denormalize_table(table, output.slice('columns', 'order', 'except', 'include')).to_s
|
140
|
+
# FIXME: define format based on table.store.format
|
141
|
+
case table.store.type
|
142
|
+
when :postgres
|
143
|
+
postgres(exec: query, csv: true, output: output_file)
|
144
|
+
when :hive
|
145
|
+
# FIXME: Replace with exec once SBI-530 is fixed
|
146
|
+
Tempfile.open('etl') do |tmp|
|
147
|
+
tmp.write(query)
|
148
|
+
tmp.flush
|
149
|
+
hive(file: tmp.path, output: output_file)
|
150
|
+
end
|
151
|
+
else
|
152
|
+
raise "'table' output not supported for #{output['table']}"
|
153
|
+
end
|
154
|
+
elsif output['hive'] && output['hive'].is_a?(Hash)
|
155
|
+
hive(file: example_file(output['hive']['file']), output: output_file)
|
156
|
+
elsif output['psql'] && output['psql'].is_a?(String)
|
157
|
+
postgres(exec: output['psql'], csv: true, output: output_file)
|
158
|
+
elsif output['psql'] && output['psql'].is_a?(Hash)
|
159
|
+
postgres(file: example_file(output['psql']['file']), variables: output['psql'].fetch('variables', {}), csv: true, output: output_file)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def example_fixture(options = {})
|
164
|
+
Masamune::JobFixture.load(options.merge(type: self.class.example_type), binding)
|
165
|
+
end
|
166
|
+
|
167
|
+
module ClassMethods
|
168
|
+
def example_current_dir
|
169
|
+
example_file_path_info[:current_dir]
|
170
|
+
end
|
171
|
+
|
172
|
+
def example_default_config
|
173
|
+
return unless respond_to?(:described_class)
|
174
|
+
return unless described_class.respond_to?(:class_options)
|
175
|
+
described_class.class_options[:config].try(:default)
|
176
|
+
end
|
177
|
+
|
178
|
+
def example_fixture_file(options = {})
|
179
|
+
Masamune::JobFixture.file_name(options.merge(path: File.dirname(file_path), type: example_type))
|
180
|
+
end
|
181
|
+
|
182
|
+
def example_step
|
183
|
+
return unless respond_to?(:description)
|
184
|
+
File.join(example_current_dir, description)
|
185
|
+
end
|
186
|
+
|
187
|
+
def example_type
|
188
|
+
example_file_path_info[:example_type]
|
189
|
+
end
|
190
|
+
|
191
|
+
private
|
192
|
+
|
193
|
+
EXAMPLE_FILE_PATH_INFO = %r{(?<current_dir>.*?)/spec/((?<example_name>\w+)_)?(?<example_type>\w+)_spec\.rb\z}
|
194
|
+
def example_file_path_info
|
195
|
+
return {} unless respond_to?(:file_path)
|
196
|
+
@example_file_path_info ||= EXAMPLE_FILE_PATH_INFO.match(file_path) || {}
|
197
|
+
end
|
198
|
+
|
199
|
+
def example_name
|
200
|
+
example_file_path_info[:example_name]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module Masamune::StepExampleGroup
|
24
|
+
module StepFixtureContext
|
25
|
+
shared_context 'step_fixture' do |context_options = {}|
|
26
|
+
fixture_file = example_fixture_file(context_options.slice(:fixture, :file, :path))
|
27
|
+
step_file = example_step
|
28
|
+
|
29
|
+
args = context_options[:args]
|
30
|
+
subject do
|
31
|
+
capture_popen([step_file, args].compact.join(' '), input)
|
32
|
+
end
|
33
|
+
|
34
|
+
context "with #{fixture_file} fixture" do
|
35
|
+
let(:fixture) { Masamune::StepFixture.load({file: fixture_file}, binding) }
|
36
|
+
|
37
|
+
let(:input) { fixture.input }
|
38
|
+
let(:output) { fixture.output }
|
39
|
+
|
40
|
+
it 'should match output' do
|
41
|
+
is_expected.to eq(output)
|
42
|
+
end
|
43
|
+
|
44
|
+
after(:each) do |example|
|
45
|
+
if example.exception && ENV['MASAMUNE_RECORD']
|
46
|
+
shell = Thor::Shell::Basic.new
|
47
|
+
shell.say(example.exception)
|
48
|
+
if shell.yes?('Save recording?')
|
49
|
+
fixture.output = subject
|
50
|
+
fixture.save
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.included(base)
|
59
|
+
base.send(:include, Masamune::SharedExampleGroup)
|
60
|
+
base.send(:include, StepFixtureContext)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
RSpec.configure do |config|
|
65
|
+
config.include Masamune::StepExampleGroup, :type => :step, :file_path => %r{.*/spec/.*step_spec\.rb}
|
66
|
+
config.include Masamune::StepExampleGroup, :type => :step, :file_path => %r{.*/spec/.*mapper_spec\.rb}
|
67
|
+
config.include Masamune::StepExampleGroup, :type => :step, :file_path => %r{.*/spec/.*reducer_spec\.rb}
|
68
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014-2015, VMware, Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'active_support/core_ext/string/indent'
|
24
|
+
|
25
|
+
module Masamune
|
26
|
+
class StepFixture
|
27
|
+
INDENT = 2
|
28
|
+
|
29
|
+
def initialize(options = {})
|
30
|
+
@file = options[:file]
|
31
|
+
@data = options[:data]
|
32
|
+
@type = options[:type] || 'step'
|
33
|
+
|
34
|
+
@data['input'] ||= []
|
35
|
+
@data['output'] ||= []
|
36
|
+
end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
def load(options = {}, context = binding)
|
40
|
+
file = options[:file]
|
41
|
+
raise ArgumentError, "Fixture '#{file}' does not exist" unless File.exists?(file)
|
42
|
+
YAML.load(ERB.new(File.read(file)).result(context)).tap do |data|
|
43
|
+
return new(options.merge(data: data))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def suffix(options = {})
|
50
|
+
"#{options[:type] || 'step'}_fixture.yml"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def file_name
|
55
|
+
@file
|
56
|
+
end
|
57
|
+
|
58
|
+
def path
|
59
|
+
@path || File.dirname(@file)
|
60
|
+
end
|
61
|
+
|
62
|
+
def save
|
63
|
+
FileUtils.mkdir_p(path)
|
64
|
+
File.open(file_name, 'w') do |file|
|
65
|
+
file.puts '---'
|
66
|
+
file.puts 'input: |'
|
67
|
+
@data['input'].split("\n").each do |line|
|
68
|
+
file.puts line.indent(INDENT)
|
69
|
+
end
|
70
|
+
file.puts
|
71
|
+
file.puts 'output: |'
|
72
|
+
@data['output'].split("\n").each do |line|
|
73
|
+
file.puts line.indent(INDENT)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
file_name
|
77
|
+
end
|
78
|
+
|
79
|
+
def input
|
80
|
+
@data['input']
|
81
|
+
end
|
82
|
+
|
83
|
+
def output
|
84
|
+
@data['output']
|
85
|
+
end
|
86
|
+
|
87
|
+
def output=(output)
|
88
|
+
@data['output'] = output
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -20,19 +20,42 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
-
module Masamune
|
24
|
-
module
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
module Masamune::TaskExampleGroup
|
24
|
+
module TaskFixtureContent
|
25
|
+
shared_context 'task_fixture' do |context_options = {}|
|
26
|
+
include_context 'job_fixture', context_options
|
27
|
+
let!(:default_options) { configuration.as_options }
|
28
|
+
|
29
|
+
let(:stdout) { @stdout }
|
30
|
+
let(:stderr) { @stderr }
|
31
|
+
let(:status) { @status }
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
let(:command) { nil }
|
34
|
+
let(:options) { [] }
|
35
|
+
|
36
|
+
subject(:execute_command) do
|
37
|
+
n = context_options.fetch(:idempotent, false) ? 2 : 1
|
38
|
+
n = 1 if ENV['MASAMUNE_FASTER_SPEC']
|
39
|
+
capture(!default_options.include?('--debug')) do
|
40
|
+
n.times do
|
41
|
+
Array.wrap(command).each do |cmd|
|
42
|
+
described_class.start([cmd, *(default_options + options)].compact)
|
43
|
+
end
|
44
|
+
end
|
34
45
|
end
|
35
46
|
end
|
36
47
|
end
|
37
48
|
end
|
49
|
+
|
50
|
+
def self.included(base)
|
51
|
+
base.send(:include, Masamune::ExampleGroup)
|
52
|
+
base.send(:include, Masamune::Actions::Filesystem)
|
53
|
+
base.send(:include, Masamune::Actions::Hive)
|
54
|
+
base.send(:include, Masamune::Transform::DenormalizeTable)
|
55
|
+
base.send(:include, TaskFixtureContent)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
RSpec.configure do |config|
|
60
|
+
config.include Masamune::TaskExampleGroup, :type => :task, :file_path => %r{.*/spec/.*task_spec\.rb}
|
38
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: masamune
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Andrews
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: user_agent_parser
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rspec
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,7 +276,6 @@ files:
|
|
262
276
|
- lib/masamune/tasks/shell_thor.rb
|
263
277
|
- lib/masamune/template.rb
|
264
278
|
- lib/masamune/thor.rb
|
265
|
-
- lib/masamune/thor_loader.rb
|
266
279
|
- lib/masamune/topological_hash.rb
|
267
280
|
- lib/masamune/transform.rb
|
268
281
|
- lib/masamune/transform/bulk_upsert.rb
|
@@ -351,6 +364,8 @@ files:
|
|
351
364
|
- spec/masamune/environment_spec.rb
|
352
365
|
- spec/masamune/filesystem_spec.rb
|
353
366
|
- spec/masamune/helpers/postgres_spec.rb
|
367
|
+
- spec/masamune/rspec/job_fixture_spec.rb
|
368
|
+
- spec/masamune/rspec/shared_example_group_spec.rb
|
354
369
|
- spec/masamune/schema/catalog_spec.rb
|
355
370
|
- spec/masamune/schema/column_spec.rb
|
356
371
|
- spec/masamune/schema/dimension_spec.rb
|
@@ -387,9 +402,15 @@ files:
|
|
387
402
|
- spec/masamune_spec.rb
|
388
403
|
- spec/spec_helper.rb
|
389
404
|
- spec/support/masamune/example_group.rb
|
405
|
+
- spec/support/masamune/job_example_group.rb
|
406
|
+
- spec/support/masamune/job_fixture.rb
|
390
407
|
- spec/support/masamune/mock_command.rb
|
391
408
|
- spec/support/masamune/mock_delegate.rb
|
392
409
|
- spec/support/masamune/mock_filesystem.rb
|
410
|
+
- spec/support/masamune/shared_example_group.rb
|
411
|
+
- spec/support/masamune/step_example_group.rb
|
412
|
+
- spec/support/masamune/step_fixture.rb
|
413
|
+
- spec/support/masamune/task_example_group.rb
|
393
414
|
- spec/support/masamune/thor_mute.rb
|
394
415
|
- spec/support/rspec/example/action_example_group.rb
|
395
416
|
- spec/support/rspec/example/task_example_group.rb
|
@@ -454,6 +475,8 @@ test_files:
|
|
454
475
|
- spec/masamune/environment_spec.rb
|
455
476
|
- spec/masamune/filesystem_spec.rb
|
456
477
|
- spec/masamune/helpers/postgres_spec.rb
|
478
|
+
- spec/masamune/rspec/job_fixture_spec.rb
|
479
|
+
- spec/masamune/rspec/shared_example_group_spec.rb
|
457
480
|
- spec/masamune/schema/catalog_spec.rb
|
458
481
|
- spec/masamune/schema/column_spec.rb
|
459
482
|
- spec/masamune/schema/dimension_spec.rb
|
@@ -490,9 +513,15 @@ test_files:
|
|
490
513
|
- spec/masamune_spec.rb
|
491
514
|
- spec/spec_helper.rb
|
492
515
|
- spec/support/masamune/example_group.rb
|
516
|
+
- spec/support/masamune/job_example_group.rb
|
517
|
+
- spec/support/masamune/job_fixture.rb
|
493
518
|
- spec/support/masamune/mock_command.rb
|
494
519
|
- spec/support/masamune/mock_delegate.rb
|
495
520
|
- spec/support/masamune/mock_filesystem.rb
|
521
|
+
- spec/support/masamune/shared_example_group.rb
|
522
|
+
- spec/support/masamune/step_example_group.rb
|
523
|
+
- spec/support/masamune/step_fixture.rb
|
524
|
+
- spec/support/masamune/task_example_group.rb
|
496
525
|
- spec/support/masamune/thor_mute.rb
|
497
526
|
- spec/support/rspec/example/action_example_group.rb
|
498
527
|
- spec/support/rspec/example/task_example_group.rb
|