componenttest

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 9 Imported by: 29

Documentation

Overview

Package componenttest define types and functions used to help test packages implementing the component package interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDocs added in v0.5.0

func CheckDocs(projectPath string, relativeComponentsPath string, projectGoModule string) error

CheckDocs returns an error if README.md for at least one enabled component is missing. "projectPath" is the absolute path to the root of the project to which the components belong. "defaultComponentsFilePath" is the path to the file that contains imports to all required components, "goModule" is the Go module to which the imports belong. This method is intended to be used only to verify documentation in Opentelemetry core and contrib repositories. Examples, 1) Usage in the core repo:

componenttest.CheckDocs(

		"path/to/project",
		"service/defaultcomponents/defaults.go",
     "go.opentelemetry.io/collector",
	)

2) Usage in the contrib repo: componenttest.CheckDocs(

		"path/to/project",
		"cmd/otelcontrib/components.go",
     "github.com/open-telemetry/opentelemetry-collector-contrib",
	).

func NewNopHost

func NewNopHost() component.Host

NewNopHost returns a new instance of NopHost with proper defaults for most tests.

Types

type ErrorWaitingHost

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

ErrorWaitingHost mocks an component.Host for test purposes.

func NewErrorWaitingHost

func NewErrorWaitingHost() *ErrorWaitingHost

NewErrorWaitingHost returns a new instance of ErrorWaitingHost with proper defaults for most tests.

func (*ErrorWaitingHost) GetExporters

func (*ErrorWaitingHost) GetExtensions

func (*ErrorWaitingHost) GetFactory

GetFactory of the specified kind. Returns the factory for a component type.

func (*ErrorWaitingHost) ReportFatalError

func (ews *ErrorWaitingHost) ReportFatalError(err error)

ReportFatalError is used to report to the host that the extension encountered a fatal error (i.e.: an error that the instance can't recover from) after its start function has already returned.

func (*ErrorWaitingHost) WaitForFatalError

func (ews *ErrorWaitingHost) WaitForFatalError(timeout time.Duration) (receivedError bool, err error)

WaitForFatalError waits the given amount of time until an error is reported via ReportFatalError. It returns the error, if any, and a bool to indicated if an error was received before the time out.

type NopHost

type NopHost struct {
}

NopHost mocks a receiver.ReceiverHost for test purposes.

func (*NopHost) GetExporters

func (*NopHost) GetExtensions

func (nh *NopHost) GetExtensions() map[configmodels.Extension]component.ServiceExtension

func (*NopHost) GetFactory

func (nh *NopHost) GetFactory(_ component.Kind, _ configmodels.Type) component.Factory

GetFactory of the specified kind. Returns the factory for a component type.

func (*NopHost) ReportFatalError

func (nh *NopHost) ReportFatalError(_ error)

ReportFatalError is used to report to the host that the receiver encountered a fatal error (i.e.: an error that the instance can't recover from) after its start function has already returned.

Jump to

Keyboard shortcuts

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