go_tests

package module
v0.0.0-...-318a3d5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeptnSpecVersion      = "0.2.0"
	KeptnNamespaceEnvVar  = "KEPTN_NAMESPACE"
	DefaultKeptnNamespace = "keptn"
)

Variables

This section is empty.

Functions

func AddNamespaceToName

func AddNamespaceToName(projectName string) string

func ApiDELETERequest

func ApiDELETERequest(path string, retries int) (*req.Resp, error)

func ApiGETRequest

func ApiGETRequest(path string, retries int) (*req.Resp, error)

func ApiPOSTRequest

func ApiPOSTRequest(path string, payload interface{}, retries int) (*req.Resp, error)

func ApiPUTRequest

func ApiPUTRequest(path string, payload interface{}, retries int) (*req.Resp, error)

func CheckIfWebhookSubscriptionExists

func CheckIfWebhookSubscriptionExists(project, event string) (bool, error)

func CompareServiceNameWithDeploymentName

func CompareServiceNameWithDeploymentName(serviceName string, deploymentName string) (bool, error)

func CreateProject

func CreateProject(projectName string, shipyardFilePath string) (string, error)

func CreateProjectWithProxy

func CreateProjectWithProxy(projectName string, shipyardFilePath string, proxyURL string) (string, error)

func CreateProjectWithSSH

func CreateProjectWithSSH(projectName string, shipyardFilePath string) (string, error)

func CreateSubscription

func CreateSubscription(t *testing.T, serviceName string, subscription models.EventSubscription) (string, error)

func CreateTmpFile

func CreateTmpFile(fileNamePattern, fileContent string) (string, error)

func CreateTmpShipyardFile

func CreateTmpShipyardFile(shipyardContent string) (string, error)

func CreateWebhookProject

func CreateWebhookProject(t *testing.T, projectName, serviceName string) (string, string)

func DeleteFile

func DeleteFile(t *testing.T, filePath string)

func ExecuteCommand

func ExecuteCommand(cmd string) (string, error)

func ExecuteCommandf

func ExecuteCommandf(cmd string, a ...interface{}) (string, error)

func GetApiCredentials

func GetApiCredentials() (string, string, error)

func GetDiagnostics

func GetDiagnostics(service string, container string) string

func GetEventTraceForContext

func GetEventTraceForContext(keptnContext, projectName string) ([]*models.KeptnContextExtendedCE, error)

func GetEventsOfType

func GetEventsOfType(keptnContext, projectName, stage, eventType string) ([]*models.KeptnContextExtendedCE, error)

func GetFromConfigMap

func GetFromConfigMap(namespace string, configMapName string, getDataByKeyFn func(data map[string]string) string) (string, error)

func GetGiteaToken

func GetGiteaToken() (string, error)

GetGiteaToken checks whether the GITEA_TOKEN environment variable is set. If yes, it will return the value for that var. If not, it will try to fetch the token from the secret 'gitea-access' in the keptn namespace

func GetGiteaUser

func GetGiteaUser() string

func GetImageOfDeploymentContainer

func GetImageOfDeploymentContainer(deploymentName, containerName string) (string, error)

func GetIntegrationWithName

func GetIntegrationWithName(name string) (models.Integration, error)

func GetKeptnNameSpaceFromEnv

func GetKeptnNameSpaceFromEnv() string

func GetLatestEventOfType

func GetLatestEventOfType(keptnContext, projectName, stage, eventType string) (*models.KeptnContextExtendedCE, error)

func GetMongoDBCredentials

func GetMongoDBCredentials() (string, string, error)

GetMongoDBCredentials retrieves the credentials of the mongodb user from the mongodb credentials secret

func GetPodNamesOfDeployment

func GetPodNamesOfDeployment(labelSelector string) ([]string, error)

func GetPrivateKeyAndPassphrase

func GetPrivateKeyAndPassphrase() (string, string, error)

func GetProject

func GetProject(projectName string) (*models.ExpandedProject, error)

func GetPublicURLOfService

func GetPublicURLOfService(serviceName, projectName, stageName string) (string, error)

func GetRepositoryBranches

func GetRepositoryBranches(project string) (*http.Response, error)

func GetServiceExternalIP

func GetServiceExternalIP(namespace string, service string) (string, error)

func GetState

func GetState(projectName string) (*models.SequenceStates, *req.Resp, error)

func GetStateByContext

func GetStateByContext(projectName, keptnContext string) (*models.SequenceStates, *req.Resp, error)

func ImportUploadZipToProject

func ImportUploadZipToProject(urlPath, projectName, filePath string) (int, error)

func IsEqual

func IsEqual(t *testing.T, expected, actual interface{}, property string) bool

func KubeCtlApplyFromURL

func KubeCtlApplyFromURL(url string, namespace ...string) (func() error, error)

KubeCtlApplyFromURL wraps the kubectl command line tool in order to perform a "kubectl apply" command with resources downloaded from the given "url". The default namespace (set via KEPTN_NAMESPACE) will be used but can be overridden using the "namespace" param. The function returns a function which can be called to apply the corresponding "kubectl delete" command to undo the "kubectl apply" command

func KubeCtlDeleteFromURL

func KubeCtlDeleteFromURL(url string, namespace ...string) error

func KubeCtlPortForwardSvc

func KubeCtlPortForwardSvc(ctx context.Context, svcName, localPort string, remotePort string, namespace ...string) error

func PerformResourceServiceTest

func PerformResourceServiceTest(t *testing.T, projectName string, serviceName string, checkCommit bool, fail bool) (string, *models.KeptnContextExtendedCE)

func PrintLogsOfPods

func PrintLogsOfPods(t *testing.T, pods []string)

func PrintLogsWithDeploymentName

func PrintLogsWithDeploymentName(deploymentName string) (string, error)

func PutConfigMapDataVal

func PutConfigMapDataVal(namespace string, configMapName string, key string, val string) error

func RecreateGitUpstreamRepository

func RecreateGitUpstreamRepository(project string) error

RecreateGitUpstreamRepository creates a kubernetes job that (re)creates the upstream repo for a project on the internal gitea instance

func RecreateProjectUpstream

func RecreateProjectUpstream(newProjectName string) error

func RestartPod

func RestartPod(deploymentName string) error

func RestartPodsWithSelector

func RestartPodsWithSelector(useInClusterConfig bool, namespace string, selector string) error

RestartPodsWithSelector restarts the pods which are found in the provided namespace and selector

func SetEnvVarsOfDeployment

func SetEnvVarsOfDeployment(deploymentName string, containerName string, envVars []v1.EnvVar) error

func SetImageOfDeploymentContainer

func SetImageOfDeploymentContainer(deploymentName, containerName, image string) error

func SetRecreateUpgradeStrategyForDeployment

func SetRecreateUpgradeStrategyForDeployment(deploymentName string) error

SetRecreateUpgradeStrategyForDeployment sets the upgrade strategy of a deployment to "Recreate". Needed for our minishift tests right now, as there are problems with the RollingUpdate strategy of the shipyard-controller Should become obsolete when we switch to testing on an OpenShift 4.x cluster instead.

func SetShipyardControllerEnvVar

func SetShipyardControllerEnvVar(t *testing.T, envVarName, envVarValue string) error

SetShipyardControllerEnvVar sets the provided value of the shipyard-controller deployment. This function is specific to the shipyard-controller, and eventually we should avoid setting env vars of deployments in general, as this leads to the respective pod being restarted, which increases the duration of the integration tests and prevents us from executing tests in parallel

func StringArr

func StringArr(el ...string) []string

func TestAirgappedImagesAreSetCorrectly

func TestAirgappedImagesAreSetCorrectly(t *testing.T)

func Test_BackupRestore

func Test_BackupRestore(t *testing.T)

func Test_CreateProjectWithCustomBranchName

func Test_CreateProjectWithCustomBranchName(t *testing.T)

func Test_DeliveryAssistant

func Test_DeliveryAssistant(t *testing.T)

func Test_EvaluationGitCommitID

func Test_EvaluationGitCommitID(t *testing.T)

func Test_ExecutingWebhookTargetingClusterInternalAddressesFails

func Test_ExecutingWebhookTargetingClusterInternalAddressesFails(t *testing.T)

Test_ExecutingWebhookTargetingClusterInternalAddressesFails tests whether the webhook requests targeting an internal component (e.g. shipyard-controller) is blocked

func Test_ImportCorrectManifest

func Test_ImportCorrectManifest(t *testing.T)

Test_ImportCorrectManifest uploads a valid zip manifest which creates a Keptn service, secret and webhook and validates the result

func Test_ImportCorrectManifestNonExistingProject

func Test_ImportCorrectManifestNonExistingProject(t *testing.T)

Test_ImportCorrectManifestNonExistingProject uploads a valid manifest with a non-existing project which throws an error when uploading

func Test_ImportMalformedZipFileCorrectName

func Test_ImportMalformedZipFileCorrectName(t *testing.T)

Test_ImportMalformedZipFileCorrectName uploads an invalid zip with incorrect structure and mapping that throws an error while uploading

func Test_ManageSecrets_CreateUpdateAndDeleteSecret

func Test_ManageSecrets_CreateUpdateAndDeleteSecret(t *testing.T)

func Test_ProvisioningURL

func Test_ProvisioningURL(t *testing.T)

@Description: Test_ProvisioningURL tests the behaviour of the system, when no git credentials are submitted by user as * they should be provisioned by a 3rd partly REST API when AUTOMATIC_PROVISIONING_URL env variable is set. We are using * a simple mockserver to mock the responses from the 3rd partly REST API, which responses with a valid git credentials. * @Outcome Creating and deleting the project is tested using the provisoned git credentials * @Issue 7149

func Test_ProvisioningURL_hiddenURL

func Test_ProvisioningURL_hiddenURL(t *testing.T)

func Test_ProxyAuth

func Test_ProxyAuth(t *testing.T)

func Test_QualityGates

func Test_QualityGates(t *testing.T)

func Test_ResourceServiceBasic

func Test_ResourceServiceBasic(t *testing.T)

func Test_ResourceServiceGETCommitID

func Test_ResourceServiceGETCommitID(t *testing.T)

func Test_SSHPublicKeyAuth

func Test_SSHPublicKeyAuth(t *testing.T)

func Test_SequenceQueue_TriggerMultiple

func Test_SequenceQueue_TriggerMultiple(t *testing.T)

func Test_UniformRegistration_RegistrationOfKeptnIntegration

func Test_UniformRegistration_RegistrationOfKeptnIntegration(t *testing.T)

Test_UniformRegistration_RegistrationOfKeptnIntegration tests whether a deployed Keptn Integration gets correctly registered/unregistered to/from the Keptn control plane

func Test_UniformRegistration_RegistrationOfKeptnIntegrationMultiplePods

func Test_UniformRegistration_RegistrationOfKeptnIntegrationMultiplePods(t *testing.T)

Test_UniformRegistration_RegistrationOfKeptnIntegration tests whether a deployed Keptn Integration gets correctly registered/unregistered to/from the Keptn control plane

func Test_UniformRegistration_RegistrationOfKeptnIntegrationRemoteExecPlane

func Test_UniformRegistration_RegistrationOfKeptnIntegrationRemoteExecPlane(t *testing.T)

Test_UniformRegistration_RegistrationOfKeptnIntegration tests whether a deployed Keptn Integration gets correctly registered/unregistered to/from the Keptn control plane - in this case, the service runs in the remote execution plane

func Test_UniformRegistration_TestAPI

func Test_UniformRegistration_TestAPI(t *testing.T)

Test_UniformRegistration_TestAPI directly tests the API for (un)registering Keptn integrations to the Keptn control plane

func Test_Webhook

func Test_Webhook(t *testing.T)

Test_Webhook contains a test for the "happy path". Note, that for this test we temporarily disable the restriction of only being allowed to call external targets with the webhook service

func Test_Webhook_Failures

func Test_Webhook_Failures(t *testing.T)

Test_Webhook_Failures contains tests for possible types of failures that can potentially happen while processing a webhook request (e.g. webhook configuration not found, ...)

func TriggerEvaluation

func TriggerEvaluation(projectName, stageName, serviceName string) (string, error)

func TriggerSequence

func TriggerSequence(projectName, serviceName, stageName, sequenceName string, eventData keptncommon.EventProperties) (string, error)

func UpdateConfigMap

func UpdateConfigMap(namespace string, configMapName string, replaceConfig func(cm *v1.ConfigMap)) error

func UpdateMockserverConfig

func UpdateMockserverConfig(t *testing.T, project string)

func VerifyBlueGreenDeployment

func VerifyBlueGreenDeployment(serviceName, projectName, stageName, artifactImage, artifactTag string) error

func VerifyDirectDeployment

func VerifyDirectDeployment(serviceName, projectName, stageName, artifactImage, artifactTag string) error

func VerifyMainRepositoryBranchName

func VerifyMainRepositoryBranchName(project string, branchName string) (bool, error)

func VerifySequenceEndsUpInState

func VerifySequenceEndsUpInState(t *testing.T, projectName string, context *models.EventContext, timeout time.Duration, desiredStates []string)

func VerifyTaskStartedEventExists

func VerifyTaskStartedEventExists(t *testing.T, keptnContext, projectName, stage string, taskName string)

func WaitAndCheckDeployment

func WaitAndCheckDeployment(deploymentName, namespace string, timeout time.Duration, options WaitForDeploymentOptions) error

func WaitForDeploymentInNamespace

func WaitForDeploymentInNamespace(deploymentName, namespace string) error

WaitForDeploymentInNamespace deprecated, use WaitAndCheckDeployment

func WaitForDeploymentToBeScaledDown

func WaitForDeploymentToBeScaledDown(deploymentName string) error

func WaitForPodOfDeployment

func WaitForPodOfDeployment(deploymentName string) error

func WaitForURL

func WaitForURL(url string, timeout time.Duration) error

Types

type APICaller

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

func GetInternalKeptnAPI

func GetInternalKeptnAPI(ctx context.Context, internalService, localPort string, remotePort string) (*APICaller, error)

func NewAPICaller

func NewAPICaller() (*APICaller, error)

func NewAPICallerWithBaseURL

func NewAPICallerWithBaseURL(baseURL string) (*APICaller, error)

func (*APICaller) Delete

func (a *APICaller) Delete(path string, retries int) (*req.Resp, error)

func (*APICaller) Get

func (a *APICaller) Get(path string, retries int) (*req.Resp, error)

func (*APICaller) Post

func (a *APICaller) Post(path string, payload interface{}, retries int) (*req.Resp, error)

func (*APICaller) Put

func (a *APICaller) Put(path string, payload interface{}, retries int) (*req.Resp, error)

type APIEventSender

type APIEventSender struct {
}

func (*APIEventSender) Send

func (sender *APIEventSender) Send(ctx context.Context, event v2.Event) error

func (*APIEventSender) SendEvent

func (sender *APIEventSender) SendEvent(event v2.Event) error

type BranchBody

type BranchBody struct {
	Name string `json:"name"`
}

type HTTPOverrideForwardedRequest

type HTTPOverrideForwardedRequest struct {
	RequestOverride RequestOverride `json:"requestOverride,omitempty"`
}

type HTTPRequest

type HTTPRequest struct {
	Method  string    `json:"method,omitempty"`
	Path    string    `json:"path,omitempty"`
	Headers []Headers `json:"headers,omitempty"`
}

type Headers

type Headers struct {
	Name   string   `json:"name,omitempty"`
	Values []string `json:"values,omitempty"`
}

type K8SEvent

type K8SEvent struct {
	Reason        string    `json:"reason"`
	Type          string    `json:"type"`
	Message       string    `json:"message"`
	LastTimestamp time.Time `json:"lastTimestamp"`
}

type K8SEventArray

type K8SEventArray struct {
	Items []K8SEvent `json:"items"`
}

func GetOOMEvents

func GetOOMEvents() (K8SEventArray, error)

type OpenTriggeredEventsResponse

type OpenTriggeredEventsResponse struct {
	Events []*models.KeptnContextExtendedCE `json:"events"`
}

type Payload

type Payload struct {
	HTTPRequest                  HTTPRequest                  `json:"httpRequest,omitempty"`
	HTTPOverrideForwardedRequest HTTPOverrideForwardedRequest `json:"httpOverrideForwardedRequest,omitempty"`
}

type RequestOverride

type RequestOverride struct {
	Method  string    `json:"method,omitempty"`
	Path    string    `json:"path,omitempty"`
	Headers []Headers `json:"headers,omitempty"`
}

type WaitForDeploymentOptions

type WaitForDeploymentOptions struct {
	WithImageName string
}

Jump to

Keyboard shortcuts

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