ventriloquist 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -4
  3. data/CHANGELOG.md +31 -0
  4. data/DEVELOPMENT.md +37 -0
  5. data/Gemfile +13 -13
  6. data/Gemfile.lock +48 -50
  7. data/LICENSE.txt +1 -1
  8. data/README.md +65 -114
  9. data/development/Vagrantfile +20 -55
  10. data/lib/ventriloquist/cap/platforms/debian/elixir_install.rb +23 -16
  11. data/lib/ventriloquist/cap/platforms/debian/erlang_install.rb +13 -10
  12. data/lib/ventriloquist/cap/platforms/debian/go_install.rb +18 -3
  13. data/lib/ventriloquist/cap/platforms/debian/phantomjs_install.rb +22 -4
  14. data/lib/ventriloquist/cap/platforms/debian/python.rb +2 -0
  15. data/lib/ventriloquist/cap/platforms/linux/nvm_install_nodejs.rb +2 -0
  16. data/lib/ventriloquist/cap/platforms/linux/rvm_install_ruby.rb +2 -0
  17. data/lib/ventriloquist/cap/services/debian/ventriloquist_containers_upstart.rb +1 -1
  18. data/lib/ventriloquist/cap/utils/debian/prepare_container_for_docker.rb +35 -0
  19. data/lib/ventriloquist/cap/utils/linux/download.rb +24 -10
  20. data/lib/ventriloquist/cap/utils.rb +5 -0
  21. data/lib/ventriloquist/config.rb +1 -1
  22. data/lib/ventriloquist/platforms/elixir.rb +7 -2
  23. data/lib/ventriloquist/platforms/erlang.rb +3 -0
  24. data/lib/ventriloquist/platforms/go.rb +7 -2
  25. data/lib/ventriloquist/platforms/nodejs.rb +9 -2
  26. data/lib/ventriloquist/platforms/phantomjs.rb +7 -2
  27. data/lib/ventriloquist/platforms/python.rb +9 -2
  28. data/lib/ventriloquist/platforms/ruby.rb +9 -2
  29. data/lib/ventriloquist/platforms_builder.rb +7 -2
  30. data/lib/ventriloquist/plugin.rb +0 -4
  31. data/lib/ventriloquist/provisioner.rb +10 -5
  32. data/lib/ventriloquist/service.rb +4 -5
  33. data/lib/ventriloquist/services/elastic_search.rb +1 -1
  34. data/lib/ventriloquist/services/mail_catcher.rb +1 -1
  35. data/lib/ventriloquist/services/memcached.rb +1 -1
  36. data/lib/ventriloquist/services/mysql.rb +1 -1
  37. data/lib/ventriloquist/services/postgresql.rb +1 -1
  38. data/lib/ventriloquist/services/redis.rb +2 -2
  39. data/lib/ventriloquist/services/rethink_db.rb +1 -5
  40. data/lib/ventriloquist/services_builder.rb +10 -7
  41. data/lib/ventriloquist/version.rb +1 -1
  42. data/services/base/Dockerfile +19 -11
  43. data/services/build-all.sh +11 -11
  44. data/services/elasticsearch/Dockerfile +4 -1
  45. data/services/mailcatcher/Dockerfile +11 -1
  46. data/services/memcached/Dockerfile +9 -4
  47. data/services/mysql/5.5/Dockerfile +1 -0
  48. data/services/mysql/5.6/Dockerfile +8 -4
  49. data/services/openjdk7/Dockerfile +6 -1
  50. data/services/postgresql/9.1/Dockerfile +8 -5
  51. data/services/postgresql/9.1/config/bin/prepare-postgres +2 -0
  52. data/services/postgresql/9.2/Dockerfile +7 -5
  53. data/services/postgresql/9.2/config/bin/prepare-postgres +2 -0
  54. data/services/postgresql/9.3/Dockerfile +5 -5
  55. data/services/postgresql/9.3/config/bin/prepare-postgres +2 -0
  56. data/services/redis/Dockerfile +7 -4
  57. data/services/rethinkdb/Dockerfile +8 -1
  58. data/spec/spec_helper.rb +7 -9
  59. data/spec/unit/platforms_builder_spec.rb +5 -9
  60. data/spec/unit/service_spec.rb +14 -16
  61. data/spec/unit/services_builder_spec.rb +10 -20
  62. data/ventriloquist.gemspec +0 -2
  63. metadata +11 -23
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class ElasticSearch < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['9292:9292']
7
+ @config[:args] ||= '-p 9292:9292'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class MailCatcher < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['1025:1025', '1080:1080']
7
+ @config[:args] ||= '-p 1025:1025 -p 1080:1080'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class Memcached < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['11211:11211']
7
+ @config[:args] ||= '-p 11211:11211'
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class MySql < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['3306:3306']
7
+ @config[:args] ||= '-p 3306:3306'
8
8
  end
9
9
 
10
10
  def provision(machine)
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class PostgreSQL < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['5432:5432']
7
+ @config[:args] ||= '-p 5432:5432'
8
8
  end
9
9
 
10
10
  def provision(machine)
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  class Redis < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= ['6379:6379']
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.2'
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
@@ -4,11 +4,7 @@ module VagrantPlugins
4
4
  class RethinkDB < Service
5
5
  def initialize(*args)
6
6
  super
7
- @config[:ports] ||= [
8
- '28015:28015',
9
- '29015:29015',
10
- '8080:8080'
11
- ]
7
+ @config[:args] ||= '-p 28015:28015 -p 29015:29015 -p 8080:8080'
12
8
  end
13
9
  end
14
10
  end
@@ -11,7 +11,7 @@ module VagrantPlugins
11
11
  module Ventriloquist
12
12
  class ServicesBuilder
13
13
  MAPPING = {
14
- 'pg' => Services::PostgreSQL,
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
- name, tag = name.to_s.split(':')
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
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Ventriloquist
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -1,16 +1,24 @@
1
1
  # Base image for creating Ventriloquist services
2
2
 
3
- FROM ubuntu:quantal
3
+ FROM debian:jessie
4
4
  MAINTAINER Fabio Rehm "fgrehm@gmail.com"
5
5
 
6
- ENV LC_ALL C
7
- ENV DEBIAN_FRONTEND noninteractive
8
-
9
- RUN echo "deb http://archive.ubuntu.com/ubuntu quantal main universe" > /etc/apt/sources.list && \
10
- apt-get update && \
11
- apt-get -y upgrade && \
12
- apt-get install -y wget curl vim language-pack-en build-essential software-properties-common && \
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
@@ -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}-pg postgresql/9.3
10
- docker build -t ${PREFIX}-pg:9.2 postgresql/9.2
11
- docker build -t ${PREFIX}-pg:9.1 postgresql/9.1
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:5.5 mysql/5.5
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-0.90.7.deb -O /tmp/elasticsearch.deb -q --no-check-certificate && \
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 install -y ruby ruby-dev sqlite3 libsqlite3-dev && apt-get clean
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.googlecode.com/files/memcached-1.4.15.tar.gz -O /tmp/memcached.tar.gz && \
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.15 && \
9
- apt-get install libevent1-dev -y && \
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* && apt-get clean
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 install libaio-dev -y && \
7
- wget -q http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-debian6.0-x86_64.deb -O /tmp/mysql.deb && \
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 # Save some disk space
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 install -y openjdk-7-jre-headless && apt-get clean
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
- # prevent apt from starting postgres right after the installation
6
- RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d; chmod +x /usr/sbin/policy-rc.d && \
7
- apt-get install -y -q postgresql-9.1 postgresql-contrib-9.1 && \
8
- apt-get clean && \
9
- rm /usr/sbin/policy-rc.d # allow autostart again
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
@@ -5,6 +5,8 @@ set -e
5
5
  user=$1
6
6
  password=$2
7
7
 
8
+ sed -i 's/^\(lc_.*\)$/# \1/g' /etc/postgresql/9.1/main/postgresql.conf
9
+
8
10
  /etc/init.d/postgresql start
9
11
 
10
12
  su postgres -c "createuser --superuser ${user}"
@@ -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 | sudo apt-key add - && \
6
- echo "deb http://apt.postgresql.org/pub/repos/apt precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
7
- apt-get update
8
-
9
- RUN apt-get install -y postgresql-9.2 postgresql-contrib-9.2 && \
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 /
@@ -5,6 +5,8 @@ set -e
5
5
  user=$1
6
6
  password=$2
7
7
 
8
+ sed -i 's/^\(lc_.*\)$/# \1/g' /etc/postgresql/9.2/main/postgresql.conf
9
+
8
10
  /etc/init.d/postgresql start
9
11
 
10
12
  su postgres -c "createuser --superuser ${user}"
@@ -2,11 +2,11 @@
2
2
 
3
3
  FROM fgrehm/ventriloquist-base
4
4
 
5
- RUN wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - && \
6
- echo "deb http://apt.postgresql.org/pub/repos/apt precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
7
- apt-get update
8
-
9
- RUN apt-get install -y postgresql-9.3 postgresql-contrib-9.3 && \
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 /
@@ -5,6 +5,8 @@ set -e
5
5
  user=$1
6
6
  password=$2
7
7
 
8
+ sed -i 's/^\(lc_.*\)$/# \1/g' /etc/postgresql/9.3/main/postgresql.conf
9
+
8
10
  /etc/init.d/postgresql start
9
11
 
10
12
  su postgres -c "createuser --superuser ${user}"
@@ -2,14 +2,17 @@
2
2
 
3
3
  FROM fgrehm/ventriloquist-base
4
4
 
5
- # Make sure to update lib/ventriloquist/services/redis.rb if the version gets bumped
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.2 && \
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 ppa:rethinkdb/ppa && \
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 'bogus/rspec'
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.treat_symbols_as_metadata_keys_with_true_values = true
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
- verify_contract(:platforms_builder)
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 have(3).items
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[:version]).to eq('version')
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[:version]).to eq('latest')
40
+ expect(your_lang.config[:versions]).to eq(['1.2'])
45
41
  end
46
42
 
47
43
  it 'configures services using defined configs' do
@@ -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
- verify_contract(:service)
10
-
11
- let(:docker_client) { fake(:docker_client, container_running?: false) }
12
- fake(:communicator) { VagrantPlugins::CommunicatorSSH::Communicator }
13
- fake(:ui) { Vagrant::UI::Interface }
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', tag: 'latest' } }
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.run_container(service_conf)
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.sudo('mkdir -p /var/lib/ventriloquist/cids')
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.run_container(with{|c| c[:cidfile] == expected_cidfile})
33
+ expect(docker_client).to have_received(:run_container).with(hash_including(cidfile: expected_cidfile))
36
34
  end
37
35
 
38
- it 'sets dns to 127.0.0.1 to reduce latency' do
39
- expect(docker_client).to have_received.run_container(with{|c| c[:dns] == "127.0.0.1"})
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) { fake(:docker_client, container_running?: true) }
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.run_container(any_args)
45
+ expect(docker_client).to_not have_received(:run_container)
48
46
  end
49
47
  end
50
48
  end