client

package
v0.0.0-...-439ea99 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

* Copyright Skyramp Authors 2024

* Copyright Skyramp Authors 2024

* Copyright Skyramp Authors 2024

* Copyright Skyramp Authors 2024

* Copyright Skyramp Authors 2024

Index

Constants

View Source
const RequirementPath = "requirements.txt"

Variables

This section is empty.

Functions

func LoadCustomImageInKind

func LoadCustomImageInKind(img string, clusterName string) error

func NewGrpcEndpoint

func NewGrpcEndpoint(name, grpcServiceName string, protoFile, address string, serviceOption *types.Service) *types.EndpointDescription

NewGrpcEndpoint creates a new grpc endpoint name: the name of the endpoint grpcServiceName: the name of the grpc service protoFile: the path of the proto file address: the address of the service serviceOption: the service option return: the endpoint description

func NewRestEndpoint

func NewRestEndpoint(name, path string, openApiFile, address string, serviceOption *types.Service) *types.EndpointDescription

NewRestEndpoint creates a new REST endpoint name: the name of the endpoint path: the path of the REST endpoint openApiFile: the path of the openapi file address: the address of the service serviceOption: the service option

Types

type Client

type Client interface {
	// InstallWorker installs the worker in the client's environment.
	// It returns an error if the worker installation fails.
	InstallWorker() error

	// UninstallWorker uninstalls the worker in the client's environment.
	// It returns an error if the worker uninstallation fails.
	UninstallWorker() error

	// TesterStart starts the test in the client's environment.
	// It takes the test scenario, test name, global variables, and global headers as parameters.
	// It returns an error if the test fails to start.
	TesterStart(scenario []*Scenario, testName string, globalVars map[string]interface{}, globalHeaders map[string]string) (*types.TestStatusResponse, error)

	// MockerApply applies the mock in the client's environment.
	// It takes the response values and traffic configuration as parameters.
	// It returns an error if the mock fails to apply.
	MockerApply(response []*ResponseValue, trafficConfig *types.TrafficConfig) error

	// TestStatus returns the status of the test in the client's environment.
	// It returns the test status response.
	TestStatus() *types.TestStatusResponse

	// SetWorkerImage overrides the default worker image.
	// It takes the image and tag as parameters.
	SetWorkerImage(image, tag string)
}

Client represents an interface for interacting with Skyramp.

type DockerClient

type DockerClient struct {
	// Address is the Skyramp worker's daemon address.
	Address string

	// NetworkName is the name of the Docker network where the Skyramp worker gets installed.
	NetworkName string

	// HostPort is the port to be used by the Skyramp worker.
	HostPort int

	// WorkerImageRepo is the repository for the worker image.
	WorkerImageRepo string

	// WorkerImageTag is the tag associated with the worker image.
	WorkerImageTag string
}

DockerClient represents a client configuration for interacting with Docker.

func NewDockerClient

func NewDockerClient(address, targetNetworkName string, hostPort int) *DockerClient

NewDockerClient creates a new Docker client. It takes the address, target network name, and host port as parameters.

func (*DockerClient) GetTesterStatus

func (c *DockerClient) GetTesterStatus() (*types.TestStatusResponse, int, error)

GetTesterStatus returns the status of the test in the docker environment. It returns the test status response, status code, and error.

func (*DockerClient) InstallWorker

func (c *DockerClient) InstallWorker() error

InstallWorker installs the worker in the docker environment. It returns an error if the worker installation fails.

func (*DockerClient) MockerApply

func (c *DockerClient) MockerApply(response []*ResponseValue, trafficConfig *types.TrafficConfig) error

func (*DockerClient) SetWorkerImage

func (c *DockerClient) SetWorkerImage(image, tag string)

SetWorkerImage overrides the default worker image. It takes the image and tag as parameters.

func (*DockerClient) TestStatus

func (c *DockerClient) TestStatus() *types.TestStatusResponse

TestStatus returns the status of the test in the docker environment. It returns the test status response.

func (*DockerClient) TesterStart

func (c *DockerClient) TesterStart(
	scenario []*Scenario,
	testName string,
	globalVars map[string]interface{},
	globalHeaders map[string]string,
) (*types.TestStatusResponse, error)

TesterStart starts the test in the docker environment. It takes the test scenario, test name, global variables, and global headers as parameters. It returns an error if the test fails to start.

func (*DockerClient) UninstallWorker

func (c *DockerClient) UninstallWorker() error

UninstallWorker uninstalls the worker in the docker environment. It returns an error if the worker uninstallation fails.

type KubernetesClient

type KubernetesClient struct {
	// KubeconfigPath is the path to the kubeconfig file
	KubeconfigPath string
	// K8sContext is the context to use
	K8sContext string
	// ClusterName is the name of the cluster
	ClusterName string
	// Namespace is the namespace to use
	Namespace string
	// WorkerImageRepo is the repository of the worker image
	WorkerImageRepo string
	// WorkerImageTag is the tag of the worker image
	WorkerImageTag string
}

KubernetesClient is a client for interacting with Kubernetes

func NewKubernetesClient

func NewKubernetesClient(kubeconfigPath, k8sContext, clusterName, namespace string) *KubernetesClient

NewKubernetesClient creates a new Kubernetes client

func (*KubernetesClient) GetTesterStatus

func (k *KubernetesClient) GetTesterStatus() (*types.TestStatusResponse, int, error)

func (*KubernetesClient) InstallWorker

func (k *KubernetesClient) InstallWorker() error

InstallWorker installs the Skyramp worker on the Kubernetes cluster

func (*KubernetesClient) MockerApply

func (k *KubernetesClient) MockerApply(response []*ResponseValue, trafficConfig *types.TrafficConfig) error

MockerApply applies the given mocks to the Kubernetes cluster It takes the response values and traffic configuration as parameters. It returns an error if the mock fails to apply.

func (*KubernetesClient) SetWorkerImage

func (k *KubernetesClient) SetWorkerImage(image, tag string)

SetWorkerImage used for using custom worker image

func (*KubernetesClient) TestStatus

func (k *KubernetesClient) TestStatus() *types.TestStatusResponse

TestStatus returns the status of the tests on the Kubernetes cluster It returns the status of the tests.

func (*KubernetesClient) TesterStart

func (k *KubernetesClient) TesterStart(
	scenario []*Scenario,
	testName string,
	globalVars map[string]interface{},
	globalHeaders map[string]string,
) (*types.TestStatusResponse, error)

TesterStart starts the tests on the Kubernetes cluster It takes the scenario, test name, global variables, and global headers as parameters. It returns an error if the tests fail to start.

func (*KubernetesClient) UninstallWorker

func (k *KubernetesClient) UninstallWorker() error

UninstallWorker uninstalls the Skyramp worker from the Kubernetes cluster

type Request

type Request struct {
	*types.TestRequest
	EndpointDescription *types.EndpointDescription
}

func NewRequest

func NewRequest(name string, endpointDesc *types.EndpointDescription, methodName, blob string) *Request

func (*Request) SetCookies

func (r *Request) SetCookies(cookies map[string]string)

func (*Request) SetHeader

func (r *Request) SetHeader(header map[string]string)

func (*Request) SetJSFunction

func (r *Request) SetJSFunction(jsFunction, jsPath string) error

func (*Request) SetParams

func (r *Request) SetParams(params []*types.RestParam)

func (*Request) SetPythonFunction

func (r *Request) SetPythonFunction(pythonFunction, pythonPath string) error

func (*Request) SetVars

func (r *Request) SetVars(vars map[string]interface{})

type ResponseValue

type ResponseValue struct {
	*types.Response
	TrafficConfig       *types.TrafficConfig
	EndpointDescription *types.EndpointDescription
}

func NewResponseValue

func NewResponseValue(name string, endpointDesc *types.EndpointDescription, methodName, blob string, trafficConfig *types.TrafficConfig) *ResponseValue

func (*ResponseValue) SetCookies

func (r *ResponseValue) SetCookies(cookies map[string]string)

func (*ResponseValue) SetHeader

func (r *ResponseValue) SetHeader(header map[string]string)

func (*ResponseValue) SetJSFunction

func (r *ResponseValue) SetJSFunction(jsFunction, jsPath string) error

func (*ResponseValue) SetParams

func (r *ResponseValue) SetParams(params []*types.RestParam)

func (*ResponseValue) SetPythonFunction

func (r *ResponseValue) SetPythonFunction(pythonFunction, pythonPath string) error

type Scenario

type Scenario struct {
	TestScenario        *types.TestScenario
	Requests            []*Request
	EndpointDescription *types.EndpointDescription
}

func NewScenario

func NewScenario(name string) *Scenario

func (*Scenario) SetAssertEqual

func (s *Scenario) SetAssertEqual(str1, str2 string)

func (*Scenario) SetRequest

func (s *Scenario) SetRequest(request *Request) *types.TestStep

Jump to

Keyboard shortcuts

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