Documentation ¶
Overview ¶
Package test holds the project's end-to-end tests (e2e).
Index ¶
- Variables
- func AddToInformer(t *testing.T, store cache.Store) func(ktesting.Action) (bool, runtime.Object, error)
- func CollectPodLogs(ctx context.Context, c *clients, podName, namespace string, ...)
- func CreateImage(ref string, objs ...runtime.Object) (string, error)
- func CreateImageWithAnnotations(ref string, mapper ObjectAnnotationMapper, objs ...runtime.Object) (string, error)
- func EnsureConfigurationConfigMapsExist(d *Data)
- func GenerateKeys(c elliptic.Curve, hashFunc crypto.Hash) (signature.SignerVerifier, *ecdsa.PrivateKey, []byte, error)
- func GetKeysFromFile(ctx context.Context, t *testing.T) (*ecdsa.PrivateKey, string)
- func GetObjectName(obj runtime.Object) string
- func GetSignedPipeline(unsigned *v1beta1.Pipeline, signer signature.Signer, name string) (*v1beta1.Pipeline, error)
- func GetSignedTask(unsigned *v1beta1.Task, signer signature.Signer, name string) (*v1beta1.Task, error)
- func GetSignerFromFile(ctx context.Context, t *testing.T) (signature.Signer, string)
- func GetUnsignedPipeline(name string) *v1beta1.Pipeline
- func GetUnsignedTask(name string) *v1beta1.Task
- func PrependResourceVersionReactor(f *ktesting.Fake)
- func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers)
- func SetupMatchAllVerificationPolicies(t *testing.T, namespace string) (signature.SignerVerifier, *fakek8s.Clientset, []*v1alpha1.VerificationPolicy)
- func SetupTrustedResourceConfig(ctx context.Context, verificationNoMatchPolicy string) context.Context
- func SetupVerificationPolicies(t *testing.T) (signature.SignerVerifier, *ecdsa.PrivateKey, *fakek8s.Clientset, ...)
- func WaitForDeploymentState(ctx context.Context, c *clients, name string, namespace string, ...) error
- func WaitForPipelineRunState(ctx context.Context, c *clients, name string, polltimeout time.Duration, ...) error
- func WaitForPodState(ctx context.Context, c *clients, name string, namespace string, ...) error
- func WaitForServiceExternalIPState(ctx context.Context, c *clients, namespace, name string, ...) error
- func WaitForTaskRunState(ctx context.Context, c *clients, name string, inState ConditionAccessorFn, ...) error
- type Assets
- type Clients
- type ConditionAccessorFn
- func Chain(fns ...ConditionAccessorFn) ConditionAccessorFn
- func Failed(name string) ConditionAccessorFn
- func FailedWithMessage(message, name string) ConditionAccessorFn
- func FailedWithReason(reason, name string) ConditionAccessorFn
- func PipelineRunFailed(name string) ConditionAccessorFn
- func PipelineRunPending(name string) ConditionAccessorFn
- func PipelineRunSucceed(name string) ConditionAccessorFn
- func Running(name string) ConditionAccessorFn
- func Succeed(name string) ConditionAccessorFn
- func TaskRunFailed(name string) ConditionAccessorFn
- func TaskRunSucceed(name string) ConditionAccessorFn
- type Data
- type Informers
- type ObjectAnnotationMapper
- type RawRequest
- type Request
- type Requester
- type ResolvedResource
- type ResourceVersionReactor
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultObjectAnnotationMapper does the "right" thing by conforming to the Tekton Bundle spec. DefaultObjectAnnotationMapper = func(obj runtime.Object) map[string]string { return map[string]string{ tkremote.TitleAnnotation: GetObjectName(obj), tkremote.KindAnnotation: strings.TrimSuffix(strings.ToLower(obj.GetObjectKind().GroupVersionKind().Kind), "s"), tkremote.APIVersionAnnotation: obj.GetObjectKind().GroupVersionKind().Version, } } )
Functions ¶
func AddToInformer ¶ added in v0.14.0
func AddToInformer(t *testing.T, store cache.Store) func(ktesting.Action) (bool, runtime.Object, error)
AddToInformer returns a function to add ktesting.Actions to the cache store
func CollectPodLogs ¶ added in v0.5.0
func CollectPodLogs(ctx context.Context, c *clients, podName, namespace string, logf logging.FormatLogger)
CollectPodLogs will get the logs for all containers in a Pod
func CreateImage ¶ added in v0.12.0
CreateImage will push a new OCI image artifact with the provided raw data object as a layer and return the full image reference with a digest to fetch the image. Key must be specified as [lowercase kind]/[object name]. The image ref with a digest is returned.
func CreateImageWithAnnotations ¶ added in v0.24.0
func CreateImageWithAnnotations(ref string, mapper ObjectAnnotationMapper, objs ...runtime.Object) (string, error)
CreateImageWithAnnotations is the base form of #CreateImage which accepts an ObjectAnnotationMapper to map an object to the annotations for it.
func EnsureConfigurationConfigMapsExist ¶ added in v0.41.0
func EnsureConfigurationConfigMapsExist(d *Data)
EnsureConfigurationConfigMapsExist makes sure all the configmaps exists.
func GenerateKeys ¶ added in v0.43.0
func GenerateKeys(c elliptic.Curve, hashFunc crypto.Hash) (signature.SignerVerifier, *ecdsa.PrivateKey, []byte, error)
GenerateKeys creates public key files, return the SignerVerifier
func GetKeysFromFile ¶ added in v0.43.0
GetKeysFromFile generates key files to tmpdir, return keys and pubkey path
func GetObjectName ¶ added in v0.42.0
GetObjectName returns the ObjectMetadata.Name field which every resource should have.
func GetSignedPipeline ¶ added in v0.42.0
func GetSignedPipeline(unsigned *v1beta1.Pipeline, signer signature.Signer, name string) (*v1beta1.Pipeline, error)
GetSignedPipeline signed the given pipeline and rename it with given name
func GetSignedTask ¶ added in v0.42.0
func GetSignedTask(unsigned *v1beta1.Task, signer signature.Signer, name string) (*v1beta1.Task, error)
GetSignedTask signed the given task and rename it with given name
func GetSignerFromFile ¶ added in v0.42.0
GetSignerFromFile generates key files to tmpdir, return signer and pubkey path
func GetUnsignedPipeline ¶ added in v0.42.0
GetUnsignedPipeline returns unsigned pipeline with given name
func GetUnsignedTask ¶ added in v0.42.0
GetUnsignedTask returns unsigned task with given name
func PrependResourceVersionReactor ¶ added in v0.14.0
PrependResourceVersionReactor will instrument a client-go testing Fake with a reactor that simulates resourceVersion changes on mutations. This does not work with patches.
func SeedTestData ¶
SeedTestData returns Clients and Informers populated with the given Data.
func SetupMatchAllVerificationPolicies ¶ added in v0.43.0
func SetupMatchAllVerificationPolicies(t *testing.T, namespace string) (signature.SignerVerifier, *fakek8s.Clientset, []*v1alpha1.VerificationPolicy)
SetupMatchAllVerificationPolicies set verification policies with a Pattern to match all resources SignerVerifier is returned to sign resources The k8s clientset is returned to fetch secret from it. VerificationPolicies are returned to fetch public keys
func SetupTrustedResourceConfig ¶ added in v0.42.0
func SetupTrustedResourceConfig(ctx context.Context, verificationNoMatchPolicy string) context.Context
SetupTrustedResourceConfig configures the trusted-resources-verification-no-match-policy feature flag with the given mode for testing
func SetupVerificationPolicies ¶ added in v0.43.0
func SetupVerificationPolicies(t *testing.T) (signature.SignerVerifier, *ecdsa.PrivateKey, *fakek8s.Clientset, []*v1alpha1.VerificationPolicy)
SetupVerificationPolicies set verification policies and secrets to store public keys. This function helps to setup 3 kinds of VerificationPolicies: 1. One public key in inline data 2. One public key in secret 3. 2 authorities referring to the same secret. This is to test and make sure we don't have duplicate counts SignerVerifier is returned to sign resources The k8s clientset is returned to fetch secret from it. VerificationPolicies are returned to fetch public keys
func WaitForDeploymentState ¶ added in v0.9.0
func WaitForDeploymentState(ctx context.Context, c *clients, name string, namespace string, inState func(d *appsv1.Deployment) (bool, error), desc string) error
WaitForDeploymentState polls the status of the Deployment called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForPipelineRunState ¶
func WaitForPipelineRunState(ctx context.Context, c *clients, name string, polltimeout time.Duration, inState ConditionAccessorFn, desc, version string) error
WaitForPipelineRunState polls the status of the PipelineRun called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState. version will be used to determine the client to be applied for the wait.
func WaitForPodState ¶
func WaitForPodState(ctx context.Context, c *clients, name string, namespace string, inState func(r *corev1.Pod) (bool, error), desc string) error
WaitForPodState polls the status of the Pod called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForServiceExternalIPState ¶
func WaitForServiceExternalIPState(ctx context.Context, c *clients, namespace, name string, inState func(s *corev1.Service) (bool, error), desc string) error
WaitForServiceExternalIPState polls the status of the a k8s Service called name from client every interval until an external ip is assigned indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState.
func WaitForTaskRunState ¶
func WaitForTaskRunState(ctx context.Context, c *clients, name string, inState ConditionAccessorFn, desc, version string) error
WaitForTaskRunState polls the status of the TaskRun called name from client every interval until inState returns `true` indicating it is done, returns an error or timeout. desc will be used to name the metric that is emitted to track how long it took for name to get into the state checked by inState. version will be used to determine the client to be applied for the wait.
Types ¶
type Assets ¶ added in v0.10.0
type Assets struct { Logger *zap.SugaredLogger Controller *controller.Impl Clients Clients Informers Informers Recorder *record.FakeRecorder Ctx context.Context }
Assets holds references to the controller, logs, clients, and informers.
type Clients ¶
type Clients struct { Pipeline *fakepipelineclientset.Clientset Kube *fakekubeclientset.Clientset CloudEvents cloudeventclient.CEClient ResolutionRequests *fakeresolutionclientset.Clientset }
Clients holds references to clients which are useful for reconciler tests.
type ConditionAccessorFn ¶ added in v0.11.0
type ConditionAccessorFn func(ca apis.ConditionAccessor) (bool, error)
ConditionAccessorFn is a condition function used polling functions
func Chain ¶ added in v0.18.0
func Chain(fns ...ConditionAccessorFn) ConditionAccessorFn
Chain allows multiple ConditionAccessorFns to be chained together, checking the condition of each in order.
func Failed ¶ added in v0.11.0
func Failed(name string) ConditionAccessorFn
Failed provides a poll condition function that checks if the ConditionAccessor resource has failed or not.
func FailedWithMessage ¶ added in v0.11.0
func FailedWithMessage(message, name string) ConditionAccessorFn
FailedWithMessage provides a poll function that checks if the ConditionAccessor resource has failed with the TimeoudOut reason
func FailedWithReason ¶ added in v0.11.0
func FailedWithReason(reason, name string) ConditionAccessorFn
FailedWithReason provides a poll function that checks if the ConditionAccessor resource has failed with the TimeoudOut reason
func PipelineRunFailed ¶
func PipelineRunFailed(name string) ConditionAccessorFn
PipelineRunFailed provides a poll condition function that checks if the PipelineRun has failed.
func PipelineRunPending ¶ added in v0.21.0
func PipelineRunPending(name string) ConditionAccessorFn
PipelineRunPending provides a poll condition function that checks if the PipelineRun has been marked pending by the Tekton controller.
func PipelineRunSucceed ¶
func PipelineRunSucceed(name string) ConditionAccessorFn
PipelineRunSucceed provides a poll condition function that checks if the PipelineRun has successfully completed.
func Running ¶ added in v0.11.0
func Running(name string) ConditionAccessorFn
Running provides a poll condition function that checks if the ConditionAccessor resource is currently running.
func Succeed ¶ added in v0.11.0
func Succeed(name string) ConditionAccessorFn
Succeed provides a poll condition function that checks if the ConditionAccessor resource has successfully completed or not.
func TaskRunFailed ¶
func TaskRunFailed(name string) ConditionAccessorFn
TaskRunFailed provides a poll condition function that checks if the TaskRun has failed.
func TaskRunSucceed ¶
func TaskRunSucceed(name string) ConditionAccessorFn
TaskRunSucceed provides a poll condition function that checks if the TaskRun has successfully completed.
type Data ¶
type Data struct { PipelineRuns []*v1beta1.PipelineRun Pipelines []*v1beta1.Pipeline TaskRuns []*v1beta1.TaskRun Tasks []*v1beta1.Task ClusterTasks []*v1beta1.ClusterTask CustomRuns []*v1beta1.CustomRun Pods []*corev1.Pod Namespaces []*corev1.Namespace ConfigMaps []*corev1.ConfigMap ServiceAccounts []*corev1.ServiceAccount LimitRange []*corev1.LimitRange ResolutionRequests []*resolutionv1alpha1.ResolutionRequest ExpectedCloudEventCount int VerificationPolicies []*v1alpha1.VerificationPolicy }
Data represents the desired state of the system (i.e. existing resources) to seed controllers with.
type Informers ¶
type Informers struct { PipelineRun informersv1beta1.PipelineRunInformer Pipeline informersv1beta1.PipelineInformer TaskRun informersv1beta1.TaskRunInformer Run informersv1alpha1.RunInformer CustomRun informersv1beta1.CustomRunInformer Task informersv1beta1.TaskInformer ClusterTask informersv1beta1.ClusterTaskInformer Pod coreinformers.PodInformer ConfigMap coreinformers.ConfigMapInformer ServiceAccount coreinformers.ServiceAccountInformer LimitRange coreinformers.LimitRangeInformer ResolutionRequest resolutioninformersv1alpha1.ResolutionRequestInformer VerificationPolicy informersv1alpha1.VerificationPolicyInformer }
Informers holds references to informers which are useful for reconciler tests.
type ObjectAnnotationMapper ¶ added in v0.24.0
ObjectAnnotationMapper is a func alias that maps a runtime Object to the Tekton Bundle annotations map.
type RawRequest ¶ added in v0.47.0
type RawRequest struct { // the request name Name string // the request namespace Namespace string // the params for the request Params []pipelinev1beta1.Param }
RawRequest stores the raw request data
func (*RawRequest) Request ¶ added in v0.47.0
func (r *RawRequest) Request() resolution.Request
Request returns a Request interface based on the RawRequest.
type Request ¶ added in v0.47.0
type Request struct {
RawRequest
}
Request implements resolution.Request and makes it easier to mock input for submit Using inline structs is to avoid conflicts between field names and method names.
func NewRequest ¶ added in v0.47.0
func NewRequest(name, namespace string, params []pipelinev1beta1.Param) *Request
NewRequest creates a mock request that is populated with the given name namespace and params
func (*Request) Name ¶ added in v0.47.0
Name implements resolution.Request and returns the mock name given to it on initialization.
func (*Request) Namespace ¶ added in v0.47.0
Namespace implements resolution.Request and returns the mock namespace given to it on initialization.
func (*Request) Params ¶ added in v0.47.0
func (r *Request) Params() pipelinev1beta1.Params
Params implements resolution.Request and returns the mock params given to it on initialization.
type Requester ¶ added in v0.35.0
type Requester struct { // The resolved resource object to return when a request is // submitted. ResolvedResource resolution.ResolvedResource // An error to return when a request is submitted. SubmitErr error // Params that should match those on the request in order to return the resolved resource Params []pipelinev1beta1.Param }
Requester implements resolution.Requester and makes it easier to mock the outcome of a remote pipelineRef or taskRef resolution.
func NewRequester ¶ added in v0.35.0
func NewRequester(resource resolution.ResolvedResource, err error) *Requester
NewRequester creates a mock requester that resolves to the given resource or returns the given error on Submit().
func (*Requester) Submit ¶ added in v0.35.0
func (r *Requester) Submit(ctx context.Context, resolverName resolution.ResolverName, req resolution.Request) (resolution.ResolvedResource, error)
Submit implements resolution.Requester, accepting the name of a resolver and a request for a specific remote file, and then returns whatever mock data was provided on initialization.
type ResolvedResource ¶ added in v0.35.0
type ResolvedResource struct { // The resolved bytes to return when resolution is complete. ResolvedData []byte // An error to return instead of the resolved bytes after // resolution completes. DataErr error // Annotations to return when resolution is complete. ResolvedAnnotations map[string]string // ResolvedRefSource to return the source reference of the remote data ResolvedRefSource *pipelinev1beta1.RefSource }
ResolvedResource implements resolution.ResolvedResource and makes it easier to mock the resolved content of a fetched pipeline or task.
func NewResolvedResource ¶ added in v0.35.0
func NewResolvedResource(data []byte, annotations map[string]string, source *pipelinev1beta1.RefSource, dataErr error) *ResolvedResource
NewResolvedResource creates a mock resolved resource that is populated with the given data and annotations or returns the given error from its Data() method.
func (*ResolvedResource) Annotations ¶ added in v0.35.0
func (r *ResolvedResource) Annotations() map[string]string
Annotations implements resolution.ResolvedResource and returns the mock annotations given to it on initialization.
func (*ResolvedResource) Data ¶ added in v0.35.0
func (r *ResolvedResource) Data() ([]byte, error)
Data implements resolution.ResolvedResource and returns the mock data and/or error given to it on initialization.
func (*ResolvedResource) RefSource ¶ added in v0.47.0
func (r *ResolvedResource) RefSource() *pipelinev1beta1.RefSource
RefSource is the source reference of the remote data that records where the remote file came from including the url, digest and the entrypoint.
type ResourceVersionReactor ¶ added in v0.14.0
type ResourceVersionReactor struct {
// contains filtered or unexported fields
}
ResourceVersionReactor is an implementation of Reactor for our tests