docker-spoon 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -24,25 +24,15 @@ def dump_load_path
24
24
  end
25
25
  end
26
26
  require 'bundler'
27
+ require 'rspec/core/rake_task'
27
28
  require 'rake/clean'
28
-
29
- require 'rake/testtask'
30
-
31
29
  require 'cucumber'
32
30
  require 'cucumber/rake/task'
33
- gem 'rdoc' # we need the installed RDoc gem, not the system one
34
- require 'rdoc/task'
35
31
 
36
32
  include Rake::DSL
37
33
 
38
34
  Bundler::GemHelper.install_tasks
39
35
 
40
-
41
- Rake::TestTask.new do |t|
42
- t.pattern = 'test/tc_*.rb'
43
- end
44
-
45
-
46
36
  CUKE_RESULTS = 'results.html'
47
37
  CLEAN << CUKE_RESULTS
48
38
  Cucumber::Rake::Task.new(:features) do |t|
@@ -50,12 +40,12 @@ Cucumber::Rake::Task.new(:features) do |t|
50
40
  t.fork = false
51
41
  end
52
42
 
53
- Rake::RDocTask.new do |rd|
54
-
55
- rd.main = "README.rdoc"
56
-
57
- rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
43
+ task(:testsetup) do
44
+ cmd = 'bundle exec bin/spoon --url tcp://127.0.0.1:2375 --build --builddir docker --image spoon_test'
45
+ sh(cmd)
58
46
  end
59
47
 
60
- task :default => [:test,:features]
48
+ RSpec::Core::RakeTask.new(:spec)
49
+
50
+ task :default => [:features]
61
51
 
data/bin/spoon CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'optparse'
4
- require 'methadone'
5
3
  require 'spoon.rb'
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency('rdoc')
24
24
  spec.add_development_dependency('aruba')
25
25
  spec.add_development_dependency('rake', '~> 0.9.2')
26
- spec.add_dependency('methadone', '~> 1.4.0')
27
- spec.add_dependency('docker-api', '~> 1.13')
26
+ spec.add_dependency('docker-api', '~> 1.17.0')
28
27
  spec.add_dependency('rainbow', '~> 2.0')
29
28
  end
@@ -0,0 +1,49 @@
1
+ Feature: Test building
2
+
3
+ Scenario: --build should fail with an invalid configuration
4
+
5
+ Given a file named "spoon_config" with:
6
+ """
7
+ options[:url] = "tcp://127.0.0.1:2375"
8
+ options[:image] = "spoon_test"
9
+ options[:builddir] = "."
10
+ """
11
+
12
+ When I run `spoon -c spoon_config --build`
13
+ Then the exit status should be 1
14
+ And the output should contain:
15
+ """
16
+ must contain a Dockerfile... cannot continue
17
+ """
18
+
19
+ Given a file named "spoon_config" with:
20
+ """
21
+ options[:url] = "tcp://127.0.0.1:2375"
22
+ options[:image] = "spoon_test"
23
+ options[:builddir] = "/tmp/this_18881_random_dir_should_not_exist"
24
+ """
25
+
26
+ When I run `spoon -c spoon_config --build`
27
+ Then the exit status should be 1
28
+ And the output should contain:
29
+ """
30
+ must contain a Dockerfile... cannot continue
31
+ """
32
+
33
+ Scenario: --build should work with a valid configuration
34
+
35
+ Given a file named "spoon_config" with:
36
+ """
37
+ options[:url] = "tcp://127.0.0.1:2375"
38
+ options[:image] = "spoon_test"
39
+ options[:builddir] = "../../docker"
40
+ """
41
+
42
+ When I run `spoon -c spoon_config --build`
43
+ Then the exit status should be 0
44
+ And the output should contain:
45
+ """
46
+ Successfully built
47
+ """
48
+
49
+
@@ -0,0 +1,81 @@
1
+ @build @clean
2
+ Feature: Creating, Listing, Killing, Restarting and Destroying containers works
3
+
4
+ Scenario: Creating, Listing & Destroying containers works
5
+
6
+ Given a file named "spoon_config" with:
7
+ """
8
+ options[:url] = "tcp://127.0.0.1:2375"
9
+ options[:image] = "spoon_test"
10
+ options[:prefix] = "test-"
11
+ """
12
+
13
+ When I run `spoon -c spoon_config -l`
14
+ Then the exit status should be 0
15
+ And the output should contain:
16
+ """
17
+ No spoon containers running at tcp://127.0.0.1:2375
18
+ """
19
+
20
+ When I run `spoon -c spoon_config testcontainer19919 --nologin`
21
+ Then the exit status should be 0
22
+ And the output should contain:
23
+ """
24
+ The 'test-testcontainer19919' container doesn't exist, creating...
25
+ """
26
+
27
+ When I run `spoon -c spoon_config -l`
28
+ Then the exit status should be 0
29
+ And the output should contain:
30
+ """
31
+ List of available spoon containers:
32
+ """
33
+ And the output should contain:
34
+ """
35
+ testcontainer19919 [ Running ] spoon_test
36
+ """
37
+
38
+ When I run `spoon -c spoon_config --kill testcontainer19919`
39
+ Then the exit status should be 0
40
+ And the output should contain:
41
+ """
42
+ Container test-testcontainer19919 killed
43
+ """
44
+
45
+ When I run `spoon -c spoon_config -l`
46
+ Then the exit status should be 0
47
+ And the output should contain:
48
+ """
49
+ testcontainer19919 [ Stopped ] spoon_test
50
+ """
51
+
52
+ When I run `spoon -c spoon_config --restart testcontainer19919`
53
+ Then the exit status should be 0
54
+ And the output should contain:
55
+ """
56
+ Container test-testcontainer19919 restarted
57
+ """
58
+
59
+ When I run `spoon -c spoon_config -l`
60
+ Then the exit status should be 0
61
+ And the output should contain:
62
+ """
63
+ testcontainer19919 [ Running ] spoon_test
64
+ """
65
+
66
+ When I run `spoon -c spoon_config -d testcontainer19919` interactively
67
+ And I type "n"
68
+ Then the exit status should be 0
69
+ And the output should contain:
70
+ """
71
+ Delete aborted..
72
+ """
73
+
74
+ When I run `spoon -c spoon_config -d testcontainer19919` interactively
75
+ And I type "y"
76
+ Then the exit status should be 0
77
+ And the output should contain:
78
+ """
79
+ Destroying test-testcontainer19919
80
+ Done!
81
+ """
@@ -0,0 +1,25 @@
1
+ Feature: Test debug mode
2
+
3
+ Scenario: Normally should not see any debugging output
4
+
5
+ Given a file named "spoon_config" with:
6
+ """
7
+ options[:url] = "tcp://127.0.0.1:2375"
8
+ options[:image] = "spoon_test"
9
+ """
10
+
11
+ When I run `spoon -c spoon_config -l`
12
+ Then the exit status should be 0
13
+ And the output should not contain "D: "
14
+
15
+ Scenario: With --debug I should see debug output
16
+
17
+ Given a file named "spoon_config" with:
18
+ """
19
+ options[:url] = "tcp://127.0.0.1:2375"
20
+ options[:image] = "spoon_test"
21
+ """
22
+
23
+ When I run `spoon -c spoon_config -l --debug`
24
+ Then the exit status should be 0
25
+ And the output should contain "D: "
@@ -0,0 +1,24 @@
1
+ @docker_env
2
+ Feature: Validate URL Config
3
+
4
+ Scenario: Use DOCKER_HOST
5
+
6
+ Given a file named "spoon_config" with:
7
+ """
8
+ options[:url] = "tcp://127.0.0.1:2376"
9
+ options[:image] = "spoon_test"
10
+ """
11
+
12
+ When I run `spoon -c /dev/null --prefix "test-" -l`
13
+ Then the exit status should be 0
14
+ And the output should contain:
15
+ """
16
+ No spoon containers running at tcp://127.0.0.1:2375
17
+ """
18
+
19
+ When I run `spoon -c spoon_config -l`
20
+ Then the exit status should be 1
21
+ And the output should contain:
22
+ """
23
+ Connection refused
24
+ """
@@ -0,0 +1,67 @@
1
+ Feature: spoon provides help as necessary
2
+
3
+ Scenario: App provides help
4
+
5
+ When I run `spoon --help`
6
+ Then the exit status should be 0
7
+ And the output should contain "--version"
8
+ And the output should contain "--list"
9
+ And the output should contain "--destroy"
10
+ And the output should contain "--build"
11
+ And the output should contain "--builddir"
12
+ And the output should contain "--url"
13
+ And the output should contain "--list-images"
14
+ And the output should contain "--image"
15
+ And the output should contain "--network"
16
+ And the output should contain "--prefix"
17
+ And the output should contain "--config"
18
+ And the output should contain "--debug"
19
+ And the output should contain "--debugssh"
20
+ And the output should contain "--force"
21
+
22
+ Scenario: Missing arguments throw error
23
+
24
+ When I run `spoon --builddir`
25
+ Then the exit status should be 1
26
+ And the output should contain "missing argument:"
27
+
28
+ When I run `spoon --config`
29
+ Then the exit status should be 1
30
+ And the output should contain "missing argument:"
31
+
32
+ When I run `spoon --destroy`
33
+ Then the exit status should be 1
34
+ And the output should contain "missing argument:"
35
+
36
+ When I run `spoon --image`
37
+ Then the exit status should be 1
38
+ And the output should contain "missing argument:"
39
+
40
+ When I run `spoon --kill`
41
+ Then the exit status should be 1
42
+ And the output should contain "missing argument:"
43
+
44
+ When I run `spoon --network`
45
+ Then the exit status should be 1
46
+ And the output should contain "missing argument:"
47
+
48
+ When I run `spoon --portforwards`
49
+ Then the exit status should be 1
50
+ And the output should contain "missing argument:"
51
+
52
+ When I run `spoon --ports`
53
+ Then the exit status should be 1
54
+ And the output should contain "missing argument:"
55
+
56
+ When I run `spoon --prefix`
57
+ Then the exit status should be 1
58
+ And the output should contain "missing argument:"
59
+
60
+ When I run `spoon --restart`
61
+ Then the exit status should be 1
62
+ And the output should contain "missing argument:"
63
+
64
+ When I run `spoon --url`
65
+ Then the exit status should be 1
66
+ And the output should contain "missing argument:"
67
+
@@ -0,0 +1,17 @@
1
+ @build
2
+ Feature: Test listing of images
3
+
4
+ Scenario: As a user of spoon I should be able to list images
5
+
6
+ Given a file named "spoon_config" with:
7
+ """
8
+ options[:url] = "tcp://127.0.0.1:2375"
9
+ options[:image] = "spoon_test"
10
+ """
11
+
12
+ When I run `spoon -c spoon_config --list-images`
13
+ Then the exit status should be 0
14
+ And the output should contain:
15
+ """
16
+ Image: ["spoon_test:latest"]
17
+ """
@@ -0,0 +1,94 @@
1
+ @build @clean
2
+ Feature: Test ssh port forward specification
3
+
4
+ Scenario: portforwards defined in config file with single port
5
+
6
+ Given a file named "spoon_config" with:
7
+ """
8
+ options[:url] = "tcp://127.0.0.1:2375"
9
+ options[:image] = "spoon_test"
10
+ options[:portforwards] = [ "19919" ]
11
+ """
12
+
13
+ When I run `spoon -c spoon_config testcontainer19919 --nologin`
14
+ Then the exit status should be 0
15
+ And the output should contain:
16
+ """
17
+ SSH Forwards: -L 19919:127.0.0.1:19919
18
+ """
19
+
20
+ Scenario: portforwards defined on command line with dynamic mapping
21
+
22
+ Given a file named "spoon_config" with:
23
+ """
24
+ options[:url] = "tcp://127.0.0.1:2375"
25
+ options[:image] = "spoon_test"
26
+ """
27
+
28
+ When I run `spoon -c spoon_config testcontainer19919 --portforwards 19919 --nologin`
29
+ Then the exit status should be 0
30
+ And the output should contain:
31
+ """
32
+ SSH Forwards: -L 19919:127.0.0.1:19919
33
+ """
34
+
35
+ Scenario: portforwards defined in config file with different rport
36
+
37
+ Given a file named "spoon_config" with:
38
+ """
39
+ options[:url] = "tcp://127.0.0.1:2375"
40
+ options[:image] = "spoon_test"
41
+ options[:portforwards] = [ '19919:19918' ]
42
+ """
43
+
44
+ When I run `spoon -c spoon_config testcontainer19919 --nologin`
45
+ Then the exit status should be 0
46
+ And the output should contain:
47
+ """
48
+ SSH Forwards: -L 19919:127.0.0.1:19918
49
+ """
50
+
51
+ Scenario: portforwards defined on command line with different rport
52
+
53
+ Given a file named "spoon_config" with:
54
+ """
55
+ options[:url] = "tcp://127.0.0.1:2375"
56
+ options[:image] = "spoon_test"
57
+ """
58
+
59
+ When I run `spoon -c spoon_config testcontainer19919 --portforwards 19919:19918 --nologin`
60
+ Then the exit status should be 0
61
+ And the output should contain:
62
+ """
63
+ SSH Forwards: -L 19919:127.0.0.1:19918
64
+ """
65
+
66
+ Scenario: Multiple portforwards defined
67
+
68
+ Given a file named "spoon_config" with:
69
+ """
70
+ options[:url] = "tcp://127.0.0.1:2375"
71
+ options[:image] = "spoon_test"
72
+ """
73
+
74
+ When I run `spoon -c spoon_config testcontainer19919 --portforwards 19919,18818 --nologin`
75
+ Then the exit status should be 0
76
+ And the output should contain:
77
+ """
78
+ SSH Forwards: -L 19919:127.0.0.1:19919 -L 18818:127.0.0.1:18818
79
+ """
80
+
81
+ Scenario: Multiple portforwards defined with different rport
82
+
83
+ Given a file named "spoon_config" with:
84
+ """
85
+ options[:url] = "tcp://127.0.0.1:2375"
86
+ options[:image] = "spoon_test"
87
+ """
88
+
89
+ When I run `spoon -c spoon_config testcontainer19919 --portforwards 19919:19918,18818:18819 --nologin`
90
+ Then the exit status should be 0
91
+ And the output should contain:
92
+ """
93
+ SSH Forwards: -L 19919:127.0.0.1:19918 -L 18818:127.0.0.1:18819
94
+ """
@@ -0,0 +1,126 @@
1
+ @build @clean
2
+ Feature: Test port specification
3
+
4
+ Scenario: Ports defined in config file with dynamic mapping
5
+
6
+ Given a file named "spoon_config" with:
7
+ """
8
+ options[:url] = "tcp://127.0.0.1:2375"
9
+ options[:image] = "spoon_test"
10
+ options[:ports] = [ 19919 ]
11
+ """
12
+
13
+ When I run `spoon -c spoon_config testcontainer19919 --nologin`
14
+ Then the exit status should be 0
15
+
16
+ When I run `spoon -c spoon_config -n testcontainer19919`
17
+ Then the exit status should be 0
18
+ And the output should contain:
19
+ """
20
+ Host: 127.0.0.1
21
+ """
22
+ And the output should contain "22 ->"
23
+ And the output should contain "19919 -> "
24
+
25
+ Scenario: Ports defined on command line with dynamic mapping
26
+
27
+ Given a file named "spoon_config" with:
28
+ """
29
+ options[:url] = "tcp://127.0.0.1:2375"
30
+ options[:image] = "spoon_test"
31
+ """
32
+
33
+ When I run `spoon -c spoon_config testcontainer19919 --ports 19919 --nologin`
34
+ Then the exit status should be 0
35
+
36
+ When I run `spoon -c spoon_config -n testcontainer19919`
37
+ Then the exit status should be 0
38
+ And the output should contain:
39
+ """
40
+ Host: 127.0.0.1
41
+ """
42
+ And the output should contain "22 ->"
43
+ And the output should contain "19919 -> "
44
+
45
+ Scenario: Ports defined in config file with static mapping
46
+
47
+ Given a file named "spoon_config" with:
48
+ """
49
+ options[:url] = "tcp://127.0.0.1:2375"
50
+ options[:image] = "spoon_test"
51
+ options[:ports] = [ '19919:19919' ]
52
+ """
53
+
54
+ When I run `spoon -c spoon_config testcontainer19919 --nologin`
55
+ Then the exit status should be 0
56
+
57
+ When I run `spoon -c spoon_config -n testcontainer19919`
58
+ Then the exit status should be 0
59
+ And the output should contain:
60
+ """
61
+ Host: 127.0.0.1
62
+ """
63
+ And the output should contain "22 ->"
64
+ And the output should contain "19919 -> 19919"
65
+
66
+ Scenario: Ports defined on command line with static mapping
67
+
68
+ Given a file named "spoon_config" with:
69
+ """
70
+ options[:url] = "tcp://127.0.0.1:2375"
71
+ options[:image] = "spoon_test"
72
+ """
73
+
74
+ When I run `spoon -c spoon_config testcontainer19919 --ports 19919:19919 --nologin`
75
+ Then the exit status should be 0
76
+
77
+ When I run `spoon -c spoon_config -n testcontainer19919`
78
+ Then the exit status should be 0
79
+ And the output should contain:
80
+ """
81
+ Host: 127.0.0.1
82
+ """
83
+ And the output should contain "22 ->"
84
+ And the output should contain "19919 -> 19919"
85
+
86
+ Scenario: Multiple ports defined, dynamic
87
+
88
+ Given a file named "spoon_config" with:
89
+ """
90
+ options[:url] = "tcp://127.0.0.1:2375"
91
+ options[:image] = "spoon_test"
92
+ """
93
+
94
+ When I run `spoon -c spoon_config testcontainer19919 --ports 19919,18818 --nologin`
95
+ Then the exit status should be 0
96
+
97
+ When I run `spoon -c spoon_config -n testcontainer19919`
98
+ Then the exit status should be 0
99
+ And the output should contain:
100
+ """
101
+ Host: 127.0.0.1
102
+ """
103
+ And the output should contain "22 ->"
104
+ And the output should contain "19919 -> "
105
+ And the output should contain "18818 -> "
106
+
107
+ Scenario: Multiple ports defined, static
108
+
109
+ Given a file named "spoon_config" with:
110
+ """
111
+ options[:url] = "tcp://127.0.0.1:2375"
112
+ options[:image] = "spoon_test"
113
+ """
114
+
115
+ When I run `spoon -c spoon_config testcontainer19919 --ports 19919:19919,18818:18818 --nologin`
116
+ Then the exit status should be 0
117
+
118
+ When I run `spoon -c spoon_config -n testcontainer19919`
119
+ Then the exit status should be 0
120
+ And the output should contain:
121
+ """
122
+ Host: 127.0.0.1
123
+ """
124
+ And the output should contain "22 ->"
125
+ And the output should contain "19919 -> 19919"
126
+ And the output should contain "18818 -> 18818"