testhelpers

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectedKeys

func ExpectedKeys(m map[string]IPSetExpectation) []string

ExpectedKeys returns the sorted keys of an expectation map.

func LoadNetworkPolicyList

func LoadNetworkPolicyList(t *testing.T, path string) *networkingv1.NetworkPolicyList

LoadNetworkPolicyList reads a NetworkPolicyList fixture.

func LoadNodeList

func LoadNodeList(t *testing.T, path string) *v1.NodeList

LoadNodeList reads a NodeList fixture.

func LoadPodList

func LoadPodList(t *testing.T, path string) *v1.PodList

LoadPodList reads a PodList fixture.

func LoadServiceList

func LoadServiceList(t *testing.T, path string) *v1.ServiceList

LoadServiceList reads a ServiceList fixture.

func MergeExpectations

func MergeExpectations(maps ...map[string]IPSetExpectation) map[string]IPSetExpectation

MergeExpectations merges multiple expectation maps.

func NormalizeSnapshotEntry

func NormalizeSnapshotEntry(entry string) string

NormalizeSnapshotEntry normalizes entries for stable comparisons.

func ParseRestoreScript

func ParseRestoreScript(script string) map[string]IPSetExpectation

ParseRestoreScript parses an ipset restore script into expectations.

func ParseSnapshot

func ParseSnapshot(t *testing.T, path string) map[string]IPSetExpectation

ParseSnapshot parses an ipset save snapshot focusing on kube-router managed sets.

func ParseSnapshotWithFilter

func ParseSnapshotWithFilter(t *testing.T, path string, includeFn func(string) bool) map[string]IPSetExpectation

ParseSnapshotWithFilter parses an ipset snapshot and retains set names that satisfy includeFn.

Types

type FakeIPSetHandler

type FakeIPSetHandler struct {
	// contains filtered or unexported fields
}

FakeIPSetHandler captures ipset operations for tests.

func NewFakeIPSetHandler

func NewFakeIPSetHandler(isIPv6 bool) *FakeIPSetHandler

NewFakeIPSetHandler returns a fake utils.IPSetHandler for the requested IP family.

func (*FakeIPSetHandler) Add

func (h *FakeIPSetHandler) Add(_ *utils.Set) error

Add is part of the utils.IPSetHandler interface.

func (*FakeIPSetHandler) Create

func (h *FakeIPSetHandler) Create(setName string, createOptions ...string) (*utils.Set, error)

Create records the set options.

func (*FakeIPSetHandler) Destroy

func (h *FakeIPSetHandler) Destroy(setName string) error

Destroy removes the set.

func (*FakeIPSetHandler) DestroyAllWithin

func (h *FakeIPSetHandler) DestroyAllWithin() error

DestroyAllWithin resets tracked sets.

func (*FakeIPSetHandler) Flush

func (h *FakeIPSetHandler) Flush() error

Flush is a no-op for the fake handler.

func (*FakeIPSetHandler) Get

func (h *FakeIPSetHandler) Get(setName string) *utils.Set

Get returns metadata for a tracked set.

func (*FakeIPSetHandler) Name

func (h *FakeIPSetHandler) Name(name string) string

Name normalizes a set name for the family.

func (*FakeIPSetHandler) RefreshSet

func (h *FakeIPSetHandler) RefreshSet(setName string, entriesWithOptions [][]string, setType string)

RefreshSet records entries for the given set.

func (*FakeIPSetHandler) Restore

func (h *FakeIPSetHandler) Restore() error

Restore builds and records the restore script.

func (*FakeIPSetHandler) RestoreSets

func (h *FakeIPSetHandler) RestoreSets(names []string) error

RestoreSets builds and records the restore script for the provided sets.

func (*FakeIPSetHandler) Restored

func (h *FakeIPSetHandler) Restored() string

Restored returns the last restore script that was generated.

func (*FakeIPSetHandler) Save

func (h *FakeIPSetHandler) Save() error

Save is a no-op for the fake handler.

func (*FakeIPSetHandler) Sets

func (h *FakeIPSetHandler) Sets() map[string]*utils.Set

Sets returns all tracked sets.

func (*FakeIPSetHandler) Snapshot

func (h *FakeIPSetHandler) Snapshot() map[string]IPSetExpectation

Snapshot returns a normalized set expectation map useful for assertions.

type IPSetExpectation

type IPSetExpectation struct {
	SetType string
	Entries []string
}

IPSetExpectation captures a set type and sorted entries for comparisons.

Jump to

Keyboard shortcuts

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