data

package
v0.0.0-...-ee3d319 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Adding to the Connector

The Connector is a very large interface that defines how to access the main state of the database and data central to Evergreen's function. All methods of the Connector are contained in the data package in files depending on the main type they allow access to (i.e. all test access is contained in data/test.go).

Extending Connector should only be done when the desired functionality cannot be performed using a combination of the methods it already contains or when such combination would be unseemingly slow or expensive.

To add to the Connector, add the method signature into the interface in data/data.go. Next, add the implementation that interacts with the database to the database backed object. These objects are named by the resource they allow access to. The object that allows access to Hosts is called DBHostConnector. Finally, add a mock implementation to the mock object. For Hosts again, this object would be called MockHostConnector.

Implementing database backed methods requires using methods in Evergreen's model package. As much database specific information as possible should be kept out of the these methods. For example, if a new aggregation pipeline is needed to complete the request, it should be defined in the Evergreen model package and used only to aggregate in the method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogConfigChanges

func LogConfigChanges(newSettings *evergreen.Settings, oldSettings *evergreen.Settings, u *user.DBUser) error

func ParseProjects

func ParseProjects(jsonBytes []json.RawMessage) ([]model.GeneratedProject, error)

Types

type CLIUpdateConnector

type CLIUpdateConnector struct{}

func (*CLIUpdateConnector) GetCLIUpdate

func (c *CLIUpdateConnector) GetCLIUpdate() (*model.APICLIUpdate, error)

type Connector

type Connector interface {
	// Get and Set SuperUsers provide access to the list of API super users.
	GetSuperUsers() []string
	SetSuperUsers([]string)

	// Get and Set URL provide access to the main url string of the API.
	GetURL() string
	SetURL(string)

	// Get and Set Prefix provide access to the prefix that prepends all of the
	// URL paths.
	GetPrefix() string
	SetPrefix(string)

	// FindTaskById is a method to find a specific task given its ID.
	FindTaskById(string) (*task.Task, error)
	FindOldTasksByID(string) ([]task.Task, error)
	FindTasksByIds([]string) ([]task.Task, error)
	SetTaskPriority(*task.Task, string, int64) error
	SetTaskActivated(string, string, bool) error
	ResetTask(string, string) error
	AbortTask(string, string) error

	// FindTasksByBuildId is a method to find a set of tasks which all have the same
	// BuildId. It takes the buildId being queried for as its first parameter,
	// as well as a taskId and limit for paginating through the results.
	// It returns a list of tasks which match.
	FindTasksByBuildId(string, string, string, int, int) ([]task.Task, error)

	// FindBuildById is a method to find the build matching the same BuildId.
	FindBuildById(string) (*build.Build, error)
	// SetBuildPriority and SetBuildActivated change the status of the input build
	SetBuildPriority(string, int64) error
	SetBuildActivated(string, string, bool) error

	// AbortBuild is a method to abort the build matching the same BuildId.
	AbortBuild(string, string) error
	// RestartBuild is a method to restart the build matching the same BuildId.
	RestartBuild(string, string) error

	// FindProjects is a method to find projects as ordered by name
	FindProjects(string, int, int, bool) ([]model.ProjectRef, error)
	// FindProjectVars is a method to fetch the vars for a given project
	FindProjectVars(string) (*model.ProjectVars, error)
	// FindProjectByBranch is a method to find the projectref given a branch name.
	FindProjectByBranch(string) (*model.ProjectRef, error)
	// GetVersionsAndVariants returns recent versions for a project
	GetVersionsAndVariants(int, int, *model.Project) (*restModel.VersionVariantData, error)

	// FindByProjectAndCommit is a method to find a set of tasks which ran as part of
	// certain version in a project. It takes the projectId, commit hash, and a taskId
	// for paginating through the results.
	FindTasksByProjectAndCommit(string, string, string, string, int, int) ([]task.Task, error)

	// FindTestsByTaskId is a method to find a set of tests that correspond to
	// a given task. It takes a taskId, testName to start from, test status to filter,
	// limit, and sort to provide additional control over the results.
	FindTestsByTaskId(string, string, string, int, int, int) ([]testresult.TestResult, error)

	// FindUserById is a method to find a specific user given its ID.
	FindUserById(string) (auth.APIUser, error)

	// FindHostsById is a method to find a sorted list of hosts given an ID to
	// start from.
	FindHostsById(string, string, string, int, int) ([]host.Host, error)
	FindHostById(string) (*host.Host, error)

	// FindHostByIdWithOwner finds a host with given host ID that was
	// started by the given user. If the given user is a super-user,
	// the host will also be returned regardless of who the host was
	// started by
	FindHostByIdWithOwner(string, auth.User) (*host.Host, error)

	// NewIntentHost is a method to insert an intent host given a distro and the name of a saved public key
	NewIntentHost(string, string, string, *user.DBUser) (*host.Host, error)

	// FetchContext is a method to fetch a context given a series of identifiers.
	FetchContext(string, string, string, string, string) (model.Context, error)

	// FindAllDistros is a method to find a sorted list of all distros.
	FindAllDistros() ([]distro.Distro, error)

	// FindTaskSystemMetrics and FindTaskProcessMetrics provide
	// access to the metrics data collected by agents during task execution
	FindTaskSystemMetrics(string, time.Time, int, int) ([]*message.SystemInfo, error)
	FindTaskProcessMetrics(string, time.Time, int, int) ([][]*message.ProcessInfo, error)

	// FindCostByVersionId returns cost data of a version given its ID.
	FindCostByVersionId(string) (*task.VersionCost, error)

	// FindCostByDistroId returns cost data of a distro given its ID and a time range.
	// Interested time range is given as a start time and duration.
	FindCostByDistroId(string, time.Time, time.Duration) (*task.DistroCost, error)

	// FindVersionById returns version given its ID.
	FindVersionById(string) (*version.Version, error)

	// FindPatchesByProject provides access to the patches corresponding to the input project ID
	// as ordered by creation time.
	FindPatchesByProject(string, time.Time, int, bool) ([]patch.Patch, error)
	// FindPatchByUser finds patches for the input user as ordered by creation time
	FindPatchesByUser(string, time.Time, int, bool) ([]patch.Patch, error)

	// FindPatchById fetches the patch corresponding to the input patch ID.
	FindPatchById(string) (*patch.Patch, error)

	// AbortVersion aborts all tasks of a version given its ID.
	AbortVersion(string) error

	// AbortPatch aborts the patch corresponding to the input patch ID and deletes if not finalized.
	AbortPatch(string, string) error
	// AbortPatchesFromPullRequest aborts patches with the same PR Number,
	// in the same repository, at the pull request's close time
	AbortPatchesFromPullRequest(*github.PullRequestEvent) error

	// RestartVersion restarts all completed tasks of a version given its ID and the caller.
	RestartVersion(string, string) error
	// SetPatchPriority and SetPatchActivated change the status of the input patch
	SetPatchPriority(string, int64) error
	SetPatchActivated(string, string, bool) error

	// GetEvergreenSettings/SetEvergreenSettings retrieves/sets the system-wide settings document
	GetEvergreenSettings() (*evergreen.Settings, error)
	GetBanner() (string, string, error)
	SetEvergreenSettings(*restModel.APIAdminSettings, *evergreen.Settings, *user.DBUser, bool) (*evergreen.Settings, error)
	// SetAdminBanner sets set the banner in the system-wide settings document
	SetAdminBanner(string, *user.DBUser) error
	// SetBannerTheme sets set the banner theme in the system-wide settings document
	SetBannerTheme(string, *user.DBUser) error
	// SetAdminBanner sets set the service flags in the system-wide settings document
	SetServiceFlags(evergreen.ServiceFlags, *user.DBUser) error
	RestartFailedTasks(amboy.Queue, model.RestartTaskOptions) (*restModel.RestartTasksResponse, error)
	RevertConfigTo(string, string) error
	GetAdminEventLog(time.Time, int) ([]restModel.APIAdminEvent, error)

	FindCostTaskByProject(string, string, time.Time, time.Time, int, int) ([]task.Task, error)

	// FindRecentTasks finds tasks that have recently finished.
	FindRecentTasks(int) ([]task.Task, *task.ResultCounts, error)
	// GetHostStatsByDistro returns host stats broken down by distro
	GetHostStatsByDistro() ([]host.StatsByDistro, error)

	AddPublicKey(*user.DBUser, string, string) error
	DeletePublicKey(*user.DBUser, string) error

	AddPatchIntent(patch.Intent, amboy.Queue) error

	SetHostStatus(*host.Host, string, string) error
	SetHostExpirationTime(*host.Host, time.Time) error

	// TerminateHost terminates the given host via the cloud provider's API
	TerminateHost(context.Context, *host.Host, string) error

	// FindProjectAliases queries the database to find all aliases.
	FindProjectAliases(string) ([]model.ProjectAlias, error)

	// TriggerRepotracker creates an amboy job to get the commits from a
	// Github Push Event
	TriggerRepotracker(amboy.Queue, string, *github.PushEvent) error

	// GetCLIUpdate fetches the current cli version and the urls to download
	GetCLIUpdate() (*restModel.APICLIUpdate, error)

	// GenerateTasks parses JSON files for `generate.tasks` and creates the new builds and tasks.
	GenerateTasks(string, []json.RawMessage) error
}

Connector is an interface that contains all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.

type DBAdminConnector

type DBAdminConnector struct{}

func (*DBAdminConnector) GetAdminEventLog

func (ac *DBAdminConnector) GetAdminEventLog(before time.Time, n int) ([]restModel.APIAdminEvent, error)

func (*DBAdminConnector) GetBanner

func (ac *DBAdminConnector) GetBanner() (string, string, error)

func (*DBAdminConnector) GetEvergreenSettings

func (ac *DBAdminConnector) GetEvergreenSettings() (*evergreen.Settings, error)

GetEvergreenSettings retrieves the admin settings document from the DB

func (*DBAdminConnector) RestartFailedTasks

func (ac *DBAdminConnector) RestartFailedTasks(queue amboy.Queue, opts model.RestartTaskOptions) (*restModel.RestartTasksResponse, error)

RestartFailedTasks attempts to restart failed tasks that started between 2 times

func (*DBAdminConnector) RevertConfigTo

func (ac *DBAdminConnector) RevertConfigTo(guid string, user string) error

func (*DBAdminConnector) SetAdminBanner

func (ac *DBAdminConnector) SetAdminBanner(text string, u *user.DBUser) error

SetAdminBanner sets the admin banner in the DB and event logs it

func (*DBAdminConnector) SetBannerTheme

func (ac *DBAdminConnector) SetBannerTheme(themeString string, u *user.DBUser) error

SetBannerTheme sets the banner theme in the DB and event logs it

func (*DBAdminConnector) SetEvergreenSettings

func (ac *DBAdminConnector) SetEvergreenSettings(changes *restModel.APIAdminSettings,
	oldSettings *evergreen.Settings, u *user.DBUser, persist bool) (*evergreen.Settings, error)

SetEvergreenSettings sets the admin settings document in the DB and event logs it

func (*DBAdminConnector) SetServiceFlags

func (ac *DBAdminConnector) SetServiceFlags(flags evergreen.ServiceFlags, u *user.DBUser) error

SetServiceFlags sets the service flags in the DB and event logs it

type DBAliasConnector

type DBAliasConnector struct{}

DBAliasConnector is a struct that implements the Alias related methods from the Connector through interactions with the backing database.

func (*DBAliasConnector) FindProjectAliases

func (d *DBAliasConnector) FindProjectAliases(projectId string) ([]model.ProjectAlias, error)

FindProjectAliases queries the database to find all aliases.

type DBBuildConnector

type DBBuildConnector struct{}

DBBuildConnector is a struct that implements the Build related methods from the Connector through interactions with the backing database.

func (*DBBuildConnector) AbortBuild

func (bc *DBBuildConnector) AbortBuild(buildId string, user string) error

AbortBuild wraps the service level AbortBuild

func (*DBBuildConnector) FindBuildById

func (bc *DBBuildConnector) FindBuildById(buildId string) (*build.Build, error)

FindBuildById uses the service layer's build type to query the backing database for a specific build.

func (*DBBuildConnector) FindProjectByBranch

func (bc *DBBuildConnector) FindProjectByBranch(branch string) (*model.ProjectRef, error)

FindProjectByBranch queries the project_refs database to find the name of the project a given branch falls under.

func (*DBBuildConnector) RestartBuild

func (bc *DBBuildConnector) RestartBuild(buildId string, user string) error

RestartBuild wraps the service level RestartBuild

func (*DBBuildConnector) SetBuildActivated

func (bc *DBBuildConnector) SetBuildActivated(buildId string, user string, activated bool) error

SetBuildActivated wraps the service level method

func (*DBBuildConnector) SetBuildPriority

func (bc *DBBuildConnector) SetBuildPriority(buildId string, priority int64) error

SetBuildPriority wraps the service level method

type DBConnector

DBConnector is a struct that implements all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.

func (*DBConnector) FindHostByIdWithOwner

func (dbc *DBConnector) FindHostByIdWithOwner(hostID string, user auth.User) (*host.Host, error)

func (*DBConnector) GetPrefix

func (ctx *DBConnector) GetPrefix() string

func (*DBConnector) GetSuperUsers

func (ctx *DBConnector) GetSuperUsers() []string

func (*DBConnector) GetURL

func (ctx *DBConnector) GetURL() string

func (*DBConnector) SetPrefix

func (ctx *DBConnector) SetPrefix(prefix string)

func (*DBConnector) SetSuperUsers

func (ctx *DBConnector) SetSuperUsers(su []string)

func (*DBConnector) SetURL

func (ctx *DBConnector) SetURL(url string)

type DBContextConnector

type DBContextConnector struct{}

DBContextConnector is a struct that implements the Context related functions of the ServiceConnector interface through interactions with the backing database.

func (*DBContextConnector) FetchContext

func (dc *DBContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)

LoadContext fetches the context through a call to the service layer.

type DBDistroConnector

type DBDistroConnector struct{}

DBDistroConnector is a struct that implements the Distro related methods from the Connector through interactions with the backing database.

func (*DBDistroConnector) FindAllDistros

func (dc *DBDistroConnector) FindAllDistros() ([]distro.Distro, error)

FindAllDistros queries the database to find all distros.

func (*DBDistroConnector) FindCostByDistroId

func (tc *DBDistroConnector) FindCostByDistroId(distroId string,
	starttime time.Time, duration time.Duration) (*task.DistroCost, error)

FindCostByDistroId queries the backing database for cost data associated with the given distroId. This is done by aggregating TimeTaken over all tasks of the given distro that match the time range.

type DBHostConnector

type DBHostConnector struct{}

DBHostConnector is a struct that implements the Host related methods from the Connector through interactions with the backing database.

func (*DBHostConnector) FindHostById

func (hc *DBHostConnector) FindHostById(id string) (*host.Host, error)

FindHostById queries the database for the host with id matching the hostId

func (*DBHostConnector) FindHostsById

func (hc *DBHostConnector) FindHostsById(id, status, user string, limit int, sortDir int) ([]host.Host, error)

FindHostsById uses the service layer's host type to query the backing database for the hosts.

func (*DBHostConnector) NewIntentHost

func (hc *DBHostConnector) NewIntentHost(distroID, keyNameOrVal, taskID string, user *user.DBUser) (*host.Host, error)

NewIntentHost is a method to insert an intent host given a distro and a public key The public key can be the name of a saved key or the actual key string

func (*DBHostConnector) SetHostExpirationTime

func (hc *DBHostConnector) SetHostExpirationTime(host *host.Host, newExp time.Time) error

func (*DBHostConnector) SetHostStatus

func (hc *DBHostConnector) SetHostStatus(host *host.Host, status, user string) error

func (*DBHostConnector) TerminateHost

func (hc *DBHostConnector) TerminateHost(ctx context.Context, host *host.Host, user string) error

type DBMetricsConnector

type DBMetricsConnector struct{}

func (*DBMetricsConnector) FindTaskProcessMetrics

func (mc *DBMetricsConnector) FindTaskProcessMetrics(taskId string, ts time.Time, limit, sort int) ([][]*message.ProcessInfo, error)

func (*DBMetricsConnector) FindTaskSystemMetrics

func (mc *DBMetricsConnector) FindTaskSystemMetrics(taskId string, ts time.Time, limit, sort int) ([]*message.SystemInfo, error)

type DBPatchConnector

type DBPatchConnector struct{}

DBPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with the backing database.

func (*DBPatchConnector) AbortPatch

func (pc *DBPatchConnector) AbortPatch(patchId string, user string) error

AbortPatch uses the service level CancelPatch method to abort a single patch with matching Id.

func (*DBPatchConnector) AbortPatchesFromPullRequest

func (p *DBPatchConnector) AbortPatchesFromPullRequest(event *github.PullRequestEvent) error

func (*DBPatchConnector) FindPatchById

func (pc *DBPatchConnector) FindPatchById(patchId string) (*patch.Patch, error)

FindPatchById queries the backing database for the patch matching patchId.

func (*DBPatchConnector) FindPatchesByProject

func (pc *DBPatchConnector) FindPatchesByProject(projectId string, ts time.Time, limit int, sortAsc bool) ([]patch.Patch, error)

FindPatchesByProject uses the service layer's patches type to query the backing database for the patches.

func (*DBPatchConnector) FindPatchesByUser

func (pc *DBPatchConnector) FindPatchesByUser(user string, ts time.Time, limit int, sortAsc bool) ([]patch.Patch, error)

func (*DBPatchConnector) SetPatchActivated

func (pc *DBPatchConnector) SetPatchActivated(patchId string, user string, activated bool) error

SetPatchActivated attempts to set the priority on the patch and the corresponding version. Will not error if no version exists.

func (*DBPatchConnector) SetPatchPriority

func (pc *DBPatchConnector) SetPatchPriority(patchId string, priority int64) error

SetPatchPriority attempts to set the priority on the corresponding version. Will not error if no version exists.

type DBPatchIntentConnector

type DBPatchIntentConnector struct{}

func (*DBPatchIntentConnector) AddPatchIntent

func (p *DBPatchIntentConnector) AddPatchIntent(intent patch.Intent, queue amboy.Queue) error

type DBProjectConnector

type DBProjectConnector struct{}

DBPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with the backing database.

func (*DBProjectConnector) FindProjectVars

func (pc *DBProjectConnector) FindProjectVars(identifier string) (*model.ProjectVars, error)

FindProjectVars fetches the vars struct for a given project

func (*DBProjectConnector) FindProjects

func (pc *DBProjectConnector) FindProjects(key string, limit int, sortDir int, isAuthenticated bool) ([]model.ProjectRef, error)

FindProjects queries the backing database for the specified projects

type DBStatusConnector

type DBStatusConnector struct{}

DBStatusConnector is a struct that implements the status related methods from the Connector through interactions with the backing database.

func (*DBStatusConnector) FindRecentTasks

func (c *DBStatusConnector) FindRecentTasks(minutes int) ([]task.Task, *task.ResultCounts, error)

FindRecentTasks queries the database to find all distros.

func (*DBStatusConnector) GetHostStatsByDistro

func (c *DBStatusConnector) GetHostStatsByDistro() ([]host.StatsByDistro, error)

GetHostStatsByDistro returns counts of up hosts broken down by distro

type DBTaskConnector

type DBTaskConnector struct{}

DBTaskConnector is a struct that implements the Task related methods from the Connector through interactions with he backing database.

func (*DBTaskConnector) AbortTask

func (tc *DBTaskConnector) AbortTask(taskId string, user string) error

func (*DBTaskConnector) FindCostTaskByProject

func (tc *DBTaskConnector) FindCostTaskByProject(project, taskId string, starttime,
	endtime time.Time, limit, sortDir int) ([]task.Task, error)

FindCostTaskByProject queries the backing database for tasks of a project that finishes in the given time range.

func (*DBTaskConnector) FindOldTasksByID

func (tc *DBTaskConnector) FindOldTasksByID(id string) ([]task.Task, error)

func (*DBTaskConnector) FindTaskById

func (tc *DBTaskConnector) FindTaskById(taskId string) (*task.Task, error)

FindTaskById uses the service layer's task type to query the backing database for the task with the given taskId.

func (*DBTaskConnector) FindTasksByBuildId

func (tc *DBTaskConnector) FindTasksByBuildId(buildId, taskId, status string, limit int, sortDir int) ([]task.Task, error)

FindTasksByBuildId uses the service layer's task type to query the backing database for a list of task that matches buildId. It accepts the startTaskId and a limit to allow for pagination of the queries. It returns results sorted by taskId.

func (*DBTaskConnector) FindTasksByIds

func (tc *DBTaskConnector) FindTasksByIds(ids []string) ([]task.Task, error)

func (*DBTaskConnector) FindTasksByProjectAndCommit

func (tc *DBTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId,
	status string, limit, sortDir int) ([]task.Task, error)

func (*DBTaskConnector) ResetTask

func (tc *DBTaskConnector) ResetTask(taskId, username string) error

ResetTask sets the task to be in an unexecuted state and prepares it to be run again.

func (*DBTaskConnector) SetTaskActivated

func (tc *DBTaskConnector) SetTaskActivated(taskId, user string, activated bool) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

func (*DBTaskConnector) SetTaskPriority

func (tc *DBTaskConnector) SetTaskPriority(t *task.Task, user string, priority int64) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

type DBTestConnector

type DBTestConnector struct{}

DBTestConnector is a struct that implements the Test related methods from the Connector through interactions with the backing database.

func (*DBTestConnector) FindTestsByTaskId

func (tc *DBTestConnector) FindTestsByTaskId(taskId, filename, status string, limit,
	sort, execution int) ([]testresult.TestResult, error)

type DBUserConnector

type DBUserConnector struct{}

DBUserConnector is a struct that implements the User related interface of the Connector interface through interactions with the backing database.

func (*DBUserConnector) AddPublicKey

func (u *DBUserConnector) AddPublicKey(user *user.DBUser, keyName, keyValue string) error

func (*DBUserConnector) DeletePublicKey

func (u *DBUserConnector) DeletePublicKey(user *user.DBUser, keyName string) error

func (*DBUserConnector) FindUserById

func (tc *DBUserConnector) FindUserById(userId string) (auth.APIUser, error)

FindUserById uses the service layer's user type to query the backing database for the user with the given Id.

type DBVersionConnector

type DBVersionConnector struct{}

DBVersionConnector is a struct that implements Version related methods from the Connector through interactions with the backing database.

func (*DBVersionConnector) AbortVersion

func (vc *DBVersionConnector) AbortVersion(versionId string) error

AbortVersion aborts all tasks of a version given its ID. It wraps the service level AbortVersion.

func (*DBVersionConnector) FindCostByVersionId

func (vc *DBVersionConnector) FindCostByVersionId(versionId string) (*task.VersionCost, error)

FindCostByVersionId queries the backing database for cost data associated with the given versionId. This is done by aggregating TimeTaken over all tasks of the given version.

func (*DBVersionConnector) FindVersionById

func (vc *DBVersionConnector) FindVersionById(versionId string) (*version.Version, error)

FindVersionById queries the backing database for the version with the given versionId.

func (*DBVersionConnector) GetVersionsAndVariants

func (vc *DBVersionConnector) GetVersionsAndVariants(skip, numVersionElements int, project *model.Project) (*restModel.VersionVariantData, error)

Fetch versions until 'numVersionElements' elements are created, including elements consisting of multiple versions rolled-up into one. The skip value indicates how many versions back in time should be skipped before starting to fetch versions, the project indicates which project the returned versions should be a part of.

func (*DBVersionConnector) RestartVersion

func (vc *DBVersionConnector) RestartVersion(versionId string, caller string) error

RestartVersion wraps the service level RestartVersion, which restarts completed tasks associated with a given versionId. If abortInProgress is true, it also sets the abort flag on any in-progress tasks. In addition, it updates all builds containing the tasks affected.

type GenerateConnector

type GenerateConnector struct{}

func (*GenerateConnector) GenerateTasks

func (gc *GenerateConnector) GenerateTasks(taskID string, jsonBytes []json.RawMessage) error

GenerateTasks parses JSON files for `generate.tasks` and creates the new builds and tasks.

type MockAdminConnector

type MockAdminConnector struct {
	MockSettings *evergreen.Settings
	// contains filtered or unexported fields
}

func (*MockAdminConnector) GetAdminEventLog

func (ac *MockAdminConnector) GetAdminEventLog(before time.Time, n int) ([]restModel.APIAdminEvent, error)

func (*MockAdminConnector) GetBanner

func (ac *MockAdminConnector) GetBanner() (string, string, error)

func (*MockAdminConnector) GetEvergreenSettings

func (ac *MockAdminConnector) GetEvergreenSettings() (*evergreen.Settings, error)

GetEvergreenSettings retrieves the admin settings document from the mock connector

func (*MockAdminConnector) RestartFailedTasks

RestartFailedTasks mocks a response to restarting failed tasks

func (*MockAdminConnector) RevertConfigTo

func (ac *MockAdminConnector) RevertConfigTo(guid string, user string) error

func (*MockAdminConnector) SetAdminBanner

func (ac *MockAdminConnector) SetAdminBanner(text string, u *user.DBUser) error

SetAdminBanner sets the admin banner in the mock connector

func (*MockAdminConnector) SetBannerTheme

func (ac *MockAdminConnector) SetBannerTheme(themeString string, u *user.DBUser) error

func (*MockAdminConnector) SetEvergreenSettings

func (ac *MockAdminConnector) SetEvergreenSettings(changes *restModel.APIAdminSettings,
	oldSettings *evergreen.Settings, u *user.DBUser, persist bool) (*evergreen.Settings, error)

SetEvergreenSettings sets the admin settings document in the mock connector

func (*MockAdminConnector) SetServiceFlags

func (ac *MockAdminConnector) SetServiceFlags(flags evergreen.ServiceFlags, u *user.DBUser) error

SetServiceFlags sets the service flags in the mock connector

type MockAliasConnector

type MockAliasConnector struct{}

MockAliasConnector is a struct that implements mock versions of Alias-related methods for testing.

func (*MockAliasConnector) FindProjectAliases

func (d *MockAliasConnector) FindProjectAliases(projectId string) ([]model.ProjectAlias, error)

FindAllAliases is a mock implementation for testing.

type MockBuildConnector

type MockBuildConnector struct {
	CachedBuilds         []build.Build
	CachedProjects       map[string]*model.ProjectRef
	CachedAborted        map[string]string
	FailOnChangePriority bool
	FailOnAbort          bool
	FailOnRestart        bool
}

MockBuildConnector is a struct that implements the Build related methods from the Connector through interactions with the backing database.

func (*MockBuildConnector) AbortBuild

func (bc *MockBuildConnector) AbortBuild(buildId string, user string) error

AbortBuild sets the value of the input build Id in CachedAborted to true.

func (*MockBuildConnector) FindBuildById

func (bc *MockBuildConnector) FindBuildById(buildId string) (*build.Build, error)

FindBuildById iterates through the CachedBuilds slice to find the build with matching id field.

func (*MockBuildConnector) FindProjectByBranch

func (bc *MockBuildConnector) FindProjectByBranch(branch string) (*model.ProjectRef, error)

FindProjectByBranch accesses the map of branch names to project names to find the project corresponding to a given branch.

func (*MockBuildConnector) RestartBuild

func (bc *MockBuildConnector) RestartBuild(buildId string, user string) error

RestartBuild does absolutely nothing

func (*MockBuildConnector) SetBuildActivated

func (bc *MockBuildConnector) SetBuildActivated(buildId string, user string, activated bool) error

SetBuildActivated sets the activated and activated_by fields on the input build.

func (*MockBuildConnector) SetBuildPriority

func (bc *MockBuildConnector) SetBuildPriority(buildId string, priority int64) error

SetBuildPriority throws an error if instructed

type MockCLIUpdateConnector

type MockCLIUpdateConnector struct {
	// contains filtered or unexported fields
}

func (*MockCLIUpdateConnector) GetCLIUpdate

func (c *MockCLIUpdateConnector) GetCLIUpdate() (*model.APICLIUpdate, error)

type MockConnector

func (*MockConnector) FindHostByIdWithOwner

func (dbc *MockConnector) FindHostByIdWithOwner(hostID string, user auth.User) (*host.Host, error)

func (*MockConnector) GetPrefix

func (ctx *MockConnector) GetPrefix() string

func (*MockConnector) GetSuperUsers

func (ctx *MockConnector) GetSuperUsers() []string

func (*MockConnector) GetURL

func (ctx *MockConnector) GetURL() string

func (*MockConnector) SetPrefix

func (ctx *MockConnector) SetPrefix(prefix string)

func (*MockConnector) SetSuperUsers

func (ctx *MockConnector) SetSuperUsers(su []string)

func (*MockConnector) SetURL

func (ctx *MockConnector) SetURL(url string)

type MockContextConnector

type MockContextConnector struct {
	CachedContext model.Context
	CachedErr     error
}

MockContextConnector is a struct that mocks the context methods by storing context to be fetched by its method.

func (*MockContextConnector) FetchContext

func (mc *MockContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)

FetchContext returns the context cached within the MockContextConnector.

type MockDistroConnector

type MockDistroConnector struct {
	CachedDistros []distro.Distro
	CachedTasks   []task.Task
}

MockDistroConnector is a struct that implements mock versions of Distro-related methods for testing.

func (*MockDistroConnector) FindAllDistros

func (mdc *MockDistroConnector) FindAllDistros() ([]distro.Distro, error)

FindAllDistros is a mock implementation for testing.

func (*MockDistroConnector) FindCostByDistroId

func (mdc *MockDistroConnector) FindCostByDistroId(distroId string,
	starttime time.Time, duration time.Duration) (*task.DistroCost, error)

FindCostByDistroId returns results based on the cached tasks and cached distros in the MockDistroConnector.

type MockGenerateConnector

type MockGenerateConnector struct{}

func (*MockGenerateConnector) GenerateTasks

func (gc *MockGenerateConnector) GenerateTasks(taskID string, jsonBytes []json.RawMessage) error

type MockHostConnector

type MockHostConnector struct {
	CachedHosts []host.Host
}

MockHostConnector is a struct that implements the Host related methods from the Connector through interactions with he backing database.

func (*MockHostConnector) FindHostById

func (hc *MockHostConnector) FindHostById(id string) (*host.Host, error)

func (*MockHostConnector) FindHostsById

func (hc *MockHostConnector) FindHostsById(id, status, user string, limit int, sort int) ([]host.Host, error)

FindHostsById searches the mock hosts slice for hosts and returns them

func (*MockHostConnector) FindHostsByIdOnly

func (hc *MockHostConnector) FindHostsByIdOnly(id, status, user string, limit int, sort int) ([]host.Host, error)

func (*MockHostConnector) NewIntentHost

func (hc *MockHostConnector) NewIntentHost(distroID, keyNameOrVal, taskID string, user *user.DBUser) (*host.Host, error)

NewIntentHost is a method to mock "insert" an intent host given a distro and a public key The public key can be the name of a saved key or the actual key string

func (*MockHostConnector) SetHostExpirationTime

func (hc *MockHostConnector) SetHostExpirationTime(host *host.Host, newExp time.Time) error

func (*MockHostConnector) SetHostStatus

func (hc *MockHostConnector) SetHostStatus(host *host.Host, status, user string) error

func (*MockHostConnector) TerminateHost

func (hc *MockHostConnector) TerminateHost(ctx context.Context, host *host.Host, user string) error

type MockMetricsConnector

type MockMetricsConnector struct {
	System  map[string][]*message.SystemInfo
	Process map[string][][]*message.ProcessInfo
}

func (*MockMetricsConnector) FindTaskProcessMetrics

func (mc *MockMetricsConnector) FindTaskProcessMetrics(taskId string, ts time.Time, limit, sort int) ([][]*message.ProcessInfo, error)

func (*MockMetricsConnector) FindTaskSystemMetrics

func (mc *MockMetricsConnector) FindTaskSystemMetrics(taskId string, ts time.Time, limit, sort int) ([]*message.SystemInfo, error)

type MockPatchConnector

type MockPatchConnector struct {
	CachedPatches  []patch.Patch
	CachedAborted  map[string]string
	CachedPriority map[string]int64
}

MockPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with he backing database.

func (*MockPatchConnector) AbortPatch

func (pc *MockPatchConnector) AbortPatch(patchId string, user string) error

AbortPatch sets the value of patchId in CachedAborted to user.

func (*MockPatchConnector) AbortPatchesFromPullRequest

func (c *MockPatchConnector) AbortPatchesFromPullRequest(event *github.PullRequestEvent) error

func (*MockPatchConnector) FindPatchById

func (pc *MockPatchConnector) FindPatchById(patchId string) (*patch.Patch, error)

FindPatchById iterates through the slice of CachedPatches to find the matching patch.

func (*MockPatchConnector) FindPatchesByProject

func (hp *MockPatchConnector) FindPatchesByProject(projectId string, ts time.Time, limit int, sortAsc bool) ([]patch.Patch, error)

FindPatchesByProject queries the cached patches splice for the matching patches. Assumes CachedPatches is sorted by increasing creation time.

func (*MockPatchConnector) FindPatchesByUser

func (hp *MockPatchConnector) FindPatchesByUser(user string, ts time.Time, limit int, sortAsc bool) ([]patch.Patch, error)

FindPatchesByUser iterates through the cached patches slice to find the correct patches

func (*MockPatchConnector) SetPatchActivated

func (pc *MockPatchConnector) SetPatchActivated(patchId string, user string, activated bool) error

SetPatchActivated sets the boolean activated field on the input patch.

func (*MockPatchConnector) SetPatchPriority

func (pc *MockPatchConnector) SetPatchPriority(patchId string, priority int64) error

SetPatchPriority sets the patch priority in the CachedPriority map.

type MockPatchIntentConnector

type MockPatchIntentConnector struct {
	CachedIntents map[MockPatchIntentKey]patch.Intent
}

func (*MockPatchIntentConnector) AddPatchIntent

func (p *MockPatchIntentConnector) AddPatchIntent(newIntent patch.Intent, _ amboy.Queue) error

type MockPatchIntentKey

type MockPatchIntentKey struct {
	// contains filtered or unexported fields
}

type MockProjectConnector

type MockProjectConnector struct {
	CachedProjects []model.ProjectRef
	CachedVars     []*model.ProjectVars
}

MockPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with he backing database.

func (*MockProjectConnector) FindProjectVars

func (pc *MockProjectConnector) FindProjectVars(identifier string) (*model.ProjectVars, error)

FindProjectVars fetches the vars struct for a given project from the CachedVars map

func (*MockProjectConnector) FindProjects

func (pc *MockProjectConnector) FindProjects(key string, limit int, sortDir int, isAuthenticated bool) ([]model.ProjectRef, error)

FindProjects queries the cached projects slice for the matching projects. Assumes CachedProjects is sorted in alphabetical order of project identifier.

type MockRepoTrackerConnector

type MockRepoTrackerConnector struct{}

func (*MockRepoTrackerConnector) TriggerRepotracker

func (c *MockRepoTrackerConnector) TriggerRepotracker(_ amboy.Queue, _ string, event *github.PushEvent) error

type MockStatusConnector

type MockStatusConnector struct {
	CachedTasks     []task.Task
	CachedResults   *task.ResultCounts
	CachedHostStats []host.StatsByDistro
}

MockStatusConnector is a struct that implements mock versions of Distro-related methods for testing.

func (*MockStatusConnector) FindRecentTasks

func (c *MockStatusConnector) FindRecentTasks(minutes int) ([]task.Task, *task.ResultCounts, error)

FindRecentTasks is a mock implementation for testing.

func (*MockStatusConnector) GetHostStatsByDistro

func (c *MockStatusConnector) GetHostStatsByDistro() ([]host.StatsByDistro, error)

GetHostStatsByDistro returns mock stats for hosts broken down by distro

type MockTaskConnector

type MockTaskConnector struct {
	CachedTasks    []task.Task
	CachedOldTasks []task.Task
	CachedAborted  map[string]string
	StoredError    error
	FailOnAbort    bool
}

MockTaskConnector stores a cached set of tasks that are queried against by the implementations of the Connector interface's Task related functions.

func (*MockTaskConnector) AbortTask

func (tc *MockTaskConnector) AbortTask(taskId, user string) error

func (*MockTaskConnector) FindCostTaskByProject

func (mtc *MockTaskConnector) FindCostTaskByProject(project, taskId string,
	starttime, endtime time.Time, limit, sortDir int) ([]task.Task, error)

func (*MockTaskConnector) FindOldTasksByID

func (mtc *MockTaskConnector) FindOldTasksByID(id string) ([]task.Task, error)

func (*MockTaskConnector) FindTaskById

func (mtc *MockTaskConnector) FindTaskById(taskId string) (*task.Task, error)

FindTaskById provides a mock implementation of the functions for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.

func (*MockTaskConnector) FindTasksByBuildId

func (mtc *MockTaskConnector) FindTasksByBuildId(buildId, startTaskId, status string, limit,
	sortDir int) ([]task.Task, error)

FindTaskByBuildId provides a mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.

func (*MockTaskConnector) FindTasksByIds

func (mtc *MockTaskConnector) FindTasksByIds(taskIds []string) ([]task.Task, error)

func (*MockTaskConnector) FindTasksByProjectAndCommit

func (mtc *MockTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId,
	status string, limit, sortDir int) ([]task.Task, error)

FindTasksBytaskId

func (*MockTaskConnector) ResetTask

func (mtc *MockTaskConnector) ResetTask(taskId, username string) error

func (*MockTaskConnector) SetTaskActivated

func (mtc *MockTaskConnector) SetTaskActivated(taskId, user string, activated bool) error

SetTaskActivated changes the activation value of a task using a call to the service layer function.

func (*MockTaskConnector) SetTaskPriority

func (mtc *MockTaskConnector) SetTaskPriority(it *task.Task, user string, priority int64) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

type MockTestConnector

type MockTestConnector struct {
	CachedTests []testresult.TestResult
	StoredError error
}

MockTaskConnector stores a cached set of tests that are queried against by the implementations of the Connector interface's Test related functions.

func (*MockTestConnector) FindTestsByTaskId

func (mtc *MockTestConnector) FindTestsByTaskId(taskId, testFilename, status string, limit,
	sort, execution int) ([]testresult.TestResult, error)

type MockUserConnector

type MockUserConnector struct {
	CachedUsers map[string]*user.DBUser
}

MockUserConnector stores a cached set of users that are queried against by the implementations of the UserConnector interface's functions.

func (*MockUserConnector) AddPublicKey

func (muc *MockUserConnector) AddPublicKey(dbuser *user.DBUser, keyName, keyValue string) error

func (*MockUserConnector) DeletePublicKey

func (muc *MockUserConnector) DeletePublicKey(u *user.DBUser, keyName string) error

func (*MockUserConnector) FindUserById

func (muc *MockUserConnector) FindUserById(userId string) (auth.APIUser, error)

FindUserById provides a mock implementation of the User functions from the Connector that does not need to use a database. It returns results based on the cached users in the MockUserConnector.

type MockVersionConnector

type MockVersionConnector struct {
	CachedTasks             []task.Task
	CachedVersions          []version.Version
	CachedRestartedVersions map[string]string
}

MockVersionConnector stores a cached set of tasks that are queried against by the implementations of the Connector interface's Version related functions.

func (*MockVersionConnector) AbortVersion

func (mvc *MockVersionConnector) AbortVersion(versionId string) error

AbortVersion aborts all tasks of a version given its ID. Specifically, it sets the Aborted key of the tasks to true if they are currently in abortable statuses.

func (*MockVersionConnector) FindCostByVersionId

func (mvc *MockVersionConnector) FindCostByVersionId(versionId string) (*task.VersionCost, error)

FindCostByVersionId is the mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockVersionConnector.

func (*MockVersionConnector) FindVersionById

func (mvc *MockVersionConnector) FindVersionById(versionId string) (*version.Version, error)

FindVersionById is the mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached versions in the MockVersionConnector.

func (*MockVersionConnector) GetVersionsAndVariants

func (mvc *MockVersionConnector) GetVersionsAndVariants(skip, numVersionElements int, project *model.Project) (*restModel.VersionVariantData, error)

func (*MockVersionConnector) RestartVersion

func (mvc *MockVersionConnector) RestartVersion(versionId string, caller string) error

The main function of the RestartVersion() for the MockVersionConnector is to test connectivity. It sets the value of versionId in CachedRestartedVersions to the caller.

type RepoTrackerConnector

type RepoTrackerConnector struct{}

func (*RepoTrackerConnector) TriggerRepotracker

func (c *RepoTrackerConnector) TriggerRepotracker(q amboy.Queue, msgID string, event *github.PushEvent) error

Jump to

Keyboard shortcuts

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