Documentation ¶
Index ¶
- Variables
- type Communicator
- type LoggerProducer
- type Mock
- func (c *Mock) AddPublicKey(ctx context.Context, keyName, keyValue string) error
- func (c *Mock) AttachFiles(ctx context.Context, td TaskData, taskFiles []*artifact.File) error
- func (*Mock) ChangeSpawnHostPassword(context.Context, string, string) error
- func (c *Mock) Close()
- func (c *Mock) CreateHost(ctx context.Context, td TaskData, options apimodels.CreateHost) error
- func (*Mock) CreateSpawnHost(ctx context.Context, distroID string, keyName string) (*model.APIHost, error)
- func (c *Mock) DeletePublicKey(ctx context.Context, keyName string) error
- func (c *Mock) EndTask(ctx context.Context, detail *apimodels.TaskEndDetail, td TaskData) (*apimodels.EndTaskResponse, error)
- func (*Mock) ExtendSpawnHostExpiration(context.Context, string, int) error
- func (c *Mock) FetchExpansionVars(ctx context.Context, td TaskData) (*apimodels.ExpansionVars, error)
- func (c *Mock) GenerateTasks(ctx context.Context, td TaskData, jsonBytes []json.RawMessage) error
- func (c *Mock) GetBannerMessage(ctx context.Context) (string, error)
- func (c *Mock) GetClientConfig(ctx context.Context) (*evergreen.ClientConfig, error)
- func (c *Mock) GetCurrentUsersKeys(ctx context.Context) ([]model.APIPubKey, error)
- func (c *Mock) GetDistro(ctx context.Context, td TaskData) (*distro.Distro, error)
- func (c *Mock) GetDistrosList(ctx context.Context) ([]model.APIDistro, error)
- func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
- func (c *Mock) GetEvents(ctx context.Context, ts time.Time, limit int) ([]interface{}, error)
- func (c *Mock) GetHostID() string
- func (c *Mock) GetHostSecret() string
- func (c *Mock) GetHosts(ctx context.Context, f func([]*model.APIHost) error) error
- func (c *Mock) GetHostsByUser(ctx context.Context, user string) ([]*model.APIHost, error)
- func (c *Mock) GetJSONData(ctx context.Context, td TaskData, tn, dn, vn string) ([]byte, error)
- func (c *Mock) GetJSONHistory(ctx context.Context, td TaskData, tags bool, tn, dn string) ([]byte, error)
- func (c *Mock) GetLoggerProducer(ctx context.Context, td TaskData) LoggerProducer
- func (c *Mock) GetManifest(ctx context.Context, td TaskData) (*manifest.Manifest, error)
- func (c *Mock) GetMockMessages() map[string][]apimodels.LogMessage
- func (c *Mock) GetNextTask(ctx context.Context, details *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error)
- func (c *Mock) GetPatchFile(ctx context.Context, td TaskData, patchFileID string) (string, error)
- func (c *Mock) GetProcessInfoLength(id string) int
- func (c *Mock) GetProjectRef(ctx context.Context, td TaskData) (*serviceModel.ProjectRef, error)
- func (c *Mock) GetServiceFlags(ctx context.Context) (*model.APIServiceFlags, error)
- func (c *Mock) GetSettings(ctx context.Context) (*evergreen.Settings, error)
- func (c *Mock) GetSubscriptions(_ context.Context) ([]event.Subscription, error)
- func (c *Mock) GetSystemInfoLength() int
- func (c *Mock) GetTask(ctx context.Context, td TaskData) (*task.Task, error)
- func (c *Mock) GetTaskPatch(ctx context.Context, td TaskData) (*patchmodel.Patch, error)
- func (c *Mock) GetVersion(ctx context.Context, td TaskData) (*version.Version, error)
- func (c *Mock) Heartbeat(ctx context.Context, td TaskData) (bool, error)
- func (c *Mock) KeyValInc(ctx context.Context, td TaskData, kv *serviceModel.KeyVal) error
- func (c *Mock) LastMessageAt() time.Time
- func (c *Mock) ListAliases(ctx context.Context, keyName string) ([]serviceModel.ProjectAlias, error)
- func (c *Mock) ListHosts(_ context.Context, _ TaskData) ([]model.APIHost, error)
- func (c *Mock) PostJSONData(ctx context.Context, td TaskData, path string, data interface{}) error
- func (c *Mock) RestartRecentTasks(ctx context.Context, starAt, endAt time.Time) error
- func (c *Mock) RevertSettings(ctx context.Context, guid string) error
- func (c *Mock) S3Copy(ctx context.Context, td TaskData, req *apimodels.S3CopyRequest) error
- func (c *Mock) SendLogMessages(ctx context.Context, td TaskData, msgs []apimodels.LogMessage) error
- func (c *Mock) SendProcessInfo(ctx context.Context, td TaskData, procs []*message.ProcessInfo) error
- func (c *Mock) SendSystemInfo(ctx context.Context, td TaskData, sysinfo *message.SystemInfo) error
- func (c *Mock) SendTestLog(ctx context.Context, td TaskData, log *serviceModel.TestLog) (string, error)
- func (c *Mock) SendTestResults(ctx context.Context, td TaskData, results *task.LocalTestResults) error
- func (c *Mock) SetAPIKey(apiKey string)
- func (c *Mock) SetAPIUser(apiUser string)
- func (c *Mock) SetBannerMessage(ctx context.Context, m string, t evergreen.BannerTheme) error
- func (c *Mock) SetHostID(hostID string)
- func (c *Mock) SetHostSecret(hostSecret string)
- func (c *Mock) SetMaxAttempts(attempts int)
- func (c *Mock) SetServiceFlags(ctx context.Context, f *model.APIServiceFlags) error
- func (c *Mock) SetTimeoutMax(timeoutMax time.Duration)
- func (c *Mock) SetTimeoutStart(timeoutStart time.Duration)
- func (c *Mock) StartTask(ctx context.Context, td TaskData) error
- func (*Mock) TerminateSpawnHost(ctx context.Context, hostID string) error
- func (c *Mock) UpdateLastMessageTime()
- func (c *Mock) UpdateSettings(ctx context.Context, update *model.APIAdminSettings) (*model.APIAdminSettings, error)
- type TaskData
Constants ¶
This section is empty.
Variables ¶
var HTTPConflictError = errors.New(evergreen.TaskConflict)
Functions ¶
This section is empty.
Types ¶
type Communicator ¶
type Communicator interface { // --------------------------------------------------------------------- // Begin legacy API methods // --------------------------------------------------------------------- // // Setters // // SetTimeoutStart sets the initial timeout for a request. SetTimeoutStart(time.Duration) // SetTimeoutMax sets the maximum timeout for a request. SetTimeoutMax(time.Duration) // SetMaxAttempts sets the number of attempts a request will be made. SetMaxAttempts(int) // SetHostID sets the host ID. SetHostID(string) // SetHostSecret sets the host secret. SetHostSecret(string) // GetHostID returns the host ID. GetHostID() string // GetHostSecret returns the host secret. GetHostSecret() string // Method to release resources used by the communicator. Close() // Updates the clients local concept of it's last updated // time; used by agents to determine timeouts. UpdateLastMessageTime() LastMessageAt() time.Time // Agent Operations // // StartTask marks the task as started. StartTask(context.Context, TaskData) error // EndTask marks the task as finished with the given status EndTask(context.Context, *apimodels.TaskEndDetail, TaskData) (*apimodels.EndTaskResponse, error) // GetTask returns the active task. GetTask(context.Context, TaskData) (*task.Task, error) // GetProjectRef loads the task's project. GetProjectRef(context.Context, TaskData) (*model.ProjectRef, error) // GetDistro returns the distro for the task. GetDistro(context.Context, TaskData) (*distro.Distro, error) // GetVersion loads the task's version. GetVersion(context.Context, TaskData) (*version.Version, error) // Heartbeat sends a heartbeat to the API server. The server can respond with // an "abort" response. This function returns true if the agent should abort. Heartbeat(context.Context, TaskData) (bool, error) // FetchExpansionVars loads expansions for a communicator's task from the API server. FetchExpansionVars(context.Context, TaskData) (*apimodels.ExpansionVars, error) // GetNextTask returns a next task response by getting the next task for a given host. GetNextTask(context.Context, *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error) // Constructs a new LogProducer instance for use by tasks. GetLoggerProducer(context.Context, TaskData) LoggerProducer // Sends a group of log messages to the API Server SendLogMessages(context.Context, TaskData, []apimodels.LogMessage) error SendProcessInfo(context.Context, TaskData, []*message.ProcessInfo) error SendSystemInfo(context.Context, TaskData, *message.SystemInfo) error // The following operations use the legacy API server and are // used by task commands. SendTestResults(context.Context, TaskData, *task.LocalTestResults) error SendTestLog(context.Context, TaskData, *model.TestLog) (string, error) GetTaskPatch(context.Context, TaskData) (*patchmodel.Patch, error) GetPatchFile(context.Context, TaskData, string) (string, error) // The following operations are used by AttachFiles(context.Context, TaskData, []*artifact.File) error GetManifest(context.Context, TaskData) (*manifest.Manifest, error) S3Copy(context.Context, TaskData, *apimodels.S3CopyRequest) error KeyValInc(context.Context, TaskData, *model.KeyVal) error // these are for the taskdata/json plugin that saves perf data PostJSONData(context.Context, TaskData, string, interface{}) error GetJSONData(context.Context, TaskData, string, string, string) ([]byte, error) GetJSONHistory(context.Context, TaskData, bool, string, string) ([]byte, error) // GenerateTasks posts new tasks for the `generate.tasks` command. GenerateTasks(context.Context, TaskData, []json.RawMessage) error // Spawn-hosts for tasks methods CreateHost(context.Context, TaskData, apimodels.CreateHost) error ListHosts(context.Context, TaskData) ([]restmodel.APIHost, error) // Client Configuration methods // SetAPIUser(string) SetAPIKey(string) // Admin methods // SetBannerMessage(context.Context, string, evergreen.BannerTheme) error GetBannerMessage(context.Context) (string, error) SetServiceFlags(context.Context, *restmodel.APIServiceFlags) error GetServiceFlags(context.Context) (*restmodel.APIServiceFlags, error) RestartRecentTasks(context.Context, time.Time, time.Time) error GetSettings(context.Context) (*evergreen.Settings, error) UpdateSettings(context.Context, *restmodel.APIAdminSettings) (*restmodel.APIAdminSettings, error) GetEvents(context.Context, time.Time, int) ([]interface{}, error) RevertSettings(context.Context, string) error // Host methods GetHostsByUser(context.Context, string) ([]*restmodel.APIHost, error) // Spawnhost methods // CreateSpawnHost(context.Context, string, string) (*restmodel.APIHost, error) TerminateSpawnHost(context.Context, string) error ChangeSpawnHostPassword(context.Context, string, string) error ExtendSpawnHostExpiration(context.Context, string, int) error GetHosts(context.Context, func([]*restmodel.APIHost) error) error // Fetch list of distributions evergreen can spawn GetDistrosList(context.Context) ([]restmodel.APIDistro, error) // Fetch the current authenticated user's public keys GetCurrentUsersKeys(context.Context) ([]restmodel.APIPubKey, error) AddPublicKey(context.Context, string, string) error // Delete a key with specified name from the current authenticated user DeletePublicKey(context.Context, string) error // List variant/task aliases ListAliases(context.Context, string) ([]model.ProjectAlias, error) // GetClientConfig fetches the ClientConfig for the evergreen server GetClientConfig(context.Context) (*evergreen.ClientConfig, error) // GetSubscriptions fetches the subscriptions for the user defined // in the local evergreen yaml GetSubscriptions(context.Context) ([]event.Subscription, error) }
Communicator is an interface for communicating with the API server.
func NewCommunicator ¶
func NewCommunicator(serverURL string) Communicator
NewCommunicator returns a Communicator capable of making HTTP REST requests against the API server. To change the default retry behavior, use the SetTimeoutStart, SetTimeoutMax, and SetMaxAttempts methods.
type LoggerProducer ¶
type LoggerProducer interface { // The Execution/Task/System loggers provide a grip-like // logging interface for the distinct logging channels that the // Evergreen agent provides to tasks Execution() grip.Journaler Task() grip.Journaler System() grip.Journaler // The writer functions return an io.Writer for use with // exec.Cmd operations for capturing standard output and standard // error from sbprocesses. TaskWriter(level.Priority) io.WriteCloser SystemWriter(level.Priority) io.WriteCloser // Close releases all resources by calling Close on all underlying senders. Close() error }
LoggerProducer provides a mechanism for agents (and command pluings) to access the process' logging facilities. The interfaces are all based on grip interfaces and abstractions, and the behavior of the interfaces is dependent on the configuration and implementation of the LoggerProducer instance.
func NewSingleChannelLogHarness ¶
func NewSingleChannelLogHarness(name string, sender send.Sender) LoggerProducer
NewSingleChannelLogHarnness returns a log implementation that uses a LoggerProducer where Execution, Task, and System systems all use the same sender. The Local channel still wraps the default global sender.
This implementation is primarily for testing and should be used with the InternalSender, which permits introspection of log messages.
type Mock ¶
type Mock struct { // mock behavior NextTaskShouldFail bool NextTaskShouldConflict bool GetPatchFileShouldFail bool NextTaskResponse *apimodels.NextTaskResponse NextTaskIsNil bool EndTaskResponse *apimodels.EndTaskResponse EndTaskShouldFail bool EndTaskResult endTaskResult ShellExecFilename string TimeoutFilename string HeartbeatShouldAbort bool HeartbeatShouldErr bool TaskExecution int GetSubscriptionsFail bool AttachedFiles map[string][]*artifact.File LogID string LocalTestResults *task.LocalTestResults TestLogs []*serviceModel.TestLog TestLogCount int // metrics collection ProcInfo map[string][]*message.ProcessInfo SysInfo map[string]*message.SystemInfo PatchFiles map[string]string LastMessageSent time.Time // contains filtered or unexported fields }
Mock mocks EvergreenREST for testing.
func (*Mock) AddPublicKey ¶
func (*Mock) AttachFiles ¶
SendFiles attaches task files.
func (*Mock) ChangeSpawnHostPassword ¶
func (*Mock) CreateHost ¶
func (*Mock) CreateSpawnHost ¶
func (*Mock) CreateSpawnHost(ctx context.Context, distroID string, keyName string) (*model.APIHost, error)
CreateSpawnHost will return a mock host that would have been intended
func (*Mock) DeletePublicKey ¶
func (*Mock) EndTask ¶
func (c *Mock) EndTask(ctx context.Context, detail *apimodels.TaskEndDetail, td TaskData) (*apimodels.EndTaskResponse, error)
EndTask returns a mock EndTaskResponse.
func (*Mock) ExtendSpawnHostExpiration ¶
func (*Mock) FetchExpansionVars ¶
func (c *Mock) FetchExpansionVars(ctx context.Context, td TaskData) (*apimodels.ExpansionVars, error)
FetchExpansionVars returns a mock ExpansionVars.
func (*Mock) GenerateTasks ¶
GenerateTasks posts new tasks for the `generate.tasks` command.
func (*Mock) GetBannerMessage ¶
func (*Mock) GetClientConfig ¶
func (*Mock) GetCurrentUsersKeys ¶
func (*Mock) GetDistrosList ¶
func (*Mock) GetEndTaskDetail ¶
func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
GetEndTaskDetail returns the task end detail saved in the mock.
func (*Mock) GetHostSecret ¶
func (*Mock) GetHostsByUser ¶
GetHostsByUser will return an array with a single mock host
func (*Mock) GetJSONData ¶
func (*Mock) GetJSONHistory ¶
func (*Mock) GetLoggerProducer ¶
func (c *Mock) GetLoggerProducer(ctx context.Context, td TaskData) LoggerProducer
GetLoggerProducer constructs a single channel log producer.
func (*Mock) GetManifest ¶
func (*Mock) GetMockMessages ¶
func (c *Mock) GetMockMessages() map[string][]apimodels.LogMessage
GetMockMessages returns the mock's logs.
func (*Mock) GetNextTask ¶
func (c *Mock) GetNextTask(ctx context.Context, details *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error)
GetNextTask returns a mock NextTaskResponse.
func (*Mock) GetPatchFile ¶
func (*Mock) GetProcessInfoLength ¶
func (*Mock) GetProjectRef ¶
func (c *Mock) GetProjectRef(ctx context.Context, td TaskData) (*serviceModel.ProjectRef, error)
GetProjectRef returns a mock ProjectRef.
func (*Mock) GetServiceFlags ¶
func (*Mock) GetSettings ¶
func (*Mock) GetSubscriptions ¶
func (*Mock) GetSystemInfoLength ¶
func (*Mock) GetTaskPatch ¶
func (*Mock) GetVersion ¶
GetVersion return a mock Version.
func (*Mock) LastMessageAt ¶
func (*Mock) ListAliases ¶
func (c *Mock) ListAliases(ctx context.Context, keyName string) ([]serviceModel.ProjectAlias, error)
func (*Mock) PostJSONData ¶
func (*Mock) RestartRecentTasks ¶
func (*Mock) SendLogMessages ¶
SendTaskLogMessages posts tasks messages to the api server
func (*Mock) SendProcessInfo ¶
func (*Mock) SendSystemInfo ¶
func (*Mock) SendTestLog ¶
func (c *Mock) SendTestLog(ctx context.Context, td TaskData, log *serviceModel.TestLog) (string, error)
SendTestLog posts a test log for a communicator's task. Is a noop if the test Log is nil.
func (*Mock) SendTestResults ¶
func (c *Mock) SendTestResults(ctx context.Context, td TaskData, results *task.LocalTestResults) error
SendResults posts a set of test results for the communicator's task. If results are empty or nil, this operation is a noop.
func (*Mock) SetAPIUser ¶
func (*Mock) SetBannerMessage ¶
nolint
func (*Mock) SetHostSecret ¶
func (*Mock) SetMaxAttempts ¶
func (*Mock) SetServiceFlags ¶
func (*Mock) SetTimeoutMax ¶
func (*Mock) TerminateSpawnHost ¶
func (*Mock) UpdateLastMessageTime ¶
func (c *Mock) UpdateLastMessageTime()
func (*Mock) UpdateSettings ¶
func (c *Mock) UpdateSettings(ctx context.Context, update *model.APIAdminSettings) (*model.APIAdminSettings, error)