Class: Kitchen::Verifier::Busser

Inherits:
Base
  • Object
show all
Defined in:
lib/kitchen/verifier/busser.rb

Overview

Command string generator to interface with Busser. The commands that are generated are safe to pass to an SSH command or as an unix command argument (escaped in single quotes).

Author:

Instance Attribute Summary

Attributes included from Configurable

#instance

Instance Method Summary collapse

Methods inherited from Base

#call, #cleanup_sandbox, #doctor, kitchen_verifier_api_version, #prepare_command, #sandbox_path

Methods included from Logging

#banner, #debug, #error, #fatal, #info, #warn

Methods included from Configurable

#[], #bourne_shell?, #calculate_path, #config_keys, #diagnose, #diagnose_plugin, #finalize_config!, included, #name, #powershell_shell?, #remote_path_join, #unix_os?, #verify_dependencies, #windows_os?

Constructor Details

#initialize(config = {}) ⇒ Busser

Creates a new Busser object using the provided configuration data which will be merged with any default configuration.

Parameters:

  • config (Hash) (defaults to: {})

    provided driver configuration



57
58
59
# File 'lib/kitchen/verifier/busser.rb', line 57

def initialize(config = {})
  init_config(config)
end

Instance Method Details

#create_sandboxObject

Creates a temporary directory on the local workstation into which verifier related files and directories can be copied or created. The contents of this directory will be copied over to the instance before invoking the verifier’s run command. After this method completes, it is expected that the contents of the sandbox is complete and ready for copy to the remote instance.

Note: any subclasses would be well advised to call super first when overriding this method, for example:

Examples:

overriding ‘#create_sandbox`


class MyVerifier < Kitchen::Verifier::Base
  def create_sandbox
    super
    # any further file copies, preparations, etc.
  end
end


62
63
64
65
66
# File 'lib/kitchen/verifier/busser.rb', line 62

def create_sandbox
  super
  prepare_helpers
  prepare_suites
end

#init_commandString

Generates a command string which will perform any data initialization or configuration required after the verifier software is installed but before the sandbox has been transferred to the instance. If no work is required, then ‘nil` will be returned.

Returns:

  • (String)

    a command string



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/kitchen/verifier/busser.rb', line 69

def init_command
  return if local_suite_files.empty?

  cmd = sudo(config[:busser_bin]).dup
    .tap { |str| str.insert(0, "& ") if powershell_shell? }

  prefix_command(wrap_shell_code(Util.outdent!(<<-CMD)))
    #{busser_env}

    #{cmd} suite cleanup
  CMD
end

#install_commandString

Generates a command string which will install and configure the verifier software on an instance. If no work is required, then ‘nil` will be returned.

Returns:

  • (String)

    a command string



83
84
85
86
87
88
89
# File 'lib/kitchen/verifier/busser.rb', line 83

def install_command
  return if local_suite_files.empty?

  vars = install_command_vars

  prefix_command(shell_code_from_file(vars, "busser_install_command"))
end

#run_cmdString

Deprecated.

When backwards compatibility for old Busser methods is removed, this method will no longer be available. Use ‘#run_command` in its place.

Legacy method stub for ‘#run_cmd` which calls `#run_command`.

Returns:

  • (String)

    command string



119
# File 'lib/kitchen/verifier/busser.rb', line 119

define_method(:run_cmd) { run_command }

#run_commandString

Generates a command string which will invoke the main verifier command on the prepared instance. If no work is required, then ‘nil` will be returned.

Returns:

  • (String)

    a command string



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/kitchen/verifier/busser.rb', line 92

def run_command
  return if local_suite_files.empty?

  cmd = sudo(config[:busser_bin]).dup
    .tap { |str| str.insert(0, "& ") if powershell_shell? }

  prefix_command(wrap_shell_code(Util.outdent!(<<-CMD)))
    #{busser_env}

    #{cmd} test #{plugins.join(" ").gsub!("busser-", "")}
  CMD
end

#setup_cmdString

Deprecated.

When backwards compatibility for old Busser methods is removed, this method will no longer be available. Use ‘#install_command` in its place.

Legacy method stub for ‘#setup_cmd` which calls `#install_command`.

Returns:

  • (String)

    command string



111
# File 'lib/kitchen/verifier/busser.rb', line 111

define_method(:setup_cmd) { install_command }

#sync_cmdObject

Deprecated.

When backwards compatibility for old Busser methods is removed, this method will no longer be available. Use ‘transport#upload` to transfer test files in its place.

Legacy method stub for ‘#sync_cmd`.



126
127
128
129
130
131
# File 'lib/kitchen/verifier/busser.rb', line 126

def sync_cmd
  warn("Legacy call to #sync_cmd cannot be preserved, meaning that " \
    "test files will not be uploaded. " \
    "Code that calls #sync_cmd can now use the transport#upload " \
    "method to transfer files.")
end