base

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const TestControllerName = "gate.haproxy.org/hug"
View Source
const (
	TestMapThroughRuntime = false
)

Variables

View Source
var StandardMaps = []string{
	"domain_wildcard_path_exact.map",
	"domain_wildcard_sni.map",
	"path_exact.map",
	"path_prefix.map",
	"path_regex.map",
	"sni.map",
}

Functions

func WriteKubeconfig

func WriteKubeconfig(cfg *rest.Config, rootPath string) (string, error)

WriteKubeconfig writes the given rest.Config to a kubeconfig file. It returns the path to the file and an error if it fails.

Types

type BaseSuite

type BaseSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

func (*BaseSuite) BackendFromManifest

func (b *BaseSuite) BackendFromManifest(manifestPath, manifestName string) *models.Backend

func (*BaseSuite) CheckEntryInMapFile added in v0.8.0

func (b *BaseSuite) CheckEntryInMapFile(mapFileRelativePath, key, value string) bool

func (*BaseSuite) CheckMapContents added in v0.8.0

func (b *BaseSuite) CheckMapContents(mapFileRelativePath, expectedMapPath string) bool

func (*BaseSuite) CheckMapFileContents added in v0.9.0

func (b *BaseSuite) CheckMapFileContents(mapFileRelativePath, expectedMapPath string) bool

func (*BaseSuite) CheckRuntimeMapContents added in v0.9.0

func (b *BaseSuite) CheckRuntimeMapContents(mapFileRelativePath, expectedMapPath string) bool

func (*BaseSuite) CleanupFixtures

func (b *BaseSuite) CleanupFixtures(fixturePath string, manifestNames []string)

func (*BaseSuite) CleanupFixturesCheckMapFiles added in v0.9.0

func (b *BaseSuite) CleanupFixturesCheckMapFiles(fixturePath string, manifestNames []string, mapFileRelativePaths []string)

CleanupFixturesCheckMapFiles is similar to CleanupFixtures, but it takes an additional argument mapFileRelativePath, which is the path to the map file that should be cleaned up. This is useful for tests that create a map file and then need to clean it up after the test has finished.

Note that CleanupFixturesCheckMapFiles will wait until the map file is empty before returning. This is to ensure that the test does not finish before the cleanup has finished.

func (*BaseSuite) CleanupFixturesInNamespace

func (b *BaseSuite) CleanupFixturesInNamespace(fixturePath, namespace string, manifestNames []string)

func (*BaseSuite) ConsistentlyNoReload added in v0.9.0

func (b *BaseSuite) ConsistentlyNoReload(oldPid string, duration time.Duration)

ConsistentlyNoReload executes a check repeatedly for a duration. It t.Fatalf() if the condition ever returns false.

func (*BaseSuite) CreateFixtures

func (b *BaseSuite) CreateFixtures(fixturePath string, manifestNames []string)

CreateFixtures will create all the objects from manifests that are in the fixturePath directory They are created in the test namespace To create in a specific namespace use CreateFixturesInNamespace If manifestNames is empty, it will create all objects that are in the directory If manifestNames, it will create only the objects in manifestNames (a sublist of the files in fixturePath)

func (*BaseSuite) CreateFixturesInNamespace

func (b *BaseSuite) CreateFixturesInNamespace(fixturePath, namespace string, manifestNames []string)

func (*BaseSuite) ExpectAttachedRoute added in v0.9.0

func (b *BaseSuite) ExpectAttachedRoute(ctx context.Context, namespace, gwName, listenerName string, expectNbAttachedRoutes int32)

func (*BaseSuite) ExpectBackends

func (b *BaseSuite) ExpectBackends(ctx context.Context, expectationPath string, expectedBackends []string)

func (*BaseSuite) ExpectBackendsDoNotExist

func (b *BaseSuite) ExpectBackendsDoNotExist(ctx context.Context, backendThatShouldNotExist string)

func (*BaseSuite) ExpectCertificates

func (b *BaseSuite) ExpectCertificates(ctx context.Context, expectedCerts []*models.SslCertificate)

For now: only checks the following certificate fields: - StorageName - Subject (for CN) Check is performed using the RUNTIME command on haproxy

func (*BaseSuite) ExpectCrtLists

func (b *BaseSuite) ExpectCrtLists(ctx context.Context, expectedCrtLists map[futils.FilePath][]string)

ExpectCrtLists checks that the crt-list are the expectedCrtLists For now, there is no CN method to get the content of the crt-list : "show ssl crt-list <filename>" The only existing method in CN is "show ssl crt-list" that gives the list of crt-lists So, for now, we check the content of the crt-list from the crt-list file, not from the RUNTIME.

func (*BaseSuite) ExpectFrontends

func (b *BaseSuite) ExpectFrontends(ctx context.Context, expectationPath string, expectedFrontends []string)

func (*BaseSuite) ExpectMapContents added in v0.9.0

func (b *BaseSuite) ExpectMapContents(mapFilePath, expectedMapPath string)

func (*BaseSuite) ExpectRouteConditionsUpdated added in v0.9.0

func (b *BaseSuite) ExpectRouteConditionsUpdated(ctx context.Context, namespace, name string, expectedConditions rc.RouteConditions)

func (*BaseSuite) ExpectServers added in v0.9.0

func (b *BaseSuite) ExpectServers(backend string, expectedServers []string)

func (*BaseSuite) FrontendFromManifest

func (b *BaseSuite) FrontendFromManifest(manifestPath, manifestName string) *models.Frontend

func (*BaseSuite) GetMapFileFrom added in v0.8.0

func (b *BaseSuite) GetMapFileFrom(mapFileRelativePath string) ([]string, error)

func (*BaseSuite) SetupSuite

func (b *BaseSuite) SetupSuite(crdRelativePath string, levelsUp int)

func (*BaseSuite) TearDownSuite

func (b *BaseSuite) TearDownSuite()

func (*BaseSuite) Test

func (b *BaseSuite) Test() IntTest

func (*BaseSuite) WaitForNoReloadsAnyMore added in v0.9.0

func (b *BaseSuite) WaitForNoReloadsAnyMore(
	overAllDuration time.Duration,
	consistentlyDurationWithoutReloads time.Duration,
) string

WaitForNoReloadsAnyMore checks during an overall overAllDuration That we reach a stable state without reloads for at least consistentlyDurationWithoutReloads We set a timer stabilityTimer and if at any point during the stability window a reload occurs, we reset this timer. If we reach the overAllDuration without a stable window without reload we issue a t.Fatalf()

func (*BaseSuite) YamlToConditions

func (b *BaseSuite) YamlToConditions(yamlPath string) conditions.Conditions

func (*BaseSuite) YamlToListenerStatuses

func (b *BaseSuite) YamlToListenerStatuses(yamlPath string) []gatewayv1.ListenerStatus

func (*BaseSuite) YamlToRouteConditions

func (b *BaseSuite) YamlToRouteConditions(yamlPath string) rc.RouteConditions

type IntTest

type IntTest struct {
	Ctx           context.Context
	Client        ctrlruntimeclient.Client
	RuntimeClient runtime.Runtime
	HaproxyClient hapapi.HAProxyClient
	TestEnv       *envtest.Environment

	Namespace         string
	HaproxyCfgDir     string
	RuntimeSocketPath string
	// contains filtered or unexported fields
}

func NewIntTest

func NewIntTest(t *testing.T, crdRelativePath string, levelsUp int) (test IntTest, err error)

func (*IntTest) StartTestEnv

func (test *IntTest) StartTestEnv(t *testing.T)

func (*IntTest) StopTestEnv

func (test *IntTest) StopTestEnv(t *testing.T)

Jump to

Keyboard shortcuts

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