masamune 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +15 -0
- data/bin/masamune-elastic-mapreduce +4 -0
- data/bin/masamune-hive +4 -0
- data/bin/masamune-psql +4 -0
- data/bin/masamune-shell +4 -0
- data/lib/masamune.rb +56 -0
- data/lib/masamune/accumulate.rb +60 -0
- data/lib/masamune/actions.rb +38 -0
- data/lib/masamune/actions/data_flow.rb +131 -0
- data/lib/masamune/actions/date_parse.rb +75 -0
- data/lib/masamune/actions/elastic_mapreduce.rb +68 -0
- data/lib/masamune/actions/execute.rb +52 -0
- data/lib/masamune/actions/filesystem.rb +37 -0
- data/lib/masamune/actions/hadoop_filesystem.rb +40 -0
- data/lib/masamune/actions/hadoop_streaming.rb +41 -0
- data/lib/masamune/actions/hive.rb +74 -0
- data/lib/masamune/actions/postgres.rb +76 -0
- data/lib/masamune/actions/postgres_admin.rb +34 -0
- data/lib/masamune/actions/s3cmd.rb +44 -0
- data/lib/masamune/actions/transform.rb +89 -0
- data/lib/masamune/after_initialize_callbacks.rb +55 -0
- data/lib/masamune/cached_filesystem.rb +110 -0
- data/lib/masamune/commands.rb +37 -0
- data/lib/masamune/commands/elastic_mapreduce.rb +119 -0
- data/lib/masamune/commands/hadoop_filesystem.rb +57 -0
- data/lib/masamune/commands/hadoop_streaming.rb +116 -0
- data/lib/masamune/commands/hive.rb +178 -0
- data/lib/masamune/commands/interactive.rb +37 -0
- data/lib/masamune/commands/postgres.rb +128 -0
- data/lib/masamune/commands/postgres_admin.rb +72 -0
- data/lib/masamune/commands/postgres_common.rb +33 -0
- data/lib/masamune/commands/retry_with_backoff.rb +60 -0
- data/lib/masamune/commands/s3cmd.rb +70 -0
- data/lib/masamune/commands/shell.rb +202 -0
- data/lib/masamune/configuration.rb +195 -0
- data/lib/masamune/data_plan.rb +31 -0
- data/lib/masamune/data_plan/builder.rb +66 -0
- data/lib/masamune/data_plan/elem.rb +190 -0
- data/lib/masamune/data_plan/engine.rb +162 -0
- data/lib/masamune/data_plan/rule.rb +292 -0
- data/lib/masamune/data_plan/set.rb +176 -0
- data/lib/masamune/environment.rb +164 -0
- data/lib/masamune/filesystem.rb +567 -0
- data/lib/masamune/has_environment.rb +40 -0
- data/lib/masamune/helpers.rb +27 -0
- data/lib/masamune/helpers/postgres.rb +84 -0
- data/lib/masamune/io.rb +33 -0
- data/lib/masamune/last_element.rb +53 -0
- data/lib/masamune/method_logger.rb +41 -0
- data/lib/masamune/multi_io.rb +39 -0
- data/lib/masamune/schema.rb +36 -0
- data/lib/masamune/schema/catalog.rb +233 -0
- data/lib/masamune/schema/column.rb +527 -0
- data/lib/masamune/schema/dimension.rb +133 -0
- data/lib/masamune/schema/event.rb +121 -0
- data/lib/masamune/schema/fact.rb +133 -0
- data/lib/masamune/schema/map.rb +265 -0
- data/lib/masamune/schema/row.rb +133 -0
- data/lib/masamune/schema/store.rb +115 -0
- data/lib/masamune/schema/table.rb +308 -0
- data/lib/masamune/schema/table_reference.rb +76 -0
- data/lib/masamune/spec_helper.rb +23 -0
- data/lib/masamune/string_format.rb +34 -0
- data/lib/masamune/tasks/elastic_mapreduce_thor.rb +60 -0
- data/lib/masamune/tasks/hive_thor.rb +55 -0
- data/lib/masamune/tasks/postgres_thor.rb +47 -0
- data/lib/masamune/tasks/shell_thor.rb +63 -0
- data/lib/masamune/template.rb +77 -0
- data/lib/masamune/thor.rb +186 -0
- data/lib/masamune/thor_loader.rb +38 -0
- data/lib/masamune/topological_hash.rb +34 -0
- data/lib/masamune/transform.rb +47 -0
- data/lib/masamune/transform/bulk_upsert.psql.erb +64 -0
- data/lib/masamune/transform/bulk_upsert.rb +52 -0
- data/lib/masamune/transform/consolidate_dimension.rb +54 -0
- data/lib/masamune/transform/deduplicate_dimension.psql.erb +52 -0
- data/lib/masamune/transform/deduplicate_dimension.rb +53 -0
- data/lib/masamune/transform/define_event_view.hql.erb +51 -0
- data/lib/masamune/transform/define_event_view.rb +60 -0
- data/lib/masamune/transform/define_index.psql.erb +34 -0
- data/lib/masamune/transform/define_schema.hql.erb +23 -0
- data/lib/masamune/transform/define_schema.psql.erb +79 -0
- data/lib/masamune/transform/define_schema.rb +56 -0
- data/lib/masamune/transform/define_table.hql.erb +34 -0
- data/lib/masamune/transform/define_table.psql.erb +95 -0
- data/lib/masamune/transform/define_table.rb +40 -0
- data/lib/masamune/transform/define_unique.psql.erb +30 -0
- data/lib/masamune/transform/insert_reference_values.psql.erb +43 -0
- data/lib/masamune/transform/insert_reference_values.rb +64 -0
- data/lib/masamune/transform/load_dimension.rb +47 -0
- data/lib/masamune/transform/load_fact.rb +45 -0
- data/lib/masamune/transform/operator.rb +96 -0
- data/lib/masamune/transform/relabel_dimension.psql.erb +76 -0
- data/lib/masamune/transform/relabel_dimension.rb +39 -0
- data/lib/masamune/transform/rollup_fact.psql.erb +79 -0
- data/lib/masamune/transform/rollup_fact.rb +149 -0
- data/lib/masamune/transform/snapshot_dimension.psql.erb +75 -0
- data/lib/masamune/transform/snapshot_dimension.rb +74 -0
- data/lib/masamune/transform/stage_dimension.psql.erb +39 -0
- data/lib/masamune/transform/stage_dimension.rb +83 -0
- data/lib/masamune/transform/stage_fact.psql.erb +80 -0
- data/lib/masamune/transform/stage_fact.rb +111 -0
- data/lib/masamune/version.rb +25 -0
- data/spec/fixtures/aggregate.sql.erb +25 -0
- data/spec/fixtures/comment.sql.erb +27 -0
- data/spec/fixtures/invalid.sql.erb +23 -0
- data/spec/fixtures/relative.sql.erb +23 -0
- data/spec/fixtures/simple.sql.erb +28 -0
- data/spec/fixtures/whitespace.sql.erb +30 -0
- data/spec/masamune/actions/elastic_mapreduce_spec.rb +108 -0
- data/spec/masamune/actions/execute_spec.rb +50 -0
- data/spec/masamune/actions/hadoop_filesystem_spec.rb +44 -0
- data/spec/masamune/actions/hadoop_streaming_spec.rb +74 -0
- data/spec/masamune/actions/hive_spec.rb +117 -0
- data/spec/masamune/actions/postgres_admin_spec.rb +58 -0
- data/spec/masamune/actions/postgres_spec.rb +134 -0
- data/spec/masamune/actions/s3cmd_spec.rb +44 -0
- data/spec/masamune/actions/transform_spec.rb +144 -0
- data/spec/masamune/after_initialization_callbacks_spec.rb +61 -0
- data/spec/masamune/cached_filesystem_spec.rb +167 -0
- data/spec/masamune/commands/hadoop_filesystem_spec.rb +50 -0
- data/spec/masamune/commands/hadoop_streaming_spec.rb +106 -0
- data/spec/masamune/commands/hive_spec.rb +117 -0
- data/spec/masamune/commands/postgres_admin_spec.rb +69 -0
- data/spec/masamune/commands/postgres_spec.rb +100 -0
- data/spec/masamune/commands/retry_with_backoff_spec.rb +116 -0
- data/spec/masamune/commands/s3cmd_spec.rb +50 -0
- data/spec/masamune/commands/shell_spec.rb +101 -0
- data/spec/masamune/configuration_spec.rb +102 -0
- data/spec/masamune/data_plan/builder_spec.rb +91 -0
- data/spec/masamune/data_plan/elem_spec.rb +102 -0
- data/spec/masamune/data_plan/engine_spec.rb +356 -0
- data/spec/masamune/data_plan/rule_spec.rb +407 -0
- data/spec/masamune/data_plan/set_spec.rb +517 -0
- data/spec/masamune/environment_spec.rb +65 -0
- data/spec/masamune/filesystem_spec.rb +1421 -0
- data/spec/masamune/helpers/postgres_spec.rb +95 -0
- data/spec/masamune/schema/catalog_spec.rb +613 -0
- data/spec/masamune/schema/column_spec.rb +696 -0
- data/spec/masamune/schema/dimension_spec.rb +137 -0
- data/spec/masamune/schema/event_spec.rb +75 -0
- data/spec/masamune/schema/fact_spec.rb +117 -0
- data/spec/masamune/schema/map_spec.rb +593 -0
- data/spec/masamune/schema/row_spec.rb +28 -0
- data/spec/masamune/schema/store_spec.rb +49 -0
- data/spec/masamune/schema/table_spec.rb +395 -0
- data/spec/masamune/string_format_spec.rb +60 -0
- data/spec/masamune/tasks/elastic_mapreduce_thor_spec.rb +57 -0
- data/spec/masamune/tasks/hive_thor_spec.rb +75 -0
- data/spec/masamune/tasks/postgres_thor_spec.rb +42 -0
- data/spec/masamune/tasks/shell_thor_spec.rb +51 -0
- data/spec/masamune/template_spec.rb +77 -0
- data/spec/masamune/thor_spec.rb +238 -0
- data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +200 -0
- data/spec/masamune/transform/consolidate_dimension_spec.rb +62 -0
- data/spec/masamune/transform/deduplicate_dimension_spec.rb +84 -0
- data/spec/masamune/transform/define_event_view_spec.rb +84 -0
- data/spec/masamune/transform/define_schema_spec.rb +83 -0
- data/spec/masamune/transform/define_table.dimension_spec.rb +306 -0
- data/spec/masamune/transform/define_table.fact_spec.rb +291 -0
- data/spec/masamune/transform/define_table.table_spec.rb +525 -0
- data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +111 -0
- data/spec/masamune/transform/insert_reference_values.fact_spec.rb +149 -0
- data/spec/masamune/transform/load_dimension_spec.rb +76 -0
- data/spec/masamune/transform/load_fact_spec.rb +89 -0
- data/spec/masamune/transform/relabel_dimension_spec.rb +102 -0
- data/spec/masamune/transform/rollup_fact_spec.rb +333 -0
- data/spec/masamune/transform/snapshot_dimension_spec.rb +103 -0
- data/spec/masamune/transform/stage_dimension_spec.rb +115 -0
- data/spec/masamune/transform/stage_fact_spec.rb +204 -0
- data/spec/masamune_spec.rb +32 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/support/masamune/example_group.rb +36 -0
- data/spec/support/masamune/mock_command.rb +99 -0
- data/spec/support/masamune/mock_delegate.rb +51 -0
- data/spec/support/masamune/mock_filesystem.rb +96 -0
- data/spec/support/masamune/thor_mute.rb +35 -0
- data/spec/support/rspec/example/action_example_group.rb +34 -0
- data/spec/support/rspec/example/task_example_group.rb +80 -0
- data/spec/support/rspec/example/transform_example_group.rb +36 -0
- data/spec/support/shared_examples/postgres_common_examples.rb +53 -0
- metadata +462 -0
@@ -0,0 +1,28 @@
|
|
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
|
+
|
24
|
+
|
25
|
+
|
26
|
+
SELECT * FROM <%= table %>;
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,30 @@
|
|
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
|
+
|
24
|
+
|
25
|
+
SELECT 1;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
SELECT 2;
|
@@ -0,0 +1,108 @@
|
|
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 'spec_helper'
|
24
|
+
|
25
|
+
describe Masamune::Actions::ElasticMapreduce do
|
26
|
+
let(:klass) do
|
27
|
+
Class.new do
|
28
|
+
include Masamune::HasEnvironment
|
29
|
+
include Masamune::AfterInitializeCallbacks
|
30
|
+
include Masamune::Actions::ElasticMapreduce
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:instance) { klass.new }
|
35
|
+
let(:configuration) { {} }
|
36
|
+
let(:extra) { [] }
|
37
|
+
|
38
|
+
before do
|
39
|
+
allow(instance).to receive_message_chain(:configuration, :elastic_mapreduce).and_return(configuration)
|
40
|
+
allow(instance).to receive(:extra).and_return(extra)
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.elastic_mapreduce' do
|
44
|
+
before do
|
45
|
+
mock_command(/\Aelastic-mapreduce/, mock_success)
|
46
|
+
end
|
47
|
+
|
48
|
+
subject { instance.elastic_mapreduce }
|
49
|
+
|
50
|
+
it { is_expected.to be_success }
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.after_initialize' do
|
54
|
+
let(:options) { {} }
|
55
|
+
|
56
|
+
subject(:after_initialize_invoke) do
|
57
|
+
instance.after_initialize_invoke(options)
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when configuration is empty' do
|
61
|
+
it { expect { subject }.to_not raise_error }
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when jobflow not required due to extra options' do
|
65
|
+
let(:configuration) { {enabled: true} }
|
66
|
+
let(:extra) { ['--create', '--name', 'zombo_cluster'] }
|
67
|
+
it { expect { subject }.to_not raise_error }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when jobflow is missing' do
|
71
|
+
let(:configuration) { {enabled: true} }
|
72
|
+
it { expect { subject }.to raise_error Thor::RequiredArgumentMissingError, /No value provided for required options '--jobflow'/ }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when jobflow does not exist' do
|
76
|
+
let(:configuration) { {enabled: true} }
|
77
|
+
let(:options) { {jobflow: 'j-XYZ'} }
|
78
|
+
before do
|
79
|
+
mock_command(/\Aelastic-mapreduce/, mock_failure)
|
80
|
+
end
|
81
|
+
it { expect { subject }.to raise_error Thor::RequiredArgumentMissingError, /Value 'j-XYZ' for '--jobflow' doesn't exist/ }
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'when jobflow exists' do
|
85
|
+
let(:configuration) { {enabled: true} }
|
86
|
+
let(:options) { {jobflow: 'j-XYZ'} }
|
87
|
+
before do
|
88
|
+
mock_command(/\Aelastic-mapreduce/, mock_success)
|
89
|
+
end
|
90
|
+
it do
|
91
|
+
expect { subject }.to_not raise_error
|
92
|
+
expect(configuration[:jobflow]).to eq('j-XYZ')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when jobflow is symbolic' do
|
97
|
+
let(:configuration) { {enabled: true, jobflows: {'build' => 'j-XYZ'}} }
|
98
|
+
let(:options) { {jobflow: 'build', } }
|
99
|
+
before do
|
100
|
+
mock_command(/\Aelastic-mapreduce/, mock_success)
|
101
|
+
end
|
102
|
+
it do
|
103
|
+
expect { subject }.to_not raise_error
|
104
|
+
expect(configuration[:jobflow]).to eq('j-XYZ')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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 'spec_helper'
|
24
|
+
|
25
|
+
describe Masamune::Actions::Execute do
|
26
|
+
let(:klass) do
|
27
|
+
Class.new do
|
28
|
+
include Masamune::HasEnvironment
|
29
|
+
include Masamune::Actions::Execute
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:instance) { klass.new }
|
34
|
+
|
35
|
+
describe '.execute' do
|
36
|
+
context 'with a simple command' do
|
37
|
+
let(:command) { %w(echo ping) }
|
38
|
+
let(:options) { {fail_fast: true} }
|
39
|
+
|
40
|
+
it { expect { |b| instance.execute(*command, options, &b) }.to yield_with_args('ping', 0) }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with a simple command with input' do
|
44
|
+
let(:command) { %w(cat) }
|
45
|
+
let(:options) { {input: 'pong', fail_fast: true} }
|
46
|
+
|
47
|
+
it { expect { |b| instance.execute(*command, options, &b) }.to yield_with_args('pong', 0) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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 'spec_helper'
|
24
|
+
|
25
|
+
describe Masamune::Actions::HadoopFilesystem do
|
26
|
+
let(:klass) do
|
27
|
+
Class.new do
|
28
|
+
include Masamune::HasEnvironment
|
29
|
+
include Masamune::Actions::HadoopFilesystem
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:instance) { klass.new }
|
34
|
+
|
35
|
+
describe '.hadoop_filesystem' do
|
36
|
+
before do
|
37
|
+
mock_command(/\Ahadoop/, mock_success)
|
38
|
+
end
|
39
|
+
|
40
|
+
subject { instance.hadoop_filesystem }
|
41
|
+
|
42
|
+
it { is_expected.to be_success }
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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 'spec_helper'
|
24
|
+
|
25
|
+
describe Masamune::Actions::HadoopStreaming do
|
26
|
+
let(:klass) do
|
27
|
+
Class.new do
|
28
|
+
include Masamune::HasEnvironment
|
29
|
+
include Masamune::Actions::HadoopStreaming
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:extra) { [] }
|
34
|
+
let(:instance) { klass.new }
|
35
|
+
|
36
|
+
before do
|
37
|
+
instance.environment = Masamune::ExampleGroup
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.hadoop_streaming' do
|
41
|
+
before do
|
42
|
+
mock_command(/\Ahadoop/, mock_success)
|
43
|
+
end
|
44
|
+
|
45
|
+
subject { instance.hadoop_streaming(extra: extra) }
|
46
|
+
|
47
|
+
it { is_expected.to be_success }
|
48
|
+
|
49
|
+
context 'with jobflow' do
|
50
|
+
before do
|
51
|
+
allow(instance).to receive_message_chain(:configuration, :elastic_mapreduce).and_return({jobflow: 'j-XYZ'})
|
52
|
+
mock_command(/\Ahadoop/, mock_failure)
|
53
|
+
mock_command(/\Aelastic-mapreduce/, mock_success, StringIO.new('ssh fakehost exit'))
|
54
|
+
mock_command(/\Assh fakehost hadoop/, mock_success)
|
55
|
+
end
|
56
|
+
|
57
|
+
it { is_expected.to be_success }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with jobflow and extra' do
|
61
|
+
let(:extra) { ['-D', 'EXTRA'] }
|
62
|
+
|
63
|
+
before do
|
64
|
+
allow(instance).to receive_message_chain(:configuration, :elastic_mapreduce).and_return({jobflow: 'j-XYZ'})
|
65
|
+
mock_command(/\Ahadoop/, mock_failure)
|
66
|
+
mock_command(/\Aelastic-mapreduce/, mock_success, StringIO.new('ssh fakehost exit'))
|
67
|
+
mock_command(/\Assh fakehost -D EXTRA hadoop/, mock_failure)
|
68
|
+
mock_command(/\Assh fakehost hadoop .*? -D EXTRA/, mock_success)
|
69
|
+
end
|
70
|
+
|
71
|
+
it { is_expected.to be_success }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,117 @@
|
|
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 'spec_helper'
|
24
|
+
|
25
|
+
describe Masamune::Actions::Hive do
|
26
|
+
let(:klass) do
|
27
|
+
Class.new do
|
28
|
+
include Masamune::HasEnvironment
|
29
|
+
include Masamune::AfterInitializeCallbacks
|
30
|
+
include Masamune::Actions::Hive
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:filesystem) { Masamune::MockFilesystem.new }
|
35
|
+
let(:instance) { klass.new }
|
36
|
+
let(:configuration) { {database: 'test'} }
|
37
|
+
|
38
|
+
before do
|
39
|
+
filesystem.add_path(:tmp_dir, File.join(Dir.tmpdir, SecureRandom.hex))
|
40
|
+
allow(instance).to receive(:filesystem) { filesystem }
|
41
|
+
allow(instance).to receive_message_chain(:configuration, :elastic_mapreduce).and_return({})
|
42
|
+
allow(instance).to receive_message_chain(:configuration, :hive).and_return(configuration)
|
43
|
+
allow(instance).to receive_message_chain(:define_schema, :to_file) { 'schema.hql' }
|
44
|
+
allow_any_instance_of(Masamune::MockFilesystem).to receive(:copy_file_to_dir)
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.hive' do
|
48
|
+
before do
|
49
|
+
mock_command(/\Ahive/, mock_success)
|
50
|
+
end
|
51
|
+
|
52
|
+
subject { instance.hive }
|
53
|
+
|
54
|
+
it { is_expected.to be_success }
|
55
|
+
|
56
|
+
context 'with jobflow' do
|
57
|
+
before do
|
58
|
+
allow(instance).to receive_message_chain(:configuration, :elastic_mapreduce).and_return({jobflow: 'j-XYZ'})
|
59
|
+
mock_command(/\Ahive/, mock_failure)
|
60
|
+
mock_command(/\Aelastic-mapreduce/, mock_success, StringIO.new('ssh fakehost exit'))
|
61
|
+
mock_command(/\Assh fakehost hive/, mock_success)
|
62
|
+
end
|
63
|
+
|
64
|
+
subject { instance.hive }
|
65
|
+
|
66
|
+
it { is_expected.to be_success }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.after_initialize' do
|
71
|
+
let(:options) { {} }
|
72
|
+
let(:configuration) { {database: 'test'} }
|
73
|
+
|
74
|
+
subject(:after_initialize_invoke) do
|
75
|
+
instance.after_initialize_invoke(options)
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'with default database' do
|
79
|
+
let(:configuration) { {database: 'default'} }
|
80
|
+
before do
|
81
|
+
expect(instance).to receive(:hive).with(exec: an_instance_of(String)).never
|
82
|
+
after_initialize_invoke
|
83
|
+
end
|
84
|
+
it 'should not call hive with create database' do; end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with database' do
|
88
|
+
before do
|
89
|
+
expect(instance).to receive(:hive).with(exec: 'CREATE DATABASE IF NOT EXISTS test;', :database => nil).once.and_return(mock_success)
|
90
|
+
expect(instance).to receive(:hive).with(file: an_instance_of(String)).once.and_return(mock_success)
|
91
|
+
after_initialize_invoke
|
92
|
+
end
|
93
|
+
it 'should call hive with create database' do; end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'with location' do
|
97
|
+
let(:configuration) { {database: 'test', location: '/tmp'} }
|
98
|
+
before do
|
99
|
+
expect(instance).to receive(:hive).with(exec: 'CREATE DATABASE IF NOT EXISTS test LOCATION "/tmp";', :database => nil).once.and_return(mock_success)
|
100
|
+
expect(instance).to receive(:hive).with(file: an_instance_of(String)).once.and_return(mock_success)
|
101
|
+
after_initialize_invoke
|
102
|
+
end
|
103
|
+
it 'should call hive with create database' do; end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'with dryrun' do
|
107
|
+
let(:options) { {dry_run: true} }
|
108
|
+
before do
|
109
|
+
expect(instance).to receive(:hive).with(exec: 'CREATE DATABASE IF NOT EXISTS test;', :database => nil).once.and_return(mock_success)
|
110
|
+
expect(instance).to receive(:hive).with(exec: 'SHOW TABLES;', safe: true, fail_fast: false).once.and_return(mock_success)
|
111
|
+
expect(instance).to receive(:hive).with(file: an_instance_of(String)).once.and_return(mock_success)
|
112
|
+
after_initialize_invoke
|
113
|
+
end
|
114
|
+
it 'should call hive with show tables' do; end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|