diagnostics

package
v0.0.0-...-be2ef80 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeploymentServiceUnavailable = errors.New("Deployment service unavailable")

ErrDeploymentServiceUnavailable is returned when it is not possible to talk to the deployment service

View Source
var ErrInvalidOption = errors.New("Invalid option")
View Source
var ErrKeyNotFound = errors.New("Key not found")

ErrKeyNotFound is returned when the requested key is not found in the context

View Source
var RegisteredDiagnostics []Diagnostic

RegisteredDiagnostics are a list of diagnostics that are registered

Functions

func RegisterDiagnostic

func RegisterDiagnostic(diagnostic Diagnostic)

RegisterDiagnostic registers a diagnostic into the global list of diagnostics

Types

type Diagnostic

type Diagnostic struct {
	Name     string
	Tags     Tags
	Generate func(TestContext) error
	Verify   func(VerificationTestContext)
	Cleanup  func(TestContext) error
	// Skip allows skipping diagnostics based on some condition
	Skip func(TestContext) (bool, string, error)
}

Diagnostic is a structure that describes a test we can run. It will first get a chance to generate data in the Generate function. Then, it will have chance do any verifications in Verify. Be sure to use the testify framework there. The last step it will get to perform is any cleanup in Cleanup. All steps are optional, only name is required

func (Diagnostic) MatchesFilters

func (d Diagnostic) MatchesFilters(tagFilters []TagFilter) bool

MatchesFilters determines if a set of TagFilters matches the diagnostic negations are applied in such a way that they are AND'd together nonnegations are OR'd together

type Option

type Option struct {
	Key   string
	Value string
}

func OptionFromString

func OptionFromString(option string) (*Option, error)

func OptionsFromStrings

func OptionsFromStrings(options []string) ([]*Option, error)

func (*Option) AsInt

func (o *Option) AsInt(defaultVal int) int

func (*Option) AsString

func (o *Option) AsString(defaultVal string) string

func (*Option) MarshalText

func (o *Option) MarshalText() (text []byte, err error)

func (*Option) UnmarshalText

func (o *Option) UnmarshalText(text []byte) error

type Tag

type Tag string

Tag is a grouping identifier that can be used for filtering

type TagFilter

type TagFilter string

TagFilter represents the intent to filter tags

func StringArrayToTagFilters

func StringArrayToTagFilters(strs []string) []TagFilter

StringArrayToTagFilters converts a string array to Tags

func (TagFilter) IsNegate

func (t TagFilter) IsNegate() bool

IsNegate returns true if the intent is to negate the filter

func (TagFilter) Tag

func (t TagFilter) Tag() Tag

Tag returns the Tag name of the filter as a Tag it will strip negations

type Tags

type Tags []Tag

Tags is a group of tags

func (Tags) Matches

func (tags Tags) Matches(tagToMatch Tag) bool

Matches returns true if there is a matching tag

type TestContext

type TestContext interface {
	// GetValue returns the value for a given key. It will decode it into value,
	// which should be a pointer to a map or a struct
	GetValue(key string, value interface{}) error
	// SetValue sets key to the given value.
	SetValue(key string, value interface{})
	// WriteJSON writes out to json all the values that have been set, along with
	// the admin token that was used or generated
	WriteJSON(writer io.Writer) error
	// DoLBRequest performs an authenticated request against the automate load balancer
	DoLBRequest(path string, opts ...lbrequest.Opts) (*http.Response, error)
	// PublishViaNATS publishes the messages to the automate event gateway
	PublishViaNATS([][]byte) error
	// GetOption returns the Option for the given key
	GetOption(key string) *Option
	// GetVersion returns the version of automate that is running
	GetVersion() (string, error)
	// IsIAMV2 returns whether or not automate is on the latest version of IAM
	IsIAMV2() (bool, error)
	// CleanupAdminToken deletes the admin token generated for the diagnostics test runner
	CleanupAdminToken() error
}

TestContext is the context that is passed to all diagnostics. They may set and retrieve values from it. The values can be saved to JSON to be recalled later

func LoadTestContext

func LoadTestContext(dsClient api.DeploymentClient, reader io.Reader, opts ...TestContextOpt) (TestContext, error)

LoadTestContext loads a saved TestContext

func NewTestContext

func NewTestContext(dsClient api.DeploymentClient, opts ...TestContextOpt) TestContext

NewTestContext creates a test context with the given DeploymentClient

type TestContextOpt

type TestContextOpt func(*testContext)

TestContextOpt is an functional option creating a test context

func WithAdminToken

func WithAdminToken(token string) TestContextOpt

WithAdminToken sets the admin token to use

func WithLBURL

func WithLBURL(url url.URL) TestContextOpt

func WithOptions

func WithOptions(options []*Option) TestContextOpt

type VerificationTestContext

type VerificationTestContext interface {
	TestContext
	Errorf(format string, args ...interface{})
	FailNow()
}

VerificationTestContext is accepted by the Verify stage of a diagnostic. This interface will allow the Verify to use the testify testing framework to write assertions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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