masamune 0.15.6 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/Rakefile +1 -1
- data/bin/{masamune-elastic-mapreduce → masamune-aws-emr} +3 -3
- data/bin/masamune-dump +1 -1
- data/bin/masamune-hive +1 -1
- data/bin/masamune-psql +1 -1
- data/bin/masamune-shell +1 -1
- data/lib/masamune.rb +1 -1
- data/lib/masamune/actions.rb +1 -1
- data/lib/masamune/actions/{elastic_mapreduce.rb → aws_emr.rb} +14 -30
- data/lib/masamune/actions/data_flow.rb +1 -1
- data/lib/masamune/actions/date_parse.rb +1 -1
- data/lib/masamune/actions/execute.rb +1 -1
- data/lib/masamune/actions/filesystem.rb +1 -1
- data/lib/masamune/actions/hadoop_filesystem.rb +1 -1
- data/lib/masamune/actions/hadoop_streaming.rb +10 -8
- data/lib/masamune/actions/hive.rb +2 -2
- data/lib/masamune/actions/invoke_parallel.rb +1 -1
- data/lib/masamune/actions/postgres.rb +1 -1
- data/lib/masamune/actions/postgres_admin.rb +1 -1
- data/lib/masamune/actions/s3cmd.rb +1 -1
- data/lib/masamune/actions/transform.rb +1 -1
- data/lib/masamune/after_initialize_callbacks.rb +1 -1
- data/lib/masamune/cached_filesystem.rb +2 -2
- data/lib/masamune/commands.rb +1 -1
- data/lib/masamune/commands/{elastic_mapreduce.rb → aws_emr.rb} +38 -29
- data/lib/masamune/commands/hadoop_filesystem.rb +1 -1
- data/lib/masamune/commands/hadoop_streaming.rb +1 -1
- data/lib/masamune/commands/hive.rb +1 -1
- data/lib/masamune/commands/postgres.rb +1 -1
- data/lib/masamune/commands/postgres_admin.rb +1 -1
- data/lib/masamune/commands/postgres_common.rb +1 -1
- data/lib/masamune/commands/retry_with_backoff.rb +1 -1
- data/lib/masamune/commands/s3cmd.rb +1 -1
- data/lib/masamune/commands/shell.rb +11 -7
- data/lib/masamune/configuration.rb +2 -38
- data/lib/masamune/data_plan.rb +1 -1
- data/lib/masamune/data_plan/builder.rb +1 -1
- data/lib/masamune/data_plan/elem.rb +1 -1
- data/lib/masamune/data_plan/engine.rb +1 -1
- data/lib/masamune/data_plan/rule.rb +1 -1
- data/lib/masamune/data_plan/set.rb +1 -1
- data/lib/masamune/environment.rb +1 -1
- data/lib/masamune/filesystem.rb +1 -1
- data/lib/masamune/has_environment.rb +1 -1
- data/lib/masamune/helpers.rb +1 -1
- data/lib/masamune/helpers/postgres.rb +1 -1
- data/lib/masamune/io.rb +1 -1
- data/lib/masamune/last_element.rb +1 -1
- data/lib/masamune/method_logger.rb +1 -1
- data/lib/masamune/multi_io.rb +1 -1
- data/lib/masamune/schema.rb +1 -1
- data/lib/masamune/schema/catalog.rb +1 -1
- data/lib/masamune/schema/column.rb +1 -1
- data/lib/masamune/schema/dimension.rb +1 -1
- data/lib/masamune/schema/fact.rb +1 -1
- data/lib/masamune/schema/map.rb +1 -1
- data/lib/masamune/schema/row.rb +1 -1
- data/lib/masamune/schema/store.rb +1 -1
- data/lib/masamune/schema/table.rb +1 -1
- data/lib/masamune/schema/table_reference.rb +1 -1
- data/lib/masamune/spec_helper.rb +1 -1
- data/lib/masamune/string_format.rb +1 -1
- data/lib/masamune/tasks/aws_emr_thor.rb +79 -0
- data/lib/masamune/tasks/dump_thor.rb +1 -1
- data/lib/masamune/tasks/hive_thor.rb +2 -2
- data/lib/masamune/tasks/postgres_thor.rb +1 -1
- data/lib/masamune/tasks/shell_thor.rb +1 -1
- data/lib/masamune/template.rb +1 -1
- data/lib/masamune/thor.rb +1 -1
- data/lib/masamune/topological_hash.rb +1 -1
- data/lib/masamune/transform.rb +1 -1
- data/lib/masamune/transform/bulk_upsert.rb +1 -1
- data/lib/masamune/transform/common.rb +1 -1
- data/lib/masamune/transform/common/denormalize_table.rb +1 -1
- data/lib/masamune/transform/consolidate_dimension.rb +1 -1
- data/lib/masamune/transform/deduplicate_dimension.rb +1 -1
- data/lib/masamune/transform/define_schema.rb +1 -1
- data/lib/masamune/transform/define_table.rb +1 -1
- data/lib/masamune/transform/denormalize_table.rb +1 -1
- data/lib/masamune/transform/hive.rb +1 -1
- data/lib/masamune/transform/hive/define_schema.hql.erb +1 -1
- data/lib/masamune/transform/hive/define_table.hql.erb +1 -1
- data/lib/masamune/transform/hive/define_table.rb +1 -1
- data/lib/masamune/transform/hive/denormalize_table.hql.erb +1 -1
- data/lib/masamune/transform/hive/denormalize_table.rb +1 -1
- data/lib/masamune/transform/insert_reference_values.rb +1 -1
- data/lib/masamune/transform/load_dimension.rb +1 -1
- data/lib/masamune/transform/load_fact.rb +1 -1
- data/lib/masamune/transform/operator.rb +1 -1
- data/lib/masamune/transform/postgres.rb +1 -1
- data/lib/masamune/transform/postgres/bulk_upsert.psql.erb +1 -1
- data/lib/masamune/transform/postgres/bulk_upsert.rb +1 -1
- data/lib/masamune/transform/postgres/deduplicate_dimension.psql.erb +1 -1
- data/lib/masamune/transform/postgres/deduplicate_dimension.rb +1 -1
- data/lib/masamune/transform/postgres/define_foreign_key.psql.erb +1 -1
- data/lib/masamune/transform/postgres/define_index.psql.erb +1 -1
- data/lib/masamune/transform/postgres/define_inheritance.psql.erb +1 -1
- data/lib/masamune/transform/postgres/define_schema.psql.erb +1 -1
- data/lib/masamune/transform/postgres/define_table.psql.erb +1 -1
- data/lib/masamune/transform/postgres/define_table.rb +1 -1
- data/lib/masamune/transform/postgres/define_unique.psql.erb +1 -1
- data/lib/masamune/transform/postgres/denormalize_table.psql.erb +1 -1
- data/lib/masamune/transform/postgres/denormalize_table.rb +1 -1
- data/lib/masamune/transform/postgres/insert_reference_values.psql.erb +1 -1
- data/lib/masamune/transform/postgres/insert_reference_values.rb +1 -1
- data/lib/masamune/transform/postgres/relabel_dimension.psql.erb +1 -1
- data/lib/masamune/transform/postgres/relabel_dimension.rb +1 -1
- data/lib/masamune/transform/postgres/replace_table.psql.erb +1 -1
- data/lib/masamune/transform/postgres/rollup_fact.psql.erb +1 -1
- data/lib/masamune/transform/postgres/rollup_fact.rb +1 -1
- data/lib/masamune/transform/postgres/snapshot_dimension.psql.erb +1 -1
- data/lib/masamune/transform/postgres/snapshot_dimension.rb +1 -1
- data/lib/masamune/transform/postgres/stage_dimension.psql.erb +1 -1
- data/lib/masamune/transform/postgres/stage_dimension.rb +1 -1
- data/lib/masamune/transform/postgres/stage_fact.psql.erb +1 -1
- data/lib/masamune/transform/postgres/stage_fact.rb +1 -1
- data/lib/masamune/transform/relabel_dimension.rb +1 -1
- data/lib/masamune/transform/rollup_fact.rb +1 -1
- data/lib/masamune/transform/snapshot_dimension.rb +1 -1
- data/lib/masamune/transform/stage_dimension.rb +1 -1
- data/lib/masamune/transform/stage_fact.rb +1 -1
- data/lib/masamune/version.rb +2 -2
- data/spec/fixtures/aggregate.sql.erb +1 -1
- data/spec/fixtures/comment.sql.erb +1 -1
- data/spec/fixtures/invalid.sql.erb +1 -1
- data/spec/fixtures/relative.sql.erb +1 -1
- data/spec/fixtures/simple.sql.erb +1 -1
- data/spec/fixtures/whitespace.sql.erb +1 -1
- data/spec/masamune/actions/{elastic_mapreduce_spec.rb → aws_emr_spec.rb} +22 -42
- data/spec/masamune/actions/execute_spec.rb +1 -1
- data/spec/masamune/actions/hadoop_filesystem_spec.rb +1 -1
- data/spec/masamune/actions/hadoop_streaming_spec.rb +8 -8
- data/spec/masamune/actions/hive_spec.rb +5 -5
- data/spec/masamune/actions/invoke_parallel_spec.rb +1 -1
- data/spec/masamune/actions/postgres_admin_spec.rb +1 -1
- data/spec/masamune/actions/postgres_spec.rb +1 -1
- data/spec/masamune/actions/s3cmd_spec.rb +1 -1
- data/spec/masamune/actions/transform_spec.rb +1 -1
- data/spec/masamune/after_initialization_callbacks_spec.rb +1 -1
- data/spec/masamune/cached_filesystem_spec.rb +1 -1
- data/spec/masamune/commands/aws_emr_spec.rb +115 -0
- data/spec/masamune/commands/hadoop_filesystem_spec.rb +1 -1
- data/spec/masamune/commands/hadoop_streaming_spec.rb +1 -1
- data/spec/masamune/commands/hive_spec.rb +1 -1
- data/spec/masamune/commands/postgres_admin_spec.rb +1 -1
- data/spec/masamune/commands/postgres_spec.rb +1 -1
- data/spec/masamune/commands/retry_with_backoff_spec.rb +1 -1
- data/spec/masamune/commands/s3cmd_spec.rb +1 -1
- data/spec/masamune/commands/shell_spec.rb +79 -2
- data/spec/masamune/configuration_spec.rb +1 -65
- data/spec/masamune/data_plan/builder_spec.rb +1 -1
- data/spec/masamune/data_plan/elem_spec.rb +1 -1
- data/spec/masamune/data_plan/engine_spec.rb +1 -1
- data/spec/masamune/data_plan/rule_spec.rb +1 -1
- data/spec/masamune/data_plan/set_spec.rb +1 -1
- data/spec/masamune/environment_spec.rb +1 -1
- data/spec/masamune/filesystem_spec.rb +1 -1
- data/spec/masamune/helpers/postgres_spec.rb +1 -1
- data/spec/masamune/rspec/job_fixture_spec.rb +1 -1
- data/spec/masamune/rspec/mock_filesystem_spec.rb +1 -1
- data/spec/masamune/rspec/shared_example_group_spec.rb +1 -1
- data/spec/masamune/schema/catalog_spec.rb +1 -1
- data/spec/masamune/schema/column_spec.rb +1 -1
- data/spec/masamune/schema/dimension_spec.rb +1 -1
- data/spec/masamune/schema/fact_spec.rb +1 -1
- data/spec/masamune/schema/map_spec.rb +1 -1
- data/spec/masamune/schema/row_spec.rb +1 -1
- data/spec/masamune/schema/store_spec.rb +1 -1
- data/spec/masamune/schema/table_spec.rb +1 -1
- data/spec/masamune/string_format_spec.rb +1 -1
- data/spec/masamune/tasks/aws_emr_thor_spec.rb +69 -0
- data/spec/masamune/tasks/dump_thor_spec.rb +1 -1
- data/spec/masamune/tasks/hive_thor_spec.rb +1 -1
- data/spec/masamune/tasks/postgres_thor_spec.rb +1 -1
- data/spec/masamune/tasks/shell_thor_spec.rb +1 -1
- data/spec/masamune/template_spec.rb +1 -1
- data/spec/masamune/thor_spec.rb +1 -1
- data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +1 -1
- data/spec/masamune/transform/consolidate_dimension_spec.rb +1 -1
- data/spec/masamune/transform/deduplicate_dimension_spec.rb +1 -1
- data/spec/masamune/transform/define_schema_spec.rb +1 -1
- data/spec/masamune/transform/define_table.dimension_spec.rb +1 -1
- data/spec/masamune/transform/define_table.fact_spec.rb +1 -1
- data/spec/masamune/transform/define_table.table_spec.rb +1 -1
- data/spec/masamune/transform/denormalize_table_spec.rb +1 -1
- data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +1 -1
- data/spec/masamune/transform/insert_reference_values.fact_spec.rb +1 -1
- data/spec/masamune/transform/load_dimension_spec.rb +1 -1
- data/spec/masamune/transform/load_fact_spec.rb +1 -1
- data/spec/masamune/transform/relabel_dimension_spec.rb +1 -1
- data/spec/masamune/transform/rollup_fact_spec.rb +1 -1
- data/spec/masamune/transform/snapshot_dimension_spec.rb +1 -1
- data/spec/masamune/transform/stage_dimension_spec.rb +1 -1
- data/spec/masamune/transform/stage_fact_spec.rb +1 -1
- data/spec/masamune_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/masamune/example_group.rb +1 -1
- data/spec/support/masamune/job_example_group.rb +1 -1
- data/spec/support/masamune/job_fixture.rb +1 -1
- data/spec/support/masamune/mock_command.rb +1 -1
- data/spec/support/masamune/mock_delegate.rb +1 -1
- data/spec/support/masamune/mock_filesystem.rb +1 -1
- data/spec/support/masamune/shared_example_group.rb +1 -1
- data/spec/support/masamune/step_example_group.rb +1 -1
- data/spec/support/masamune/step_fixture.rb +1 -1
- data/spec/support/masamune/task_example_group.rb +1 -1
- data/spec/support/masamune/thor_mute.rb +1 -1
- data/spec/support/rspec/example/action_example_group.rb +1 -1
- data/spec/support/rspec/example/task_example_group.rb +1 -1
- data/spec/support/rspec/example/transform_example_group.rb +1 -1
- data/spec/support/shared_examples/postgres_common_examples.rb +1 -1
- metadata +14 -13
- data/lib/masamune/commands/interactive.rb +0 -37
- data/lib/masamune/tasks/elastic_mapreduce_thor.rb +0 -61
- data/spec/masamune/tasks/elastic_mapreduce_thor_spec.rb +0 -54
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014-2016, 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
|
+
describe Masamune::Commands::AwsEmr do
|
24
|
+
let(:configuration) { {} }
|
25
|
+
let(:attrs) { {} }
|
26
|
+
|
27
|
+
let(:delegate) { double }
|
28
|
+
let(:instance) { described_class.new(delegate, attrs) }
|
29
|
+
|
30
|
+
before do
|
31
|
+
allow(delegate).to receive(:logger).and_return(double)
|
32
|
+
allow(delegate).to receive_message_chain(:configuration, :aws_emr).and_return(configuration)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#command_env' do
|
36
|
+
subject { instance.command_env }
|
37
|
+
it { is_expected.to be_empty }
|
38
|
+
|
39
|
+
context 'with config file' do
|
40
|
+
let(:configuration) { {config_file: '/etc/aws/config'} }
|
41
|
+
it { is_expected.to eq({'AWS_CONFIG_FILE' => '/etc/aws/config'}) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#command_args' do
|
46
|
+
subject { instance.command_args }
|
47
|
+
|
48
|
+
it { is_expected.to eq(['aws', 'emr', 'ssh']) }
|
49
|
+
|
50
|
+
context 'with --cluster-id j-XYZ' do
|
51
|
+
let(:delegate) { double(command_args: ['hive', '-e', "'show tables;'"]) }
|
52
|
+
let(:attrs) { { cluster_id: 'j-XYZ' } }
|
53
|
+
|
54
|
+
before do
|
55
|
+
expect(instance).to receive(:execute).with('aws', 'emr', 'ssh', '--cluster-id', 'j-XYZ', '--command', 'exit', {fail_fast: true, safe: true}).
|
56
|
+
and_yield('ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=10 -i /etc/ssh/aws.key hadoop@ec2-10.0.0.1.compute-1.amazonaws.com exit').
|
57
|
+
and_yield("Warning: Permanently added 'ec2-10.0.0.1.compute-1.amazonaws.com,10.0.0.1' (ECDSA) to the list of known hosts.")
|
58
|
+
end
|
59
|
+
|
60
|
+
it { is_expected.to eq(['ssh', '-o', 'StrictHostKeyChecking=no', '-o', 'ServerAliveInterval=10', '-i', '/etc/ssh/aws.key', 'hadoop@ec2-10.0.0.1.compute-1.amazonaws.com', 'hive' , '-e', "'show tables;'"]) }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with action' do
|
64
|
+
let(:configuration) { { create_cluster: { options: {'--ami-version' => '3.5.0'} } } }
|
65
|
+
let(:attrs) { { action: 'create-cluster', extra: ['--instance-type', 'm1.large'] } }
|
66
|
+
it { is_expected.to eq(['aws', 'emr', 'create-cluster', '--ami-version', '3.5.0', '--instance-type', 'm1.large']) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with action and option override (symbolized)' do
|
70
|
+
let(:configuration) { { create_cluster: { options: {:'--ami-version' => '3.5.0'} } } }
|
71
|
+
let(:attrs) { { action: 'create-cluster', extra: ['--ami-version', '4.0.0', '--instance-type', 'm1.large'] } }
|
72
|
+
it { is_expected.to eq(['aws', 'emr', 'create-cluster', '--ami-version', '4.0.0', '--instance-type', 'm1.large']) }
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with action and option override (stringified)' do
|
76
|
+
let(:configuration) { { 'create_cluster' => { 'options' => {'--ami-version' => '3.5.0'} } } }
|
77
|
+
let(:attrs) { { action: 'create-cluster', extra: ['--ami-version', '4.0.0', '--instance-type', 'm1.large'] } }
|
78
|
+
it { is_expected.to eq(['aws', 'emr', 'create-cluster', '--ami-version', '4.0.0', '--instance-type', 'm1.large']) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with action: wait' do
|
82
|
+
let(:attrs) { { action: 'wait', cluster_id: 'j-XYZ' } }
|
83
|
+
it { is_expected.to eq(['aws', 'emr', 'wait', 'cluster-running', '--cluster-id', 'j-XYZ']) }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context '#interactive?' do
|
88
|
+
subject { instance.interactive? }
|
89
|
+
it { is_expected.to eq(false) }
|
90
|
+
|
91
|
+
context 'with interactive: true' do
|
92
|
+
let(:attrs) { { interactive: true } }
|
93
|
+
it { is_expected.to eq(true) }
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'with interactive: false' do
|
97
|
+
let(:attrs) { { interactive: false } }
|
98
|
+
it { is_expected.to eq(false) }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when delegate.interactive? is true' do
|
102
|
+
before do
|
103
|
+
allow(delegate).to receive(:interactive?).and_return(true)
|
104
|
+
end
|
105
|
+
it { is_expected.to eq(true) }
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'when delegate.interactive? is false' do
|
109
|
+
before do
|
110
|
+
allow(delegate).to receive(:interactive?).and_return(false)
|
111
|
+
end
|
112
|
+
it { is_expected.to eq(false) }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -23,10 +23,12 @@
|
|
23
23
|
describe Masamune::Commands::Shell do
|
24
24
|
let(:input) { nil }
|
25
25
|
let(:options) { {fail_fast: false} }
|
26
|
-
let(:delegate) {
|
26
|
+
let(:delegate) { double }
|
27
27
|
let(:instance) { described_class.new(delegate, options) }
|
28
28
|
|
29
29
|
describe '#execute' do
|
30
|
+
let(:delegate) { Masamune::MockDelegate.new(command, input) }
|
31
|
+
|
30
32
|
subject do
|
31
33
|
instance.execute
|
32
34
|
end
|
@@ -35,6 +37,8 @@ describe Masamune::Commands::Shell do
|
|
35
37
|
let(:command) { %Q{bash -c "echo 'stdout 1'; echo 'stderr 1' 1>&2; echo 'stdout 2'; echo 'stderr 2' 1>&2"} }
|
36
38
|
|
37
39
|
before do
|
40
|
+
expect(instance.logger).to receive(:debug).with(/\Aexecute: TZ=UTC bash -c .*\z/)
|
41
|
+
expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 0\z/)
|
38
42
|
subject
|
39
43
|
end
|
40
44
|
|
@@ -47,6 +51,8 @@ describe Masamune::Commands::Shell do
|
|
47
51
|
let(:command) { %Q{bash -c 'exit 1'} }
|
48
52
|
|
49
53
|
before do
|
54
|
+
expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c 'exit 1'))
|
55
|
+
expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 1\z/)
|
50
56
|
subject
|
51
57
|
end
|
52
58
|
|
@@ -58,12 +64,23 @@ describe Masamune::Commands::Shell do
|
|
58
64
|
context 'with fail_fast and simple command that fails' do
|
59
65
|
let(:command) { %Q{bash -c 'exit 1'} }
|
60
66
|
let(:options) { {fail_fast: true} }
|
67
|
+
|
68
|
+
before do
|
69
|
+
expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c 'exit 1'))
|
70
|
+
expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 1\z/)
|
71
|
+
end
|
72
|
+
|
61
73
|
it { expect { subject }.to raise_error RuntimeError, "fail_fast: #{command}" }
|
62
74
|
end
|
63
75
|
|
64
76
|
context 'when command is interrupted' do
|
65
77
|
let(:command) { %Q{bash -c "echo 'test'"} }
|
66
78
|
|
79
|
+
before do
|
80
|
+
expect(instance.logger).to receive(:debug).with(%q(execute: TZ=UTC bash -c "echo 'test'"))
|
81
|
+
expect(instance.logger).to receive(:debug).with(/status: .* exit 0/)
|
82
|
+
end
|
83
|
+
|
67
84
|
before do
|
68
85
|
expect(delegate).to receive(:after_execute) { raise Interrupt }
|
69
86
|
subject
|
@@ -76,6 +93,11 @@ describe Masamune::Commands::Shell do
|
|
76
93
|
let(:command) { 'cat' }
|
77
94
|
let(:input) { "ping\npong" }
|
78
95
|
|
96
|
+
before do
|
97
|
+
expect(instance.logger).to receive(:debug).with('execute: TZ=UTC cat')
|
98
|
+
expect(instance.logger).to receive(:debug).with(/\Astatus: .* exit 0\z/)
|
99
|
+
end
|
100
|
+
|
79
101
|
before do
|
80
102
|
subject
|
81
103
|
end
|
@@ -89,6 +111,10 @@ describe Masamune::Commands::Shell do
|
|
89
111
|
let(:command) { 'cat' }
|
90
112
|
let(:input) { "ping\npong" }
|
91
113
|
|
114
|
+
before do
|
115
|
+
expect(instance.logger).to receive(:debug).with('execute: TZ=UTC cat')
|
116
|
+
end
|
117
|
+
|
92
118
|
before do
|
93
119
|
expect_any_instance_of(IO).to receive(:wait_writable).and_return(nil)
|
94
120
|
end
|
@@ -96,4 +122,55 @@ describe Masamune::Commands::Shell do
|
|
96
122
|
it { expect { subject }.to raise_error RuntimeError, /IO stdin not ready/ }
|
97
123
|
end
|
98
124
|
end
|
125
|
+
|
126
|
+
context '#command_args' do
|
127
|
+
subject do
|
128
|
+
instance.command_args
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'when delegate does not implement command_args' do
|
132
|
+
it { expect { subject }.to raise_error RuntimeError, /no command_args/ }
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when delegate implements command_args' do
|
136
|
+
before do
|
137
|
+
allow(delegate).to receive(:command_args).and_return(command_args)
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'with nil command_args' do
|
141
|
+
let(:command_args) { nil }
|
142
|
+
it { expect { subject }.to raise_error RuntimeError, /no command_args/ }
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'with empty command_args' do
|
146
|
+
let(:command_args) { [] }
|
147
|
+
it { is_expected.to be_empty }
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'with expected command_args (array)' do
|
151
|
+
let(:command_args) { ['cat'] }
|
152
|
+
it { is_expected.to eq(['cat']) }
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'with expected command_args (string)' do
|
156
|
+
let(:command_args) { 'cat' }
|
157
|
+
it { is_expected.to eq(['cat']) }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'with command_args containing nil' do
|
161
|
+
let(:command_args) { ['echo', nil, 'foo'] }
|
162
|
+
it { is_expected.to eq(['echo', 'foo']) }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'with command_args containing an integer' do
|
166
|
+
let(:command_args) { ['echo', nil, 5] }
|
167
|
+
it { is_expected.to eq(['echo', '5']) }
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'with nested command_args' do
|
171
|
+
let(:command_args) { [['echo'], ['foo']] }
|
172
|
+
it { is_expected.to eq(['echo', 'foo']) }
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
99
176
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -45,68 +45,4 @@ describe Masamune::Configuration do
|
|
45
45
|
it { is_expected.to eq(['--debug', '--dry-run']) }
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
49
|
-
describe '#bind_template' do
|
50
|
-
let(:section) { nil }
|
51
|
-
let(:template) { nil }
|
52
|
-
let(:params) { nil }
|
53
|
-
|
54
|
-
subject do
|
55
|
-
instance.bind_template(section, template, params)
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with invalid template section' do
|
59
|
-
let(:section) { :missing_section }
|
60
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when template section is missing' do
|
64
|
-
let(:section) { :elastic_mapreduce }
|
65
|
-
it { expect { subject }.to raise_error(ArgumentError) }
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'with valid template section' do
|
69
|
-
let(:section) { :elastic_mapreduce }
|
70
|
-
before do
|
71
|
-
instance.elastic_mapreduce[:templates] = {
|
72
|
-
list_with_state: {
|
73
|
-
command: '--list --key-pair %key_pair --start %state --verbose=%verbose',
|
74
|
-
default: {
|
75
|
-
state: 'RUNNING',
|
76
|
-
verbose: true
|
77
|
-
}
|
78
|
-
},
|
79
|
-
broken_template: nil
|
80
|
-
}
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'when template is missing' do
|
84
|
-
let(:template) { :missing_template }
|
85
|
-
it { expect { subject }.to raise_error(ArgumentError, 'no template for missing_template') }
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'when template is broken' do
|
89
|
-
let(:template) { :broken_template }
|
90
|
-
it { expect { subject }.to raise_error(ArgumentError, 'no template for broken_template') }
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'when params missing but default exists' do
|
94
|
-
let(:template) { :list_with_state }
|
95
|
-
let(:params) { {key_pair: 'emr-2013'} }
|
96
|
-
it { is_expected.to eq(['--list', '--key-pair', 'emr-2013', '--start', 'RUNNING', '--verbose=true']) }
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'when params missing and default missing' do
|
100
|
-
let(:template) { :list_with_state }
|
101
|
-
let(:params) { {state: 'COMPLETED'} }
|
102
|
-
it { expect { subject }.to raise_error(ArgumentError, 'no param for %key_pair') }
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'with params' do
|
106
|
-
let(:template) { :list_with_state }
|
107
|
-
let(:params) { {key_pair: 'emr-2013', state: 'COMPLETED'} }
|
108
|
-
it { is_expected.to eq(['--list', '--key-pair', 'emr-2013', '--start', 'COMPLETED', '--verbose=true']) }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
48
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
#
|
3
|
-
# Copyright (c) 2014-
|
3
|
+
# Copyright (c) 2014-2016, VMware, Inc. All Rights Reserved.
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|