client

package
v0.50.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package client contains clients used to communicate with the remote service

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallStackInitializers

func CallStackInitializers[Env any](t *testing.T, env *Env, upResult auto.UpResult) error

CallStackInitializers validates an environment struct and initialise a stack. If a field of Env implements [pulumiStackInitializer], then [initFromPulumiStack] is called for this field.

func CheckEnvStructValid

func CheckEnvStructValid[Env any]() error

CheckEnvStructValid validates an environment struct

Types

type Agent

type Agent interface {
	// Version runs version command returns the runtime Agent version
	Version(commandArgs ...AgentArgsOption) string

	// Hostname runs hostname command and returns the runtime Agent hostname
	Hostname(commandArgs ...AgentArgsOption) string

	// Config runs config command and returns the runtime agent config
	Config(commandArgs ...AgentArgsOption) string

	// ConfigWithError runs config command and returns the runtime agent config or an error
	ConfigWithError(commandArgs ...AgentArgsOption) (string, error)

	// Flare runs flare command and returns the output. You should use the FakeIntake client to fetch the flare archive
	Flare(commandArgs ...AgentArgsOption) string

	// Health runs health command and returns the runtime agent health
	Health() (string, error)

	// ConfigCheck runs configcheck command and returns the runtime agent configcheck
	ConfigCheck(commandArgs ...AgentArgsOption) string

	// Integration run integration command and returns the output
	Integration(commandArgs ...AgentArgsOption) string

	// IntegrationWithError run integration command and returns the output
	IntegrationWithError(commandArgs ...AgentArgsOption) (string, error)

	// Secret runs the secret command
	Secret(commandArgs ...AgentArgsOption) string

	// IsReady runs status command and returns true if the command returns a zero exit code.
	// This function should rarely be used.
	IsReady() bool

	// Status runs status command and returns a Status struct
	Status(commandArgs ...AgentArgsOption) *Status

	// StatusWithError runs status command and returns a Status struct and error
	StatusWithError(commandArgs ...AgentArgsOption) (*Status, error)

	// WaitAgentLogs waits for the agent log corresponding to the pattern
	// agent-name can be: datadog-agent, system-probe, security-agent
	// pattern: is the log that we are looking for
	// Retries every 500 ms up to timeout.
	// Returns error on failure.
	WaitAgentLogs(agentName string, pattern string) error
	// contains filtered or unexported methods
}

Agent is an interface to run Agent command.

type AgentArgsOption

type AgentArgsOption = func(*agentArgs)

AgentArgsOption is an optional function parameter type for Agent arguments

func WithArgs

func WithArgs(args []string) AgentArgsOption

WithArgs sets the Agent arguments

type AgentClient added in v0.50.0

type AgentClient struct {
	// contains filtered or unexported fields
}

AgentClient is a type that provides methods to run remote commands on a test-infra-definition Agent.

func NewAgentClient added in v0.50.0

func NewAgentClient(t *testing.T, vm VM, os os.OS, shouldWaitForReady bool) (*AgentClient, error)

NewAgentClient creates a new instance of AgentClient

func (AgentClient) Config added in v0.50.0

func (agent AgentClient) Config(commandArgs ...AgentArgsOption) string

Config runs config command and returns the runtime agent config

func (AgentClient) ConfigCheck added in v0.50.0

func (agent AgentClient) ConfigCheck(commandArgs ...AgentArgsOption) string

ConfigCheck runs configcheck command and returns the runtime agent configcheck

func (AgentClient) ConfigWithError added in v0.50.0

func (agent AgentClient) ConfigWithError(commandArgs ...AgentArgsOption) (string, error)

ConfigWithError runs config command and returns the runtime agent config or an error

func (AgentClient) Flare added in v0.50.0

func (agent AgentClient) Flare(commandArgs ...AgentArgsOption) string

Flare runs flare command and returns the output. You should use the FakeIntake client to fetch the flare archive

func (AgentClient) Health added in v0.50.0

func (agent AgentClient) Health() (string, error)

Health runs health command and returns the runtime agent health

func (AgentClient) Hostname added in v0.50.0

func (agent AgentClient) Hostname(commandArgs ...AgentArgsOption) string

Hostname runs hostname command and returns the runtime Agent hostname

func (AgentClient) Integration added in v0.50.0

func (agent AgentClient) Integration(commandArgs ...AgentArgsOption) string

Integration run integration command and returns the output

func (AgentClient) IntegrationWithError added in v0.50.0

func (agent AgentClient) IntegrationWithError(commandArgs ...AgentArgsOption) (string, error)

IntegrationWithError run integration command and returns the output

func (AgentClient) IsReady added in v0.50.0

func (agent AgentClient) IsReady() bool

IsReady runs status command and returns true if the command returns a zero exit code. This function should rarely be used.

func (AgentClient) Secret added in v0.50.0

func (agent AgentClient) Secret(commandArgs ...AgentArgsOption) string

Secret runs the secret command

func (AgentClient) Status added in v0.50.0

func (agent AgentClient) Status(commandArgs ...AgentArgsOption) *Status

Status runs status command and returns a Status struct

func (AgentClient) StatusWithError added in v0.50.0

func (agent AgentClient) StatusWithError(commandArgs ...AgentArgsOption) (*Status, error)

StatusWithError runs status command and returns a Status struct and error

func (AgentClient) Version added in v0.50.0

func (agent AgentClient) Version(commandArgs ...AgentArgsOption) string

Version runs version command returns the runtime Agent version

func (AgentClient) WaitAgentLogs added in v0.50.0

func (agent AgentClient) WaitAgentLogs(agentName string, pattern string) error

WaitAgentLogs waits for the agent log corresponding to the pattern agent-name can be: datadog-agent, system-probe, security-agent pattern: is the log that we are looking for Retries every 500 ms up to timeout. Returns error on failure.

type Docker

type Docker struct {
	// contains filtered or unexported fields
}

A Docker client that is connected to an docker.Deamon.

func NewDocker

func NewDocker(daemon *docker.Daemon) *Docker

NewDocker creates a new instance of Docker

func (*Docker) ExecuteCommand

func (docker *Docker) ExecuteCommand(containerName string, commands ...string) string

ExecuteCommand executes a command on containerName and returns the output.

func (*Docker) ExecuteCommandStdoutStdErr

func (docker *Docker) ExecuteCommandStdoutStdErr(containerName string, commands ...string) (string, string, error)

ExecuteCommandStdoutStdErr executes a command on containerName and returns the output, the error output and an error.

func (*Docker) ExecuteCommandWithErr

func (docker *Docker) ExecuteCommandWithErr(containerName string, commands ...string) (string, error)

ExecuteCommandWithErr executes a command on containerName and returns the output and an error.

func (*Docker) GetAgent added in v0.50.0

func (docker *Docker) GetAgent() Agent

GetAgent gets an instance that implements the Agent interface. This function panics, if there is no agent container.

func (*Docker) GetAgentContainerName

func (docker *Docker) GetAgentContainerName() string

GetAgentContainerName gets the agent container name

func (*Docker) GetClient

func (docker *Docker) GetClient() *client.Client

GetClient gets the docker client.

type EC2Metadata

type EC2Metadata struct {
	// contains filtered or unexported fields
}

EC2Metadata contains a pointer to a VM and its AWS token

func NewEC2Metadata

func NewEC2Metadata(vm VM) *EC2Metadata

NewEC2Metadata creates a new EC2Metadata given an EC2 VM

func (*EC2Metadata) Get

func (m *EC2Metadata) Get(name string) string

Get returns EC2 instance name

type Fakeintake

type Fakeintake struct {
	*fakeintake.Client
	// contains filtered or unexported fields
}

A Fakeintake client that is connected to a fakeintake ECS task defined in test-infra-definition.

func NewFakeintake

func NewFakeintake(exporter *infraFakeintake.ConnectionExporter) *Fakeintake

NewFakeintake creates a new instance of

type PulumiStackAgent added in v0.50.0

type PulumiStackAgent struct {
	Agent
	// contains filtered or unexported fields
}

PulumiStackAgent is a type that implements Agent and uses the pulumi stack filled by agent.Installer to setup the connection with the Agent.

func NewPulumiStackAgent added in v0.50.0

func NewPulumiStackAgent(installer *agent.Installer, agentClientOptions ...agentclientparams.Option) *PulumiStackAgent

NewPulumiStackAgent creates a new instance of an Agent connected to an agent.Installer.

type PulumiStackVM added in v0.50.0

type PulumiStackVM struct {
	VM
	// contains filtered or unexported fields
}

PulumiStackVM is a type that implements VM and uses the pulumi stack filled by component.VM to setup the connection with the VM.

func NewPulumiStackVM added in v0.50.0

func NewPulumiStackVM(infraVM commonvm.VM) *PulumiStackVM

NewPulumiStackVM creates a new instance of PulumiStackVM

func (*PulumiStackVM) GetOS added in v0.50.0

func (vm *PulumiStackVM) GetOS() commonos.OS

GetOS is a temporary method while NewVMClient and AgentNewClient require an instance of OS.

type Status

type Status struct {
	Content string
}

Status contains the Agent status content

type VM

type VM interface {
	// ExecuteWithError executes a command and returns an error if any.
	ExecuteWithError(command string, options ...executeparams.Option) (string, error)

	// Execute executes a command and returns its output.
	Execute(command string, options ...executeparams.Option) string

	// CopyFile copy file to the remote host
	CopyFile(src string, dst string)

	// CopyFolder copy a folder to the remote host
	CopyFolder(srcFolder string, dstFolder string)
}

VM is an interface that provides methods to run commands on a virtual machine.

type VMClient added in v0.50.0

type VMClient struct {
	// contains filtered or unexported fields
}

VMClient is a type that implements VM interface to interact with a remote VM.

func NewVMClient added in v0.50.0

func NewVMClient(t *testing.T, connection *utils.Connection, osType componentos.Type) (*VMClient, error)

NewVMClient creates a new instance of VMClient.

func (*VMClient) CopyFile added in v0.50.0

func (vmClient *VMClient) CopyFile(src string, dst string)

CopyFile copy file to the remote host

func (*VMClient) CopyFolder added in v0.50.0

func (vmClient *VMClient) CopyFolder(srcFolder string, dstFolder string)

CopyFolder copy a folder to the remote host

func (*VMClient) Execute added in v0.50.0

func (vmClient *VMClient) Execute(command string, options ...executeparams.Option) string

Execute executes a command and returns its output.

func (*VMClient) ExecuteWithError added in v0.50.0

func (vmClient *VMClient) ExecuteWithError(command string, options ...executeparams.Option) (string, error)

ExecuteWithError executes a command and returns an error if any.

Directories

Path Synopsis
Package agentclientparams implements function parameters for [e2e.Agent]
Package agentclientparams implements function parameters for [e2e.Agent]
Package executeparams implements function parameters for [client.vmClient]
Package executeparams implements function parameters for [client.vmClient]

Jump to

Keyboard shortcuts

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