remote

package
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTests

func RunTests(t *testing.T, tests []TestCase)

RunTests runs all passed tests.

Types

type Error

type Error struct {
	SubCommand string
	ExitCode   int
	Stderr     string
}

Error represents an error that occurred while calling zsm on a remote host.

func (*Error) Error

func (e *Error) Error() string

type Host

type Host struct {
	User    string
	Addr    string
	AuthKey gossh.Signer
	HostKey gossh.PublicKey

	RemoteZSM string
	// contains filtered or unexported fields
}

Host represents a remote host on which ZSM is installed.

func (*Host) Close

func (h *Host) Close() error

Close closes the connection to the remote host.

func (*Host) Dial

func (h *Host) Dial() error

Dial creates a SSH connection to the remote host.

func (*Host) ListSnapshots

func (h *Host) ListSnapshots() ([]snapshot.Name, error)

ListSnapshots lists all snapshots available on the remote host.

func (*Host) ReceiveSnapshot

func (h *Host) ReceiveSnapshot(targetFS string, name snapshot.Name, r io.Reader) error

ReceiveSnapshot lets the remote host receive a snapshot with the passed name.

The snapshot data is read from r. It is written to targetFS with the name that is passed to ReceiveSnapshot.

Example:

Let a snapshot have the name zsm_test@2020-04-10T09:45:58.564585005Z and targetFS the value target_fs.

The remote host then writes the snapshot to target_fs/zsm_test@2020-04-10T09:45:58.564585005Z

type SSHTestServer

type SSHTestServer struct {
	// AuthorizedKeys contains public SSH keys of clients allowed to connect to
	// the server. Changes made after calling Serve are ignored.
	AuthorizedKeys []ssh.PublicKey

	// Receives the host key of this server once it has been initialized.
	HostKey chan<- gossh.Signer

	// The server writes any command a client passed when initiating a session
	// into this channel. Setting Command after calling Serve has no effect.
	Command chan<- []string

	// The server writes anything read from stdin into this channel.
	// Setting Stdin after calling Serve has no effect.
	Stdin chan<- []byte

	// The server writes this to stdout.
	// Setting Stdout after calling Serve has no effect.
	Stdout []byte

	// The server writes this to stderr.
	// Setting Stderr after calling Serve has no effect.
	Stderr []byte

	// Any errors that occur while handling a request are written to this channel.
	// Setting Errors after calling Serve has no effect.
	Errors chan<- error

	// The server terminates all sessions with this exit code. Changing ExitCode
	// after calling Serve has no effect.
	ExitCode int
	// contains filtered or unexported fields
}

SSHTestServer represents a simple SSH server for testing purposes.

func (*SSHTestServer) Close

func (s *SSHTestServer) Close() error

Close closes the server.

func (*SSHTestServer) Serve

func (s *SSHTestServer) Serve(l net.Listener) error

Serve accepts incoming connections to l.

type TestCase

type TestCase struct {
	Name string

	// Call calls invokes a method on the remote Host. It should return any error
	// returned by the called host method. Additionally it may use the passed T
	// to perform further assertions.
	Call func(*testing.T, *Host) error

	Stdin  func(*testing.T) []byte // returns stdin expected to be sent to remote host
	Stdout func(*testing.T) []byte // returns stdout expected to be sent by remote host
	Stderr func(*testing.T) []byte // returns stderr expected to be sent by remote host

	ZSMExitCode int      // expected exit code of remote zsm
	ZSMCommand  []string // expected arguments for remote zsm

	// Abort waiting on channels after this time elapsed.
	// Default 10ms per channel
	ChannelTimeout time.Duration
	// contains filtered or unexported fields
}

TestCase defines a test case for remote zsm invocation.

Directories

Path Synopsis
cmd
testserver
testserver provides a command to start the remote.SSHTestServer.
testserver provides a command to start the remote.SSHTestServer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL