testhelper

package
v0.3.44 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package testhelper provides test helpers which don't depend on viamcartographer

Package testhelper provides test helpers which don't depend on viamcartographer

Index

Constants

View Source
const (
	// NumPointCloudFiles is the number of mock lidar data files we want to use for the
	// integration tests. The files are stored in the mock_data/lidar slam artifact directory.
	NumPointCloudFiles = 10
	// NumMovementSensorData is the amount of mock movement sensor data we want to use for the
	// integration tests. The data is stored in the mock_data/movement_sensor/data.txt slam artifact file.
	NumMovementSensorData = 40
)
View Source
const (
	// SlamTimeFormat is the timestamp format used in the dataprocess.
	SlamTimeFormat = "2006-01-02T15:04:05.0000Z"
	// CartoFacadeTimeoutForTest is the timeout used for capi requests for tests.
	CartoFacadeTimeoutForTest = 5 * time.Second
	// CartoFacadeInternalTimeoutForTest is the timeout used for internal capi requests for tests.
	CartoFacadeInternalTimeoutForTest = 15 * time.Minute

	// LidarWithErroringFunctions is a lidar whose functions return errors.
	LidarWithErroringFunctions s.TestSensor = "stub_lidar"
	// MovementSensorWithErroringFunctions is a movement sensor whose functions return errors.
	MovementSensorWithErroringFunctions s.TestSensor = "stub_movement_sensor"
	// NoMovementSensor is a movement sensor that represents that no movement sensor is set up or added.
	NoMovementSensor s.TestSensor = ""
)

Variables

This section is empty.

Functions

func ClearDirectory

func ClearDirectory(t *testing.T, path string)

ClearDirectory deletes the contents in the path directory without deleting path itself.

func CreateIntegrationSLAMService

func CreateIntegrationSLAMService(
	t *testing.T,
	cfg *vcConfig.Config,
	timedLidar s.TimedLidar,
	timedMovementSensor s.TimedMovementSensor,
	logger logging.Logger,
) (slam.Service, error)

CreateIntegrationSLAMService creates a slam service for testing.

func CreateSLAMService

func CreateSLAMService(
	t *testing.T,
	cfg *vcConfig.Config,
	logger logging.Logger,
) (slam.Service, error)

CreateSLAMService creates a slam service for testing.

func CreateTimestampFilename

func CreateTimestampFilename(dataDirectory, lidarName, fileType string, timeStamp time.Time) string

CreateTimestampFilename creates an absolute filename with a primary sensor name and timestamp written into the filename.

func InitInternalState

func InitInternalState(t *testing.T, includeEditedMap bool) (string, func())

InitInternalState creates the internal state directory within a temp directory with an internal state pbstream file & returns the data directory & a function to delete the data directory.

func InitTestCL

func InitTestCL(t *testing.T, logger logging.Logger) func()

InitTestCL initializes the carto library & returns a function to terminate it.

func IntegrationCartographer added in v0.3.41

func IntegrationCartographer(
	t *testing.T,
	existingMap string,
	subAlgo viamcartographer.SubAlgo,
	logger logging.Logger,
	online bool,
	useIMU bool,
	useOdometer bool,
	enableMapping bool,
	expectedMode cartofacade.SlamMode,
) []byte

IntegrationCartographer is responsible for running a viam-cartographer process using the desired mock sensors. Once started it will wait for all data to be processed by monitoring sensor channels. After data has been fully processed, the endpoints Position, PointCloudMap, and InternalState are evaluated, and the process is closed out. The final internal state of cartographer is then returned.

func ResetFolder

func ResetFolder(path string) error

ResetFolder removes all content in path and creates a new directory in its place.

func SetupStubDeps

func SetupStubDeps(lidarName, movementSensorName s.TestSensor, t *testing.T) resource.Dependencies

SetupStubDeps returns stubbed dependencies based on the camera the stubs fail tests if called.

Types

This section is empty.

Jump to

Keyboard shortcuts

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