Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'poolparty'
- require File.dirname(__FILE__) + "/../mysqler"
- describe "Mysql plugin" do
- before(:all) do
- @master, @instances = PoolParty::PluginSpecHelper.define_stubs(1)
- @mysqler = Mysqler.new
- Mysqler.stub!(:new).and_return @mysqler
- @mysqler.stub!(:read_config_file).and_return({:user => "iamauser",:password => 1234,:backup_dir => "mysql-backup"})
- end
- it "should be a PoolParty::Plugin" do
- Mysqler.superclass.should == PoolParty::Plugin
- end
- it "should load the plugin settings from a file" do
- @mysqler.load_db_settings
- @mysqler.db_settings.should_not == nil
- @mysqler.db_settings[:user].should == 'iamauser'
- end
- it "should upload config files to new instances" do
- @master.should_receive(:scp).with("#{PoolParty.user_dir}/config/my.cnf", "/etc/my.cnf")
- @master.stub!(:scp).with("mysqler.monit.conf", "/etc/monit.d/mysqler.monit.conf").and_return true
- @master.configure_cloud
- end
- it "should upload the mysqler.monit config files to the instances" do
- @master.stub!(:scp).with("#{PoolParty.user_dir}/config/my.cnf", "/etc/my.cnf")
- @master.should_receive(:scp).with("mysqler.monit.conf", "/etc/monit.d/mysqler.monit.conf").and_return true
- @master.configure_cloud
- end
- describe "setup for restore database" do
- before(:each) do
- @mysqler.stub!(:start_monit).and_return true
- @mysqler.stub!(:setup_backup).and_return true
- end
- it "should restore the database from backups when restarting" do
- @mysqler.load_db_settings
- @master.should_receive(:ssh).with("mysql -u #{@mysqler.db_settings[:user]} -p#{@mysqler.db_settings[:password]} < /data/#{@mysqler.db_settings[:backup_dir]}/db_dump.sql").and_return true
- @master.configure_cloud
- end
- end
- describe "setup for setup backups" do
- before(:each) do
- @mysqler.stub!(:start_monit).and_return true
- @mysqler.stub!(:restore_database).and_return true
- end
- it "should setup backups when installing a new database instance" do
- @mysqler.load_db_settings
- @master.should_receive(:ssh).with("cp #{@master.base_tmp_dir}/mysql-backup /etc/cron.d").and_return true
- @master.configure_cloud
- end
- end
- describe "setup for starting monit" do
- before(:each) do
- @mysqler.stub!(:setup_backup).and_return true
- @mysqler.stub!(:restore_database).and_return true
- end
- it "should start monit once new installation is completed" do
- @mysqler.load_db_settings
- @master.should_receive(:ssh).with("/etc/init.d/monit start").and_return true
- @master.configure_cloud
- end
- end
- end
Add Comment
Please, Sign In to add comment