e2e

package
v1.13.11 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TestNamespace the namespace in which to run the test.
	TestNamespace = "E2E_TEST_NAMESPACE" /* #nosec */
	// PrimarySCMTokenEnvVar is the name of the environment variable containing the Git SCM token for the bot user.
	PrimarySCMTokenEnvVar = "E2E_PRIMARY_SCM_TOKEN" /* #nosec */
	// PrimarySCMUserEnvVar is the name of the environment variable containing the Git SCM username of the bot user.
	PrimarySCMUserEnvVar = "E2E_PRIMARY_SCM_USER"
	// ApproverSCMTokenEnvVar is the name of the environment variable containing the Git SCM token for the approver.
	ApproverSCMTokenEnvVar = "E2E_APPROVER_SCM_TOKEN" /* #nosec */
	// ApproverSCMUserEnvVar is the name of the environment variable containing the Git SCM username of the approver.
	ApproverSCMUserEnvVar = "E2E_APPROVER_SCM_USER"
	// HmacTokenEnvVar is the name of the environment variable containing the webhook secret.
	HmacTokenEnvVar = "E2E_HMAC_TOKEN" /* #nosec */
	// GitServerEnvVar is the name of the environment variable containing URL to the Git SCM provider
	GitServerEnvVar = "E2E_GIT_SERVER"
	// GitKindEnvVar is the name of the environment variable containing the Git SCM kind
	GitKindEnvVar = "E2E_GIT_KIND"
	// BaseRepoName is the name of the environment variable containing is the base name for the test repo. Will be suffixed with a random seed.
	BaseRepoName = "lh-e2e-test"
	// TestRepoName name of the test repo.
	TestRepoName = "E2E_TEST_REPO"
	// JenkinsURL the URL to the Jenkins test instance.
	JenkinsURL = "E2E_JENKINS_URL"
	// JenkinsUser username for making Jenkins API requests.
	JenkinsUser = "E2E_JENKINS_USER"
	// JenkinsAPIToken API token for Jenkins.
	JenkinsAPIToken = "E2E_JENKINS_API_TOKEN" /* #nosec */
	// JenkinsGitCredentialID id of the global Jenkins Git credentials
	JenkinsGitCredentialID = "E2E_JENKINS_GIT_CREDENTIAL_ID"
)

Variables

This section is empty.

Functions

func AddCollaborator

func AddCollaborator(approver string, repo *scm.Repository, botClient *scm.Client, approverClient *scm.Client) error

AddCollaborator adds the approver user to the repo

func AddHoldLabelToPullRequestWithChatOpsCommand

func AddHoldLabelToPullRequestWithChatOpsCommand(lhClient scmprovider.SCMClient, pr *scm.PullRequest) error

AddHoldLabelToPullRequestWithChatOpsCommand returns an error of the command fails to add the do-not-merge/hold label

func AddReviewerToPullRequestWithChatOpsCommand

func AddReviewerToPullRequestWithChatOpsCommand(lhClient scmprovider.SCMClient, pr *scm.PullRequest, reviewer string) error

AddReviewerToPullRequestWithChatOpsCommand returns an error of the command fails to add the reviewer to either the reviewers list or the assignees list

func AddWIPLabelToPullRequestByUpdatingTitle

func AddWIPLabelToPullRequestByUpdatingTitle(lhClient scmprovider.SCMClient, scmClient *scm.Client, pr *scm.PullRequest) error

AddWIPLabelToPullRequestByUpdatingTitle adds the WIP label by adding WIP to a pull request's title

func ApplyConfigAndPluginsConfigMaps

func ApplyConfigAndPluginsConfigMaps(cfg *config.Config, pluginsCfg *plugins.Configuration) error

ApplyConfigAndPluginsConfigMaps takes the config and plugins and creates/applies the config maps in the cluster using kubectl

func ApprovePullRequest

func ApprovePullRequest(lhClient scmprovider.SCMClient, approverClient scmprovider.SCMClient, pr *scm.PullRequest) error

ApprovePullRequest attempts to /approve a PR with the given approver git provider, then verify the label is there with the default provider

func AttemptToLGTMOwnPullRequest

func AttemptToLGTMOwnPullRequest(scmClient *scm.Client, pr *scm.PullRequest) error

AttemptToLGTMOwnPullRequest return an error if the /lgtm fails to add the lgtm label to PR

func BuildLog added in v0.0.845

func BuildLog(url string) (string, error)

BuildLog retrieves the build log as string from the specified URL.

func CreateBaseRepository

func CreateBaseRepository(botUser, approver string, botClient *scm.Client, gitClient git.Client) (*scm.Repository, *git.Repo, error)

CreateBaseRepository creates the repository that will be used for tests

func CreateGitClient

func CreateGitClient(gitServerURL string, userFunc func() string, tokenFunc func() (string, error)) (git.Client, error)

CreateGitClient creates the git client used for cloning and making changes to the test repository

func CreateHMACToken

func CreateHMACToken() (string, error)

CreateHMACToken creates an HMAC token for use in webhooks, defaulting to the E2E_HMAC_TOKEN env var if set

func CreateSCMClient

func CreateSCMClient(userFunc func() string, tokenFunc func() (string, error)) (*scm.Client, scmprovider.SCMClient, string, error)

CreateSCMClient takes functions that return the username and token to use, and creates the scm.Client and Lighthouse SCM client

func CreateWebHook

func CreateWebHook(scmClient *scm.Client, repo *scm.Repository, hmacToken string) error

CreateWebHook creates a webhook on the SCM provider for the repository

func ExpectCommandExecution

func ExpectCommandExecution(dir string, commandTimeout time.Duration, exitCode int, c string, args ...string)

ExpectCommandExecution performs the given command in the current work directory and asserts that it completes successfully

func ExpectThatPullRequestDoesNotHaveLabel

func ExpectThatPullRequestDoesNotHaveLabel(lhClient scmprovider.SCMClient, pullRequestNumber int, owner, repo, label string) error

ExpectThatPullRequestDoesNotHaveLabel returns an error if the PR does have the specified label

func ExpectThatPullRequestHasCommentMatching

func ExpectThatPullRequestHasCommentMatching(scmClient *scm.Client, pr *scm.PullRequest, matchFunc func(comments []*scm.Comment) error) error

ExpectThatPullRequestHasCommentMatching returns an error if the PR does not have a comment matching the provided function

func ExpectThatPullRequestHasLabel

func ExpectThatPullRequestHasLabel(lhClient scmprovider.SCMClient, pullRequestNumber int, owner, repo, label string) error

ExpectThatPullRequestHasLabel returns an error if the PR does not have the specified label

func ExpectThatPullRequestMatches

func ExpectThatPullRequestMatches(lhClient scmprovider.SCMClient, pullRequestNumber int, owner, repo string, matchFunc func(request *scm.PullRequest) error) error

ExpectThatPullRequestMatches returns an error if the PR does not satisfy the provided function

func GetApproverName

func GetApproverName() string

GetApproverName gets the approver user's username

func GetApproverSCMToken

func GetApproverSCMToken() (string, error)

GetApproverSCMToken gets the token used by the approver

func GetBotName

func GetBotName() string

GetBotName gets the bot user name

func GetCommitStatus added in v0.0.845

func GetCommitStatus(scmClient *scm.Client, repoName string, sha string, statusName string) (*scm.Status, error)

GetCommitStatus retrieves the status check with the specified name for the specified sha

func GetPrimarySCMToken

func GetPrimarySCMToken() (string, error)

GetPrimarySCMToken gets the token used by the bot/primary user

func GitKind

func GitKind() string

GitKind returns the git provider flavor being used

func ProcessConfigAndPlugins

func ProcessConfigAndPlugins(owner, repo, namespace, agent, jenkinsURL string) (*config.Config, *plugins.Configuration, error)

ProcessConfigAndPlugins reads the templates for the config and plugins config maps and replaces the owner, repo, and namespace in them

func RunWithReporters

func RunWithReporters(t *testing.T, suiteID string)

RunWithReporters runs a suite with better logging and gathering of test results

func URLForFile added in v0.0.845

func URLForFile(providerType string, serverURL string, owner string, repo string, path string) string

URLForFile returns the SCM provider URL for a specific file in the repository.

func WaitForPullRequestCommitStatus

func WaitForPullRequestCommitStatus(scmClient *scm.Client, pr *scm.PullRequest, contexts []string, desiredStatuses ...string)

WaitForPullRequestCommitStatus checks a pull request until either it reaches a given status in all the contexts supplied or a timeout is reached.

func WaitForPullRequestToMerge

func WaitForPullRequestToMerge(lhClient scmprovider.SCMClient, pr *scm.PullRequest)

WaitForPullRequestToMerge checks the PR's status until it's merged or timed out.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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