contained_mr 0.3.1 → 0.3.2
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.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/VERSION +1 -1
- data/contained_mr.gemspec +4 -3
- data/lib/contained_mr/job.rb +4 -2
- data/lib/contained_mr/template.rb +1 -1
- data/test/helper.rb +11 -9
- data/test/test_job.rb +31 -0
- data/test/test_template.rb +13 -0
- data/testdata/invalid/Dockerfile +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440ccef564b310bd2bc7752380b7d97861ab2020
|
4
|
+
data.tar.gz: 15f09bb85ba6e21447b38b26d0790b09342d3f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 814c12447b2d338a6781cc81419117b189c19598f9dc942f0f8264dd05dfbd4d4cab297ee029a6efe9808cb5b5366cdb0968c6617ba9165eda169c76f2cc0b24
|
7
|
+
data.tar.gz: e4b768cb0013ea3dc9b8f9817481eda342c87d966cb4dfcc206f175a5112826960d1c540e53ceaf1729f401e67c3ffb3dab38857e66ff7acda747f36c1f34c61
|
data/README.md
CHANGED
@@ -33,6 +33,17 @@ be executed in every shell where `contained-mr` is used.
|
|
33
33
|
eval "$(docker-machine env dev)"
|
34
34
|
```
|
35
35
|
|
36
|
+
### Cleanup
|
37
|
+
|
38
|
+
When tests go wrong, they often leave dead containers and images behind.
|
39
|
+
Removing all stopped containers and all unused images is a big stick that works
|
40
|
+
quite well in development environments.
|
41
|
+
|
42
|
+
```bash
|
43
|
+
docker ps --all --quiet --no-trunc | xargs docker rm
|
44
|
+
docker images --quiet --no-trunc | xargs docker rmi
|
45
|
+
```
|
46
|
+
|
36
47
|
|
37
48
|
## Contributing to contained_mr
|
38
49
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/contained_mr.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.3.
|
5
|
+
# stub: contained_mr 0.3.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "contained_mr"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.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"]
|
13
13
|
s.authors = ["Victor Costan"]
|
14
|
-
s.date = "2015-10-
|
14
|
+
s.date = "2015-10-12"
|
15
15
|
s.description = "Plumbing for running mappers and reducers inside Docker containers"
|
16
16
|
s.email = "victor@costan.us"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
|
|
63
63
|
"testdata/hello/mapreduced.yml",
|
64
64
|
"testdata/hello/reducer.sh",
|
65
65
|
"testdata/input.hello",
|
66
|
+
"testdata/invalid/Dockerfile",
|
66
67
|
"testdata/job.hello"
|
67
68
|
]
|
68
69
|
s.homepage = "http://github.com/pwnall/contained_mr"
|
data/lib/contained_mr/job.rb
CHANGED
@@ -65,7 +65,8 @@ class ContainedMr::Job
|
|
65
65
|
end
|
66
66
|
|
67
67
|
tar_io = mapper_tar_context mapper_input
|
68
|
-
image = Docker::Image.build_from_tar tar_io, t: mapper_image_tag
|
68
|
+
image = Docker::Image.build_from_tar tar_io, t: mapper_image_tag,
|
69
|
+
forcerm: 1
|
69
70
|
@mapper_image_id = image.id
|
70
71
|
end
|
71
72
|
|
@@ -81,7 +82,8 @@ class ContainedMr::Job
|
|
81
82
|
end
|
82
83
|
|
83
84
|
tar_io = reducer_tar_context
|
84
|
-
image = Docker::Image.build_from_tar tar_io, t: reducer_image_tag
|
85
|
+
image = Docker::Image.build_from_tar tar_io, t: reducer_image_tag,
|
86
|
+
forcerm: 1
|
85
87
|
@reducer_image_id = image.id
|
86
88
|
end
|
87
89
|
|
@@ -77,7 +77,7 @@ class ContainedMr::Template
|
|
77
77
|
#
|
78
78
|
# @param {IO} tar_io IO implementation that produces the image's .tar file
|
79
79
|
def build_image(tar_io)
|
80
|
-
image = Docker::Image.build_from_tar tar_io, t: image_tag
|
80
|
+
image = Docker::Image.build_from_tar tar_io, t: image_tag, forcerm: 1
|
81
81
|
@image_id = image.id
|
82
82
|
end
|
83
83
|
private :build_image
|
data/test/helper.rb
CHANGED
@@ -33,15 +33,17 @@ require 'contained_mr'
|
|
33
33
|
class MiniTest::Test
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
36
|
+
['hello', 'invalid'].each do |dir|
|
37
|
+
File.unlink "testdata/#{dir}.zip" if File.file?("testdata/#{dir}.zip")
|
38
|
+
Zip::File.open("testdata/#{dir}.zip", Zip::File::CREATE) do |zip|
|
39
|
+
files = Dir.chdir("testdata/#{dir}") { Dir.glob('**/*') }.sort
|
40
|
+
files.each do |file|
|
41
|
+
path = File.join "testdata/#{dir}", file
|
42
|
+
if File.directory? path
|
43
|
+
zip.mkdir file
|
44
|
+
elsif File.file? path
|
45
|
+
zip.add file, path
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/test/test_job.rb
CHANGED
@@ -31,6 +31,20 @@ class TestJob < MiniTest::Test
|
|
31
31
|
assert_nil @job.reducer_runner, "Reducer started prematurely"
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_build_mapper_image_does_not_leak_containers
|
35
|
+
old_containers = Docker::Container.all(all: true)
|
36
|
+
@template.stubs(:mapper_dockerfile).returns(
|
37
|
+
"FROM contained_mrtests/base.hello\nRUN /bin/false\n")
|
38
|
+
|
39
|
+
assert_raises Docker::Error::UnexpectedResponseError do
|
40
|
+
@job.build_mapper_image File.read('testdata/input.hello')
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_equal nil, @job.mapper_image_id
|
44
|
+
containers = Docker::Container.all(all: true)
|
45
|
+
assert_equal old_containers.length, containers.length
|
46
|
+
end
|
47
|
+
|
34
48
|
def test_created_mapper_image_tags
|
35
49
|
@job.build_mapper_image File.read('testdata/input.hello')
|
36
50
|
|
@@ -95,6 +109,23 @@ class TestJob < MiniTest::Test
|
|
95
109
|
'contained_mrtests/reducer.testjob:latest'
|
96
110
|
end
|
97
111
|
|
112
|
+
def test_build_reducer_image_does_not_leak_containers
|
113
|
+
@job.build_mapper_image File.read('testdata/input.hello')
|
114
|
+
1.upto(3) { |i| @job.run_mapper i }
|
115
|
+
|
116
|
+
old_containers = Docker::Container.all(all: true)
|
117
|
+
@template.stubs(:reducer_dockerfile).returns(
|
118
|
+
"FROM contained_mrtests/base.hello\nRUN /bin/false\n")
|
119
|
+
|
120
|
+
assert_raises Docker::Error::UnexpectedResponseError do
|
121
|
+
@job.build_reducer_image
|
122
|
+
end
|
123
|
+
|
124
|
+
assert_equal nil, @job.reducer_image_id
|
125
|
+
containers = Docker::Container.all(all: true)
|
126
|
+
assert_equal old_containers.length, containers.length
|
127
|
+
end
|
128
|
+
|
98
129
|
def test_run_reducer
|
99
130
|
@job.build_mapper_image File.read('testdata/input.hello')
|
100
131
|
1.upto(3) { |i| @job.run_mapper i }
|
data/test/test_template.rb
CHANGED
@@ -35,6 +35,19 @@ class TestTemplate < MiniTest::Test
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_invalid_template_does_not_leave_containers_behind
|
39
|
+
old_containers = Docker::Container.all(all: true)
|
40
|
+
|
41
|
+
assert_raises Docker::Error::UnexpectedResponseError do
|
42
|
+
template = ContainedMr.new_template 'contained_mrtests', 'invalid',
|
43
|
+
StringIO.new(File.binread('testdata/invalid.zip'))
|
44
|
+
template.destroy
|
45
|
+
end
|
46
|
+
|
47
|
+
containers = Docker::Container.all(all: true)
|
48
|
+
assert_equal old_containers.length, containers.length
|
49
|
+
end
|
50
|
+
|
38
51
|
def test_destory_with_two_templates
|
39
52
|
template2 = ContainedMr.new_template 'contained_mrtests', 'hello2',
|
40
53
|
StringIO.new(File.binread('testdata/hello.zip'))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contained_mr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- testdata/hello/mapreduced.yml
|
189
189
|
- testdata/hello/reducer.sh
|
190
190
|
- testdata/input.hello
|
191
|
+
- testdata/invalid/Dockerfile
|
191
192
|
- testdata/job.hello
|
192
193
|
homepage: http://github.com/pwnall/contained_mr
|
193
194
|
licenses:
|