services

package
v0.0.0-...-604d171 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Service interfaces bases

Service interfaces bases

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceAdapter

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

func NewServiceAdapter

func NewServiceAdapter(dut *lab_api.Dut, dutClient api.DutServiceClient, noReboot bool) ServiceAdapter

func (ServiceAdapter) CopyData

func (s ServiceAdapter) CopyData(ctx context.Context, sourceUrl string, destPath string) error

CopyData caches a file for a DUT locally from a GS url.

func (ServiceAdapter) CreateDirectories

func (s ServiceAdapter) CreateDirectories(ctx context.Context, dirs []string) error

Create directories is a thin wrapper around an mkdir command. Done here as it is expected to be reused often by many services.

func (ServiceAdapter) DeleteDirectory

func (s ServiceAdapter) DeleteDirectory(ctx context.Context, dir string) error

DeleteDirectory is a thin wrapper around an rm command. Done here as it is expected to be reused often by many services.

func (ServiceAdapter) ForceReconnectWithBackoff

func (s ServiceAdapter) ForceReconnectWithBackoff(ctx context.Context) error

ForceReconnectWithBackoff is a thin wrapper around DUT service's ForceReconnectWithBackoff.

func (ServiceAdapter) PathExists

func (s ServiceAdapter) PathExists(ctx context.Context, path string) (bool, error)

PathExists determines if a path exists in a DUT

func (ServiceAdapter) PipeData

func (s ServiceAdapter) PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error

PipeData uses the caching infrastructure to bring a file locally, allowing a user to pipe the result to any desired application.

func (ServiceAdapter) Restart

func (s ServiceAdapter) Restart(ctx context.Context) error

Restart restarts a DUT

func (ServiceAdapter) RunCmd

func (s ServiceAdapter) RunCmd(ctx context.Context, cmd string, args []string) (string, error)

RunCmd runs a command in a remote DUT

type ServiceAdapterInterface

type ServiceAdapterInterface interface {
	// RunCmd takes a command and argument and executes it remotely in the DUT,
	// returning the stdout as the string result and any execution error as the error.
	RunCmd(ctx context.Context, cmd string, args []string) (string, error)
	// Restart restarts a DUT (allowing cros-dut to reconnect for connection caching).
	Restart(ctx context.Context) error
	// PathExists is a simple wrapper for RunCmd for the sake of simplicity. If
	// the path exists True is returned, else False. An error implies a
	// a communication failure.
	PathExists(ctx context.Context, path string) (bool, error)
	// PipeData uses the caching infrastructure to bring an image into the lab.
	// Contrary to CopyData, the data here is pipeable to whatever is fed into
	// pipeCommand, rather than directly placed locally.
	PipeData(ctx context.Context, sourceUrl string, pipeCommand string) error
	// CopyData uses the caching infrastructure to copy a remote image to
	// the local path specified by destPath.
	CopyData(ctx context.Context, sourceUrl string, destPath string) error
	// DeleteDirectory is a simple wrapper for RunCmd for the sake of simplicity.
	DeleteDirectory(ctx context.Context, dir string) error
	// CreateDirectory is a simple wrapper for RunCmd for the sake of simplicity.
	// All directories specified in the array will be created.
	// As this uses "-p" option, subdirs are created regardless of whether parents
	// exist or not.
	CreateDirectories(ctx context.Context, dirs []string) error
	// ForceReconnectWithBackoff waits for the DUT to come back up/reconnect.
	ForceReconnectWithBackoff(ctx context.Context) error
}

ServiceAdapters are used to interface with a DUT All methods here are proxies to cros-dut (with some additions for simplicity)

type ServiceInterface

type ServiceInterface interface {
	// GetFirstState returns the first state in this state machine
	GetFirstState() ServiceState

	// CleanupOnFailure "undoes" the service execution to the extent possible,
	// removing temporary files, and, if feasible, reverting the run commands.
	// CleanupOnFailure function will be called if any ServiceState returns an
	// error when running Execute().
	// |states| will include all ServiceStates that were run; naturally, all of
	// them but last one would have succeeded to Execute().
	// |executionErr| is the error returned by Execute() of the last (failed)
	// ServiceState.
	CleanupOnFailure(states []ServiceState, executionErr error) error
}

ServiceInterface represents the state machine for this specific service installation. It holds installation metadata and provides helpers, including the generator of the first state for that installation.

type ServiceState

type ServiceState interface {
	// Execute Runs the state
	Execute(ctx context.Context) error
	// Next gets the next state in the state machine
	Next() ServiceState
	// Name gets the fully qualified name of this state
	Name() string
}

ServiceState is a single state representation.

Directories

Path Synopsis
Package crosservice state machine construction and helper
Package crosservice state machine construction and helper

Jump to

Keyboard shortcuts

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