Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigForEnvConfig(t *testing.T, envcfg *rest.Config) manager.Config
- func CreateNamespace(ctx context.Context, t *testing.T, client ctrlclient.Client) corev1.Namespace
- func CreatePod(ctx context.Context, t *testing.T, client ctrlclient.Client, ns string) corev1.Pod
- func NewControllerClient(t *testing.T, scheme *runtime.Scheme, cfg *rest.Config) ctrlclient.Client
- func RunManager(ctx context.Context, t *testing.T, envcfg *rest.Config, ...) (loggerHook *test.Hook)
- func Scheme(t *testing.T, opts ...SchemeOption) *k8sruntime.Scheme
- func Setup(t *testing.T, scheme *k8sruntime.Scheme, optModifiers ...OptionModifier) *rest.Config
- func StartAdminAPIServerMock(t *testing.T) *httptest.Server
- func StartReconcilers(ctx context.Context, t *testing.T, scheme *runtime.Scheme, cfg *rest.Config, ...)
- func WithGatewayAPI(t *testing.T, s *k8sruntime.Scheme)
- func WithGatewayFeatureEnabled(cfg *manager.Config)
- func WithKong(t *testing.T, s *k8sruntime.Scheme)
- func WithPublishService(namespace string) func(cfg *manager.Config)
- type ModifyManagerConfigFn
- type OptionModifier
- type Options
- type SchemeOption
Constants ¶
const (
// PublishServiceName is the name of the publish service used in Gateway API tests.
PublishServiceName = "publish-svc"
)
Variables ¶
var DefaultEnvTestOpts = Options{ InstallGatewayCRDs: true, InstallKongCRDs: true, }
Functions ¶
func ConfigForEnvConfig ¶ added in v2.10.0
ConfigForEnvConfig prepares a manager.Config for use in tests It will start a mock Admin API server which will be set in KIC's config and which will be automatically stopped during test cleanup.
func CreateNamespace ¶
CreateNamespace creates namespace using the provided client and returns it.
func NewControllerClient ¶ added in v2.10.2
NewControllerClient returns a new controller-runtime Client for provided runtime.Scheme and rest.Config.
func RunManager ¶ added in v2.11.0
func RunManager( ctx context.Context, t *testing.T, envcfg *rest.Config, modifyCfgFns ...func(cfg *manager.Config), ) (loggerHook *test.Hook)
RunManager runs the manager in a goroutine. It's possible to modify the manager's configuration by passing in modifyCfgFns. The manager is stopped when the context is canceled.
func Scheme ¶ added in v2.11.0
func Scheme(t *testing.T, opts ...SchemeOption) *k8sruntime.Scheme
Scheme returns a new scheme with the default Kubernetes types registered. It accepts optional SchemeOptions to register additional types.
func Setup ¶
func Setup(t *testing.T, scheme *k8sruntime.Scheme, optModifiers ...OptionModifier) *rest.Config
Setup sets up the envtest environment which will be stopped on test cleanup using t.Cleanup().
Note: If you want apiserver output on stdout set KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT to true when running tests.
func StartAdminAPIServerMock ¶ added in v2.10.0
StartAdminAPIServerMock starts a mock Kong Admin API server. Server's .Close() method will be called during test's cleanup.
func StartReconcilers ¶ added in v2.11.0
func StartReconcilers(ctx context.Context, t *testing.T, scheme *runtime.Scheme, cfg *rest.Config, reconcilers ...controllers.Reconciler)
StartReconcilers creates a controller manager and starts the provided reconciler as its runnable. It also adds a t.Cleanup which waits for the manager to exit so that the test can be self contained and logs from different tests' managers don't mix up.
func WithGatewayAPI ¶ added in v2.11.0
func WithGatewayAPI(t *testing.T, s *k8sruntime.Scheme)
WithGatewayAPI registers the Gateway API types with the scheme.
func WithGatewayFeatureEnabled ¶ added in v2.11.0
func WithKong ¶ added in v2.11.0
func WithKong(t *testing.T, s *k8sruntime.Scheme)
WithKong registers the Kong types with the scheme.
func WithPublishService ¶ added in v2.11.0
Types ¶
type ModifyManagerConfigFn ¶ added in v2.11.0
type OptionModifier ¶ added in v2.11.0
func WithInstallGatewayCRDs ¶ added in v2.12.0
func WithInstallGatewayCRDs(install bool) OptionModifier
func WithInstallKongCRDs ¶ added in v2.11.0
func WithInstallKongCRDs(install bool) OptionModifier
type SchemeOption ¶ added in v2.11.0
type SchemeOption func(t *testing.T, s *k8sruntime.Scheme)