Permalink
Browse files

Merge pull request #4 from newrelic/vagrant-support

Add support for testing with Vagrant
  • Loading branch information...
2 parents 62df95e + 1ac38e8 commit 8033fbcb0fba340f484f9cce4a49e68e4bb93f66 @wjessop wjessop committed Jan 4, 2013
Showing with 293 additions and 43 deletions.
  1. +2 −0 .gitignore
  2. +4 −1 Gemfile
  3. +20 −0 Gemfile.lock
  4. +38 −0 Rakefile
  5. +28 −0 Vagrantfile
  6. +18 −8 cluster.yml
  7. +85 −34 mysql_role_swap.rb
  8. +16 −0 vagrant-configs/master.cnf
  9. +66 −0 vagrant-configs/setup.sh
  10. +16 −0 vagrant-configs/slave.cnf
View
@@ -0,0 +1,2 @@
+*.swp
+.vagrant
View
@@ -2,8 +2,11 @@ source "https://rubygems.org"
gem 'mysql', '2.8.1'
gem 'activerecord'
-#gem 'activerecord-mysql-adapter'
gem 'statemachine'
gem 'colorize'
gem 'choice'
+group :development do
+ gem 'vagrant'
+end
+
View
@@ -12,15 +12,34 @@ GEM
activesupport (3.2.9)
i18n (~> 0.6)
multi_json (~> 1.0)
+ archive-tar-minitar (0.5.2)
arel (3.0.2)
builder (3.0.4)
+ childprocess (0.3.6)
+ ffi (~> 1.0, >= 1.0.6)
choice (0.1.6)
colorize (0.5.8)
+ erubis (2.7.0)
+ ffi (1.2.0)
i18n (0.6.1)
+ json (1.5.4)
+ log4r (1.1.10)
multi_json (1.4.0)
mysql (2.8.1)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-ssh (2.2.2)
statemachine (2.0.1)
tzinfo (0.3.35)
+ vagrant (1.0.5)
+ archive-tar-minitar (= 0.5.2)
+ childprocess (~> 0.3.1)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6.0)
+ json (~> 1.5.1)
+ log4r (~> 1.1.9)
+ net-scp (~> 1.0.4)
+ net-ssh (~> 2.2.2)
PLATFORMS
ruby
@@ -31,3 +50,4 @@ DEPENDENCIES
colorize
mysql (= 2.8.1)
statemachine
+ vagrant
View
@@ -0,0 +1,38 @@
+require 'vagrant'
+
+# Default to running a test
+task :default => :test
+
+# Functional test
+desc "Test the code!"
+task :test do
+ # Startup the environment
+ env = Vagrant::Environment.new
+ puts "Configuring vagrant instances..."
+ env.cli("up")
+
+ if $?.exitstatus == 0
+ # Run the script against vagrant
+ exec("./mysql_role_swap.rb -c cluster.yml -f")
+ else
+ puts "Failed to start the vagrant environment!"
+ end
+end
+
+desc "Shutdown the vagrant environment"
+task :stop do
+ # Startup the environment
+ env = Vagrant::Environment.new
+ puts "Stopping vagrant instances..."
+ env.cli("halt")
+end
+
+desc "Remove any lingering vagrant instances"
+task :clean do
+ # Startup the environment
+ env = Vagrant::Environment.new
+ puts "Stopping vagrant instances..."
+ env.cli("halt")
+ puts "Deleting vagrant instances..."
+ env.cli("destroy", "--force")
+end
View
@@ -0,0 +1,28 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant::Config.run do |config|
+ # Every Vagrant virtual environment requires a box to build off of.
+ config.vm.box = "CentOS-6.3-x86_64-minimal"
+ config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/#{config.vm.box}.box"
+
+ # Boot with a GUI so you can see the screen. (Default is headless)
+ #config.vm.boot_mode = :gui
+
+
+ #
+ # Targets
+ #
+ config.vm.define :mysql1 do |target_config|
+ target_config.vm.host_name = 'test-mysql-1'
+ target_config.vm.network :hostonly, "192.168.50.31"
+ target_config.vm.provision :shell, :path => 'vagrant-configs/setup.sh', :args => "master"
+ end
+
+ config.vm.define :mysql2 do |target_config|
+ target_config.vm.host_name = 'test-mysql-2'
+ target_config.vm.network :hostonly, "192.168.50.32"
+ target_config.vm.provision :shell, :path => 'vagrant-configs/setup.sh', :args => "slave"
+ end
+end
+
View
@@ -1,17 +1,27 @@
+floating_ip: 192.168.50.30
+floating_ip_cidr: /32
+master_ipmi_address: 192.168.51.30
+
+ssh_username: vagrant
+ssh_key_file: ~/.vagrant.d/insecure_private_key
+
database_one:
adapter: mysql
- primary_database: dbname
+ primary_database: test
username: root
- password: XXX
- host: 10.10.5.82
+# password: rootpw
+ host: 192.168.50.31
port: 3306
- slave_password: XXX
+ slave_password: slavepw
+ floating_dev: eth1
database_two:
adapter: mysql
- primary_database: dbname
+ primary_database: test
username: root
- password: XXX
- host: 10.10.5.83
+# password: rootpw
+ host: 192.168.50.32
port: 3306
- slave_password: XXX
+ slave_password: slavepw
+ floating_dev: eth1
+
Oops, something went wrong.

0 comments on commit 8033fbc

Please sign in to comment.