contained_mr 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c256acd59c0cb4cafca0aa814733eba82b076b06
4
- data.tar.gz: 86164b32282388fa75d53310f62437082e32d801
3
+ metadata.gz: 63dd405ddd7f6926540118a53fae49b4e68eae85
4
+ data.tar.gz: 5f60e7e07994d45710b7c1a11149a36e641e6e97
5
5
  SHA512:
6
- metadata.gz: 3b4e879f960930faf614cff7398e380eb52fe0e2fafc254e2fa7e2fc6832b3746fa61425ed72fcd782fdee9b3d2d58bd439f3b0a056861f404b0b5daba0b32b7
7
- data.tar.gz: dfd206cfcf2ddc73b3747659131363cf787dfda94444b45a62235629dcad23e404beed38609acefdaafab7e23f36237007bf2e7828580dad890428cd25638b45
6
+ metadata.gz: 786419170b2c4b3d2b35d80f3897ace4503f1757e0fe3682a62fcca65d1e1de46f7c2fe721885dec65ea06c7e79ec62d4a70a352812ce9008215ee8ce735b81c
7
+ data.tar.gz: 272b5127d2bb5efec7595086b299fb25458523d37d93828b696e2565ae802d9809224be0fd489e1627c92183439d9fd6ed52de0acc27fb2ac9d7b5bed6a6c943
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/contained_mr.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: contained_mr 0.1.1 ruby lib
5
+ # stub: contained_mr 0.1.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "contained_mr"
9
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/contained_mr/runner.rb",
34
34
  "lib/contained_mr/template.rb",
35
35
  "test/helper.rb",
36
+ "test/test_cleaner.rb",
36
37
  "test/test_job.rb",
37
38
  "test/test_runner.rb",
38
39
  "test/test_template.rb",
@@ -32,9 +32,13 @@ class ContainedMr::Cleaner
32
32
  tag_prefix = "#{@name_prefix}/"
33
33
  images = Docker::Image.all
34
34
  images.each do |image|
35
- image_tags = image.info['RepoTags'] || []
36
- next unless image_tags.any? { |tag| tag.start_with? tag_prefix }
37
- image.delete
35
+ next unless image_tags = image.info['RepoTags']
36
+ image_tags.each do |image_tag|
37
+ next unless image_tag.start_with? tag_prefix
38
+ # HACK(pwnall): Trick docker-api into issuing a DELETE request by tag.
39
+ tag_image = Docker::Image.new Docker.connection, 'id' => image_tag
40
+ tag_image.delete
41
+ end
38
42
  end
39
43
  end
40
44
  private :destroy_all_images!
@@ -47,13 +47,15 @@ class ContainedMr::Job
47
47
  end
48
48
 
49
49
  unless @mapper_image_id.nil?
50
- image = Docker::Image.get @mapper_image_id
50
+ # HACK(pwnall): Trick docker-api into issuing a DELETE request by tag.
51
+ image = Docker::Image.new Docker.connection, 'id' => mapper_image_tag
51
52
  image.remove
52
53
  @mapper_image_id = nil
53
54
  end
54
55
 
55
56
  unless @reducer_image_id.nil?
56
- image = Docker::Image.get @reducer_image_id
57
+ # HACK(pwnall): Trick docker-api into issuing a DELETE request by tag.
58
+ image = Docker::Image.new Docker.connection, 'id' => reducer_image_tag
57
59
  image.remove
58
60
  @reducer_image_id = nil
59
61
  end
@@ -33,7 +33,8 @@ class ContainedMr::Template
33
33
  # This removes the template's base Docker image.
34
34
  def destroy!
35
35
  unless @image_id.nil?
36
- image = Docker::Image.get @image_id
36
+ # HACK(pwnall): Trick docker-api into issuing a DELETE request by tag.
37
+ image = Docker::Image.new Docker.connection, 'id' => image_tag
37
38
  image.remove
38
39
  @image_id = nil
39
40
  end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ class TestCleaner < MiniTest::Test
4
+ def setup
5
+ @template = ContainedMr::Template.new 'contained_mrtests', 'hello',
6
+ StringIO.new(File.binread('testdata/hello.zip'))
7
+ @job = ContainedMr::Job.new @template, 'testjob',
8
+ JSON.load(File.read('testdata/job.hello'))
9
+ @job.build_mapper_image File.read('testdata/input.hello')
10
+
11
+ @cleaner = ContainedMr::Cleaner.new 'contained_mrtests'
12
+ end
13
+
14
+ def test_destroy_all
15
+ @cleaner.destroy_all!
16
+ assert_raises Docker::Error::NotFoundError do
17
+ Docker::Image.get @job.mapper_image_tag
18
+ end
19
+ assert_raises Docker::Error::NotFoundError do
20
+ Docker::Image.get @template.image_tag
21
+ end
22
+ end
23
+
24
+ def test_destroy_all_with_duplicates
25
+ template2 = ContainedMr::Template.new 'contained_mrtests', 'hello2',
26
+ StringIO.new(File.binread('testdata/hello.zip'))
27
+ job2 = ContainedMr::Job.new template2, 'testjob2',
28
+ JSON.load(File.read('testdata/job.hello'))
29
+ job2.build_mapper_image File.read('testdata/input.hello')
30
+ @cleaner.destroy_all!
31
+ assert_raises Docker::Error::NotFoundError do
32
+ Docker::Image.get job2.mapper_image_tag
33
+ end
34
+ assert_raises Docker::Error::NotFoundError do
35
+ Docker::Image.get template2.image_tag
36
+ end
37
+ assert_raises Docker::Error::NotFoundError do
38
+ Docker::Image.get @job.mapper_image_tag
39
+ end
40
+ assert_raises Docker::Error::NotFoundError do
41
+ Docker::Image.get @template.image_tag
42
+ end
43
+ end
44
+ end
data/test/test_job.rb CHANGED
@@ -5,7 +5,7 @@ class TestJob < MiniTest::Test
5
5
  @template = ContainedMr::Template.new 'contained_mrtests', 'hello',
6
6
  StringIO.new(File.binread('testdata/hello.zip'))
7
7
  @job = ContainedMr::Job.new @template, 'testjob',
8
- JSON.load(File.read('testdata/job.hello'))
8
+ JSON.load(File.read('testdata/job.hello'))
9
9
  end
10
10
 
11
11
  def teardown
@@ -145,7 +145,42 @@ class TestJob < MiniTest::Test
145
145
  assert_raises Docker::Error::NotFoundError do
146
146
  Docker::Image.get @job.mapper_image_tag
147
147
  end
148
+ assert_raises Docker::Error::NotFoundError do
149
+ Docker::Image.get @job.reducer_image_tag
150
+ end
151
+ end
152
+
153
+ def test_destroy_with_two_jobs
154
+ @job.build_mapper_image File.read('testdata/input.hello')
155
+ 1.upto(3) { |i| @job.run_mapper i }
156
+ @job.build_reducer_image
157
+
158
+ job2 = ContainedMr::Job.new @template, 'testjob2',
159
+ JSON.load(File.read('testdata/job.hello'))
160
+ job2.build_mapper_image File.read('testdata/input.hello')
161
+ 1.upto(3) { |i| job2.run_mapper i }
162
+ job2.build_reducer_image
163
+
164
+ job2.destroy!
165
+
166
+ assert_raises Docker::Error::NotFoundError do
167
+ Docker::Image.get job2.mapper_image_tag
168
+ end
169
+ assert_raises Docker::Error::NotFoundError do
170
+ Docker::Image.get job2.reducer_image_tag
171
+ end
172
+
173
+ image = Docker::Image.get @job.mapper_image_tag
174
+ assert image, "destroy! wiped the other job's mapper image"
175
+
176
+ image = Docker::Image.get @job.reducer_image_tag
177
+ assert image, "destroy! wiped the other job's reducer image"
178
+
179
+ @job.destroy!
148
180
 
181
+ assert_raises Docker::Error::NotFoundError do
182
+ Docker::Image.get @job.mapper_image_tag
183
+ end
149
184
  assert_raises Docker::Error::NotFoundError do
150
185
  Docker::Image.get @job.reducer_image_tag
151
186
  end
data/test/test_runner.rb CHANGED
@@ -5,7 +5,7 @@ class TestRunner < MiniTest::Test
5
5
  @template = ContainedMr::Template.new 'contained_mrtests', 'hello',
6
6
  StringIO.new(File.binread('testdata/hello.zip'))
7
7
  @job = ContainedMr::Job.new @template, 'testjob',
8
- JSON.load(File.read('testdata/job.hello'))
8
+ JSON.load(File.read('testdata/job.hello'))
9
9
  @job.build_mapper_image File.read('testdata/input.hello')
10
10
  end
11
11
 
@@ -16,7 +16,7 @@ class TestRunner < MiniTest::Test
16
16
 
17
17
  def test_perform_happy_path
18
18
  runner = ContainedMr::Runner.new @job.mapper_container_options(2), 2.5,
19
- @template.mapper_output_path
19
+ @template.mapper_output_path
20
20
  runner.perform
21
21
 
22
22
  assert_equal nil, runner.container_id, 'container still running'
@@ -31,7 +31,7 @@ class TestRunner < MiniTest::Test
31
31
 
32
32
  def test_perform_exit_code
33
33
  runner = ContainedMr::Runner.new @job.mapper_container_options(3), 2.5,
34
- @template.mapper_output_path
34
+ @template.mapper_output_path
35
35
  runner.perform
36
36
 
37
37
  assert_equal nil, runner.container_id, 'container still running'
@@ -42,7 +42,7 @@ class TestRunner < MiniTest::Test
42
42
 
43
43
  def test_perform_timeout
44
44
  runner = ContainedMr::Runner.new @job.mapper_container_options(1), 2.5,
45
- @template.mapper_output_path
45
+ @template.mapper_output_path
46
46
  runner.perform
47
47
 
48
48
  assert_equal nil, runner.container_id, 'container still running'
@@ -47,4 +47,22 @@ class TestTemplate < MiniTest::Test
47
47
  Docker::Image.get @template.image_tag
48
48
  end
49
49
  end
50
+
51
+ def test_destory_with_two_templates
52
+ template2 = ContainedMr::Template.new 'contained_mrtests', 'hello2',
53
+ StringIO.new(File.binread('testdata/hello.zip'))
54
+
55
+ template2.destroy!
56
+ assert_raises Docker::Error::NotFoundError do
57
+ Docker::Image.get template2.image_tag
58
+ end
59
+
60
+ image = Docker::Image.get @template.image_tag
61
+ assert image, "destroy! wiped the other template's image"
62
+
63
+ @template.destroy!
64
+ assert_raises Docker::Error::NotFoundError do
65
+ Docker::Image.get @template.image_tag
66
+ end
67
+ end
50
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contained_mr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -144,6 +144,7 @@ files:
144
144
  - lib/contained_mr/runner.rb
145
145
  - lib/contained_mr/template.rb
146
146
  - test/helper.rb
147
+ - test/test_cleaner.rb
147
148
  - test/test_job.rb
148
149
  - test/test_runner.rb
149
150
  - test/test_template.rb