ey_enzyme 0.9.44 → 0.9.45.ruby19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ey_enzyme/api.rb +2 -0
- data/lib/ey_enzyme/cookbook_set.rb +1 -1
- data/lib/ey_enzyme/version.rb +1 -1
- data/spec/api_spec.rb +44 -0
- data/spec/log_upload_error_notify_spec.rb +45 -0
- data/spec/logging_spec.rb +9 -0
- data/spec/retry_report_and_notify_success_spec.rb +62 -0
- data/spec/spec_helper.rb +9 -0
- metadata +55 -25
data/lib/ey_enzyme/api.rb
CHANGED
@@ -73,7 +73,7 @@ module EY::Enzyme
|
|
73
73
|
Zlib::GzipWriter.open(file) { |io| io << File.read(@chef_log) }
|
74
74
|
|
75
75
|
unless @api.upload(@name, File.read(file))
|
76
|
-
@logger.error "Failed to upload #{
|
76
|
+
@logger.error "Failed to upload #{@name} log. Reporting error"
|
77
77
|
raise UploadError, "failed to upload #{@name} log"
|
78
78
|
end
|
79
79
|
rescue UploadError => error
|
data/lib/ey_enzyme/version.rb
CHANGED
data/spec/api_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe "enzyme API" do
|
5
|
+
|
6
|
+
before { FakeWeb.allow_net_connect = false }
|
7
|
+
after { FakeWeb.allow_net_connect = true }
|
8
|
+
|
9
|
+
def new_api(*args)
|
10
|
+
old_stderr = $stderr
|
11
|
+
$stderr = StringIO.new
|
12
|
+
api = EY::Enzyme::API.new(*args)
|
13
|
+
$stderr = old_stderr
|
14
|
+
api
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with an EY::Enzyme::API" do
|
18
|
+
before do
|
19
|
+
@enzyme_api = new_api("https://cloud.engineyard.com/dracul",
|
20
|
+
"i-d8babcb5",
|
21
|
+
"8c40f5769f8987489ec66a3abc944123fc0f043c",
|
22
|
+
File.dirname(__FILE__) + '/../tmp/test.log')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to post errors" do
|
26
|
+
FakeWeb.register_uri(
|
27
|
+
:post,
|
28
|
+
"https://cloud.engineyard.com/dracul/error",
|
29
|
+
:body => {}.to_json
|
30
|
+
)
|
31
|
+
|
32
|
+
begin
|
33
|
+
raise "we fail"
|
34
|
+
rescue => e
|
35
|
+
#WE need to do this because the exception is expected to have a backtrace
|
36
|
+
@enzyme_api.notify_error("user", e)
|
37
|
+
end
|
38
|
+
|
39
|
+
FakeWeb.should have_requested(:post, "https://cloud.engineyard.com/dracul/error")
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "EY::Enzyme::CookbookSet#upload" do
|
4
|
+
before do
|
5
|
+
FakeWeb.clean_registry
|
6
|
+
@api_url = "https://cloud.engineyard.example.com/dracul"
|
7
|
+
|
8
|
+
fake_cheflog_location = File.expand_path(File.dirname(__FILE__) + '/../tmp/clitestlog')
|
9
|
+
logfile_location = File.expand_path(File.dirname(__FILE__) + '/../tmp/clitestlog')
|
10
|
+
@cookbooks = EY::Enzyme::CLI.new(:logfile => logfile_location, :api => @api_url).main_cookbooks
|
11
|
+
|
12
|
+
#HAX: (might as well be a mock)
|
13
|
+
@cookbooks.instance_eval {
|
14
|
+
@chef_log = fake_cheflog_location
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "posts the log file to /store" do
|
19
|
+
FakeWeb.register_uri(
|
20
|
+
:post,
|
21
|
+
@api_url + "/store",
|
22
|
+
:body => {}.to_json
|
23
|
+
)
|
24
|
+
@cookbooks.upload
|
25
|
+
end
|
26
|
+
|
27
|
+
it "posts an error when attempt to upload logs returns 500" do
|
28
|
+
FakeWeb.register_uri(
|
29
|
+
:post,
|
30
|
+
@api_url + "/store",
|
31
|
+
:body => {}.to_json,
|
32
|
+
:status => ["500", "Internal Server Error"]
|
33
|
+
)
|
34
|
+
FakeWeb.register_uri(
|
35
|
+
:post,
|
36
|
+
@api_url + "/error",
|
37
|
+
:body => {}.to_json
|
38
|
+
)
|
39
|
+
@cookbooks.upload
|
40
|
+
posted = JSON.parse(FakeWeb.last_request.body.to_s)
|
41
|
+
posted["where_failed"].should == "logupload"
|
42
|
+
posted["message"].should == "failed to upload main log"
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "EY::Enzyme::API" do
|
4
|
+
before do
|
5
|
+
FakeWeb.clean_registry
|
6
|
+
@api_url = "https://cloud.engineyard.example.com/dracul"
|
7
|
+
|
8
|
+
logfile_location = File.expand_path(File.dirname(__FILE__) + '/../tmp/clitestlog')
|
9
|
+
@cli = EY::Enzyme::CLI.new(:logfile => logfile_location, :api => @api_url)
|
10
|
+
@api = @cli.instance_eval{ @api }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "notify_success" do
|
14
|
+
it "can notify success" do
|
15
|
+
FakeWeb.register_uri(
|
16
|
+
:post,
|
17
|
+
@api_url + "/completed",
|
18
|
+
:body => {}.to_json
|
19
|
+
)
|
20
|
+
@api.notify_success
|
21
|
+
end
|
22
|
+
|
23
|
+
it "retries on 502" do
|
24
|
+
FakeWeb.register_uri(
|
25
|
+
:post,
|
26
|
+
@api_url + "/completed",
|
27
|
+
[
|
28
|
+
{:body => {}.to_json, :status => ["502", "Bad Gateway"]},
|
29
|
+
{:body => {}.to_json, :status => ["200", "Success"]},
|
30
|
+
]
|
31
|
+
)
|
32
|
+
lambda{ @api.notify_success }.should_not raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "report" do
|
37
|
+
it "can report chef statuses" do
|
38
|
+
FakeWeb.register_uri(
|
39
|
+
:post,
|
40
|
+
@api_url + "/report",
|
41
|
+
:body => {}.to_json
|
42
|
+
)
|
43
|
+
@api.report 'report some status'
|
44
|
+
|
45
|
+
posted = JSON.parse(FakeWeb.last_request.body.to_s)
|
46
|
+
posted["message"].should == "report some status"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "doesn't raise or retry on 502" do
|
50
|
+
FakeWeb.register_uri(
|
51
|
+
:post,
|
52
|
+
@api_url + "/report",
|
53
|
+
[
|
54
|
+
{:body => {}.to_json, :status => ["502", "Bad Gateway"]},
|
55
|
+
{:body => lambda{ raise "no!" }}, #bad bad hax, doesn't work the way you would hope
|
56
|
+
]
|
57
|
+
)
|
58
|
+
lambda{ @api.report 'some status update' }.should_not raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'ey_enzyme'
|
4
|
+
require 'fakeweb'
|
5
|
+
require 'fakeweb_matcher'
|
6
|
+
|
7
|
+
tmpdir = File.expand_path(File.dirname(__FILE__) + '/../tmp')
|
8
|
+
FileUtils.mkdir_p tmpdir
|
9
|
+
FileUtils.rm Dir.glob("#{tmpdir}/*")
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_enzyme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -483342322
|
5
|
+
prerelease: 7
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
|
9
|
+
- 45
|
10
|
+
- ruby
|
11
|
+
- 19
|
12
|
+
version: 0.9.45.ruby19
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Engine Yard Inc.
|
@@ -53,15 +55,16 @@ dependencies:
|
|
53
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
56
|
none: false
|
55
57
|
requirements:
|
56
|
-
- - "
|
58
|
+
- - ">="
|
57
59
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
60
|
+
hash: -3806225206
|
59
61
|
segments:
|
60
62
|
- 0
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
|
63
|
+
- 10
|
64
|
+
- 8
|
65
|
+
- patch
|
66
|
+
- 3
|
67
|
+
version: 0.10.8.patch3
|
65
68
|
type: :runtime
|
66
69
|
version_requirements: *id003
|
67
70
|
- !ruby/object:Gem::Dependency
|
@@ -81,9 +84,25 @@ dependencies:
|
|
81
84
|
type: :runtime
|
82
85
|
version_requirements: *id004
|
83
86
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
87
|
+
name: logglier
|
85
88
|
prerelease: false
|
86
89
|
requirement: &id005 !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 29
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
- 2
|
98
|
+
- 5
|
99
|
+
version: 0.2.5
|
100
|
+
type: :runtime
|
101
|
+
version_requirements: *id005
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: rake
|
104
|
+
prerelease: false
|
105
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
87
106
|
none: false
|
88
107
|
requirements:
|
89
108
|
- - ">="
|
@@ -93,11 +112,11 @@ dependencies:
|
|
93
112
|
- 0
|
94
113
|
version: "0"
|
95
114
|
type: :development
|
96
|
-
version_requirements: *
|
115
|
+
version_requirements: *id006
|
97
116
|
- !ruby/object:Gem::Dependency
|
98
117
|
name: rspec
|
99
118
|
prerelease: false
|
100
|
-
requirement: &
|
119
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
101
120
|
none: false
|
102
121
|
requirements:
|
103
122
|
- - ~>
|
@@ -108,11 +127,11 @@ dependencies:
|
|
108
127
|
- 2
|
109
128
|
version: "1.2"
|
110
129
|
type: :development
|
111
|
-
version_requirements: *
|
130
|
+
version_requirements: *id007
|
112
131
|
- !ruby/object:Gem::Dependency
|
113
132
|
name: fakeweb
|
114
133
|
prerelease: false
|
115
|
-
requirement: &
|
134
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
116
135
|
none: false
|
117
136
|
requirements:
|
118
137
|
- - ">="
|
@@ -122,11 +141,11 @@ dependencies:
|
|
122
141
|
- 0
|
123
142
|
version: "0"
|
124
143
|
type: :development
|
125
|
-
version_requirements: *
|
144
|
+
version_requirements: *id008
|
126
145
|
- !ruby/object:Gem::Dependency
|
127
146
|
name: fakeweb-matcher
|
128
147
|
prerelease: false
|
129
|
-
requirement: &
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
130
149
|
none: false
|
131
150
|
requirements:
|
132
151
|
- - ">="
|
@@ -136,7 +155,7 @@ dependencies:
|
|
136
155
|
- 0
|
137
156
|
version: "0"
|
138
157
|
type: :development
|
139
|
-
version_requirements: *
|
158
|
+
version_requirements: *id009
|
140
159
|
description: Gem for kicking off chef recipes
|
141
160
|
email: ninja@engineyard.com
|
142
161
|
executables:
|
@@ -156,6 +175,11 @@ files:
|
|
156
175
|
- lib/ey_enzyme.rb
|
157
176
|
- bin/ey-enzyme
|
158
177
|
- bin/ey-recipes
|
178
|
+
- spec/api_spec.rb
|
179
|
+
- spec/log_upload_error_notify_spec.rb
|
180
|
+
- spec/logging_spec.rb
|
181
|
+
- spec/retry_report_and_notify_success_spec.rb
|
182
|
+
- spec/spec_helper.rb
|
159
183
|
homepage: http://github.com/engineyard/ey_enzyme
|
160
184
|
licenses: []
|
161
185
|
|
@@ -176,18 +200,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
201
|
none: false
|
178
202
|
requirements:
|
179
|
-
- - "
|
203
|
+
- - ">"
|
180
204
|
- !ruby/object:Gem::Version
|
181
|
-
hash:
|
205
|
+
hash: 25
|
182
206
|
segments:
|
183
|
-
-
|
184
|
-
|
207
|
+
- 1
|
208
|
+
- 3
|
209
|
+
- 1
|
210
|
+
version: 1.3.1
|
185
211
|
requirements: []
|
186
212
|
|
187
213
|
rubyforge_project:
|
188
|
-
rubygems_version: 1.8.
|
214
|
+
rubygems_version: 1.8.6
|
189
215
|
signing_key:
|
190
216
|
specification_version: 3
|
191
217
|
summary: Gem for kicking off chef recipes
|
192
|
-
test_files:
|
193
|
-
|
218
|
+
test_files:
|
219
|
+
- spec/api_spec.rb
|
220
|
+
- spec/log_upload_error_notify_spec.rb
|
221
|
+
- spec/logging_spec.rb
|
222
|
+
- spec/retry_report_and_notify_success_spec.rb
|
223
|
+
- spec/spec_helper.rb
|