Sha256: 5978647efb260deb76ba2f13b2d25ae1341d495e7edab8c70ad6fe11944c18d8

Contents?: true

Size: 1.87 KB

Versions: 66

Compression:

Stored size: 1.87 KB

Contents

module Beaker
  module DSL
    # These are simple patterns that appear frequently in beaker test
    # code, and are provided to simplify test construction.
    #
    #
    # It requires the class it is mixed into to provide the attribute
    # `hosts` which contain the hosts to search, these should implement
    # {Beaker::Host}'s interface. They, at least, must have #[]
    # and #to_s available and provide an array when #[]('roles') is called.
    #
    module Patterns

      # Execute a block selecting the hosts that match with the provided criteria
      # @param [Array<Host>, Host, String, Symbol] hosts_or_filter A host role as a String or Symbol that can be
      #                                                used to search for a set of Hosts,  a host name
      #                                                as a String that can be used to search for
      #                                                a set of Hosts, or a {Host}
      #                                                or Array<{Host}> to run the block against
      # @param [Hash{Symbol=>String}] opts Options to alter execution.
      # @option opts [Boolean] :run_in_parallel Whether to run on each host in parallel.
      # @param [Block] block This method will yield to a block of code passed by the caller
      #
      # @return [Array<Result>, Result, nil] An array of results, a result object, or nil.
      #   Check {Beaker::Shared::HostManager#run_block_on} for more details on this.
      def block_on hosts_or_filter, opts={}, &block
        block_hosts = nil
        if defined? hosts
          block_hosts = hosts
        end
        filter = nil
        if hosts_or_filter.is_a? String or hosts_or_filter.is_a? Symbol
          filter = hosts_or_filter
        else
          block_hosts = hosts_or_filter
        end
        run_block_on block_hosts, filter, opts, &block
      end

    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
beaker-4.42.0 lib/beaker/dsl/patterns.rb
beaker-4.41.2 lib/beaker/dsl/patterns.rb
beaker-4.41.1 lib/beaker/dsl/patterns.rb
beaker-4.41.0 lib/beaker/dsl/patterns.rb
beaker-4.40.2 lib/beaker/dsl/patterns.rb
beaker-4.40.1 lib/beaker/dsl/patterns.rb
beaker-4.40.0 lib/beaker/dsl/patterns.rb
beaker-4.39.0 lib/beaker/dsl/patterns.rb
beaker-4.38.1 lib/beaker/dsl/patterns.rb
beaker-4.38.0 lib/beaker/dsl/patterns.rb
beaker-4.37.2 lib/beaker/dsl/patterns.rb
beaker-4.37.1 lib/beaker/dsl/patterns.rb
beaker-4.37.0 lib/beaker/dsl/patterns.rb
beaker-4.36.1 lib/beaker/dsl/patterns.rb
beaker-4.36.0 lib/beaker/dsl/patterns.rb
beaker-4.35.0 lib/beaker/dsl/patterns.rb
beaker-4.34.0 lib/beaker/dsl/patterns.rb
beaker-4.33.0 lib/beaker/dsl/patterns.rb
beaker-4.32.0 lib/beaker/dsl/patterns.rb
beaker-4.31.0 lib/beaker/dsl/patterns.rb