test

package
v0.0.0-...-4232eae Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	StockImageName = "villardl/stock-60d7d0dbe2427b272042abacd4e1e644"
)
View Source
const (
	// TestTag identifies the test id
	TestTag = "testid"
)

Variables

This section is empty.

Functions

func CheckDeploymentReady

func CheckDeploymentReady(obj runtime.Object) (bool, error)

func CheckExperimentFailure

func CheckExperimentFailure(obj runtime.Object) (bool, error)

func CheckExperimentFinished

func CheckExperimentFinished(obj runtime.Object) (bool, error)

func CheckExperimentSuccess

func CheckExperimentSuccess(obj runtime.Object) (bool, error)

func CheckLatestReadyRevisionName

func CheckLatestReadyRevisionName(name string) func(obj runtime.Object) (bool, error)

func CheckServiceFound

func CheckServiceFound(obj runtime.Object) (bool, error)

func CheckServiceNotFound

func CheckServiceNotFound(reason string) func(obj runtime.Object) (bool, error)

func CheckServiceReady

func CheckServiceReady(obj runtime.Object) (bool, error)

func GetAbortExperimentResponse

func GetAbortExperimentResponse() api.Response

func GetDefaultMockResponse

func GetDefaultMockResponse() api.Response

func GetFailureMockResponse

func GetFailureMockResponse() api.Response

func GetSuccessMockResponse

func GetSuccessMockResponse() api.Response

func Logger

func Logger(t *testing.T) logr.Logger

Logger creates logger for the test

func WaitForDelete

func WaitForDelete(ctx context.Context, cl client.Client, obj runtime.Object) error

WaitForDelete polls the obj existence

func WaitForState

func WaitForState(ctx context.Context, cl client.Client, obj runtime.Object, inState InStateFunc) error

WaitForState polls the status of the object called name from client every `interval` until `inState` returns `true` indicating it is done, returns an error or timeout

Types

type AnalyticsService

type AnalyticsService struct {

	// Mock maps request to response. The key maps to request.name
	Mock map[string]api.Response
	// contains filtered or unexported fields
}

AnalyticsService with mock response

func StartAnalytics

func StartAnalytics() *AnalyticsService

StartAnalytics starts fake analytics service

func (*AnalyticsService) AddMock

func (s *AnalyticsService) AddMock(name string, response api.Response)

Mock adds response for testid

func (*AnalyticsService) Close

func (s *AnalyticsService) Close()

Close the service

func (*AnalyticsService) GetURL

func (s *AnalyticsService) GetURL() string

GetURL returns the service URL

func (*AnalyticsService) ServeHTTP

func (s *AnalyticsService) ServeHTTP(w http.ResponseWriter, r *http.Request)

type DeploymentBuilder

type DeploymentBuilder appsv1.Deployment

func NewKubernetesDeployment

func NewKubernetesDeployment(name, namespace string) *DeploymentBuilder

NewKubernetesDeployment returns a kubernetes deployment

func (*DeploymentBuilder) Build

func (d *DeploymentBuilder) Build() *appsv1.Deployment

Build converts builder to deployment

func (*DeploymentBuilder) WithContainer

func (d *DeploymentBuilder) WithContainer(name, image string, port int) *DeploymentBuilder

WithContainer adds a container spec to the deployment

func (*DeploymentBuilder) WithLabels

func (d *DeploymentBuilder) WithLabels(l map[string]string) *DeploymentBuilder

WithLabels adds labels to the deployment

type ExperimentBuilder

type ExperimentBuilder v1alpha1.Experiment

ExperimentBuilder builds experiment object

func NewExperiment

func NewExperiment(name string, namespace string) *ExperimentBuilder

NewExperiment create a new miminal experiment object

func (*ExperimentBuilder) Build

Build the experiment object

func (*ExperimentBuilder) WithAnalyticsHost

func (b *ExperimentBuilder) WithAnalyticsHost(host string) *ExperimentBuilder

func (*ExperimentBuilder) WithDummySuccessCriterion

func (b *ExperimentBuilder) WithDummySuccessCriterion() *ExperimentBuilder

WithDummySuccessCriterion adds a dummy success criterion

func (*ExperimentBuilder) WithKNativeService

func (b *ExperimentBuilder) WithKNativeService(name string) *ExperimentBuilder

WithKNativeService adds KNative target service

func (*ExperimentBuilder) WithKubernetesTargetService

func (b *ExperimentBuilder) WithKubernetesTargetService(name, baseline, candidate string) *ExperimentBuilder

WithKubernetesTargetService adds Kubernetes targetService

func (*ExperimentBuilder) WithSuccessCriterion

func (b *ExperimentBuilder) WithSuccessCriterion(sc v1alpha1.SuccessCriterion) *ExperimentBuilder

WithSuccessCriterion adds a success criterion

type Hook

type Hook func(ctx context.Context, cl client.Client) error

Hook defines a function with a client.

func CheckObjectDeleted

func CheckObjectDeleted(objects ...runtime.Object) Hook

func DeleteExperiment

func DeleteExperiment(name string, namespace string) Hook

func DeleteObject

func DeleteObject(obj runtime.Object) Hook

func DeleteObjectIfExists

func DeleteObjectIfExists(obj runtime.Object) Hook

type InStateFunc

type InStateFunc func(obj runtime.Object) (bool, error)

func WantAllStates

func WantAllStates(stateFns ...InStateFunc) InStateFunc

type KnativeServiceBuilder

type KnativeServiceBuilder servingalpha1.Service

KnativeServiceBuilder builds Knative service object

func NewKnativeService

func NewKnativeService(name string, namespace string) *KnativeServiceBuilder

NewKnativeService creates a default Knative service with one revision

func (*KnativeServiceBuilder) Build

Build the Knative Service object

func (*KnativeServiceBuilder) WithEnv

func (b *KnativeServiceBuilder) WithEnv(name string, value string) *KnativeServiceBuilder

func (*KnativeServiceBuilder) WithImage

func (*KnativeServiceBuilder) WithRevision

func (b *KnativeServiceBuilder) WithRevision(revisionName string, percent int64) *KnativeServiceBuilder

type ServiceBuilder

type ServiceBuilder corev1.Service

func NewKubernetesService

func NewKubernetesService(name, namespace string) *ServiceBuilder

NewKubernetesService returns a kubernetes service

func (*ServiceBuilder) Build

func (s *ServiceBuilder) Build() *corev1.Service

Build converts builder to service

func (*ServiceBuilder) WithPorts

func (s *ServiceBuilder) WithPorts(ports map[string]int) *ServiceBuilder

WithPorts adds ports to the service

func (*ServiceBuilder) WithSelector

func (s *ServiceBuilder) WithSelector(selector map[string]string) *ServiceBuilder

WithSelector adds selector labels to the service

Directories

Path Synopsis
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

Jump to

Keyboard shortcuts

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