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, 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



61
62
63
# File 'lib/kitchen/verifier/busser.rb', line 61

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


66
67
68
69
70
# File 'lib/kitchen/verifier/busser.rb', line 66

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



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/kitchen/verifier/busser.rb', line 73

def init_command
  return if local_suite_files.empty?

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

  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



87
88
89
90
91
92
93
# File 'lib/kitchen/verifier/busser.rb', line 87

def install_command
  return if local_suite_files.empty?

  vars = install_command_vars

  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



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

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



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/kitchen/verifier/busser.rb', line 96

def run_command
  return if local_suite_files.empty?

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

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

    #{cmd} test
  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



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

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.



130
131
132
133
134
135
# File 'lib/kitchen/verifier/busser.rb', line 130

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