test

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: Apache-2.0 Imports: 21 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.

Index

Constants

View Source
const (
	StockImageName = "villardl/stock-60d7d0dbe2427b272042abacd4e1e644"
)

Variables

This section is empty.

Functions

func CheckDeploymentReady

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

func CheckExperimentCompleted

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

func CheckExperimentPause added in v0.1.0

func CheckExperimentPause(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 GetAbortExperimentResponse

func GetAbortExperimentResponse(instance *iter8v1alpha2.Experiment) analyticsv1alpha2.Response

func GetRollToWinnerMockResponse

func GetRollToWinnerMockResponse(instance *iter8v1alpha2.Experiment, winIdx int) analyticsv1alpha2.Response

func GetRollbackMockResponse

func GetRollbackMockResponse(instance *iter8v1alpha2.Experiment) analyticsv1alpha2.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]analyticsv1alpha2.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 analyticsv1alpha2.Response)

AddMock 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 v1alpha2.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) WithAnalyticsEndpoint

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

func (*ExperimentBuilder) WithCriterion

WithCriterion adds a criterion

func (*ExperimentBuilder) WithDummyCriterion

func (b *ExperimentBuilder) WithDummyCriterion() *ExperimentBuilder

WithDummyCriterion adds a dummy criterion

func (*ExperimentBuilder) WithHostInTargetService added in v0.2.0

func (b *ExperimentBuilder) WithHostInTargetService(host, gateway string) *ExperimentBuilder

func (*ExperimentBuilder) WithKubernetesTargetService

func (b *ExperimentBuilder) WithKubernetesTargetService(name, baseline string, candidates []string) *ExperimentBuilder

WithKubernetesTargetService adds Kubernetes targetService

func (*ExperimentBuilder) WithResumeAction added in v0.1.0

func (b *ExperimentBuilder) WithResumeAction() *ExperimentBuilder

func (*ExperimentBuilder) WithRouterID

func (b *ExperimentBuilder) WithRouterID(id string) *ExperimentBuilder

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 CreateObject added in v0.1.1

func CreateObject(obj 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

func ResumeExperiment added in v0.1.0

func ResumeExperiment(exp *v1alpha2.Experiment) Hook

func UpdateObject added in v0.1.0

func UpdateObject(obj runtime.Object) Hook

type InStateFunc

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

func WantAllStates

func WantAllStates(stateFns ...InStateFunc) InStateFunc

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