voxpupuli / puppet-keepalived

Puppet Module to manage Keepalived
https://forge.puppet.com/puppet/keepalived
Apache License 2.0
49 stars 150 forks source link

Beaker tests for multiple nodes acceptance testing #66

Open petems opened 9 years ago

petems commented 9 years ago

Hi @arioch!

I remember you asking about how to write beaker specs for multiple nodes at the Puppet Contributor Summit, and I just figured out an example of how it could work:

Node set

HOSTS:
  master:
    roles:
      - default
      - master
    platform: el-6-x86_64
    box : centos-64-x64-vbox4210-nocm
    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
    hypervisor : vagrant
  backup:
    roles:
      - default
      - backup
    platform: el-6-x86_64
    box : centos-64-x64-vbox4210-nocm
    box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
    hypervisor : vagrant
CONFIG:
 type: foss
require 'spec_helper_acceptance'

if hosts.length > 1
  describe "configuring multi-node keepalived" do
    let(:ipaddresses) do
      hosts_as('backup').inject({}) do |memo,host|
        memo[host] = fact_on host, "ipaddress_eth1"
        memo
      end
    end

    hosts_as('backup').each do |host|
      it "should be able to configure a host as backup on #{host}" do
        pp = <<-EOS
          # Puppet code for BACKUP state here
        EOS
        apply_manifest_on(host, pp, :catch_failures => true)
      end
    end

    hosts_as('master').each do |host|
      it "should be able to configure a host as backup on #{host}" do
        pp = <<-EOS
          # Puppet code for MASTER state here
        EOS
        apply_manifest_on(host, pp, :catch_failures => true)
      end
    end

    # Some sort of text to destroy host here and check that IP goes back to master?

  end
end
arioch commented 9 years ago

Ohh excellent, thanks! :+1: Will have a closer look at it over the weekend.

petems commented 9 years ago

No prob! :smile: I adapted this from @hunner's HAProxy multi-node testing code