Documentation ¶
Index ¶
- Constants
- type TestContext
- func (c *TestContext) AfterEach()
- func (c *TestContext) BeforeEach()
- func (c *TestContext) Ctx() context.Context
- func (c *TestContext) EnvoyInstance() *services.EnvoyInstance
- func (c *TestContext) JustAfterEach()
- func (c *TestContext) JustBeforeEach()
- func (c *TestContext) PatchDefaultGateway(mutator func(vs *v1.Gateway) *v1.Gateway)
- func (c *TestContext) PatchDefaultVirtualService(mutator func(vs *v1.VirtualService) *v1.VirtualService)
- func (c *TestContext) ReadDefaultProxy() (*gloov1.Proxy, error)
- func (c *TestContext) ResourcesToCreate() *gloosnapshot.ApiSnapshot
- func (c *TestContext) SetRunServices(services services.What)
- func (c *TestContext) SetRunSettings(settings *gloov1.Settings)
- func (c *TestContext) TestClients() services.TestClients
- func (c *TestContext) TestUpstream() *v1helpers.TestUpstream
- type TestContextFactory
Constants ¶
const ( // DefaultHost defines the Host header that should be used to route traffic to the // default VirtualService that the TestContext creates // To make our tests more explicit we define VirtualServices with an explicit set // of domains (which match the `Host` header of a request), and DefaultHost // is the domain we use by default DefaultHost = "test.com" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TestContext ¶
type TestContext struct {
// contains filtered or unexported fields
}
TestContext represents the aggregate set of configuration needed to run a single e2e test It is intended to remove some boilerplate setup/teardown of tests out of the test themselves to ensure that tests are easier to read and maintain since they only contain the resource changes that we are validating
func (*TestContext) AfterEach ¶
func (c *TestContext) AfterEach()
func (*TestContext) BeforeEach ¶
func (c *TestContext) BeforeEach()
func (*TestContext) Ctx ¶
func (c *TestContext) Ctx() context.Context
Ctx returns the Context maintained by the TestContext The Context is cancelled during the AfterEach portion of tests
func (*TestContext) EnvoyInstance ¶
func (c *TestContext) EnvoyInstance() *services.EnvoyInstance
EnvoyInstance returns the wrapper for the running instance of Envoy that this test is using It contains utility methods to easily inspect the live configuration and statistics for the instance
func (*TestContext) JustAfterEach ¶
func (c *TestContext) JustAfterEach()
func (*TestContext) JustBeforeEach ¶
func (c *TestContext) JustBeforeEach()
func (*TestContext) PatchDefaultGateway ¶
func (c *TestContext) PatchDefaultGateway(mutator func(vs *v1.Gateway) *v1.Gateway)
PatchDefaultGateway mutates the existing Gateway generated by the TestContext
func (*TestContext) PatchDefaultVirtualService ¶
func (c *TestContext) PatchDefaultVirtualService(mutator func(vs *v1.VirtualService) *v1.VirtualService)
PatchDefaultVirtualService mutates the existing VirtualService generated by the TestContext
func (*TestContext) ReadDefaultProxy ¶
func (c *TestContext) ReadDefaultProxy() (*gloov1.Proxy, error)
ReadDefaultProxy returns the Proxy object that will be generated by the resources in the TestContext
func (*TestContext) ResourcesToCreate ¶
func (c *TestContext) ResourcesToCreate() *gloosnapshot.ApiSnapshot
ResourcesToCreate returns the ApiSnapshot of resources the TestContext maintains This snapshot is what is written to storage during the JustBeforeEach portion We return a reference to the object, so that individual tests can modify the snapshot before we write it to storage
func (*TestContext) SetRunServices ¶
func (c *TestContext) SetRunServices(services services.What)
SetRunServices can be used to modify the services (gloo, fds, uds) which will run for a test This should be called after the TestContext.BeforeEach (when the default services are applied) and before the TestContext.JustBeforeEach (when the services are run)
func (*TestContext) SetRunSettings ¶
func (c *TestContext) SetRunSettings(settings *gloov1.Settings)
SetRunSettings can be used to modify the runtime Settings object for a test This should be called after the TestContext.BeforeEach (when the default settings are applied) and before the TestContext.JustBeforeEach (when the settings are consumed)
func (*TestContext) TestClients ¶
func (c *TestContext) TestClients() services.TestClients
TestClients returns the set of resource clients that can be used to perform CRUD operations on resources used by these tests Instead of using the resource clients directly, we recommend placing resources on the ResourcesToCreate object, and letting the TestContext handle the lifecycle of those objects
func (*TestContext) TestUpstream ¶
func (c *TestContext) TestUpstream() *v1helpers.TestUpstream
TestUpstream returns the TestUpstream object that the TestContext built A TestUpstream is used to run an echo server and define the Gloo Upstream object to route to it
type TestContextFactory ¶
type TestContextFactory struct {
EnvoyFactory *services.EnvoyFactory
}
func (*TestContextFactory) NewTestContext ¶
func (f *TestContextFactory) NewTestContext(testRequirements ...helpers.Requirement) *TestContext