Documentation ¶
Overview ¶
Package greenbay provides the core greenbay application functionality, distinct from user interfaces.
The core greenbay test execution code is available here to support better testing and alternate interfaces. Currently the only interface is a command line interface, but we could wrap this functionality in a web service to support easier integration with monitoring tools or other health-check services.
The core functionality of the application is in the Application structure which stores application and facilitates the integration of output production, test running, and test configuration.
Package greenbay contains the basic type definition used in the greenbay application.
Overview ¶
The Greenbay application is a system integration testing and validation tool. It contains definitions of some generic test functions, such as "does this file exist" and "do these commands succeed." Specific tests are defined using these functions in a configuration file, and tests are run on hosts to ensure that the system is correctly configured.
The Checker interface is a superset of the amboy.Job interface. In most cases, specific check implementations inculde the check.Base type, which contains implementations of most methods (except for Run()) required by this interface.
Index ¶
- func AddFactory(name string, factory ResultsFactory)
- func SetupLogging(format string, fileName string) error
- type Application
- type Builder
- type CheckOutput
- type Checker
- type Client
- type Configuration
- type GoTest
- type GripOutput
- type JSONResults
- type JobWithError
- type OutputOptions
- func (o *OutputOptions) CollectResults(jobs <-chan amboy.Job) error
- func (o *OutputOptions) GetResultsProducer() (ResultsProducer, error)
- func (o *OutputOptions) ProduceResults(ctx context.Context, q amboy.Queue) error
- func (o *OutputOptions) Report(jobs <-chan amboy.Job) (map[string]*CheckOutput, error)
- type Report
- type Results
- type ResultsFactory
- type ResultsProducer
- type Service
- type TimingInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFactory ¶
func AddFactory(name string, factory ResultsFactory)
AddFactory provides a mechanism for adding additional results output to output registry.
func SetupLogging ¶
SetupLogging is a helper to configure the global grip logging instance, and is used in the main package to configure logging for the Greebay Service. Reconfigures the logging backend for the process' default "grip" logging instance.
Types ¶
type Application ¶
type Application struct { Output *OutputOptions Conf *Configuration NumWorkers int Tests []string Suites []string }
Application encapsulates the execution of a greenbay run. You can construct the object, either with NewApplication(), or by building a Application structure yourself.
func NewApplication ¶
func NewApplication(confPath, outFn, format string, quiet bool, jobs int, suite, tests []string) (*Application, error)
NewApplication configures the greenbay application and manages the construction of the main config object as well as the output configuration structure. Returns an error if there are problems constructing either the main config or the output configuration objects.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides an interface to build a Configuration object programmatically. Primarily useful in testing or potentially for building out a greenbay-based test service.
func NewBuilder ¶
func NewBuilder() *Builder
NewBuilder constructs a fully initialized Builder object.
func (*Builder) AddCheck ¶
AddCheck takes a greenbay.Checker implementation and adds it to the underlying config object.
func (*Builder) Conf ¶
func (b *Builder) Conf() (*Configuration, error)
Conf returns a fully constructed and resolved Configuration, returning an error if there are any parsing or validation errors.
Be aware that the config object returned is a *copy* of the config object in the builder, which allows you to generate and mutate generated multiple configs without impacting the builder's config. However, this operation does the correct but peculiar operation of copying a mutex in the config object.
Additionally, in most cases you'll want a *pointer* to this object produced by this method.
type CheckOutput ¶
type CheckOutput struct { Completed bool `bson:"completed" json:"completed" yaml:"completed"` Passed bool `bson:"passed" json:"passed" yaml:"passed"` Check string `bson:"check_type" json:"check_type" yaml:"check_type"` Name string `bson:"name" json:"name" yaml:"name"` Message string `bson:"message,omitempty" json:"message,omitempty" yaml:"message,omitempty"` Error string `bson:"error,omitempty" json:"error,omitempty" yaml:"error,omitempty"` Suites []string `bson:"suites" json:"suites" yaml:"suites"` Timing TimingInfo `bson:"timing" json:"timing" yaml:"timing"` }
CheckOutput provides a standard report format for tests that includes their result status and other metadata that may be useful in reporting data to users.
type Checker ¶
type Checker interface { // SetID modifies the ID reported by the ID() method in the // amboy.Job interface. SetID(string) // Output returns a common output format for all greenbay checks. Output() CheckOutput // Suites are a list of test suites associated with this check. SetSuites([]string) Suites() []string // Name returns the name of the checker. Use ID(), in the // amboy.Job interface to get a unique identifier for the // task. This is typically the same as the // amboy.Job.Type().Name value. Name() string // Checker includes the amboy.Job interface. amboy.Job }
Checker is a superset of amboy.Job that includes several other features unique to Greenbay checks. These methods, in addition to all methods in the amboy.Job interface, except for Run(), are implemented by the check.Base type, which specific jobs can compose.
type Client ¶
type Client struct { Conf *Configuration Output *OutputOptions Tests []string Suites []string // contains filtered or unexported fields }
Client provides all of the core greenbay operations by doing requests against a remote service, provided by GreenbayService.
type Configuration ¶
type Configuration struct { Options *options `bson:"options" json:"options" yaml:"options"` RawTests []rawTest `bson:"tests" json:"tests" yaml:"tests"` // contains filtered or unexported fields }
Configuration defines the structure for a single greenbay test run, including execution behavior (options) and check definitions.
func ReadConfig ¶
func ReadConfig(fn string) (*Configuration, error)
ReadConfig takes a path name to a configuration file (yaml formatted,) and returns a configuration format.
func (*Configuration) GetAllTests ¶
func (c *Configuration) GetAllTests(tests, suites []string) <-chan JobWithError
GetAllTests returns a channel that produces tests given lists of tests and suites.
func (*Configuration) Reload ¶
func (c *Configuration) Reload() error
Reload reparses the local test file, and makes it possible to use greenbay as a service and change the test definition without restarting the service.
func (*Configuration) TestsByName ¶
func (c *Configuration) TestsByName(names ...string) <-chan JobWithError
TestsByName is a generator takes one or more names of tests (as strings) and returns a channel of result objects that contain errors (if those names do not exist) and job objects.
func (*Configuration) TestsForSuites ¶
func (c *Configuration) TestsForSuites(names ...string) <-chan JobWithError
TestsForSuites takes the name of a suite and then produces a sequence of jobs that are part of that suite.
type GoTest ¶
type GoTest struct {
// contains filtered or unexported fields
}
GoTest defines a ResultsProducer implementation that generates output in the format of "go test -v"
func (*GoTest) Populate ¶
Populate generates output, based on the content (via the Results() method) of an amboy.Queue instance. All jobs processed by that queue must also implement the greenbay.Checker interface.
func (*GoTest) SkipPassing ¶
func (r *GoTest) SkipPassing()
SkipPassing causes the reporter to skip all passing tests in the report.
type GripOutput ¶
type GripOutput struct {
// contains filtered or unexported fields
}
GripOutput provides a ResultsProducer implementation that writes the results of a greenbay run to logging using the grip logging package.
func (*GripOutput) Populate ¶
func (r *GripOutput) Populate(jobs <-chan amboy.Job) error
Populate generates output messages based on a sequence of amboy.Jobs. All jobs must also implement the greenbay.Checker interface. Returns an error if there are any invalid jobs.
func (*GripOutput) Print ¶
func (r *GripOutput) Print() error
Print logs, to standard output, the results of the greenbay operation. If any tasks failed, this operation returns an error.
func (*GripOutput) SkipPassing ¶
func (r *GripOutput) SkipPassing()
SkipPassing causes the reporter to skip all passing tests in the report.
type JSONResults ¶
type JSONResults struct {
// contains filtered or unexported fields
}
JSONResults provides a structured output JSON format.
func (*JSONResults) Populate ¶
func (r *JSONResults) Populate(jobs <-chan amboy.Job) error
Populate generates output messages based on a sequence of amboy.Jobs. All jobs must also implement the greenbay.Checker interface. Returns an error if there are any invalid jobs.
func (*JSONResults) Print ¶
func (r *JSONResults) Print() error
Print logs, to standard output, the results of the greenbay operation. If any tasks failed, this operation returns an error.
func (*JSONResults) SkipPassing ¶
func (r *JSONResults) SkipPassing()
SkipPassing causes the reporter to skip all passing tests in the report.
type JobWithError ¶
JobWithError is a type used by the test generators and contains an amboy.Job and an error message.
type OutputOptions ¶
type OutputOptions struct {
// contains filtered or unexported fields
}
OutputOptions represents all operations for output generation, and provides methods for accessing and producing results using that configuration regardless of underlying output format.
func NewOutputOptions ¶
func NewOutputOptions(fn, format string, quiet bool) (*OutputOptions, error)
NewOutputOptions provides a constructor to generate a valid OutputOptions structure. Returns an error if the specified format is not valid or registered.
func (*OutputOptions) CollectResults ¶
func (o *OutputOptions) CollectResults(jobs <-chan amboy.Job) error
CollectResults takes a channel that produces jobs and produces results according to the options specified in the OutputOptions structure. ProduceResults returns an error if any of the tests failed in the operation.
func (*OutputOptions) GetResultsProducer ¶
func (o *OutputOptions) GetResultsProducer() (ResultsProducer, error)
GetResultsProducer returns the ResultsProducer implementation specified in the OutputOptions structure, and returns an error if the format specified in the structure does not refer to a registered type.
func (*OutputOptions) ProduceResults ¶
ProduceResults takes an amboy.Queue object and produces results according to the options specified in the OutputOptions structure. ProduceResults returns an error if any of the tests failed in the operation.
func (*OutputOptions) Report ¶
func (o *OutputOptions) Report(jobs <-chan amboy.Job) (map[string]*CheckOutput, error)
Report produces the results of a test run in a parseable map structure for programmatic use.
type Report ¶
type Report struct {
// contains filtered or unexported fields
}
Report implements a single machine-parsable json format for results, for use in the rest API
func (*Report) Populate ¶
Populate generates output, based on the content (via the Results() method) of an amboy.Queue instance. All jobs processed by that queue must also implement the greenbay.Checker interface.
func (*Report) Print ¶
Print generates the JSON report and writes the output via a fmt.Println operation.
func (*Report) SkipPassing ¶
func (r *Report) SkipPassing()
SkipPassing causes the reporter to skip all passing tests in the report.
type Results ¶
type Results struct {
// contains filtered or unexported fields
}
Results defines a ResultsProducer implementation for the Evergreen results.json output format.
func (*Results) Populate ¶
Populate generates output, based on the content (via the Results() method) of an amboy.Queue instance. All jobs processed by that queue must also implement the greenbay.Checker interface.
func (*Results) SkipPassing ¶
func (r *Results) SkipPassing()
SkipPassing causes the reporter to skip all passing tests in the report.
type ResultsFactory ¶
type ResultsFactory func() ResultsProducer
ResultsFactory defines the signature used by constructor functions for implementations of the ResultsProducer interface.
func GetResultsFactory ¶
func GetResultsFactory(name string) (ResultsFactory, bool)
GetResultsFactory provides a public mechanism for accessing constructors for result formats.
type ResultsProducer ¶
type ResultsProducer interface { // Populate takes an amboy.Queue instance that contains // completed greenbay.Checker instances to produce // output. Returns an error if the queue contained Job // instances that do not implement // greenbay.Checker. Implementations are not required to // de-duplicate tasks in the case that the Populate() method // is called multiple times on Populate(<-chan amboy.Job) error // ToFile takes a string, for a file name, and writes the // results to a file with that name. Returns an error if any // of the tasks did not pass. You may call this method // multiple times. ToFile(string) error // Print prints, to standard output, the results in a given // format. Returns an error if the results in the format have // any failed checks. Print() error // SkipPassing causes the reporter to skip all passing tests // in the report. SkipPassing() }
ResultsProducer defines a common interface for generating results in different formats.
type Service ¶
type Service struct { DisableStats bool // contains filtered or unexported fields }
Service holds the configuration and operations for running a Greenbay service.
func NewService ¶
NewService constructs a Service, but does not start the service. You will need to run Open to start the underlying workers and Run to start the HTTP service. You can set the host to the empty string, to bind the service to all interfaces.
func (*Service) Close ¶
func (s *Service) Close()
Close wraps the Close method from amboy.rest.Service, and releases all resources used by the queue.
type TimingInfo ¶
type TimingInfo struct { Start time.Time `bson:"start_time" json:"start_time" yaml:"start_time"` End time.Time `bson:"end_time" json:"end_time" yaml:"end_time"` }
TimingInfo tracks the start and end time for a task.
func (TimingInfo) Duration ¶
func (t TimingInfo) Duration() time.Duration
Duration returns a time.Duration for the timing information stored in the TimingInfo object.
Source Files ¶
- app.go
- client.go
- config.go
- config_builder.go
- config_parsing.go
- config_raw.go
- interface.go
- logging.go
- logging_linux.go
- logging_unix.go
- output_coverter.go
- output_gotest.go
- output_grip.go
- output_json_compser.go
- output_options.go
- output_producer.go
- output_registry.go
- output_report.go
- output_results.go
- service.go