Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetNSManager ¶
type NetNSManager struct {
// contains filtered or unexported fields
}
func NewNSManager ¶
func NewNSManager(t testing.TB) (*NetNSManager, error)
NewNSManager creates a new uninitialized NetNSManager.
func (*NetNSManager) Commands ¶
func (nsm *NetNSManager) Commands() map[string]script.Cmd
Commands provides a set of script commands for managing network namespaces, links, addresses, and routes. These are designed to be used in test scripts to create ephemeral network namespaces to perform tests.
func (*NetNSManager) LockThreadAndInitialize ¶
func (nsm *NetNSManager) LockThreadAndInitialize(t testing.TB, isolated bool) error
LockThreadAndInitialize locks the current thread to the OS thread and initializes the NetNSManager. It also registers a cleanup function, unlocking the thread on test completion, switching to the original network namespace, and closing all test namespaces.
The `isolated` parameter determines whether to start in the current network namespace or to completely isolate the test environment by starting in a new network namespace. Non-isolated mode allows a script to setup a link to the host network namespace but risks a mistake in a script corrupting the host network namespace.