elasticity 1.4.1 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/.rvmrc +1 -1
  2. data/.travis.yml +11 -0
  3. data/HISTORY.md +6 -0
  4. data/README.md +23 -6
  5. data/elasticity.gemspec +4 -7
  6. data/lib/elasticity/custom_jar_job.rb +3 -2
  7. data/lib/elasticity/hive_job.rb +1 -3
  8. data/lib/elasticity/pig_job.rb +1 -4
  9. data/lib/elasticity/simple_job.rb +4 -3
  10. data/lib/elasticity/version.rb +1 -1
  11. data/spec/fixtures/vcr_cassettes/add_instance_groups/one_group_successful.yml +33 -27
  12. data/spec/fixtures/vcr_cassettes/add_instance_groups/one_group_unsuccessful.yml +33 -27
  13. data/spec/fixtures/vcr_cassettes/add_jobflow_steps/add_multiple_steps.yml +236 -222
  14. data/spec/fixtures/vcr_cassettes/custom_jar_job/cloudburst.yml +33 -27
  15. data/spec/fixtures/vcr_cassettes/describe_jobflows/all_jobflows.yml +64 -58
  16. data/spec/fixtures/vcr_cassettes/direct/terminate_jobflow.yml +30 -24
  17. data/spec/fixtures/vcr_cassettes/hive_job/hive_ads.yml +30 -24
  18. data/spec/fixtures/vcr_cassettes/modify_instance_groups/set_instances_to_3.yml +30 -24
  19. data/spec/fixtures/vcr_cassettes/pig_job/apache_log_reports.yml +32 -26
  20. data/spec/fixtures/vcr_cassettes/pig_job/apache_log_reports_with_bootstrap.yml +33 -27
  21. data/spec/fixtures/vcr_cassettes/run_jobflow/word_count.yml +33 -27
  22. data/spec/fixtures/vcr_cassettes/set_termination_protection/nonexistent_job_flows.yml +33 -27
  23. data/spec/fixtures/vcr_cassettes/set_termination_protection/protect_multiple_job_flows.yml +30 -24
  24. data/spec/fixtures/vcr_cassettes/terminate_jobflows/one_jobflow.yml +30 -24
  25. data/spec/lib/elasticity/emr_spec.rb +3 -0
  26. data/spec/lib/elasticity/hive_job_spec.rb +3 -9
  27. data/spec/lib/elasticity/pig_job_spec.rb +16 -1
  28. data/spec/spec_helper.rb +39 -26
  29. metadata +14 -90
@@ -1,32 +1,38 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: !ruby/regexp /^https:\/\/elasticmapreduce.amazonaws.com\/\?AWSAccessKeyId=\S+&JobFlowIds.member.1=j-1B4D1XP0C0A35&JobFlowIds.member.2=j-1YG2MYL0HVYS5&Operation=SetTerminationProtection&.*TerminationProtected=true/
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: !ruby/regexp /^https/
6
6
  body:
7
- headers:
8
- accept:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Accept:
9
11
  - "*/*; q=0.5, application/xml"
10
- accept-encoding:
12
+ Accept-Encoding:
11
13
  - gzip, deflate
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
+ response:
15
+ status:
14
16
  code: 200
15
17
  message: OK
16
- headers:
17
- x-amzn-requestid:
18
- - 755ebe8a-6923-11e0-a9c2-c126f1bb4493
19
- content-type:
20
- - text/xml
21
- date:
22
- - Sun, 17 Apr 2011 18:49:43 GMT
23
- content-length:
18
+ headers:
19
+ Content-Length:
24
20
  - "239"
25
- body: |
26
- <SetTerminationProtectionResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
27
- <ResponseMetadata>
28
- <RequestId>755ebe8a-6923-11e0-a9c2-c126f1bb4493</RequestId>
29
- </ResponseMetadata>
30
- </SetTerminationProtectionResponse>
21
+ Date:
22
+ - Sun, 17 Apr 2011 18:49:43 GMT
23
+ Content-Type:
24
+ - text/xml
25
+ X-Amzn-Requestid:
26
+ - 755ebe8a-6923-11e0-a9c2-c126f1bb4493
27
+ body:
28
+ encoding: US-ASCII
29
+ string: |
30
+ <SetTerminationProtectionResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
31
+ <ResponseMetadata>
32
+ <RequestId>755ebe8a-6923-11e0-a9c2-c126f1bb4493</RequestId>
33
+ </ResponseMetadata>
34
+ </SetTerminationProtectionResponse>
31
35
 
32
36
  http_version: "1.1"
37
+ recorded_at: Sat, 03 Mar 2012 23:00:38 GMT
38
+ recorded_with: VCR 2.0.0
@@ -1,32 +1,38 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: !ruby/regexp /^https:\/\/elasticmapreduce.amazonaws.com\/\?AWSAccessKeyId=\S+&JobFlowIds.member.1=j-1MZ5TVWFJRSKN&Operation=TerminateJobFlows/
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: !ruby/regexp /^https/
6
6
  body:
7
- headers:
8
- accept:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Accept:
9
11
  - "*/*; q=0.5, application/xml"
10
- accept-encoding:
12
+ Accept-Encoding:
11
13
  - gzip, deflate
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
+ response:
15
+ status:
14
16
  code: 200
15
17
  message: OK
16
- headers:
17
- x-amzn-requestid:
18
- - 83e0154d-63c6-11e0-bc41-ababd98a870b
19
- content-type:
20
- - text/xml
21
- date:
22
- - Sun, 10 Apr 2011 23:01:48 GMT
23
- content-length:
18
+ headers:
19
+ Content-Length:
24
20
  - "225"
25
- body: |
26
- <TerminateJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
27
- <ResponseMetadata>
28
- <RequestId>83e0154d-63c6-11e0-bc41-ababd98a870b</RequestId>
29
- </ResponseMetadata>
30
- </TerminateJobFlowsResponse>
21
+ Date:
22
+ - Sun, 10 Apr 2011 23:01:48 GMT
23
+ Content-Type:
24
+ - text/xml
25
+ X-Amzn-Requestid:
26
+ - 83e0154d-63c6-11e0-bc41-ababd98a870b
27
+ body:
28
+ encoding: US-ASCII
29
+ string: |
30
+ <TerminateJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
31
+ <ResponseMetadata>
32
+ <RequestId>83e0154d-63c6-11e0-bc41-ababd98a870b</RequestId>
33
+ </ResponseMetadata>
34
+ </TerminateJobFlowsResponse>
31
35
 
32
36
  http_version: "1.1"
37
+ recorded_at: Sat, 03 Mar 2012 23:00:44 GMT
38
+ recorded_with: VCR 2.0.0
@@ -266,6 +266,7 @@ describe Elasticity::EMR do
266
266
  <JobFlows>
267
267
  <member>
268
268
  <ExecutionStatusDetail>
269
+ <CreationDateTime>2011-04-04T17:41:51Z</CreationDateTime>
269
270
  <State>TERMINATED</State>
270
271
  </ExecutionStatusDetail>
271
272
  <JobFlowId>j-p</JobFlowId>
@@ -274,6 +275,7 @@ describe Elasticity::EMR do
274
275
  <member>
275
276
  <ExecutionStatusDetail>
276
277
  <State>TERMINATED</State>
278
+ <CreationDateTime>2011-04-04T17:41:51Z</CreationDateTime>
277
279
  </ExecutionStatusDetail>
278
280
  <JobFlowId>j-h</JobFlowId>
279
281
  <Name>Hive Job</Name>
@@ -327,6 +329,7 @@ describe Elasticity::EMR do
327
329
  <member>
328
330
  <ExecutionStatusDetail>
329
331
  <State>TERMINATED</State>
332
+ <CreationDateTime>2011-04-04T17:41:51Z</CreationDateTime>
330
333
  </ExecutionStatusDetail>
331
334
  <JobFlowId>j-3UN6WX5RRO2AG</JobFlowId>
332
335
  <Name>The One Job Flow</Name>
@@ -57,7 +57,6 @@ describe Elasticity::HiveJob do
57
57
  "--run-hive-script",
58
58
  "--args",
59
59
  "-f", "s3n://slif-hive/test.q",
60
- "-d", "XREFS=s3n://slif-test/xrefs",
61
60
  "-d", "OUTPUT=s3n://slif-test/output"
62
61
  ],
63
62
  },
@@ -71,8 +70,7 @@ describe Elasticity::HiveJob do
71
70
  hive.log_uri = "s3n://slif-test/output/logs"
72
71
  hive.action_on_failure = "CONTINUE"
73
72
  jobflow_id = hive.run('s3n://slif-hive/test.q', {
74
- 'OUTPUT' => 's3n://slif-test/output',
75
- 'XREFS' => 's3n://slif-test/xrefs'
73
+ 'OUTPUT' => 's3n://slif-test/output'
76
74
  })
77
75
  jobflow_id.should == "new_jobflow_id"
78
76
  end
@@ -84,12 +82,8 @@ describe Elasticity::HiveJob do
84
82
  it "should kick off the sample Amazion EMR Hive application" do
85
83
  hive = Elasticity::HiveJob.new(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY)
86
84
  hive.ec2_key_name = "sharethrough_dev"
87
- jobflow_id = hive.run("s3n://elasticmapreduce/samples/hive-ads/libs/model-build.q", {
88
- "LIBS" => "s3n://elasticmapreduce/samples/hive-ads/libs",
89
- "INPUT" => "s3n://elasticmapreduce/samples/hive-ads/tables",
90
- "OUTPUT" => "s3n://slif-elasticity/hive-ads/output/2011-04-19"
91
- })
92
- jobflow_id.should == "j-1UUVYMHBLKEGN"
85
+ jobflow_id = hive.run("s3n://elasticmapreduce/samples/hive-ads/libs/model-build.q")
86
+ jobflow_id.should == "j-2I4HV6S3SDGD9"
93
87
  end
94
88
  end
95
89
 
@@ -26,6 +26,22 @@ describe Elasticity::PigJob do
26
26
  pig.instance_count = 1
27
27
  }.should raise_error(ArgumentError, "Instance count cannot be set to less than 2 (requested 1)")
28
28
  end
29
+
30
+ it "should recalculate @parallels" do
31
+ pig = Elasticity::PigJob.new("access", "secret")
32
+ lambda {
33
+ pig.instance_count = 10
34
+ }.should change(pig, :parallels)
35
+ end
36
+ end
37
+
38
+ describe "#slave_instance_type=" do
39
+ it "should recalculate @parallels" do
40
+ pig = Elasticity::PigJob.new("access", "secret")
41
+ lambda {
42
+ pig.slave_instance_type = "c1.xlarge"
43
+ }.should change(pig, :parallels)
44
+ end
29
45
  end
30
46
 
31
47
  describe "calculated value of parallels" do
@@ -207,5 +223,4 @@ describe Elasticity::PigJob do
207
223
  end
208
224
  end
209
225
 
210
-
211
226
  end
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,3 @@
1
- if !ENV["AWS_ACCESS_KEY_ID"] || !ENV["AWS_SECRET_KEY"]
2
- puts "\n\n\e[32m**********************************************************************************************"
3
- puts "Please set \e[0;1mAWS_ACCESS_KEY_ID\e[32m and \e[0;1mAWS_SECRET_KEY\e[32m in your environment to run the tests."
4
- puts ""
5
- puts "These keys can be found on your AWS Account > Security Credentials page, at the following URL:"
6
- puts ""
7
- puts " \e[0;1mhttps://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key"
8
- puts ""
9
- bourne = !ENV['SHELL'].nil? && ENV['SHELL'] =~ /(bash|ksh|zsh)/
10
- puts "\e[0mbash, zsh, ksh: #{"\e[35;1mThis is you!\e[0m" if bourne}"
11
- puts " export AWS_ACCESS_KEY_ID=01234"
12
- puts " export AWS_SECRET_KEY=56789"
13
- puts ""
14
- puts "\e[0mcsh, tcsh: #{"\e[35;1mThis is you!\e[0m" unless bourne}"
15
- puts " setenv AWS_ACCESS_KEY_ID 01234"
16
- puts " setenv AWS_SECRET_KEY 56789"
17
- puts ""
18
- puts "\e[32m**********************************************************************************************\n\n\n"
19
- exit
20
- end
21
-
22
- AWS_ACCESS_KEY_ID = ENV["AWS_ACCESS_KEY_ID"]
23
- AWS_SECRET_KEY = ENV["AWS_SECRET_KEY"]
24
-
25
1
  require 'rubygems'
26
2
  require 'bundler/setup'
27
3
 
@@ -33,11 +9,48 @@ ENV["RAILS_ENV"] ||= 'test'
33
9
 
34
10
  $:.unshift File.dirname(__FILE__)
35
11
 
36
- VCR.config do |c|
12
+ uri_regexp_matcher = lambda do |real_request, recorded_request|
13
+ real_request.uri =~ recorded_request.uri
14
+ end
15
+
16
+ VCR.configure do |c|
37
17
  c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
38
- c.stub_with :webmock
18
+ c.hook_into :webmock
19
+ c.default_cassette_options = {
20
+ :match_requests_on => [:method, uri_regexp_matcher]
21
+ }
22
+ c.before_http_request do |_|
23
+ require_aws_credentials unless VCR.current_cassette.record_mode == :none
24
+ end
39
25
  end
40
26
 
41
27
  RSpec.configure do |c|
42
28
  c.extend VCR::RSpec::Macros
29
+ end
30
+
31
+ AWS_ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] ||= 'default'
32
+ AWS_SECRET_KEY = ENV['AWS_SECRET_KEY'] ||= 'default'
33
+
34
+ def require_aws_credentials
35
+ if AWS_ACCESS_KEY_ID == 'default' && AWS_SECRET_KEY == 'default'
36
+ puts "\n\e[33m**********************************************************************************************"
37
+ puts "\e[32mIf you want to record new cassettes, you'll need to provide a set of AWS credentials so"
38
+ puts "Elasticity can interact with EMR. These keys can be found on your AWS Account > Security"
39
+ puts "Credentials page, at the following URL:"
40
+ puts ""
41
+ puts " \e[0;1mhttps://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key"
42
+ puts ""
43
+ bourne = !ENV['SHELL'].nil? && ENV['SHELL'] =~ /(bash|ksh|zsh)/
44
+ if bourne
45
+ puts "\e[32mbash, zsh, ksh:"
46
+ puts " export AWS_ACCESS_KEY_ID=01234"
47
+ puts " export AWS_SECRET_KEY=56789"
48
+ else
49
+ puts "\e[32mcsh, tcsh:"
50
+ puts " setenv AWS_ACCESS_KEY_ID 01234"
51
+ puts " setenv AWS_SECRET_KEY 56789"
52
+ end
53
+ puts "\e[33m**********************************************************************************************\n"
54
+ exit
55
+ end
43
56
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticity
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 1
10
- version: 1.4.1
5
+ version: "1.5"
11
6
  platform: ruby
12
7
  authors:
13
8
  - Robert Slifka
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-12-17 00:00:00 -08:00
13
+ date: 2012-03-05 00:00:00 -08:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,9 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
24
  version: "0"
33
25
  type: :runtime
34
26
  version_requirements: *id001
@@ -40,117 +32,54 @@ dependencies:
40
32
  requirements:
41
33
  - - ">="
42
34
  - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
35
  version: "0"
47
36
  type: :runtime
48
37
  version_requirements: *id002
49
38
  - !ruby/object:Gem::Dependency
50
- name: autotest-fsevent
39
+ name: rake
51
40
  prerelease: false
52
41
  requirement: &id003 !ruby/object:Gem::Requirement
53
42
  none: false
54
43
  requirements:
55
44
  - - ">="
56
45
  - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
46
  version: "0"
61
47
  type: :development
62
48
  version_requirements: *id003
63
49
  - !ruby/object:Gem::Dependency
64
- name: autotest-growl
50
+ name: rspec
65
51
  prerelease: false
66
52
  requirement: &id004 !ruby/object:Gem::Requirement
67
53
  none: false
68
54
  requirements:
69
55
  - - ">="
70
56
  - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
57
+ version: 2.8.0
75
58
  type: :development
76
59
  version_requirements: *id004
77
60
  - !ruby/object:Gem::Dependency
78
- name: rake
61
+ name: vcr
79
62
  prerelease: false
80
63
  requirement: &id005 !ruby/object:Gem::Requirement
81
64
  none: false
82
65
  requirements:
83
- - - ">="
66
+ - - ~>
84
67
  - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
68
+ version: "2.0"
89
69
  type: :development
90
70
  version_requirements: *id005
91
71
  - !ruby/object:Gem::Dependency
92
- name: rspec
72
+ name: webmock
93
73
  prerelease: false
94
74
  requirement: &id006 !ruby/object:Gem::Requirement
95
75
  none: false
96
76
  requirements:
97
- - - ">="
77
+ - - ~>
98
78
  - !ruby/object:Gem::Version
99
- hash: 27
100
- segments:
101
- - 2
102
- - 5
103
- - 0
104
- version: 2.5.0
79
+ version: 1.8.0
105
80
  type: :development
106
81
  version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: vcr
109
- prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
111
- none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 1
116
- segments:
117
- - 1
118
- - 5
119
- - 1
120
- version: 1.5.1
121
- type: :development
122
- version_requirements: *id007
123
- - !ruby/object:Gem::Dependency
124
- name: webmock
125
- prerelease: false
126
- requirement: &id008 !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 11
132
- segments:
133
- - 1
134
- - 6
135
- - 2
136
- version: 1.6.2
137
- type: :development
138
- version_requirements: *id008
139
- - !ruby/object:Gem::Dependency
140
- name: ZenTest
141
- prerelease: false
142
- requirement: &id009 !ruby/object:Gem::Requirement
143
- none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
151
- type: :development
152
- version_requirements: *id009
153
- description: Programmatic access to Amazon's Elastic Map Reduce service.
82
+ description: Programmatic access to Amazon's Elastic Map Reduce service, driven by the Sharethrough team's requirements for belting out EMR jobs.
154
83
  email:
155
84
  executables: []
156
85
 
@@ -163,6 +92,7 @@ files:
163
92
  - .gitignore
164
93
  - .rspec
165
94
  - .rvmrc
95
+ - .travis.yml
166
96
  - Gemfile
167
97
  - HISTORY.md
168
98
  - LICENSE
@@ -215,23 +145,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
145
  requirements:
216
146
  - - ">="
217
147
  - !ruby/object:Gem::Version
218
- hash: 3
219
- segments:
220
- - 0
221
148
  version: "0"
222
149
  required_rubygems_version: !ruby/object:Gem::Requirement
223
150
  none: false
224
151
  requirements:
225
152
  - - ">="
226
153
  - !ruby/object:Gem::Version
227
- hash: 3
228
- segments:
229
- - 0
230
154
  version: "0"
231
155
  requirements: []
232
156
 
233
157
  rubyforge_project:
234
- rubygems_version: 1.4.1
158
+ rubygems_version: 1.5.2
235
159
  signing_key:
236
160
  specification_version: 3
237
161
  summary: Programmatic access to Amazon's Elastic Map Reduce service.