testutil

package
v1.9.10-e6932adad8179d... Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 58 Imported by: 2

Documentation

Index

Constants

View Source
const TestPGDump = `` /* 1232-byte string literal not displayed */

TestPGDump is a simple example pgdump file for a table containing a few cars

View Source
const TestPGDumpNewHeader = `` /* 1024-byte string literal not displayed */

TestPGDumpNewHeader has no rows, but has a new header

View Source
const TestPGDumpNewRows = `` /* 1219-byte string literal not displayed */

TestPGDumpNewRows is the same as TestPGDump, except that it has two new rows

Variables

This section is empty.

Functions

func AuthenticateWithSAMLResponse added in v1.7.11

func AuthenticateWithSAMLResponse(t testing.TB, c *client.APIClient, samlResponse []byte)

AuthenticateWithSAMLResponse sends 'response' to Pachd's ACS, extracts the OTP from the response, converts it to a Pachyderm token, and automatically assigns it to the client 'c'

func BashCmd added in v1.6.4

func BashCmd(cmd string, subs ...string) *exec.Cmd

BashCmd is a convenience function that: 1. Performs a Go template substitution on 'cmd' using the strings in 'subs' 2. Returns a command that runs the result string from 1 as a Bash script

func Cmd added in v1.6.4

func Cmd(name string, args ...string) *exec.Cmd

Cmd is a convenience function that replaces exec.Command. It's both shorter and it uses the current process's stderr as output for the command, which makes debugging failures much easier (i.e. you get an error message rather than "exit status 1")

func DeletePachdPod added in v1.7.14

func DeletePachdPod(t testing.TB)

DeletePachdPod deletes the pachd pod in a test cluster (restarting it, e.g. to retart the PPS master)

func DeletePipelineRC added in v1.7.14

func DeletePipelineRC(t testing.TB, pipeline string)

DeletePipelineRC deletes the RC belonging to the pipeline 'pipeline'. This can be used to test PPS's robustness

func GetACSAddress added in v1.7.11

func GetACSAddress(t testing.TB, pachdAddress string) string

GetACSAddress takes a pachd address, assumed to be of the form

(host):(650|30650)

and converts it to

(host):(654|30654)

and returns that

func GetKubeClient added in v1.7.11

func GetKubeClient(t testing.TB) *kube.Clientset

GetKubeClient connects to the Kubernetes API server either from inside the cluster or from a test binary running on a machine with kubectl (it will connect to the same cluster as kubectl)

func GetTestEnterpriseCode

func GetTestEnterpriseCode() string

GetTestEnterpriseCode gets a Pachyderm Enterprise activation code from a private S3 bucket, and provides it to tests that use Pachyderm Enterprise features

func MustMarshalEl added in v1.7.11

func MustMarshalEl(t testing.TB, el *etree.Element) []byte

MustMarshalEl marshals 'el' to []byte, or fails the current test

func MustMarshalXML added in v1.7.11

func MustMarshalXML(t testing.TB, m xml.Marshaler) []byte

MustMarshalXML marshals 'm' to []byte, or fails the current test

func MustParseURL added in v1.7.11

func MustParseURL(t testing.TB, u string) *url.URL

MustParseURL marshals 'u' to a *url.URL, or fails the current test

func PrettyPrintEl added in v1.7.11

func PrettyPrintEl(t testing.TB, el *etree.Element) string

PrettyPrintEl returns 'el' indented and marshalled to a string

func UniquePort added in v1.8.3

func UniquePort() uint16

UniquePort generates a likely unique port, so that multiple servers can run concurrently. Note that it does not actually check that the port is free, but uses atomics and a fairly highly port range to maximize the likelihood that the port is available.

func UniqueString added in v1.6.4

func UniqueString(prefix string) string

UniqueString adds a UUID suffix to 'prefix'. This helps avoid name conflicts between tests that share the same Pachyderm cluster

func WithEtcdEnv added in v1.9.10

func WithEtcdEnv(cb func(*EtcdEnv) error) (err error)

WithEtcdEnv constructs a default EtcdEnv for testing during the lifetime of the callback.

func WithMockEnv added in v1.9.10

func WithMockEnv(cb func(*MockEnv) error) error

WithMockEnv sets up a MockEnv structure, passes it to the provided callback, then cleans up everything in the environment, regardless of if an assertion fails.

func WithRealEnv added in v1.9.10

func WithRealEnv(cb func(*RealEnv) error) error

WithRealEnv constructs a MockEnv, then forwards all API calls to go to API server instances for supported operations. PPS requires a kubernetes environment in order to spin up pipelines, which is not yet supported by this package, but the other API servers work.

Types

type EtcdEnv added in v1.9.10

type EtcdEnv struct {
	Context    context.Context
	Directory  string
	Etcd       *embed.Etcd
	EtcdClient *etcd.Client
}

EtcdEnv contains the basic setup for running end-to-end pachyderm tests entirely locally within the test process. It provides a temporary directory for storing data, and an embedded etcd server with a connected client.

type MockEnv added in v1.9.10

type MockEnv struct {
	EtcdEnv
	MockPachd  *MockPachd
	PachClient *client.APIClient
}

MockEnv contains the basic setup for running end-to-end pachyderm tests entirely locally within the test process. It provides a temporary directory for storing data, an embedded etcd server with a connected client, as well as a local mock pachd instance which allows a test to hook into any pachd calls.

type MockPachd added in v1.9.9

type MockPachd struct {
	Addr net.Addr

	Object      mockObjectServer
	PFS         mockPFSServer
	PPS         mockPPSServer
	Auth        mockAuthServer
	Transaction mockTransactionServer
	Enterprise  mockEnterpriseServer
	Version     mockVersionServer
	Admin       mockAdminServer
	// contains filtered or unexported fields
}

MockPachd provides an interface for running the interface for a Pachd API server locally without any of its dependencies. Tests may mock out specific API calls by providing a handler function, and later check information about the mocked calls.

func NewMockPachd added in v1.9.9

func NewMockPachd(ctx context.Context) (*MockPachd, error)

NewMockPachd constructs a mock Pachd API server whose behavior can be controlled through the MockPachd instance. By default, all API calls will error, unless a handler is specified.

func (*MockPachd) Close added in v1.9.9

func (mock *MockPachd) Close() error

Close will cancel the mock Pachd API server goroutine and return its result

func (*MockPachd) Err added in v1.9.10

func (mock *MockPachd) Err() <-chan error

Err returns a read-only channel that will receive the first error that occurs in the server group (stopping all the servers).

type MockServiceProviderProvider added in v1.7.11

type MockServiceProviderProvider func(*http.Request, string) (*saml.EntityDescriptor, error)

MockServiceProviderProvider gives tests the opportunity to inject their own SAML service provider metadata into an ID provider

func ConstServiceProviderProvider added in v1.7.11

func ConstServiceProviderProvider(md *saml.EntityDescriptor) MockServiceProviderProvider

ConstServiceProviderProvider returns a ServiceProviderProvider that always returns 'md'

func (MockServiceProviderProvider) GetServiceProvider added in v1.7.11

func (f MockServiceProviderProvider) GetServiceProvider(r *http.Request, serviceProviderID string) (*saml.EntityDescriptor, error)

GetServiceProvider implements the corresponding method in the ServiceProviderProvider interface for MockServiceProviderProvider

type RealEnv added in v1.9.10

type RealEnv struct {
	MockEnv

	AuthServer        authserver.APIServer
	PFSBlockServer    pfsserver.BlockAPIServer
	PFSServer         pfsserver.APIServer
	TransactionServer txnserver.APIServer
	// contains filtered or unexported fields
}

RealEnv contains a setup for running end-to-end pachyderm tests locally. It includes the base MockEnv struct as well as a real instance of the API server. These calls can still be mocked, but they default to calling into the real server endpoints.

type TestIDP added in v1.7.11

type TestIDP struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TestIDP is a simple SAML ID provider for testing. It can generate SAML metadata (for configs) or SAMLResponses containing signed auth assertions and group memberships (for authentication)

func NewTestIDP added in v1.7.11

func NewTestIDP(t testing.TB, pachdACSURL, pachdMetadataURL string) *TestIDP

NewTestIDP generates a new x509 cert and new test SAML ID provider

func (*TestIDP) Metadata added in v1.7.11

func (t *TestIDP) Metadata() []byte

Metadata returns serialized IDP metadata for 't'

func (*TestIDP) NewSAMLResponse added in v1.7.11

func (t *TestIDP) NewSAMLResponse(subject string, groups ...string) []byte

NewSAMLResponse generates a new signed SAMLResponse asserting that the bearer is 'subject' and is a member of the groups in 'groups'

Jump to

Keyboard shortcuts

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