ventriloquist 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/CHANGELOG.md +31 -0
- data/DEVELOPMENT.md +37 -0
- data/Gemfile +13 -13
- data/Gemfile.lock +48 -50
- data/LICENSE.txt +1 -1
- data/README.md +65 -114
- data/development/Vagrantfile +20 -55
- data/lib/ventriloquist/cap/platforms/debian/elixir_install.rb +23 -16
- data/lib/ventriloquist/cap/platforms/debian/erlang_install.rb +13 -10
- data/lib/ventriloquist/cap/platforms/debian/go_install.rb +18 -3
- data/lib/ventriloquist/cap/platforms/debian/phantomjs_install.rb +22 -4
- data/lib/ventriloquist/cap/platforms/debian/python.rb +2 -0
- data/lib/ventriloquist/cap/platforms/linux/nvm_install_nodejs.rb +2 -0
- data/lib/ventriloquist/cap/platforms/linux/rvm_install_ruby.rb +2 -0
- data/lib/ventriloquist/cap/services/debian/ventriloquist_containers_upstart.rb +1 -1
- data/lib/ventriloquist/cap/utils/debian/prepare_container_for_docker.rb +35 -0
- data/lib/ventriloquist/cap/utils/linux/download.rb +24 -10
- data/lib/ventriloquist/cap/utils.rb +5 -0
- data/lib/ventriloquist/config.rb +1 -1
- data/lib/ventriloquist/platforms/elixir.rb +7 -2
- data/lib/ventriloquist/platforms/erlang.rb +3 -0
- data/lib/ventriloquist/platforms/go.rb +7 -2
- data/lib/ventriloquist/platforms/nodejs.rb +9 -2
- data/lib/ventriloquist/platforms/phantomjs.rb +7 -2
- data/lib/ventriloquist/platforms/python.rb +9 -2
- data/lib/ventriloquist/platforms/ruby.rb +9 -2
- data/lib/ventriloquist/platforms_builder.rb +7 -2
- data/lib/ventriloquist/plugin.rb +0 -4
- data/lib/ventriloquist/provisioner.rb +10 -5
- data/lib/ventriloquist/service.rb +4 -5
- data/lib/ventriloquist/services/elastic_search.rb +1 -1
- data/lib/ventriloquist/services/mail_catcher.rb +1 -1
- data/lib/ventriloquist/services/memcached.rb +1 -1
- data/lib/ventriloquist/services/mysql.rb +1 -1
- data/lib/ventriloquist/services/postgresql.rb +1 -1
- data/lib/ventriloquist/services/redis.rb +2 -2
- data/lib/ventriloquist/services/rethink_db.rb +1 -5
- data/lib/ventriloquist/services_builder.rb +10 -7
- data/lib/ventriloquist/version.rb +1 -1
- data/services/base/Dockerfile +19 -11
- data/services/build-all.sh +11 -11
- data/services/elasticsearch/Dockerfile +4 -1
- data/services/mailcatcher/Dockerfile +11 -1
- data/services/memcached/Dockerfile +9 -4
- data/services/mysql/5.5/Dockerfile +1 -0
- data/services/mysql/5.6/Dockerfile +8 -4
- data/services/openjdk7/Dockerfile +6 -1
- data/services/postgresql/9.1/Dockerfile +8 -5
- data/services/postgresql/9.1/config/bin/prepare-postgres +2 -0
- data/services/postgresql/9.2/Dockerfile +7 -5
- data/services/postgresql/9.2/config/bin/prepare-postgres +2 -0
- data/services/postgresql/9.3/Dockerfile +5 -5
- data/services/postgresql/9.3/config/bin/prepare-postgres +2 -0
- data/services/redis/Dockerfile +7 -4
- data/services/rethinkdb/Dockerfile +8 -1
- data/spec/spec_helper.rb +7 -9
- data/spec/unit/platforms_builder_spec.rb +5 -9
- data/spec/unit/service_spec.rb +14 -16
- data/spec/unit/services_builder_spec.rb +10 -20
- data/ventriloquist.gemspec +0 -2
- metadata +11 -23
@@ -4,7 +4,7 @@ module VagrantPlugins
|
|
4
4
|
class Redis < Service
|
5
5
|
def initialize(*args)
|
6
6
|
super
|
7
|
-
@config[:
|
7
|
+
@config[:args] ||= '-p 6379:6379'
|
8
8
|
end
|
9
9
|
|
10
10
|
def provision(machine)
|
@@ -17,7 +17,7 @@ module VagrantPlugins
|
|
17
17
|
def install_client(machine)
|
18
18
|
return if machine.communicate.test('which redis-cli > /dev/null')
|
19
19
|
|
20
|
-
redis_version = '2.8.
|
20
|
+
redis_version = '2.8.8'
|
21
21
|
machine.guest.tap do |guest|
|
22
22
|
guest.capability(:install_build_tools)
|
23
23
|
# TODO: Use the same version specified on the Vagrantfile
|
@@ -11,7 +11,7 @@ module VagrantPlugins
|
|
11
11
|
module Ventriloquist
|
12
12
|
class ServicesBuilder
|
13
13
|
MAPPING = {
|
14
|
-
'
|
14
|
+
'postgres' => Services::PostgreSQL,
|
15
15
|
'elasticsearch' => Services::ElasticSearch,
|
16
16
|
'mailcatcher' => Services::MailCatcher,
|
17
17
|
'mysql' => Services::MySql,
|
@@ -51,25 +51,28 @@ module VagrantPlugins
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def create_service_provisioner(name, config, docker_client)
|
54
|
-
|
55
|
-
type = config.delete(:type) || name
|
54
|
+
type = extract_service_type(config.delete(:type) || name)
|
56
55
|
|
57
|
-
# REFACTOR: This is a bit confusing...
|
58
|
-
config[:tag] ||= (tag || 'latest')
|
59
56
|
config[:image] ||= extract_image_name(config.delete(:vimage) || name)
|
60
|
-
config[:image] << ":#{config[:tag]}"
|
61
57
|
|
62
58
|
klass = @mapping.fetch(type, Service)
|
63
|
-
klass.new(name, config, docker_client)
|
59
|
+
klass.new(name.to_s, config, docker_client)
|
64
60
|
end
|
65
61
|
|
66
62
|
def extract_image_name(name)
|
67
63
|
if name =~ /(\w+\/\w+)/
|
68
64
|
$1
|
65
|
+
# HACK: This should be noted on the README
|
66
|
+
elsif name =~ /^elasticsearch-(\d+\.\d+)$/
|
67
|
+
"fgrehm/ventriloquist-es-#{$1}"
|
69
68
|
else
|
70
69
|
"fgrehm/ventriloquist-#{name}"
|
71
70
|
end
|
72
71
|
end
|
72
|
+
|
73
|
+
def extract_service_type(type)
|
74
|
+
type.to_s.split('-').first
|
75
|
+
end
|
73
76
|
end
|
74
77
|
end
|
75
78
|
end
|
data/services/base/Dockerfile
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
# Base image for creating Ventriloquist services
|
2
2
|
|
3
|
-
FROM
|
3
|
+
FROM debian:jessie
|
4
4
|
MAINTAINER Fabio Rehm "fgrehm@gmail.com"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
RUN apt-get update && apt-get install -y \
|
7
|
+
git \
|
8
|
+
libxml2-dev \
|
9
|
+
build-essential \
|
10
|
+
make \
|
11
|
+
gcc \
|
12
|
+
locales \
|
13
|
+
curl \
|
14
|
+
psmisc \
|
15
|
+
vim \
|
16
|
+
cron \
|
17
|
+
python \
|
18
|
+
logrotate \
|
19
|
+
lsb-release \
|
20
|
+
wget && \
|
21
|
+
rm -rf /var/lib/apt/lists/* && \
|
22
|
+
rm -rf /tmp/* && \
|
13
23
|
apt-get autoremove && \
|
14
|
-
apt-get clean
|
15
|
-
locale-gen en_US && \
|
16
|
-
echo 'LANG="en_US.UTF-8"' >> /etc/default/locale
|
24
|
+
apt-get clean
|
data/services/build-all.sh
CHANGED
@@ -4,22 +4,22 @@ set -e
|
|
4
4
|
|
5
5
|
PREFIX='fgrehm/ventriloquist'
|
6
6
|
|
7
|
-
docker build -t ${PREFIX}-base base
|
7
|
+
docker build --rm -t ${PREFIX}-base base
|
8
8
|
|
9
|
-
docker build -t ${PREFIX}-
|
10
|
-
docker build -t ${PREFIX}-
|
11
|
-
docker build -t ${PREFIX}-
|
9
|
+
docker build --rm -t ${PREFIX}-postgres-9.3 postgresql/9.3
|
10
|
+
docker build --rm -t ${PREFIX}-postgres-9.2 postgresql/9.2
|
11
|
+
docker build --rm -t ${PREFIX}-postgres-9.1 postgresql/9.1
|
12
12
|
|
13
|
-
docker build -t ${PREFIX}-mysql mysql/5.6
|
14
|
-
docker build -t ${PREFIX}-mysql
|
13
|
+
docker build -t ${PREFIX}-mysql-5.6 mysql/5.6
|
14
|
+
docker build -t ${PREFIX}-mysql-5.5 mysql/5.5
|
15
15
|
|
16
|
-
docker build -t ${PREFIX}-rethinkdb rethinkdb
|
16
|
+
docker build -t ${PREFIX}-rethinkdb-1.12 rethinkdb
|
17
17
|
|
18
18
|
docker build -t ${PREFIX}-openjdk7 openjdk7
|
19
|
-
docker build -t ${PREFIX}-elasticsearch elasticsearch
|
19
|
+
docker build -t ${PREFIX}-elasticsearch-1.1 elasticsearch
|
20
20
|
|
21
|
-
docker build -t ${PREFIX}-memcached memcached
|
21
|
+
docker build -t ${PREFIX}-memcached-1.4 memcached
|
22
22
|
|
23
|
-
docker build -t ${PREFIX}-redis redis
|
23
|
+
docker build -t ${PREFIX}-redis-2.8 redis
|
24
24
|
|
25
|
-
docker build -t ${PREFIX}-mailcatcher mailcatcher
|
25
|
+
docker build -t ${PREFIX}-mailcatcher-0.5 mailcatcher
|
@@ -2,9 +2,12 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-openjdk7
|
4
4
|
|
5
|
-
RUN wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-
|
5
|
+
RUN wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.0.deb -O /tmp/elasticsearch.deb -q --no-check-certificate && \
|
6
6
|
dpkg -i /tmp/elasticsearch.deb && \
|
7
7
|
rm /tmp/elasticsearch.deb && \
|
8
|
+
rm -rf /var/lib/apt/lists/* && \
|
9
|
+
rm -rf /tmp/* && \
|
10
|
+
apt-get autoremove && \
|
8
11
|
apt-get clean
|
9
12
|
|
10
13
|
EXPOSE 9200
|
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
RUN apt-get
|
5
|
+
RUN apt-get update && \
|
6
|
+
apt-get install -y \
|
7
|
+
ruby \
|
8
|
+
ruby-dev \
|
9
|
+
sqlite3 \
|
10
|
+
libsqlite3-dev && \
|
11
|
+
rm -rf /var/lib/apt/lists/* && \
|
12
|
+
rm -rf /tmp/* && \
|
13
|
+
apt-get autoremove && \
|
14
|
+
apt-get clean
|
15
|
+
|
6
16
|
RUN gem install mailcatcher --no-ri --no-rdoc
|
7
17
|
|
8
18
|
EXPOSE 1025
|
@@ -2,15 +2,20 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
RUN wget -q http://memcached.
|
5
|
+
RUN wget -q http://www.memcached.org/files/memcached-1.4.17.tar.gz -O /tmp/memcached.tar.gz && \
|
6
6
|
cd /tmp && \
|
7
7
|
tar xvfz memcached.tar.gz && \
|
8
|
-
cd memcached-1.4.
|
9
|
-
apt-get
|
8
|
+
cd memcached-1.4.17 && \
|
9
|
+
apt-get update && \
|
10
|
+
apt-get install libevent-dev -y && \
|
10
11
|
./configure --prefix=/usr/local/memcached && \
|
11
12
|
make && \
|
12
13
|
make install && \
|
13
|
-
cd .. && rm -rf memcached* &&
|
14
|
+
cd .. && rm -rf memcached* && \
|
15
|
+
rm -rf /var/lib/apt/lists/* && \
|
16
|
+
rm -rf /tmp/* && \
|
17
|
+
apt-get autoremove && \
|
18
|
+
apt-get clean
|
14
19
|
|
15
20
|
EXPOSE 11211
|
16
21
|
CMD ["/usr/local/memcached/bin/memcached", "-u", "daemon"]
|
@@ -4,6 +4,7 @@ FROM fgrehm/ventriloquist-base
|
|
4
4
|
|
5
5
|
# prevent apt from starting mysql right after the installation
|
6
6
|
RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d && \
|
7
|
+
apt-get update && \
|
7
8
|
apt-get -q -y install mysql-server-5.5 && \
|
8
9
|
apt-get clean && \
|
9
10
|
sed -i 's/127.0.0.1/0.0.0.0/' /etc/mysql/my.cnf && \
|
@@ -3,8 +3,9 @@
|
|
3
3
|
|
4
4
|
FROM fgrehm/ventriloquist-base
|
5
5
|
|
6
|
-
RUN apt-get
|
7
|
-
|
6
|
+
RUN apt-get update && \
|
7
|
+
apt-get install libaio-dev -y && \
|
8
|
+
wget -q http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17-debian6.0-x86_64.deb -O /tmp/mysql.deb && \
|
8
9
|
dpkg -i /tmp/mysql.deb && \
|
9
10
|
rm /tmp/mysql.deb && \
|
10
11
|
groupadd mysql && \
|
@@ -17,12 +18,15 @@ RUN apt-get install libaio-dev -y && \
|
|
17
18
|
/opt/mysql/server-5.6/scripts/mysql_install_db --user=mysql --datadir=/var/lib/mysql && \
|
18
19
|
rm /opt/mysql/server-5.6/my*.cnf && \
|
19
20
|
echo 'export PATH="/opt/mysql/server-5.6/bin:$PATH"' > /etc/profile.d/mysql.sh && \
|
20
|
-
apt-get clean && \
|
21
21
|
rm /opt/mysql/server-5.6/bin/mysqld-debug && \
|
22
22
|
rm /opt/mysql/server-5.6/bin/mysqltest_* && \
|
23
23
|
rm /opt/mysql/server-5.6/bin/mysql_client_test* && \
|
24
24
|
rm /opt/mysql/server-5.6/lib/libmysqld-debug.a && \
|
25
|
-
rm -rf /opt/mysql/server-5.6/mysql-test
|
25
|
+
rm -rf /opt/mysql/server-5.6/mysql-test && \
|
26
|
+
rm -rf /var/lib/apt/lists/* && \
|
27
|
+
rm -rf /tmp/* && \
|
28
|
+
apt-get autoremove && \
|
29
|
+
apt-get clean
|
26
30
|
|
27
31
|
ADD config /
|
28
32
|
|
@@ -2,4 +2,9 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
RUN apt-get
|
5
|
+
RUN apt-get update && \
|
6
|
+
apt-get install -y openjdk-7-jre-headless && \
|
7
|
+
rm -rf /var/lib/apt/lists/* && \
|
8
|
+
rm -rf /tmp/* && \
|
9
|
+
apt-get autoremove && \
|
10
|
+
apt-get clean
|
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
apt-get
|
8
|
-
apt-get
|
9
|
-
rm /
|
5
|
+
RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \
|
6
|
+
echo "deb http://apt.postgresql.org/pub/repos/apt sid-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
|
7
|
+
apt-get update && \
|
8
|
+
apt-get install -y postgresql-9.1 postgresql-contrib-9.1 && \
|
9
|
+
rm -rf /var/lib/apt/lists/* && \
|
10
|
+
rm -rf /tmp/* && \
|
11
|
+
apt-get autoremove && \
|
12
|
+
apt-get clean
|
10
13
|
|
11
14
|
ADD config /
|
12
15
|
RUN /bin/prepare-postgres vagrant vagrant
|
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc |
|
6
|
-
echo "deb http://apt.postgresql.org/pub/repos/apt
|
7
|
-
apt-get update
|
8
|
-
|
9
|
-
|
5
|
+
RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add - && \
|
6
|
+
echo "deb http://apt.postgresql.org/pub/repos/apt sid-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
|
7
|
+
apt-get update && \
|
8
|
+
apt-get install -y postgresql-9.2 postgresql-contrib-9.2 && \
|
9
|
+
rm -rf /var/lib/apt/lists/* && \
|
10
|
+
rm -rf /tmp/* && \
|
11
|
+
apt-get autoremove && \
|
10
12
|
apt-get clean
|
11
13
|
|
12
14
|
ADD config /
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
RUN
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
RUN apt-get update && \
|
6
|
+
apt-get install -y postgresql-9.3 postgresql-contrib-9.3 && \
|
7
|
+
rm -rf /var/lib/apt/lists/* && \
|
8
|
+
rm -rf /tmp/* && \
|
9
|
+
apt-get autoremove && \
|
10
10
|
apt-get clean
|
11
11
|
|
12
12
|
ADD config /
|
data/services/redis/Dockerfile
CHANGED
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
FROM fgrehm/ventriloquist-base
|
4
4
|
|
5
|
-
|
6
|
-
RUN wget -q http://download.redis.io/releases/redis-2.8.2.tar.gz -O /tmp/redis.tar.gz && \
|
5
|
+
RUN wget -q http://download.redis.io/releases/redis-2.8.8.tar.gz -O /tmp/redis.tar.gz && \
|
7
6
|
cd /tmp && \
|
8
7
|
tar xvfz redis.tar.gz && \
|
9
|
-
cd redis-2.8.
|
8
|
+
cd redis-2.8.8 && \
|
10
9
|
make redis-server && \
|
11
10
|
mv src/redis-server /usr/bin && \
|
12
|
-
cd .. && rm -rf redis*
|
11
|
+
cd .. && rm -rf redis* && \
|
12
|
+
rm -rf /var/lib/apt/lists/* && \
|
13
|
+
rm -rf /tmp/* && \
|
14
|
+
apt-get autoremove && \
|
15
|
+
apt-get clean
|
13
16
|
|
14
17
|
EXPOSE 6379
|
15
18
|
CMD ["/usr/bin/redis-server"]
|
@@ -3,9 +3,16 @@
|
|
3
3
|
|
4
4
|
FROM fgrehm/ventriloquist-base
|
5
5
|
|
6
|
-
RUN add-apt-repository
|
6
|
+
RUN wget http://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt -O /tmp/add-apt-repository.sh.txt && \
|
7
|
+
mv /tmp/add-apt-repository.sh.txt /usr/sbin/add-apt-repository && \
|
8
|
+
chmod o+x /usr/sbin/add-apt-repository && \
|
9
|
+
chown root:root /usr/sbin/add-apt-repository && \
|
10
|
+
add-apt-repository ppa:rethinkdb/ppa && \
|
7
11
|
apt-get update && \
|
8
12
|
apt-get install -y rethinkdb && \
|
13
|
+
rm -rf /var/lib/apt/lists/* && \
|
14
|
+
rm -rf /tmp/* && \
|
15
|
+
apt-get autoremove && \
|
9
16
|
apt-get clean
|
10
17
|
|
11
18
|
# create the /rethinkdb_data dir structure
|
data/spec/spec_helper.rb
CHANGED
@@ -3,18 +3,16 @@ if ENV['COVERAGE'] == 'true'
|
|
3
3
|
SimpleCov.start
|
4
4
|
end
|
5
5
|
|
6
|
-
require '
|
7
|
-
|
6
|
+
require 'vagrant'
|
8
7
|
require 'ventriloquist'
|
9
8
|
|
10
|
-
Bogus.configure do |c|
|
11
|
-
c.search_modules << VagrantPlugins::Ventriloquist
|
12
|
-
c.search_modules << VagrantPlugins::Vocker
|
13
|
-
c.search_modules << Vagrant
|
14
|
-
end
|
15
|
-
|
16
9
|
RSpec.configure do |config|
|
17
|
-
config.
|
10
|
+
config.mock_with :rspec do |mocks|
|
11
|
+
mocks.syntax = :expect
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
mocks.verify_doubled_constant_names = true
|
14
|
+
end
|
15
|
+
|
18
16
|
config.run_all_when_everything_filtered = true
|
19
17
|
config.filter_run :focus
|
20
18
|
|
@@ -5,12 +5,8 @@ require 'ventriloquist/platforms_builder'
|
|
5
5
|
describe VagrantPlugins::Ventriloquist::PlatformsBuilder do
|
6
6
|
Platform = VagrantPlugins::Ventriloquist::Platform
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
fake(:docker_client)
|
11
|
-
|
12
|
-
let(:cfg) { {version: '13.0'} }
|
13
|
-
let(:platforms_configs) { [{my_lang: cfg}, :your_lang, ['my_plat:version']] }
|
8
|
+
let(:cfg) { {versions: '13.0'} }
|
9
|
+
let(:platforms_configs) { [{my_lang: cfg}, 'your_lang-1.2', ['my_plat-version']] }
|
14
10
|
let(:custom_mapping) { {'my_lang' => my_lang_class, 'your_lang' => your_lang_class, 'my_plat' => my_plat_class} }
|
15
11
|
|
16
12
|
let(:my_lang_class) do
|
@@ -30,18 +26,18 @@ describe VagrantPlugins::Ventriloquist::PlatformsBuilder do
|
|
30
26
|
let(:my_plat) { platforms[2] }
|
31
27
|
|
32
28
|
it 'builds a list of platform objects' do
|
33
|
-
expect(platforms).to
|
29
|
+
expect(platforms.size).to eq(3)
|
34
30
|
expect(my_lang).to be_a(my_lang_class)
|
35
31
|
expect(your_lang).to be_a(your_lang_class)
|
36
32
|
expect(my_plat).to be_a(my_plat_class)
|
37
33
|
end
|
38
34
|
|
39
35
|
it 'extracts version from platform name' do
|
40
|
-
expect(my_plat.config[:
|
36
|
+
expect(my_plat.config[:versions]).to eq(['version'])
|
41
37
|
end
|
42
38
|
|
43
39
|
it 'defaults configured version to latest' do
|
44
|
-
expect(your_lang.config[:
|
40
|
+
expect(your_lang.config[:versions]).to eq(['1.2'])
|
45
41
|
end
|
46
42
|
|
47
43
|
it 'configures services using defined configs' do
|
data/spec/unit/service_spec.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'vocker/docker_client'
|
4
3
|
require Vagrant.source_root.join('plugins/communicators/ssh/communicator')
|
4
|
+
require Vagrant.source_root.join('plugins/provisioners/docker/client')
|
5
5
|
|
6
6
|
require 'ventriloquist/service'
|
7
7
|
|
8
8
|
describe VagrantPlugins::Ventriloquist::Service do
|
9
|
-
|
10
|
-
|
11
|
-
let(:
|
12
|
-
|
13
|
-
|
14
|
-
let(:env) { fake(:environment, ui: ui) }
|
15
|
-
let(:machine) { fake(:machine, communicate: communicator, env: env) }
|
9
|
+
let(:docker_client) { instance_double(VagrantPlugins::Docker::Client, container_running?: false, run_container: false) }
|
10
|
+
let(:communicator) { instance_double(VagrantPlugins::CommunicatorSSH::Communicator, sudo: true) }
|
11
|
+
let(:ui) { instance_double(Vagrant::UI::Interface, info: true) }
|
12
|
+
let(:env) { instance_double(Vagrant::Environment, ui: ui) }
|
13
|
+
let(:machine) { instance_double(Vagrant::Machine, communicate: communicator, env: env) }
|
16
14
|
|
17
15
|
let(:service_name) { 'dbserver' }
|
18
|
-
let(:service_conf) { { image: 'user/dbserver',
|
16
|
+
let(:service_conf) { { image: 'user/dbserver', args: '--dns 127.0.0.1' } }
|
19
17
|
|
20
18
|
subject { described_class.new(service_name, service_conf, docker_client) }
|
21
19
|
|
@@ -23,28 +21,28 @@ describe VagrantPlugins::Ventriloquist::Service do
|
|
23
21
|
|
24
22
|
context 'given the container has not been created' do
|
25
23
|
it 'runs the configured container' do
|
26
|
-
expect(docker_client).to have_received.
|
24
|
+
expect(docker_client).to have_received(:run_container).with(service_conf)
|
27
25
|
end
|
28
26
|
|
29
27
|
it 'creates a directory for keeping container id files' do
|
30
|
-
expect(communicator).to have_received.
|
28
|
+
expect(communicator).to have_received(:sudo).with('mkdir -p /var/lib/ventriloquist/cids')
|
31
29
|
end
|
32
30
|
|
33
31
|
it 'assigns a cidfile based on the service name' do
|
34
32
|
expected_cidfile = "#{described_class::CONTAINER_IDS_PATH}/#{service_name}"
|
35
|
-
expect(docker_client).to have_received.
|
33
|
+
expect(docker_client).to have_received(:run_container).with(hash_including(cidfile: expected_cidfile))
|
36
34
|
end
|
37
35
|
|
38
|
-
it '
|
39
|
-
expect(docker_client).to have_received.
|
36
|
+
it 'passes on additional args' do
|
37
|
+
expect(docker_client).to have_received(:run_container).with(hash_including(args: "--dns 127.0.0.1"))
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
41
|
context 'given the container has already been created' do
|
44
|
-
let(:docker_client) {
|
42
|
+
let(:docker_client) { double(VagrantPlugins::Docker::Client, container_running?: true, run_container: true) }
|
45
43
|
|
46
44
|
it 'does not attempt to run container' do
|
47
|
-
expect(docker_client).to_not have_received
|
45
|
+
expect(docker_client).to_not have_received(:run_container)
|
48
46
|
end
|
49
47
|
end
|
50
48
|
end
|