utils

package
v2.33.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DisplayNameKey         = "display_name"
	DefaultTestDisplayName = "nginx-agent-repo"
)
View Source
const (
	InitialConfTag1 = "locally-tagged"
	InitialConfTag2 = "tagged-locally"
)

Variables

These initial conf tags come from the values located in ../testdata/configs/agent-dynamic.conf

Functions

func CreateTestAgentConfigEnv

func CreateTestAgentConfigEnv() (string, string, func(), error)

CreateTestAgentConfigEnv creates an agent config file named "temp-nginx-agent.conf" and a dynamic config named "temp-agent-dynamic.conf" meant for testing in the current working directory. Additionally, a Viper config is created that has its variables set based off the created conf files ("temp-nginx-agent.conf" and "temp-agent-dynamic.conf"). It returns the name of the config ("nginx-agent.conf"), the name of the of the dynamic config ("temp-agent-dynamic.conf"), and a function to call that deletes the both of the files that were created.

func GetDetailsMap

func GetDetailsMap() map[string]*proto.NginxDetails

func GetDetailsNginxOssConfig added in v2.21.0

func GetDetailsNginxOssConfig() string

func GetMockAgentConfig

func GetMockAgentConfig() *config.Config

func GetNginxConfig added in v2.25.0

func GetNginxConfig(contents []byte) *proto.NginxConfig

func GetProcessMap added in v2.29.0

func GetProcessMap() map[string][]*proto.NginxDetails

func GetProcesses

func GetProcesses() []*core.Process

func GetTestAgentConfigPath

func GetTestAgentConfigPath() string

GetTestAgentConfigPath gets the absolute path to the test agent config

func ProcessResponse added in v2.23.0

func ProcessResponse(resp *resty.Response) []string

func StartFakeProcesses

func StartFakeProcesses(names []string, fakeProcsDuration string) func()

StartFakeProcesses creates a fake process for each of the string names and each fake process lasts for fakeProcsDuration of time (seconds), the function that is returned can be ran to kill all the fake processes that were created.

Types

type MockCommandClient

type MockCommandClient struct {
	mock.Mock
}

func GetMockCommandClient

func GetMockCommandClient(config *proto.NginxConfig) *MockCommandClient

func NewMockCommandClient

func NewMockCommandClient() *MockCommandClient

func (*MockCommandClient) ChunksSize

func (m *MockCommandClient) ChunksSize() int

func (*MockCommandClient) Close

func (m *MockCommandClient) Close() error

func (*MockCommandClient) Connect

func (m *MockCommandClient) Connect(ctx context.Context) error

func (*MockCommandClient) DialOptions

func (m *MockCommandClient) DialOptions() []grpc.DialOption

func (*MockCommandClient) Download

func (*MockCommandClient) Recv

func (m *MockCommandClient) Recv() <-chan client.Message

func (*MockCommandClient) Send

func (m *MockCommandClient) Send(ctx context.Context, message client.Message) error

func (*MockCommandClient) Server

func (m *MockCommandClient) Server() string

func (*MockCommandClient) Upload

func (m *MockCommandClient) Upload(_ context.Context, cfg *proto.NginxConfig, messageId string) error

func (*MockCommandClient) WithBackoffSettings

func (m *MockCommandClient) WithBackoffSettings(backoffSettings backoff.BackoffSettings) client.Client

func (*MockCommandClient) WithChunkSize

func (m *MockCommandClient) WithChunkSize(i int) client.Client

func (*MockCommandClient) WithClientInterceptor

func (m *MockCommandClient) WithClientInterceptor(interceptor interceptors.ClientInterceptor) client.Client

func (*MockCommandClient) WithConnWaitDuration

func (m *MockCommandClient) WithConnWaitDuration(d time.Duration) client.Client

func (*MockCommandClient) WithDialOptions

func (m *MockCommandClient) WithDialOptions(options ...grpc.DialOption) client.Client

func (*MockCommandClient) WithInterceptor

func (m *MockCommandClient) WithInterceptor(interceptor interceptors.Interceptor) client.Client

func (*MockCommandClient) WithServer

func (m *MockCommandClient) WithServer(s string) client.Client

type MockEnvironment

type MockEnvironment struct {
	mock.Mock
}

func GetMockEnv

func GetMockEnv() *MockEnvironment

func GetMockEnvWithHostAndProcess

func GetMockEnvWithHostAndProcess() *MockEnvironment

func GetMockEnvWithProcess

func GetMockEnvWithProcess() *MockEnvironment

func NewMockEnvironment

func NewMockEnvironment() *MockEnvironment

func (*MockEnvironment) DeleteFile added in v2.29.0

func (m *MockEnvironment) DeleteFile(backup core.ConfigApplyMarker, fileName string) error

func (*MockEnvironment) DiskDevices

func (m *MockEnvironment) DiskDevices() ([]string, error)

func (*MockEnvironment) DiskUsage added in v2.30.0

func (*MockEnvironment) DiskUsage(mountpoint string) (*core.DiskUsage, error)

func (*MockEnvironment) Disks added in v2.30.0

func (*MockEnvironment) Disks() ([]*proto.DiskPartition, error)

Disks implements core.Environment.

func (*MockEnvironment) FileStat

func (m *MockEnvironment) FileStat(path string) (os.FileInfo, error)

func (*MockEnvironment) GetContainerID

func (m *MockEnvironment) GetContainerID() (string, error)

func (*MockEnvironment) GetHostname

func (m *MockEnvironment) GetHostname() string

func (*MockEnvironment) GetNetOverflow

func (m *MockEnvironment) GetNetOverflow() (float64, error)

func (*MockEnvironment) GetSystemUUID

func (m *MockEnvironment) GetSystemUUID() string

func (*MockEnvironment) IsContainer

func (m *MockEnvironment) IsContainer() bool

func (*MockEnvironment) NewHostInfo

func (m *MockEnvironment) NewHostInfo(agentVersion string, tags *[]string, configDirs string, clearCache bool) *proto.HostInfo

func (*MockEnvironment) Processes

func (m *MockEnvironment) Processes() (result []*core.Process)

func (*MockEnvironment) ReadDirectory

func (m *MockEnvironment) ReadDirectory(dir string, ext string) ([]string, error)

func (*MockEnvironment) ReadFile

func (m *MockEnvironment) ReadFile(file string) ([]byte, error)

func (*MockEnvironment) Virtualization added in v2.33.0

func (m *MockEnvironment) Virtualization() (string, string)

func (*MockEnvironment) WriteFile added in v2.29.0

func (m *MockEnvironment) WriteFile(backup core.ConfigApplyMarker, file *proto.File, confPath string) error

func (*MockEnvironment) WriteFiles

func (m *MockEnvironment) WriteFiles(backup core.ConfigApplyMarker, files []*proto.File, prefix string, allowedDirs map[string]struct{}) error

type MockMetricsReportClient

type MockMetricsReportClient struct {
	mock.Mock
}

func NewMockMetricsReportClient

func NewMockMetricsReportClient() *MockMetricsReportClient

func (*MockMetricsReportClient) Close

func (m *MockMetricsReportClient) Close() error

func (*MockMetricsReportClient) Connect

func (m *MockMetricsReportClient) Connect(ctx context.Context) error

func (*MockMetricsReportClient) DialOptions

func (m *MockMetricsReportClient) DialOptions() []grpc.DialOption

func (*MockMetricsReportClient) Send

func (*MockMetricsReportClient) Server

func (m *MockMetricsReportClient) Server() string

func (*MockMetricsReportClient) WithBackoffSettings

func (m *MockMetricsReportClient) WithBackoffSettings(backoffSettings backoff.BackoffSettings) client.Client

func (*MockMetricsReportClient) WithClientInterceptor

func (m *MockMetricsReportClient) WithClientInterceptor(interceptor interceptors.ClientInterceptor) client.Client

func (*MockMetricsReportClient) WithConnWaitDuration

func (m *MockMetricsReportClient) WithConnWaitDuration(d time.Duration) client.Client

func (*MockMetricsReportClient) WithDialOptions

func (m *MockMetricsReportClient) WithDialOptions(options ...grpc.DialOption) client.Client

func (*MockMetricsReportClient) WithInterceptor

func (m *MockMetricsReportClient) WithInterceptor(interceptor interceptors.Interceptor) client.Client

func (*MockMetricsReportClient) WithServer

func (m *MockMetricsReportClient) WithServer(s string) client.Client

type MockNginxBinary

type MockNginxBinary struct {
	mock.Mock
}

func GetMockNginxBinary

func GetMockNginxBinary() *MockNginxBinary

func NewMockNginxBinary

func NewMockNginxBinary() *MockNginxBinary

func (*MockNginxBinary) GetAccessLogs added in v2.20.0

func (m *MockNginxBinary) GetAccessLogs() map[string]string

func (*MockNginxBinary) GetChildProcesses

func (m *MockNginxBinary) GetChildProcesses() map[string][]*proto.NginxDetails

func (*MockNginxBinary) GetErrorLogs added in v2.20.0

func (m *MockNginxBinary) GetErrorLogs() map[string]string

func (*MockNginxBinary) GetNginxDetailsByID

func (m *MockNginxBinary) GetNginxDetailsByID(nginxID string) *proto.NginxDetails

func (*MockNginxBinary) GetNginxDetailsFromProcess

func (m *MockNginxBinary) GetNginxDetailsFromProcess(nginxProcess *core.Process) *proto.NginxDetails

func (*MockNginxBinary) GetNginxDetailsMapFromProcesses

func (m *MockNginxBinary) GetNginxDetailsMapFromProcesses(nginxProcesses []*core.Process) map[string]*proto.NginxDetails

func (*MockNginxBinary) GetNginxIDForProcess

func (m *MockNginxBinary) GetNginxIDForProcess(nginxProcess *core.Process) string

func (*MockNginxBinary) ReadConfig

func (m *MockNginxBinary) ReadConfig(path, nginxId, systemId string) (*proto.NginxConfig, error)

func (*MockNginxBinary) Reload

func (m *MockNginxBinary) Reload(processId, bin string) error

func (*MockNginxBinary) Start

func (m *MockNginxBinary) Start(nginxId, bin string) error

func (*MockNginxBinary) Stop

func (m *MockNginxBinary) Stop(processId, bin string) error

func (*MockNginxBinary) UpdateLogs added in v2.20.0

func (m *MockNginxBinary) UpdateLogs(existing map[string]string, newLogs map[string]string) bool

func (*MockNginxBinary) UpdateNginxDetailsFromProcesses

func (m *MockNginxBinary) UpdateNginxDetailsFromProcesses(nginxProcesses []*core.Process)

func (*MockNginxBinary) ValidateConfig

func (m *MockNginxBinary) ValidateConfig(processId, bin, configLocation string, config *proto.NginxConfig, configApply *sdk.ConfigApply) error

func (*MockNginxBinary) WriteConfig

func (m *MockNginxBinary) WriteConfig(config *proto.NginxConfig) (*sdk.ConfigApply, error)

type Symbols

type Symbols struct {
	Host string `json:"host"`
	Port int64  `json:"port"`
	TLS  bool   `json:"tls"`
}

func LoadSymbolsFile

func LoadSymbolsFile() (*Symbols, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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