testutils

package
v0.19.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SIGTERM = "-15"
	SIGKILL = "-9"
)
View Source
const CPUForTests = 0 // CPU to pin test processes to

Variables

View Source
var (
	TrackerBinary   = "../../dist/tracker"
	TrackerHostname = "localhost"
	TrackerPort     = 3366
)

Functions

func DiscoverChildProcesses

func DiscoverChildProcesses(pid int) ([]int, error)

DiscoverChildProcesses discovers all child processes of a given PID.

func ExecCmdBgWithSudoAndCtx

func ExecCmdBgWithSudoAndCtx(ctx context.Context, command string) (int, chan error)

ExecCmdBgWithSudoAndCtx executes a command with sudo in the background, and returns the PID of the process and a channel to wait for the command to exit (Check RunningTracker object about how to use this).

func ExecPinnedCmdWithTimeout

func ExecPinnedCmdWithTimeout(command string, timeout time.Duration) (int, error)

ExecPinnedCmdWithTimeout executes a cmd with a timeout and returns the PID of the process.

func IsSudoCmdAvailableForThisUser

func IsSudoCmdAvailableForThisUser() bool

IsSudoCmdAvailableForThisUser checks if the sudo command is available for the current user.

func ParseCmd

func ParseCmd(fullCmd string) (string, []string, error)

ParseCmd parses a command string into a command and arguments.

func PinProccessToCPU

func PinProccessToCPU(id ...int) error

PinProccessToCPU pins the current process to a specific CPU

func SudoKillProcess

func SudoKillProcess(pid int, force bool) error

SudoKillProcess kills a process with sudo.

Types

type RunningTracker

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

RunningTracker is a wrapper for a running tracker process as a regular process.

func NewRunningTracker

func NewRunningTracker(givenCtx context.Context, cmdLine string) *RunningTracker

NewRunningTracker creates a new RunningTracker instance.

func (*RunningTracker) IsReady

func (r *RunningTracker) IsReady() bool

IsReady checks if the tracker process is ready.

func (*RunningTracker) Start

func (r *RunningTracker) Start() (<-chan TrackerStatus, error)

Start starts the tracker process.

func (*RunningTracker) Stop

func (r *RunningTracker) Stop() error

Stop stops the tracker process.

type TrackerStatus

type TrackerStatus int
const (
	TrackerStarted TrackerStatus = iota
	TrackerFailed
	TrackerTimedout
	TrackerAlreadyRunning
)

Jump to

Keyboard shortcuts

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