Documentation
¶
Index ¶
- Constants
- func CreateRoute53DNS(t *testing.T, recordType, clusterDomain string) *route53.ChangeResourceRecordSetsOutput
- func CreateSelfSignedCert(t *testing.T)
- func DeleteRoute53DNS(clusterDomain string) *route53.ChangeResourceRecordSetsOutput
- func DeleteSelfSignedCert()
- func GenerateName() string
- func GenerateRandomDomain() string
- func GetAInfo() string
- func GetCNAMEInfo() string
- func GetHostname(urls ...string) string
- func GetKubeClient(t *testing.T) *kubernetes.Clientset
- func GetURL(url string) (string, error)
- func HeyCmd(url string, time string, c int)
- func IntegrationPreCheck()
- func KubectlCmd(args []string) (string, error)
- func RandomString(length int) string
- func RioCmd(args []string, envs ...string) (string, error)
- func RioCmdWithRetry(args []string, envs ...string) (string, error)
- func RioCmdWithTail(timeoutSeconds int, args []string, envs ...string) ([]string, error)
- func RioExecute(args []string, envs ...string) (string, error)
- func RioExecuteWithRetry(args []string, envs ...string) (string, error)
- func SetRoute53Params(t *testing.T, recordType, ipOrDNS string) *route53.ChangeResourceRecordSetsInput
- func ValidationPreCheck()
- func WaitForNoResponse(endpoint string) (string, error)
- func WaitForURLResponse(endpoint string) (string, error)
- type TestConfig
- type TestDomain
- type TestExternalService
- func (es *TestExternalService) Create(t *testing.T, target string)
- func (es *TestExternalService) GetFQDN() string
- func (es *TestExternalService) GetFirstIPAddress() string
- func (es *TestExternalService) GetKubeFQDN() string
- func (es *TestExternalService) GetKubeFirstIPAddress() string
- func (es *TestExternalService) Remove()
- type TestRiofile
- func (trf *TestRiofile) ExportStack() (map[string]interface{}, error)
- func (trf *TestRiofile) Readfile() (map[string]interface{}, error)
- func (trf *TestRiofile) Remove()
- func (trf *TestRiofile) Up(t *testing.T, filename, stackName string, args ...string)
- func (trf *TestRiofile) UpWithRepo(t *testing.T, repoName, stackName string, args ...string) error
- type TestRoute
- type TestService
- func (ts *TestService) Attach() []string
- func (ts *TestService) BuildAndCreate(t *testing.T, imageName string, imageVersion string, args ...string)
- func (ts *TestService) BuildAndStage(t *testing.T, imageName string, imageVersion string, args ...string) TestService
- func (ts *TestService) BuildImage(t *testing.T, imageName string, imageVersion string, args ...string) error
- func (ts *TestService) Create(t *testing.T, source ...string)
- func (ts *TestService) CreateExpectingError(t *testing.T, source ...string) error
- func (ts *TestService) Exec(command ...string) string
- func (ts *TestService) Export() TestService
- func (ts *TestService) ExportRaw() TestService
- func (ts *TestService) GenerateLoad(timeIncrements string, concurrency int)
- func (ts *TestService) GetAppEndpointResponse() string
- func (ts *TestService) GetAppEndpointURLs() []string
- func (ts *TestService) GetAvailableReplicas() int
- func (ts *TestService) GetComputedWeight() int
- func (ts *TestService) GetCurrentWeight() int
- func (ts *TestService) GetEndpointResponse() string
- func (ts *TestService) GetEndpointURLs() []string
- func (ts *TestService) GetImage() string
- func (ts *TestService) GetKubeAppEndpointURLs() []string
- func (ts *TestService) GetKubeAvailableReplicas() int
- func (ts *TestService) GetKubeEndpointURLs() []string
- func (ts *TestService) GetKubeFirstClusterDomain() (string, string)
- func (ts *TestService) GetPodsAndReplicas() ([]string, int)
- func (ts *TestService) GetResponseCounts(responses []string, numRequests int) map[string]int
- func (ts *TestService) GetRolloutDuration() float64
- func (ts *TestService) GetRunningPods() []string
- func (ts *TestService) GetScale() int
- func (ts *TestService) GetSpecWeight() int
- func (ts *TestService) IsReady() bool
- func (ts *TestService) Logs(args ...string) []string
- func (ts *TestService) PodsResponsesMatchAvailableReplicas(path string, numberOfReplicas int) bool
- func (ts *TestService) Promote(args ...string)
- func (ts *TestService) Remove()
- func (ts *TestService) Scale(scaleTo int)
- func (ts *TestService) Stage(source, version string) TestService
- func (ts *TestService) StageExec(source, version string) TestService
- func (ts *TestService) StageRun(source, version, port, weight string) TestService
- func (ts *TestService) WaitForDomain(domain string) error
- func (ts *TestService) WaitForScaleDown() error
- func (ts *TestService) Weight(weightSpec int, args ...string)
- func (ts *TestService) WeightWithoutWaiting(weightSpec int, args ...string)
- type TestUser
Constants ¶
const ( AdminUserBindingName = "rio-admin" AdminUserGroupName = "rio:admin" StandardBindingName = "rio-standard" StandardGroupName = "rio:standard" PrivilegedBindingName = "rio-privileged" PrivilegedGroupName = "rio:privileged" ReadonlyBindingName = "rio-readonly" ReadonlyGroupName = "rio:readonly" )
const TestingNamespace = "testing-ns"
Variables ¶
This section is empty.
Functions ¶
func CreateRoute53DNS ¶ added in v0.7.1
func CreateRoute53DNS(t *testing.T, recordType, clusterDomain string) *route53.ChangeResourceRecordSetsOutput
CreateRoute53DNS creates a CNAME if it doesn't exist or update if it exist already in the DNS Zone We use AWS Route53 as DNS provider.
func CreateSelfSignedCert ¶ added in v0.7.1
CreateSelfSignedCert creates public and private keys for a self signed certificate
func DeleteRoute53DNS ¶ added in v0.7.1
func DeleteRoute53DNS(clusterDomain string) *route53.ChangeResourceRecordSetsOutput
DeleteRoute53DNS deletes a CNAME we provide as ENV var We use AWS Route53 as DNS provider.
func DeleteSelfSignedCert ¶ added in v0.7.1
func DeleteSelfSignedCert()
DeleteSelfSignedCert deletes the generated cert files
func GenerateName ¶
func GenerateName() string
func GenerateRandomDomain ¶
func GenerateRandomDomain() string
Generates and returns a random string to use as domain name, ex: qpwb.towv
func GetAInfo ¶ added in v0.7.1
func GetAInfo() string
GetAInfo retrieves the RIO_A_RECORD environment variable
func GetCNAMEInfo ¶
func GetCNAMEInfo() string
GetCNAMEInfo retrieves the RIO_CNAME environment variable
func GetHostname ¶
func GetKubeClient ¶
func GetKubeClient(t *testing.T) *kubernetes.Clientset
GetKubeClient returns the kubernetes clientset for querying its API, defaults to KUBECONFIG env value
func HeyCmd ¶
HeyCmd generates load on a specified URL Example: url=test-testing-ns.abcdef.on-rio.io, time=90s, c=120 would run: "hey -z 90s -c 120 http://test-testing-ns.abcdef.on-rio.io:9080"
func IntegrationPreCheck ¶
func IntegrationPreCheck()
IntegrationPreCheck ensures CLI flag is passed, this way integration tests won't run during unit or validation tests
func KubectlCmd ¶
KubectlCmd executes kubectl CLI commands with your arguments Example: args=["get", "-n", "test", "services"] would run: "kubectl get -n test services"
func RioCmd ¶
RioCmd executes rio CLI commands with your arguments in testing namespace Example: args=["run", "-n", "test", "nginx"] would run: "rio --namespace testing-namespace run -n test nginx"
func RioCmdWithRetry ¶
RioCmdWithRetry executes rio CLI commands with your arguments Example: args=["run", "-n", "test", "nginx"] would run: "rio --namespace testing-namespace run -n test nginx"
func RioCmdWithTail ¶
RioCmdWithTail executes rio CLI commands that tail output with your arguments in testing namespace. Example: args=["attach", "nginx"] would run: "rio --namespace testing-namespace attach nginx"
func RioExecute ¶ added in v0.7.1
RioExecute executes rio CLI commands with arguments, use RioCmd unless you have to use a non-testing namespace
func RioExecuteWithRetry ¶ added in v0.7.1
RioExecuteWithRetry executes rio CLI commands with your arguments Example: args=["run", "-n", "test", "nginx"] would run: "rio run -n test nginx"
func SetRoute53Params ¶ added in v0.7.1
func SetRoute53Params(t *testing.T, recordType, ipOrDNS string) *route53.ChangeResourceRecordSetsInput
SetRoute53Params creates a CNAME if it doesn't exist or update if it exist already in the DNS Zone We use AWS Route53 as DNS provider.
func ValidationPreCheck ¶
func ValidationPreCheck()
ValidationPreCheck ensures CLI flag is passed, this way validation tests won't run during unit or integration tests
func WaitForNoResponse ¶
WaitForNoResponse waits until the response returned by a service is not 200
func WaitForURLResponse ¶
Wait until a URL has a response that returns 200 status code, else return error
Types ¶
type TestConfig ¶
func (*TestConfig) Create ¶
func (tc *TestConfig) Create(t *testing.T, content []string)
Executes "rio config create ns/randomconfig {fileWithContent}" This does not take a name or namespace param, that is setup by default
func (*TestConfig) GetContent ¶
func (tc *TestConfig) GetContent() []string
GetContent returns the configs Data.Content as list of strings, newline separated
func (*TestConfig) GetKubeContent ¶
func (tc *TestConfig) GetKubeContent() []string
GetKubeContent returns the kubectl configmap's Data.Content as list of strings, newline separated CLI Command Run: kubectl get cm testname -n testing-ns -o json
type TestDomain ¶
type TestDomain struct { Name string PublicDomain adminv1.PublicDomain T *testing.T }
func (*TestDomain) ApplyClusterDomain ¶ added in v0.7.1
func (td *TestDomain) ApplyClusterDomain(ip string)
ApplyClusterDomain creates and applies a custom clusterdomain
func (*TestDomain) GetDomain ¶
func (td *TestDomain) GetDomain() string
GetDomain returns standard format non-namespaced domain, ex: "foo.bar"
func (*TestDomain) GetKubeDomain ¶
func (td *TestDomain) GetKubeDomain() string
GetKubeDomain receives the TestDomain object to retrieve the test PublicDomain data CLI Command Run: "kubectl get publicdomains my-domain -n testing-ns -o json"
func (*TestDomain) GetTargetApp ¶ added in v0.7.0
func (td *TestDomain) GetTargetApp() string
GetDomain returns standard format non-namespaced domain, ex: "foo.bar"
func (*TestDomain) RegisterDomain ¶
func (td *TestDomain) RegisterDomain(t *testing.T, domain string, target string)
Executes "rio domain register {domain} {target}" and returns a TestDomain
func (*TestDomain) UnRegister ¶
func (td *TestDomain) UnRegister()
Executes "rio domain unregister" for this domain
type TestExternalService ¶
type TestExternalService struct { Target string Name string ExternalService riov1.ExternalService T *testing.T }
func GetExternalService ¶
func GetExternalService(t *testing.T, name string) TestExternalService
Takes the name of an existing external service, loads it, and returns
func (*TestExternalService) Create ¶
func (es *TestExternalService) Create(t *testing.T, target string)
Executes "rio externalservice create ns/randomservice {target}" This does not take a name or namespace param, that is setup by default
func (*TestExternalService) GetFQDN ¶
func (es *TestExternalService) GetFQDN() string
func (*TestExternalService) GetFirstIPAddress ¶
func (es *TestExternalService) GetFirstIPAddress() string
There can be multiple IPAddresses on a service, this returns first
func (*TestExternalService) GetKubeFQDN ¶
func (es *TestExternalService) GetKubeFQDN() string
GetKubeFQDN retrieves the external service FQDN value using the kubernetes clientset
func (*TestExternalService) GetKubeFirstIPAddress ¶
func (es *TestExternalService) GetKubeFirstIPAddress() string
GetKubeIPAddress retrieves the external service IP Address value using the kubernetes clientset
func (*TestExternalService) Remove ¶
func (es *TestExternalService) Remove()
Executes "rio rm" for this external service
type TestRiofile ¶
type TestRiofile struct { Name string StackName string Filepath string Stack riov1.Stack T *testing.T Kubeconfig string }
func (*TestRiofile) ExportStack ¶
func (trf *TestRiofile) ExportStack() (map[string]interface{}, error)
Return "rio export --stack {name}"
func (*TestRiofile) Readfile ¶
func (trf *TestRiofile) Readfile() (map[string]interface{}, error)
Returns raw Riofile
func (*TestRiofile) Remove ¶
func (trf *TestRiofile) Remove()
Remove a stack and its objects todo: use owner-name annotation to remove orphaned objects (potentially in pkg) if we continue to see them
func (*TestRiofile) Up ¶
func (trf *TestRiofile) Up(t *testing.T, filename, stackName string, args ...string)
Bring up a riofile by fixture file
func (*TestRiofile) UpWithRepo ¶
type TestRoute ¶
func (*TestRoute) Add ¶
func (tr *TestRoute) Add(t *testing.T, domain string, routePath string, action string, target TestService)
Executes "rio route add routename.testing-namespace/{routePath} to {service}" This does not take a domain param, that is setup by default. domain is optional, if empty it will generate a random domain. routePath is optional, if empty it will set only domain.
func (*TestRoute) GetEndpointResponse ¶
GetEndpointResponse performs an http.get against the route's full domain and path and returns response if status code is 200, otherwise it errors out
func (*TestRoute) GetEndpointURLs ¶ added in v0.7.0
GetEndpointURLs returns the URLs for this service
func (*TestRoute) GetKubeEndpointResponse ¶
GetKubeEndpointResponse performs an http.get against the route's full domain and all paths on it Returns responses if status code is 200 for all of them, otherwise it errors out
type TestService ¶
type TestService struct { Name string App string Service riov1.Service Build tektonv1alpha1.TaskRun Version string T *testing.T Kubeconfig string }
func GetService ¶
Takes name and version of existing service and returns loaded TestService
func (*TestService) Attach ¶
func (ts *TestService) Attach() []string
Attach attaches to the service: `rio --namespace testing-ns attach <service name>` and appends each line of output to an array
func (*TestService) BuildAndCreate ¶ added in v0.7.0
func (ts *TestService) BuildAndCreate(t *testing.T, imageName string, imageVersion string, args ...string)
BuildAndCreate builds a local image and runs a service using it
func (*TestService) BuildAndStage ¶ added in v0.7.0
func (ts *TestService) BuildAndStage(t *testing.T, imageName string, imageVersion string, args ...string) TestService
BuildAndStage builds a local image and stages it onto another running service
func (*TestService) BuildImage ¶ added in v0.7.0
func (ts *TestService) BuildImage(t *testing.T, imageName string, imageVersion string, args ...string) error
BuildAndCreate builds a local image and runs a service using it
func (*TestService) Create ¶
func (ts *TestService) Create(t *testing.T, source ...string)
Create generates a new rio service, named randomly in the testing namespace, and returns a new TestService with it attached. Guarantees ready state but not live endpoint
func (*TestService) CreateExpectingError ¶
func (ts *TestService) CreateExpectingError(t *testing.T, source ...string) error
func (*TestService) Exec ¶
func (ts *TestService) Exec(command ...string) string
Exec calls "rio exec ns/service {command}" on this service
func (*TestService) Export ¶
func (ts *TestService) Export() TestService
Export calls "rio export {serviceName}" and returns that in a new TestService object
func (*TestService) ExportRaw ¶
func (ts *TestService) ExportRaw() TestService
ExportRaw works the same as export, but with --raw flag
func (*TestService) GenerateLoad ¶
func (ts *TestService) GenerateLoad(timeIncrements string, concurrency int)
GenerateLoad queries the endpoint multiple times in order to put load on the service. It will execute for up to 120 seconds until there are ready pods on the service or the the AvailableReplicas equal the MaxScale
func (*TestService) GetAppEndpointResponse ¶
func (ts *TestService) GetAppEndpointResponse() string
func (*TestService) GetAppEndpointURLs ¶
func (ts *TestService) GetAppEndpointURLs() []string
GetAppEndpointURLs retrieves the service's app endpoint URLs
func (*TestService) GetAvailableReplicas ¶
func (ts *TestService) GetAvailableReplicas() int
Returns count of ready and available pods
func (*TestService) GetComputedWeight ¶ added in v0.7.0
func (ts *TestService) GetComputedWeight() int
Return service's computed weight value
func (*TestService) GetCurrentWeight ¶
func (ts *TestService) GetCurrentWeight() int
Return service's computed (actual) weight, not the spec (end-goal) weight
func (*TestService) GetEndpointResponse ¶
func (ts *TestService) GetEndpointResponse() string
GetEndpointResponse performs an http.get against the service endpoint and returns response if status code is 200, otherwise it errors out
func (*TestService) GetEndpointURLs ¶
func (ts *TestService) GetEndpointURLs() []string
GetEndpointURLs returns the URLs for this service
func (*TestService) GetImage ¶
func (ts *TestService) GetImage() string
func (*TestService) GetKubeAppEndpointURLs ¶
func (ts *TestService) GetKubeAppEndpointURLs() []string
GetKubeAppEndpointURLs returns the endpoint URL of the service's app by using kubectl and returns it as string
func (*TestService) GetKubeAvailableReplicas ¶
func (ts *TestService) GetKubeAvailableReplicas() int
GetKubeAvailableReplicas get the app number of ready replicasets with a clientset and returns true if that value match the scale given
func (*TestService) GetKubeEndpointURLs ¶
func (ts *TestService) GetKubeEndpointURLs() []string
GetKubeEndpointURLs returns the app revision endpoint URLs as an array
func (*TestService) GetKubeFirstClusterDomain ¶
func (ts *TestService) GetKubeFirstClusterDomain() (string, string)
GetKubeFirstClusterDomain returns first cluster domain
func (*TestService) GetPodsAndReplicas ¶ added in v0.7.0
func (ts *TestService) GetPodsAndReplicas() ([]string, int)
GetPodsAndReplicas waits until the service has reached its desired replica count, then returns the running pods and available replicas
func (*TestService) GetResponseCounts ¶
func (ts *TestService) GetResponseCounts(responses []string, numRequests int) map[string]int
GetResponseCounts takes an array of expected response strings and sends numRequests requests to the service's app endpoint. If it gets a response other than one in the specified array, it throws a failure. Otherwise it returns individual counts of each response.
func (*TestService) GetRolloutDuration ¶ added in v0.7.0
func (ts *TestService) GetRolloutDuration() float64
Return RolloutDuration in seconds
func (*TestService) GetRunningPods ¶
func (ts *TestService) GetRunningPods() []string
GetRunningPods returns the kubectl overview of all running pods for this service in an array Each value in the array is a string, separated by spaces, that will have the Pod's NAME READY STATUS RESTARTS AGE in that order.
func (*TestService) GetScale ¶
func (ts *TestService) GetScale() int
Returns desired scale, different from current available replicas
func (*TestService) GetSpecWeight ¶
func (ts *TestService) GetSpecWeight() int
Return service's goal weight, this is different from weight service is currently at
func (*TestService) IsReady ¶
func (ts *TestService) IsReady() bool
IsReady gets whether the service is created successfully and able to be used or not
func (*TestService) Logs ¶
func (ts *TestService) Logs(args ...string) []string
Logs calls "rio logs ns/service" on this service
func (*TestService) PodsResponsesMatchAvailableReplicas ¶
func (ts *TestService) PodsResponsesMatchAvailableReplicas(path string, numberOfReplicas int) bool
PodsResponsesMatchAvailableReplicas does a GetURL in the App endpoint and stores the response in a slice the length of the resulting slice should represent the number of responsive pods in a service. Returns true if the number of replicas is equal to the length of the responses slice.
func (*TestService) Promote ¶
func (ts *TestService) Promote(args ...string)
Promote calls "rio promote [args] service_name" to instantly promote a revision
func (*TestService) Remove ¶
func (ts *TestService) Remove()
Remove calls "rio rm" on this service. Logs error but does not fail test.
func (*TestService) Scale ¶
func (ts *TestService) Scale(scaleTo int)
Call "rio scale ns/service={scaleTo}"
func (*TestService) Stage ¶
func (ts *TestService) Stage(source, version string) TestService
Call "rio stage --image={source} ns/name:{version}", this will return a new TestService
func (*TestService) StageExec ¶ added in v0.7.1
func (ts *TestService) StageExec(source, version string) TestService
Same as stage but uses the colon style namespacing
func (*TestService) StageRun ¶ added in v0.7.1
func (ts *TestService) StageRun(source, version, port, weight string) TestService
Executes a faux stage with run: "rio run -n ng@v3 --weight 50 nginx"
func (*TestService) WaitForDomain ¶ added in v0.7.0
func (ts *TestService) WaitForDomain(domain string) error
WaitForDomain waits until either 1 minute has passed or the given domain is an available endpoint on the service or app
func (*TestService) WaitForScaleDown ¶
func (ts *TestService) WaitForScaleDown() error
WaitForScaleDown waits until either 5 minutes pass or a service has scaled down to its minimum value
func (*TestService) Weight ¶
func (ts *TestService) Weight(weightSpec int, args ...string)
Weight calls "rio weight {args} service_name={weightSpec}" on this service and waits until the service weight reaches the desired value.
func (*TestService) WeightWithoutWaiting ¶
func (ts *TestService) WeightWithoutWaiting(weightSpec int, args ...string)
WeightWithoutWaiting calls "rio weight {args} service_name={weightSpec}" on this service.