centurion 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,40 +3,89 @@ require 'centurion/docker_via_cli'
3
3
 
4
4
  describe Centurion::DockerViaCli do
5
5
  let(:docker_path) { 'docker' }
6
- let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
7
6
 
8
- it 'pulls the latest image given its name' do
9
- expect(docker_via_cli).to receive(:echo).
10
- with("docker -H=tcp://host1:2375 pull foo:latest")
11
- docker_via_cli.pull('foo')
12
- end
7
+ context 'without TLS certificates' do
8
+ let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375, docker_path) }
9
+ it 'pulls the latest image given its name' do
10
+ expect(docker_via_cli).to receive(:echo).
11
+ with("docker -H=tcp://host1:2375 pull foo:latest")
12
+ docker_via_cli.pull('foo')
13
+ end
13
14
 
14
- it 'pulls an image given its name & tag' do
15
- expect(docker_via_cli).to receive(:echo).
16
- with("docker -H=tcp://host1:2375 pull foo:bar")
17
- docker_via_cli.pull('foo', 'bar')
18
- end
15
+ it 'pulls an image given its name & tag' do
16
+ expect(docker_via_cli).to receive(:echo).
17
+ with("docker -H=tcp://host1:2375 pull foo:bar")
18
+ docker_via_cli.pull('foo', 'bar')
19
+ end
19
20
 
20
- it 'tails logs on a container' do
21
- id = '12345abcdef'
22
- expect(docker_via_cli).to receive(:echo).
23
- with("docker -H=tcp://host1:2375 logs -f #{id}")
24
- docker_via_cli.tail(id)
25
- end
21
+ it 'tails logs on a container' do
22
+ id = '12345abcdef'
23
+ expect(docker_via_cli).to receive(:echo).
24
+ with("docker -H=tcp://host1:2375 logs -f #{id}")
25
+ docker_via_cli.tail(id)
26
+ end
27
+
28
+ it 'should print all chars when one thread is running' do
29
+ expect(docker_via_cli).to receive(:run_with_echo)
30
+
31
+ allow(Thread).to receive(:list) {[double(:status => 'run')]}
32
+
33
+ docker_via_cli.pull('foo')
34
+ end
26
35
 
27
- it 'should print all chars when one thread is running' do
28
- expect(docker_via_cli).to receive(:run_with_echo)
36
+ it 'should only print lines when multiple threads are running' do
37
+ expect(docker_via_cli).to receive(:run_without_echo)
29
38
 
30
- allow(Thread).to receive(:list) {[double(:status => 'run')]}
39
+ allow(Thread).to receive(:list) {[double(:status => 'run'), double(:status => 'run')]}
31
40
 
32
- docker_via_cli.pull('foo')
41
+ docker_via_cli.pull('foo')
42
+ end
33
43
  end
44
+ context 'with TLS certificates' do
45
+ let(:tls_args) { { tls: true, tlscacert: '/certs/ca.pem',
46
+ tlscert: '/certs/cert.pem', tlskey: '/certs/key.pem' } }
47
+ let(:docker_via_cli) { Centurion::DockerViaCli.new('host1', 2375,
48
+ docker_path, tls_args) }
49
+ it 'pulls the latest image given its name' do
50
+ expect(docker_via_cli).to receive(:echo).
51
+ with('docker -H=tcp://host1:2375 ' \
52
+ '--tlsverify ' \
53
+ '--tlscacert=/certs/ca.pem ' \
54
+ '--tlscert=/certs/cert.pem ' \
55
+ '--tlskey=/certs/key.pem pull foo:latest')
56
+ docker_via_cli.pull('foo')
57
+ end
34
58
 
35
- it 'should only print lines when multiple threads are running' do
36
- expect(docker_via_cli).to receive(:run_without_echo)
59
+ it 'pulls an image given its name & tag' do
60
+ expect(docker_via_cli).to receive(:echo).
61
+ with('docker -H=tcp://host1:2375 ' \
62
+ '--tlsverify ' \
63
+ '--tlscacert=/certs/ca.pem ' \
64
+ '--tlscert=/certs/cert.pem ' \
65
+ '--tlskey=/certs/key.pem pull foo:bar')
66
+ docker_via_cli.pull('foo', 'bar')
67
+ end
37
68
 
38
- allow(Thread).to receive(:list) {[double(:status => 'run'), double(:status => 'run')]}
69
+ it 'tails logs on a container' do
70
+ id = '12345abcdef'
71
+ expect(docker_via_cli).to receive(:echo).
72
+ with('docker -H=tcp://host1:2375 ' \
73
+ '--tlsverify ' \
74
+ '--tlscacert=/certs/ca.pem ' \
75
+ '--tlscert=/certs/cert.pem ' \
76
+ "--tlskey=/certs/key.pem logs -f #{id}")
77
+ docker_via_cli.tail(id)
78
+ end
39
79
 
40
- docker_via_cli.pull('foo')
80
+ it 'attach to a container' do
81
+ id = '12345abcdef'
82
+ expect(docker_via_cli).to receive(:echo).
83
+ with('docker -H=tcp://host1:2375 ' \
84
+ '--tlsverify ' \
85
+ '--tlscacert=/certs/ca.pem ' \
86
+ '--tlscert=/certs/cert.pem ' \
87
+ "--tlskey=/certs/key.pem attach #{id}")
88
+ docker_via_cli.attach(id)
89
+ end
41
90
  end
42
91
  end
@@ -14,44 +14,51 @@ describe Centurion::Dogestry do
14
14
 
15
15
  describe '#aws_access_key_id' do
16
16
  it 'returns correct value' do
17
- registry.aws_access_key_id.should == dogestry_options[:aws_access_key_id]
17
+ expect(registry.aws_access_key_id).to eq(dogestry_options[:aws_access_key_id])
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#aws_secret_key' do
22
22
  it 'returns correct value' do
23
- registry.aws_secret_key.should == dogestry_options[:aws_secret_key]
23
+ expect(registry.aws_secret_key).to eq(dogestry_options[:aws_secret_key])
24
24
  end
25
25
  end
26
26
 
27
27
  describe '#s3_bucket' do
28
28
  it 'returns correct value' do
29
- registry.s3_bucket.should == dogestry_options[:s3_bucket]
29
+ expect(registry.s3_bucket).to eq(dogestry_options[:s3_bucket])
30
30
  end
31
31
  end
32
32
 
33
33
  describe '#s3_region' do
34
34
  it 'returns correct default value' do
35
- registry.s3_region.should == "us-east-1"
35
+ expect(registry.s3_region).to eq("us-east-1")
36
36
  end
37
37
  end
38
38
 
39
39
  describe '#s3_url' do
40
40
  it 'returns correct value' do
41
- registry.s3_url.should == "s3://#{registry.s3_bucket}/?region=#{registry.s3_region}"
41
+ expect(registry.s3_url).to eq("s3://#{registry.s3_bucket}/?region=#{registry.s3_region}")
42
42
  end
43
43
  end
44
44
 
45
45
  describe '#exec_command' do
46
46
  it 'returns correct value' do
47
- registry.exec_command('pull', repo).should start_with('dogestry')
47
+ expect(registry.exec_command('pull', repo)).to start_with('dogestry')
48
48
  end
49
49
  end
50
50
 
51
+ describe '#pull' do
52
+ it 'returns correct value' do
53
+ expect(registry).to receive(:echo).with("dogestry #{flags} pull #{registry.s3_url} #{repo}")
54
+ registry.pull(repo, pull_hosts)
55
+ end
56
+ end
57
+
51
58
  describe '#which' do
52
59
  it 'finds dogestry command line' do
53
60
  allow(File).to receive(:executable?).and_return(true)
54
- registry.which('dogestry').should_not == nil
61
+ expect(registry.which('dogestry')).to_not be_nil
55
62
  end
56
63
  end
57
64
  end
@@ -3,11 +3,11 @@ RSpec::Matchers.define :have_key_and_value do |expected_key, expected_value|
3
3
  actual.env[actual.current_environment].has_key?(expected_key.to_sym) && (actual.fetch(expected_key.to_sym) == expected_value)
4
4
  end
5
5
 
6
- failure_message_for_should do |actual|
6
+ failure_message do |actual|
7
7
  "expected that #{actual.env[actual.current_environment].keys.inspect} would include #{expected_key.inspect} with value #{expected_value.inspect}"
8
8
  end
9
9
 
10
- failure_message_for_should_not do |actual|
10
+ failure_message_when_negated do |actual|
11
11
  "expected that #{actual.env[actual.current_environment].keys.join(', ')} would not include #{expected_key.inspect} with value #{expected_value.inspect}"
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: centurion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -21,7 +21,7 @@ authors:
21
21
  autorequire:
22
22
  bindir: bin
23
23
  cert_chain: []
24
- date: 2014-11-20 00:00:00.000000000 Z
24
+ date: 2015-01-06 00:00:00.000000000 Z
25
25
  dependencies:
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: trollop