Module: Beaker::DSL::Roles

Included in:
Beaker::DSL
Defined in:
lib/beaker/dsl/roles.rb

Overview

Identifying hosts.

This aids in reaching common subsets of hosts in a testing matrix.

It requires the class it is mixed into to provide the attribute ‘hosts` which contain the hosts to search, these should implement Host’s interface. They, at least, must have #[] and #to_s available and provide an array when #[](‘roles’) is called.

Also the constant Outcomes::FailTest needs to be defined it will be raised in error conditions

Instance Method Summary collapse

Instance Method Details

#agentsArray<Host>

The hosts for which [‘roles’] include ‘agent’

Examples:

Basic usage

agents.each do |agent|
  ...test each agent in turn...
end


28
29
30
# File 'lib/beaker/dsl/roles.rb', line 28

def agents
  hosts_as 'agent'
end

#dashboardArray<Host>

The host for which [‘roles’] include ‘dashboard’

Examples:

Basic usage

on, agent, "curl https://#{database}/nodes/#{agent}"

Raises:



67
68
69
# File 'lib/beaker/dsl/roles.rb', line 67

def dashboard
  find_only_one :dashboard
end

#databaseArray<Host>

The host for which [‘roles’] include ‘database’

Examples:

Basic usage

on, agent, "curl -k http://#{database}:8080"

Raises:



54
55
56
# File 'lib/beaker/dsl/roles.rb', line 54

def database
  find_only_one :database
end

#find_only_one(role) ⇒ Host

Returns the host, if one and only one is found

Raises:

  • Raises a failure exception if one and only one host that matches the specified role is NOT found.



92
93
94
# File 'lib/beaker/dsl/roles.rb', line 92

def find_only_one role
  only_host_with_role(hosts, role)
end

#hosts_as(desired_role = nil) ⇒ Array<Host>

Select hosts that include a desired role from #hosts

Examples:

Basic usage

hairy = hosts_as :yak
hairy.each do |yak|
  on yak, 'shave'
end


84
85
86
# File 'lib/beaker/dsl/roles.rb', line 84

def hosts_as(desired_role = nil)
  hosts_with_role(hosts, desired_role)
end

#masterArray<Host>

The host for which [‘roles’] include ‘master’

Examples:

Basic usage

on, master, 'cat /etc/puppet/puppet.conf'

Raises:



41
42
43
# File 'lib/beaker/dsl/roles.rb', line 41

def master
  find_only_one :master
end