Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrDeploymentServiceUnavailable is returned when it is not possible to talk to the deployment service
var ErrInvalidOption = errors.New("Invalid option")
var ErrKeyNotFound = errors.New("Key not found")
ErrKeyNotFound is returned when the requested key is not found in the context
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 ¶
func OptionFromString ¶
func OptionsFromStrings ¶
func (*Option) MarshalText ¶
func (*Option) UnmarshalText ¶
type TagFilter ¶
type TagFilter string
TagFilter represents the intent to filter tags
func StringArrayToTagFilters ¶
StringArrayToTagFilters converts a string array to Tags
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