Documentation
¶
Index ¶
- Variables
- type Communicator
- type LogOpts
- type LoggerConfig
- type LoggerMetadata
- type LoggerProducer
- type LogkeeperMetadata
- 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) ([]string, error)
- func (*Mock) CreateSpawnHost(ctx context.Context, spawnRequest *model.HostRequestOptions) (*model.APIHost, error)
- func (c *Mock) CreateVersionFromConfig(ctx context.Context, project, message string, active bool, config []byte) (*serviceModel.Version, error)
- func (c *Mock) DeleteCommitQueueItem(ctx context.Context, projectID, item string) 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 (c *Mock) EnqueueItem(ctx context.Context, patchID string) (int, 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) GenerateTasksPoll(ctx context.Context, td TaskData) (*apimodels.GeneratePollResponse, error)
- func (c *Mock) GetBannerMessage(ctx context.Context) (string, error)
- func (c *Mock) GetClientConfig(ctx context.Context) (*evergreen.ClientConfig, error)
- func (c *Mock) GetCommitQueue(ctx context.Context, projectID string) (*model.APICommitQueue, error)
- func (c *Mock) GetCommitQueueItemAuthor(ctx context.Context, projectID, item string) (string, 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) GetDockerLogs(context.Context, string, time.Time, time.Time, bool) ([]byte, error)
- func (c *Mock) GetDockerStatus(context.Context, string) (*cloud.ContainerStatus, error)
- func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
- func (c *Mock) GetEvents(ctx context.Context, ts time.Time, limit int) ([]interface{}, error)
- func (c *Mock) GetExpansions(ctx context.Context, taskData TaskData) (util.Expansions, 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) GetLoggerMetadata() LoggerMetadata
- func (c *Mock) GetLoggerProducer(ctx context.Context, td TaskData, config *LoggerConfig) (LoggerProducer, error)
- func (c *Mock) GetManifest(ctx context.Context, td TaskData) (*manifest.Manifest, error)
- func (c *Mock) GetManifestByTask(context.Context, string) (*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) 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) GetTask(ctx context.Context, td TaskData) (*task.Task, error)
- func (c *Mock) GetTaskPatch(ctx context.Context, td TaskData) (*patchmodel.Patch, error)
- func (c *Mock) GetUserAuthorInfo(ctx context.Context, td TaskData, userID string) (*model.APIUserAuthorInformation, error)
- func (c *Mock) GetVersion(ctx context.Context, td TaskData) (*serviceModel.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.CreateHost, error)
- func (*Mock) ModifySpawnHost(ctx context.Context, hostID string, changes host.HostModifyOptions) 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) (string, error)
- func (c *Mock) SendLogMessages(ctx context.Context, td TaskData, msgs []apimodels.LogMessage) error
- func (c *Mock) SendNotification(_ context.Context, _ string, _ interface{}) 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) (*model.Version, error)
// GetExpansions returns all expansions for the task known by the app server
GetExpansions(context.Context, TaskData) (util.Expansions, 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, *LoggerConfig) (LoggerProducer, error)
GetLoggerMetadata() LoggerMetadata
// Sends a group of log messages to the API Server
SendLogMessages(context.Context, TaskData, []apimodels.LogMessage) 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) (string, 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
// GenerateTasksPoll polls for new tasks for the `generate.tasks` command.
GenerateTasksPoll(context.Context, TaskData) (*apimodels.GeneratePollResponse, error)
// Spawn-hosts for tasks methods
CreateHost(context.Context, TaskData, apimodels.CreateHost) ([]string, error)
ListHosts(context.Context, TaskData) ([]restmodel.CreateHost, 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, *restmodel.HostRequestOptions) (*restmodel.APIHost, error)
ModifySpawnHost(context.Context, string, host.HostModifyOptions) 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)
// CreateVersionFromConfig takes an evergreen config and makes runnable tasks from it
CreateVersionFromConfig(context.Context, string, string, bool, []byte) (*model.Version, error)
// Commit Queue
GetCommitQueue(ctx context.Context, projectID string) (*restmodel.APICommitQueue, error)
GetCommitQueueItemAuthor(ctx context.Context, projectID, item string) (string, error)
DeleteCommitQueueItem(ctx context.Context, projectID string, item string) error
EnqueueItem(ctx context.Context, patchID string) (int, error)
GetUserAuthorInfo(context.Context, TaskData, string) (*restmodel.APIUserAuthorInformation, error)
// Notifications
SendNotification(ctx context.Context, notificationType string, data interface{}) error
// GetDockerLogs returns logs for the given docker container
GetDockerLogs(ctx context.Context, hostID string, startTime time.Time, endTime time.Time, isError bool) ([]byte, error)
GetDockerStatus(ctx context.Context, hostID string) (*cloud.ContainerStatus, error)
// GetManifestByTask returns the manifest corresponding to the given task
GetManifestByTask(ctx context.Context, taskId string) (*manifest.Manifest, 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 LoggerConfig ¶
type LoggerMetadata ¶
type LoggerMetadata struct {
Agent []LogkeeperMetadata
System []LogkeeperMetadata
Task []LogkeeperMetadata
}
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
// Close releases all resources by calling Close on all underlying senders.
Close() error
// Closed returns true if this logger has been closed, false otherwise.
Closed() bool
}
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 LogkeeperMetadata ¶
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
HeartbeatShouldSometimesErr bool
TaskExecution int
GetSubscriptionsFail bool
CreatedHost apimodels.CreateHost
AttachedFiles map[string][]*artifact.File
LogID string
LocalTestResults *task.LocalTestResults
TestLogs []*serviceModel.TestLog
TestLogCount int
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, spawnRequest *model.HostRequestOptions) (*model.APIHost, error)
CreateSpawnHost will return a mock host that would have been intended
func (*Mock) CreateVersionFromConfig ¶
func (*Mock) DeleteCommitQueueItem ¶
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) EnqueueItem ¶
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) GenerateTasksPoll ¶
func (*Mock) GetBannerMessage ¶
func (*Mock) GetClientConfig ¶
func (*Mock) GetCommitQueue ¶
func (*Mock) GetCommitQueueItemAuthor ¶
func (*Mock) GetCurrentUsersKeys ¶
func (*Mock) GetDistrosList ¶
func (*Mock) GetDockerLogs ¶
func (*Mock) GetDockerStatus ¶
func (*Mock) GetEndTaskDetail ¶
func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
GetEndTaskDetail returns the task end detail saved in the mock.
func (*Mock) GetExpansions ¶
func (*Mock) GetHostSecret ¶
func (*Mock) GetHostsByUser ¶
GetHostsByUser will return an array with a single mock host
func (*Mock) GetJSONData ¶
func (*Mock) GetJSONHistory ¶
func (*Mock) GetLoggerMetadata ¶
func (c *Mock) GetLoggerMetadata() LoggerMetadata
func (*Mock) GetLoggerProducer ¶
func (c *Mock) GetLoggerProducer(ctx context.Context, td TaskData, config *LoggerConfig) (LoggerProducer, error)
GetLoggerProducer constructs a single channel log producer.
func (*Mock) GetManifest ¶
func (*Mock) GetManifestByTask ¶
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) 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) GetTaskPatch ¶
func (*Mock) GetUserAuthorInfo ¶
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) ModifySpawnHost ¶
func (*Mock) PostJSONData ¶
func (*Mock) RestartRecentTasks ¶
func (*Mock) SendLogMessages ¶
SendTaskLogMessages posts tasks messages to the api server
func (*Mock) SendNotification ¶
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)