masamune 0.15.6 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/Rakefile +1 -1
  4. data/bin/{masamune-elastic-mapreduce → masamune-aws-emr} +3 -3
  5. data/bin/masamune-dump +1 -1
  6. data/bin/masamune-hive +1 -1
  7. data/bin/masamune-psql +1 -1
  8. data/bin/masamune-shell +1 -1
  9. data/lib/masamune.rb +1 -1
  10. data/lib/masamune/actions.rb +1 -1
  11. data/lib/masamune/actions/{elastic_mapreduce.rb → aws_emr.rb} +14 -30
  12. data/lib/masamune/actions/data_flow.rb +1 -1
  13. data/lib/masamune/actions/date_parse.rb +1 -1
  14. data/lib/masamune/actions/execute.rb +1 -1
  15. data/lib/masamune/actions/filesystem.rb +1 -1
  16. data/lib/masamune/actions/hadoop_filesystem.rb +1 -1
  17. data/lib/masamune/actions/hadoop_streaming.rb +10 -8
  18. data/lib/masamune/actions/hive.rb +2 -2
  19. data/lib/masamune/actions/invoke_parallel.rb +1 -1
  20. data/lib/masamune/actions/postgres.rb +1 -1
  21. data/lib/masamune/actions/postgres_admin.rb +1 -1
  22. data/lib/masamune/actions/s3cmd.rb +1 -1
  23. data/lib/masamune/actions/transform.rb +1 -1
  24. data/lib/masamune/after_initialize_callbacks.rb +1 -1
  25. data/lib/masamune/cached_filesystem.rb +2 -2
  26. data/lib/masamune/commands.rb +1 -1
  27. data/lib/masamune/commands/{elastic_mapreduce.rb → aws_emr.rb} +38 -29
  28. data/lib/masamune/commands/hadoop_filesystem.rb +1 -1
  29. data/lib/masamune/commands/hadoop_streaming.rb +1 -1
  30. data/lib/masamune/commands/hive.rb +1 -1
  31. data/lib/masamune/commands/postgres.rb +1 -1
  32. data/lib/masamune/commands/postgres_admin.rb +1 -1
  33. data/lib/masamune/commands/postgres_common.rb +1 -1
  34. data/lib/masamune/commands/retry_with_backoff.rb +1 -1
  35. data/lib/masamune/commands/s3cmd.rb +1 -1
  36. data/lib/masamune/commands/shell.rb +11 -7
  37. data/lib/masamune/configuration.rb +2 -38
  38. data/lib/masamune/data_plan.rb +1 -1
  39. data/lib/masamune/data_plan/builder.rb +1 -1
  40. data/lib/masamune/data_plan/elem.rb +1 -1
  41. data/lib/masamune/data_plan/engine.rb +1 -1
  42. data/lib/masamune/data_plan/rule.rb +1 -1
  43. data/lib/masamune/data_plan/set.rb +1 -1
  44. data/lib/masamune/environment.rb +1 -1
  45. data/lib/masamune/filesystem.rb +1 -1
  46. data/lib/masamune/has_environment.rb +1 -1
  47. data/lib/masamune/helpers.rb +1 -1
  48. data/lib/masamune/helpers/postgres.rb +1 -1
  49. data/lib/masamune/io.rb +1 -1
  50. data/lib/masamune/last_element.rb +1 -1
  51. data/lib/masamune/method_logger.rb +1 -1
  52. data/lib/masamune/multi_io.rb +1 -1
  53. data/lib/masamune/schema.rb +1 -1
  54. data/lib/masamune/schema/catalog.rb +1 -1
  55. data/lib/masamune/schema/column.rb +1 -1
  56. data/lib/masamune/schema/dimension.rb +1 -1
  57. data/lib/masamune/schema/fact.rb +1 -1
  58. data/lib/masamune/schema/map.rb +1 -1
  59. data/lib/masamune/schema/row.rb +1 -1
  60. data/lib/masamune/schema/store.rb +1 -1
  61. data/lib/masamune/schema/table.rb +1 -1
  62. data/lib/masamune/schema/table_reference.rb +1 -1
  63. data/lib/masamune/spec_helper.rb +1 -1
  64. data/lib/masamune/string_format.rb +1 -1
  65. data/lib/masamune/tasks/aws_emr_thor.rb +79 -0
  66. data/lib/masamune/tasks/dump_thor.rb +1 -1
  67. data/lib/masamune/tasks/hive_thor.rb +2 -2
  68. data/lib/masamune/tasks/postgres_thor.rb +1 -1
  69. data/lib/masamune/tasks/shell_thor.rb +1 -1
  70. data/lib/masamune/template.rb +1 -1
  71. data/lib/masamune/thor.rb +1 -1
  72. data/lib/masamune/topological_hash.rb +1 -1
  73. data/lib/masamune/transform.rb +1 -1
  74. data/lib/masamune/transform/bulk_upsert.rb +1 -1
  75. data/lib/masamune/transform/common.rb +1 -1
  76. data/lib/masamune/transform/common/denormalize_table.rb +1 -1
  77. data/lib/masamune/transform/consolidate_dimension.rb +1 -1
  78. data/lib/masamune/transform/deduplicate_dimension.rb +1 -1
  79. data/lib/masamune/transform/define_schema.rb +1 -1
  80. data/lib/masamune/transform/define_table.rb +1 -1
  81. data/lib/masamune/transform/denormalize_table.rb +1 -1
  82. data/lib/masamune/transform/hive.rb +1 -1
  83. data/lib/masamune/transform/hive/define_schema.hql.erb +1 -1
  84. data/lib/masamune/transform/hive/define_table.hql.erb +1 -1
  85. data/lib/masamune/transform/hive/define_table.rb +1 -1
  86. data/lib/masamune/transform/hive/denormalize_table.hql.erb +1 -1
  87. data/lib/masamune/transform/hive/denormalize_table.rb +1 -1
  88. data/lib/masamune/transform/insert_reference_values.rb +1 -1
  89. data/lib/masamune/transform/load_dimension.rb +1 -1
  90. data/lib/masamune/transform/load_fact.rb +1 -1
  91. data/lib/masamune/transform/operator.rb +1 -1
  92. data/lib/masamune/transform/postgres.rb +1 -1
  93. data/lib/masamune/transform/postgres/bulk_upsert.psql.erb +1 -1
  94. data/lib/masamune/transform/postgres/bulk_upsert.rb +1 -1
  95. data/lib/masamune/transform/postgres/deduplicate_dimension.psql.erb +1 -1
  96. data/lib/masamune/transform/postgres/deduplicate_dimension.rb +1 -1
  97. data/lib/masamune/transform/postgres/define_foreign_key.psql.erb +1 -1
  98. data/lib/masamune/transform/postgres/define_index.psql.erb +1 -1
  99. data/lib/masamune/transform/postgres/define_inheritance.psql.erb +1 -1
  100. data/lib/masamune/transform/postgres/define_schema.psql.erb +1 -1
  101. data/lib/masamune/transform/postgres/define_table.psql.erb +1 -1
  102. data/lib/masamune/transform/postgres/define_table.rb +1 -1
  103. data/lib/masamune/transform/postgres/define_unique.psql.erb +1 -1
  104. data/lib/masamune/transform/postgres/denormalize_table.psql.erb +1 -1
  105. data/lib/masamune/transform/postgres/denormalize_table.rb +1 -1
  106. data/lib/masamune/transform/postgres/insert_reference_values.psql.erb +1 -1
  107. data/lib/masamune/transform/postgres/insert_reference_values.rb +1 -1
  108. data/lib/masamune/transform/postgres/relabel_dimension.psql.erb +1 -1
  109. data/lib/masamune/transform/postgres/relabel_dimension.rb +1 -1
  110. data/lib/masamune/transform/postgres/replace_table.psql.erb +1 -1
  111. data/lib/masamune/transform/postgres/rollup_fact.psql.erb +1 -1
  112. data/lib/masamune/transform/postgres/rollup_fact.rb +1 -1
  113. data/lib/masamune/transform/postgres/snapshot_dimension.psql.erb +1 -1
  114. data/lib/masamune/transform/postgres/snapshot_dimension.rb +1 -1
  115. data/lib/masamune/transform/postgres/stage_dimension.psql.erb +1 -1
  116. data/lib/masamune/transform/postgres/stage_dimension.rb +1 -1
  117. data/lib/masamune/transform/postgres/stage_fact.psql.erb +1 -1
  118. data/lib/masamune/transform/postgres/stage_fact.rb +1 -1
  119. data/lib/masamune/transform/relabel_dimension.rb +1 -1
  120. data/lib/masamune/transform/rollup_fact.rb +1 -1
  121. data/lib/masamune/transform/snapshot_dimension.rb +1 -1
  122. data/lib/masamune/transform/stage_dimension.rb +1 -1
  123. data/lib/masamune/transform/stage_fact.rb +1 -1
  124. data/lib/masamune/version.rb +2 -2
  125. data/spec/fixtures/aggregate.sql.erb +1 -1
  126. data/spec/fixtures/comment.sql.erb +1 -1
  127. data/spec/fixtures/invalid.sql.erb +1 -1
  128. data/spec/fixtures/relative.sql.erb +1 -1
  129. data/spec/fixtures/simple.sql.erb +1 -1
  130. data/spec/fixtures/whitespace.sql.erb +1 -1
  131. data/spec/masamune/actions/{elastic_mapreduce_spec.rb → aws_emr_spec.rb} +22 -42
  132. data/spec/masamune/actions/execute_spec.rb +1 -1
  133. data/spec/masamune/actions/hadoop_filesystem_spec.rb +1 -1
  134. data/spec/masamune/actions/hadoop_streaming_spec.rb +8 -8
  135. data/spec/masamune/actions/hive_spec.rb +5 -5
  136. data/spec/masamune/actions/invoke_parallel_spec.rb +1 -1
  137. data/spec/masamune/actions/postgres_admin_spec.rb +1 -1
  138. data/spec/masamune/actions/postgres_spec.rb +1 -1
  139. data/spec/masamune/actions/s3cmd_spec.rb +1 -1
  140. data/spec/masamune/actions/transform_spec.rb +1 -1
  141. data/spec/masamune/after_initialization_callbacks_spec.rb +1 -1
  142. data/spec/masamune/cached_filesystem_spec.rb +1 -1
  143. data/spec/masamune/commands/aws_emr_spec.rb +115 -0
  144. data/spec/masamune/commands/hadoop_filesystem_spec.rb +1 -1
  145. data/spec/masamune/commands/hadoop_streaming_spec.rb +1 -1
  146. data/spec/masamune/commands/hive_spec.rb +1 -1
  147. data/spec/masamune/commands/postgres_admin_spec.rb +1 -1
  148. data/spec/masamune/commands/postgres_spec.rb +1 -1
  149. data/spec/masamune/commands/retry_with_backoff_spec.rb +1 -1
  150. data/spec/masamune/commands/s3cmd_spec.rb +1 -1
  151. data/spec/masamune/commands/shell_spec.rb +79 -2
  152. data/spec/masamune/configuration_spec.rb +1 -65
  153. data/spec/masamune/data_plan/builder_spec.rb +1 -1
  154. data/spec/masamune/data_plan/elem_spec.rb +1 -1
  155. data/spec/masamune/data_plan/engine_spec.rb +1 -1
  156. data/spec/masamune/data_plan/rule_spec.rb +1 -1
  157. data/spec/masamune/data_plan/set_spec.rb +1 -1
  158. data/spec/masamune/environment_spec.rb +1 -1
  159. data/spec/masamune/filesystem_spec.rb +1 -1
  160. data/spec/masamune/helpers/postgres_spec.rb +1 -1
  161. data/spec/masamune/rspec/job_fixture_spec.rb +1 -1
  162. data/spec/masamune/rspec/mock_filesystem_spec.rb +1 -1
  163. data/spec/masamune/rspec/shared_example_group_spec.rb +1 -1
  164. data/spec/masamune/schema/catalog_spec.rb +1 -1
  165. data/spec/masamune/schema/column_spec.rb +1 -1
  166. data/spec/masamune/schema/dimension_spec.rb +1 -1
  167. data/spec/masamune/schema/fact_spec.rb +1 -1
  168. data/spec/masamune/schema/map_spec.rb +1 -1
  169. data/spec/masamune/schema/row_spec.rb +1 -1
  170. data/spec/masamune/schema/store_spec.rb +1 -1
  171. data/spec/masamune/schema/table_spec.rb +1 -1
  172. data/spec/masamune/string_format_spec.rb +1 -1
  173. data/spec/masamune/tasks/aws_emr_thor_spec.rb +69 -0
  174. data/spec/masamune/tasks/dump_thor_spec.rb +1 -1
  175. data/spec/masamune/tasks/hive_thor_spec.rb +1 -1
  176. data/spec/masamune/tasks/postgres_thor_spec.rb +1 -1
  177. data/spec/masamune/tasks/shell_thor_spec.rb +1 -1
  178. data/spec/masamune/template_spec.rb +1 -1
  179. data/spec/masamune/thor_spec.rb +1 -1
  180. data/spec/masamune/transform/bulk_upsert.dimension_spec.rb +1 -1
  181. data/spec/masamune/transform/consolidate_dimension_spec.rb +1 -1
  182. data/spec/masamune/transform/deduplicate_dimension_spec.rb +1 -1
  183. data/spec/masamune/transform/define_schema_spec.rb +1 -1
  184. data/spec/masamune/transform/define_table.dimension_spec.rb +1 -1
  185. data/spec/masamune/transform/define_table.fact_spec.rb +1 -1
  186. data/spec/masamune/transform/define_table.table_spec.rb +1 -1
  187. data/spec/masamune/transform/denormalize_table_spec.rb +1 -1
  188. data/spec/masamune/transform/insert_reference_values.dimension_spec.rb +1 -1
  189. data/spec/masamune/transform/insert_reference_values.fact_spec.rb +1 -1
  190. data/spec/masamune/transform/load_dimension_spec.rb +1 -1
  191. data/spec/masamune/transform/load_fact_spec.rb +1 -1
  192. data/spec/masamune/transform/relabel_dimension_spec.rb +1 -1
  193. data/spec/masamune/transform/rollup_fact_spec.rb +1 -1
  194. data/spec/masamune/transform/snapshot_dimension_spec.rb +1 -1
  195. data/spec/masamune/transform/stage_dimension_spec.rb +1 -1
  196. data/spec/masamune/transform/stage_fact_spec.rb +1 -1
  197. data/spec/masamune_spec.rb +1 -1
  198. data/spec/spec_helper.rb +1 -1
  199. data/spec/support/masamune/example_group.rb +1 -1
  200. data/spec/support/masamune/job_example_group.rb +1 -1
  201. data/spec/support/masamune/job_fixture.rb +1 -1
  202. data/spec/support/masamune/mock_command.rb +1 -1
  203. data/spec/support/masamune/mock_delegate.rb +1 -1
  204. data/spec/support/masamune/mock_filesystem.rb +1 -1
  205. data/spec/support/masamune/shared_example_group.rb +1 -1
  206. data/spec/support/masamune/step_example_group.rb +1 -1
  207. data/spec/support/masamune/step_fixture.rb +1 -1
  208. data/spec/support/masamune/task_example_group.rb +1 -1
  209. data/spec/support/masamune/thor_mute.rb +1 -1
  210. data/spec/support/rspec/example/action_example_group.rb +1 -1
  211. data/spec/support/rspec/example/task_example_group.rb +1 -1
  212. data/spec/support/rspec/example/transform_example_group.rb +1 -1
  213. data/spec/support/shared_examples/postgres_common_examples.rb +1 -1
  214. metadata +14 -13
  215. data/lib/masamune/commands/interactive.rb +0 -37
  216. data/lib/masamune/tasks/elastic_mapreduce_thor.rb +0 -61
  217. 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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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) { Masamune::MockDelegate.new(command, input) }
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-2015, VMware, Inc. All Rights Reserved.
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-2015, VMware, Inc. All Rights Reserved.
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