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) EventuallyProxyAccepted()
- func (c *TestContext) GetHttpRequestBuilder() *testutils.HttpRequestBuilder
- func (c *TestContext) GetHttpsRequestBuilder() *testutils.HttpRequestBuilder
- func (c *TestContext) JustAfterEach()
- func (c *TestContext) JustBeforeEach()
- func (c *TestContext) PatchDefaultGateway(mutator func(gw *v1.Gateway) *v1.Gateway)
- func (c *TestContext) PatchDefaultUpstream(mutator func(us *gloov1.Upstream) *gloov1.Upstream)
- 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) SetUpstreamGenerator(generator func(ctx context.Context, addr string) *v1helpers.TestUpstream)
- func (c *TestContext) TestClients() services.TestClients
- func (c *TestContext) TestUpstream() *v1helpers.TestUpstream
- type TestContextFactory
- func (f *TestContextFactory) NewTestContext(testRequirements ...testutils.Requirement) *TestContext
- func (f *TestContextFactory) NewTestContextWithConsul(testRequirements ...testutils.Requirement) *TestContextWithConsul
- func (f *TestContextFactory) NewTestContextWithVault(testRequirements ...testutils.Requirement) *TestContextWithVault
- type TestContextWithConsul
- type TestContextWithVault
Constants ¶
const ( WriteNamespace = defaults.GlooSystem DefaultVirtualServiceName = "vs-test" DefaultRouteName = "route-test" DefaultGatewayName = gatewaydefaults.GatewayProxyName DefaultProxyName = gatewaydefaults.GatewayProxyName // 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) EventuallyProxyAccepted ¶
func (c *TestContext) EventuallyProxyAccepted()
For tests that rely on changing an existing configuration.
func (*TestContext) GetHttpRequestBuilder ¶
func (c *TestContext) GetHttpRequestBuilder() *testutils.HttpRequestBuilder
GetHttpRequestBuilder returns an HttpRequestBuilder to easily build http requests used in e2e tests
func (*TestContext) GetHttpsRequestBuilder ¶
func (c *TestContext) GetHttpsRequestBuilder() *testutils.HttpRequestBuilder
GetHttpsRequestBuilder returns an HttpRequestBuilder to easily build https requests used in e2e tests
func (*TestContext) JustAfterEach ¶
func (c *TestContext) JustAfterEach()
func (*TestContext) JustBeforeEach ¶
func (c *TestContext) JustBeforeEach()
func (*TestContext) PatchDefaultGateway ¶
func (c *TestContext) PatchDefaultGateway(mutator func(gw *v1.Gateway) *v1.Gateway)
PatchDefaultGateway mutates the existing Gateway generated by the TestContext
func (*TestContext) PatchDefaultUpstream ¶
func (c *TestContext) PatchDefaultUpstream(mutator func(us *gloov1.Upstream) *gloov1.Upstream)
PatchDefaultUpstream mutates the existing Upstream 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) SetUpstreamGenerator ¶
func (c *TestContext) SetUpstreamGenerator(generator func(ctx context.Context, addr string) *v1helpers.TestUpstream)
SetUpstreamGenerator Use a different function to create a test upstream call before testContext.BeforeEach() Used for example with helpers.NewTestGrpcUpstream which has the side effect of also starting a grpc service
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 VaultFactory *services.VaultFactory ConsulFactory *services.ConsulFactory }
func (*TestContextFactory) NewTestContext ¶
func (f *TestContextFactory) NewTestContext(testRequirements ...testutils.Requirement) *TestContext
func (*TestContextFactory) NewTestContextWithConsul ¶
func (f *TestContextFactory) NewTestContextWithConsul(testRequirements ...testutils.Requirement) *TestContextWithConsul
func (*TestContextFactory) NewTestContextWithVault ¶
func (f *TestContextFactory) NewTestContextWithVault(testRequirements ...testutils.Requirement) *TestContextWithVault
type TestContextWithConsul ¶
type TestContextWithConsul struct { *TestContext // contains filtered or unexported fields }
TestContextWithConsul represents the aggregate set of configuration needed to run a single e2e test using Consul as a service registry to route traffic to. This is used rarely in tests, so we intentionally try to separate the consul logic from the core TestContext to avoid adding complexity
func (*TestContextWithConsul) ConsulInstance ¶
func (c *TestContextWithConsul) ConsulInstance() *services.ConsulInstance
ConsulInstance returns the wrapper for the running instance of Vault that this test is using
func (*TestContextWithConsul) RunConsul ¶
func (c *TestContextWithConsul) RunConsul()
RunConsul starts running the ConsulInstance and blocks until it has successfully started
type TestContextWithVault ¶
type TestContextWithVault struct { *TestContext // contains filtered or unexported fields }
TestContextWithVault represents the aggregate set of configuration needed to run a single e2e test using Vault as a secret store. This is used rarely in tests, so we intentionally try to separate the vault logic from the core TestContext to avoid adding complexity
func (*TestContextWithVault) RunVault ¶
func (v *TestContextWithVault) RunVault()
RunVault starts running the VaultInstance and blocks until it has successfully started
func (*TestContextWithVault) VaultInstance ¶
func (v *TestContextWithVault) VaultInstance() *services.VaultInstance
VaultInstance returns the wrapper for the running instance of Vault that this test is using