heroku_hatchet 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/hatchet.gemspec +1 -0
- data/lib/hatchet/app.rb +15 -2
- data/lib/hatchet/reaper.rb +48 -0
- data/lib/hatchet/version.rb +1 -1
- data/lib/hatchet.rb +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d675d2785c4891e158609756788aefc993eb2951
|
4
|
+
data.tar.gz: 79d6dbb02bbd78dbe01e702c8133740e83512f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e15797cf063d2396adf07b95f58b49efa8a95a780be8c86b7afe2b7ec396b2ae621c30f50305929c018fa7be1d20ac30c54d38c7dd5f2f59ff621be2c00aa6
|
7
|
+
data.tar.gz: cbb5d2103970d491d63b9c2f5e9a0c090b9256040ae2e37dccc5560f5cb126bae491965a5166e161f7a6e137059a022c0559256758cd71fd9c855a8b0b01dcc3
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Hatchet is a an integration testing library for developing Heroku buildpacks.
|
6
6
|
|
7
|
-
[![Build Status](https://travis-ci.org/heroku/hatchet.
|
7
|
+
[![Build Status](https://travis-ci.org/heroku/hatchet.svg?branch=master)](https://travis-ci.org/heroku/hatchet)
|
8
8
|
|
9
9
|
## Install
|
10
10
|
|
data/hatchet.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_dependency "threaded", "~> 0"
|
29
29
|
|
30
30
|
|
31
|
+
gem.add_development_dependency "minitest", "~> 4.0"
|
31
32
|
gem.add_development_dependency "rake", "~> 10"
|
32
33
|
gem.add_development_dependency "mocha", "~> 1"
|
33
34
|
gem.add_development_dependency "parallel_tests", "~> 0"
|
data/lib/hatchet/app.rb
CHANGED
@@ -15,10 +15,11 @@ module Hatchet
|
|
15
15
|
def initialize(repo_name, options = {})
|
16
16
|
@repo_name = repo_name
|
17
17
|
@directory = config.path_for_name(@repo_name)
|
18
|
-
@name = options[:name] || "
|
18
|
+
@name = options[:name] || "hatchet-t-#{SecureRandom.hex(10)}"
|
19
19
|
@debug = options[:debug] || options[:debugging]
|
20
20
|
@allow_failure = options[:allow_failure] || false
|
21
21
|
@labs = ([] << options[:labs]).flatten.compact
|
22
|
+
@reaper = Reaper.new(heroku)
|
22
23
|
end
|
23
24
|
|
24
25
|
# config is read only, should be threadsafe
|
@@ -95,9 +96,21 @@ module Hatchet
|
|
95
96
|
!heroku.get_ps(name).body.detect {|ps| ps["process"].include?("web") }.nil?
|
96
97
|
end
|
97
98
|
|
99
|
+
def create_app
|
100
|
+
3.times.retry do
|
101
|
+
begin
|
102
|
+
heroku.post_app(name: name)
|
103
|
+
rescue Heroku::API::Errors::RequestFailed => e
|
104
|
+
@reaper.cycle if e.message.match(/app limit/)
|
105
|
+
raise e
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
98
110
|
# creates a new heroku app via the API
|
99
111
|
def setup!
|
100
112
|
return self if @app_is_setup
|
113
|
+
puts "Hatchet setup: #{name.inspect} for #{repo_name.inspect}"
|
101
114
|
heroku.post_app(name: name)
|
102
115
|
set_labs!
|
103
116
|
@app_is_setup = true
|
@@ -114,7 +127,7 @@ module Hatchet
|
|
114
127
|
puts "Debugging App:#{name}"
|
115
128
|
return false
|
116
129
|
end
|
117
|
-
|
130
|
+
@reaper.cycle
|
118
131
|
end
|
119
132
|
|
120
133
|
def in_directory(directory = self.directory)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Hatchet
|
2
|
+
# Hatchet apps are useful after the tests run for debugging purposes
|
3
|
+
# the reaper is designed to allow the most recent apps to stay alive
|
4
|
+
# while keeping the total number of apps under the global Heroku limit.
|
5
|
+
# Any time you're worried about hitting the limit call @reaper.cycle
|
6
|
+
#
|
7
|
+
class Reaper
|
8
|
+
HEROKU_APP_LIMIT = Integer(ENV["HEROKU_APP_LIMIT"] || 100) # the number of apps heroku allows you to keep
|
9
|
+
HATCHET_APP_LIMT = Integer(ENV["HATCHET_APP_LIMIT"] || 20) # the number of apps hatchet keeps around
|
10
|
+
DEFAULT_REGEX = /^hatchet-t-/
|
11
|
+
attr_accessor :apps
|
12
|
+
|
13
|
+
|
14
|
+
def initialize(heroku, regex = DEFAULT_REGEX)
|
15
|
+
@heroku = heroku
|
16
|
+
@regex = regex
|
17
|
+
end
|
18
|
+
|
19
|
+
# Ascending order, oldest is last
|
20
|
+
def get_apps
|
21
|
+
@apps = @heroku.get_apps.body.sort_by {|app| DateTime.parse(app["created_at"]) }.reverse
|
22
|
+
@hatchet_apps = @apps.select {|app| app["name"].match(@regex) }
|
23
|
+
@apps
|
24
|
+
end
|
25
|
+
|
26
|
+
def cycle(apps = get_apps)
|
27
|
+
if over_limit?
|
28
|
+
destroy_oldest
|
29
|
+
cycle
|
30
|
+
else
|
31
|
+
# do nothing
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def destroy_oldest
|
36
|
+
oldest_name = @hatchet_apps.pop["name"]
|
37
|
+
puts "Destroying #{oldest_name.inspect}. Hatchet app limit: #{HATCHET_APP_LIMT}"
|
38
|
+
@heroku.delete_app(oldest_name)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def over_limit?
|
44
|
+
@apps.count > HEROKU_APP_LIMIT || @hatchet_apps.count > HATCHET_APP_LIMT
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
data/lib/hatchet/version.rb
CHANGED
data/lib/hatchet.rb
CHANGED
@@ -11,7 +11,7 @@ require 'stringio'
|
|
11
11
|
|
12
12
|
|
13
13
|
module Hatchet
|
14
|
-
RETRIES
|
14
|
+
RETRIES = Integer(ENV['HATCHET_RETRIES'] || 1)
|
15
15
|
|
16
16
|
class App
|
17
17
|
end
|
@@ -37,6 +37,7 @@ module Hatchet
|
|
37
37
|
end
|
38
38
|
|
39
39
|
require 'hatchet/version'
|
40
|
+
require 'hatchet/reaper'
|
40
41
|
require 'hatchet/app'
|
41
42
|
require 'hatchet/anvil_app'
|
42
43
|
require 'hatchet/git_app'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_hatchet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heroku-api
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: minitest
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rake
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,6 +201,7 @@ files:
|
|
187
201
|
- lib/hatchet/app.rb
|
188
202
|
- lib/hatchet/config.rb
|
189
203
|
- lib/hatchet/git_app.rb
|
204
|
+
- lib/hatchet/reaper.rb
|
190
205
|
- lib/hatchet/tasks.rb
|
191
206
|
- lib/hatchet/version.rb
|
192
207
|
- test/fixtures/buildpacks/heroku-buildpack-ruby/.gitignore
|
@@ -256,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
271
|
version: '0'
|
257
272
|
requirements: []
|
258
273
|
rubyforge_project:
|
259
|
-
rubygems_version: 2.2.
|
274
|
+
rubygems_version: 2.2.2
|
260
275
|
signing_key:
|
261
276
|
specification_version: 4
|
262
277
|
summary: Hatchet is a an integration testing library for developing Heroku buildpacks.
|
@@ -308,4 +323,3 @@ test_files:
|
|
308
323
|
- test/hatchet/multi_cmd_runner_test.rb
|
309
324
|
- test/hatchet/runner_test.rb
|
310
325
|
- test/test_helper.rb
|
311
|
-
has_rdoc:
|