Documentation
¶
Index ¶
- Constants
- func AssertCertificateIsValid(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string)
- func AssertCertificateValidity(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string, ...)
- func AssertCertificateValidityWithOptions(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string, ...)
- func AssertConnectionBlocked(t testing.TB, r *require.Assertions, client *Client, ip string, port int, ...)
- func AssertConnectionBlockedWithTimeout(t testing.TB, r *require.Assertions, client *Client, ip string, port int, ...)
- func AssertConnectionSucceeds(t testing.TB, r *require.Assertions, client *Client, ip string, port int, ...)
- func AssertDNSResolution(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, ...)
- func AssertDNSResolutionFails(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, ...)
- func AssertEventuallyConnects(t testing.TB, r *require.Assertions, client *Client, ip string, port int, ...)
- func AssertEventuallyConnectsWithTimeout(t testing.TB, r *require.Assertions, client *Client, ip string, port int, ...)
- func AssertEventuallyDNSResolves(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, ...)
- func AssertEventuallyFileExists(t testing.TB, r *require.Assertions, path string, msgAndArgs ...interface{})
- func AssertFileExists(t testing.TB, r *require.Assertions, path string, msgAndArgs ...interface{})
- func AssertFilePermissions(t testing.TB, r *require.Assertions, path string, expectedMode os.FileMode, ...)
- func AssertHTTPBodyContains(t testing.TB, a *assert.Assertions, resp *HTTPResponse, expected string, ...)
- func AssertHTTPStatus(t testing.TB, r *require.Assertions, resp *HTTPResponse, expectedStatus int, ...)
- func CheckHealthEndpoint(ip string, port int) (int, error)
- func CheckNodeHealth(testNet *TestNetwork) bool
- func CleanupStaleBPFMaps()
- func ExecInNS(ns netns.NsHandle, fn func() error) error
- func GetAllGCPNodeIPs(ctx context.Context, projectID, zone, clusterName string) ([]string, error)
- func GetAllGCPNodeNames(ctx context.Context, projectID, zone, clusterName string) ([]string, error)
- func GetCertificateSerial(t testing.TB, r *require.Assertions, certPath string) string
- func GetGCPBackendHealth(ctx context.Context, projectID, region, backendServiceName string) ([]string, error)
- func GetGCPInstanceNameByIP(ctx context.Context, projectID, zone, ip string) (string, error)
- func GetGCPManagementIP(ctx context.Context, projectID, zone, instanceName string) (string, error)
- func PolicyFixture(name string) string
- func StartNeuwerkWithClient(t testing.TB, tn *TestNetwork, policyFile string) (*NeuwerkInstance, *Client)
- func StartNeuwerkWithClientAndOptions(t testing.TB, tn *TestNetwork, opts NeuwerkOptions) (*NeuwerkInstance, *Client)
- func TestPublicKeyFile() string
- func WaitForGCPBackendHealthy(ctx context.Context, projectID, region, backendServiceName string, ...) error
- type AzureClient
- func (c *AzureClient) ExecuteRemoteCommand(ctx context.Context, vmName, command string) (string, error)
- func (c *AzureClient) GetAzureVMIPs(ctx context.Context, clusterName string) ([]string, error)
- func (c *AzureClient) GetAzureVMNames(ctx context.Context, clusterName string) ([]string, error)
- func (c *AzureClient) GetGWLBBackendHealth(ctx context.Context, lbName, backendPoolName string) (map[string]string, error)
- func (c *AzureClient) GetNodeStatsViaRunCommand(ctx context.Context, vmName, rootToken string) (map[string]interface{}, error)
- func (c *AzureClient) GetVMByName(ctx context.Context, vmName string) (*armcompute.VirtualMachine, error)
- func (c *AzureClient) StopVM(ctx context.Context, vmName string) error
- func (c *AzureClient) WaitForGWLBHealthy(ctx context.Context, lbName, backendPoolName string, timeout time.Duration) error
- func (c *AzureClient) WaitForVMRunning(ctx context.Context, vmName string, timeout time.Duration) error
- type CertificateValidityOptions
- type Client
- func (c *Client) Connect(addr string) error
- func (c *Client) ConnectWithTimeout(addr string, timeout time.Duration) error
- func (c *Client) GetIP() net.IP
- func (c *Client) HTTPDelete(url string) (*HTTPResponse, error)
- func (c *Client) HTTPGet(url string) (*HTTPResponse, error)
- func (c *Client) HTTPPost(url, contentType string, body []byte) (*HTTPResponse, error)
- func (c *Client) HTTPPut(url, contentType string, body []byte) (*HTTPResponse, error)
- func (c *Client) Ping(ip string) error
- func (c *Client) ResolveDNS(hostname string) error
- func (c *Client) ResolveDNSWithServer(hostname, dnsServer string) error
- func (c *Client) SSEConnect(url string) (*SSEConnection, *HTTPResponse, error)
- func (c *Client) SetAuthToken(token string)
- func (c *Client) TriggerReconcile(apiBaseURL string) error
- type DNSRecords
- type GCPDiscoveryOutput
- type GENEVEClient
- type HTTPResponse
- type MockDNSServer
- func NewMockDNSServer(ip string, port int) *MockDNSServer
- func NewMockDNSServerInNS(ns netns.NsHandle, ip string, port int) *MockDNSServer
- func StartMockDNS(t testing.TB, tn *TestNetwork, records DNSRecords) *MockDNSServer
- func StartMockDNSMultiNode(t testing.TB, tn *TestNetwork, records DNSRecords) *MockDNSServer
- type MockHTTPServer
- type NeuwerkInstance
- func StartNeuwerk(t interface{ ... }, testNet *TestNetwork, policyFileOrOpts interface{}) (*NeuwerkInstance, error)
- func StartNeuwerkHA(t interface{ ... }, testNet *TestNetwork, policyFile string, peers []string, ...) (*NeuwerkInstance, error)
- func StartNeuwerkVXLAN(t interface{ ... }, testNet *TestNetwork, policyFile string, peers []string, ...) (*NeuwerkInstance, error)
- func (ni *NeuwerkInstance) GetBpffsPath() string
- func (ni *NeuwerkInstance) GetRootToken() string
- func (ni *NeuwerkInstance) GetStorageDir() string
- func (ni *NeuwerkInstance) IsRunning() bool
- func (ni *NeuwerkInstance) Stop() error
- func (ni *NeuwerkInstance) StopForRestart() error
- func (ni *NeuwerkInstance) WaitForReady(timeout time.Duration) error
- type NeuwerkOptions
- type SSEConnection
- type SSEEvent
- type TestLicenseFiles
- func CreateHALicenseFiles(t interface{ ... }) (*TestLicenseFiles, error)
- func CreateLicenseFilesWithoutHA(t interface{ ... }) (*TestLicenseFiles, error)
- func LoadAllFeaturesLicenseFiles() *TestLicenseFiles
- func LoadExpiredLicenseFiles() *TestLicenseFiles
- func LoadExpiredLongAgoLicenseFiles() *TestLicenseFiles
- func LoadExpiresSoonLicenseFiles() *TestLicenseFiles
- func LoadGracePeriodLicenseFiles() *TestLicenseFiles
- func LoadHALicenseFiles() *TestLicenseFiles
- func LoadKubernetesOnlyLicenseFiles() *TestLicenseFiles
- func LoadNoHALicenseFiles() *TestLicenseFiles
- func LoadSingleNodeLicenseFiles() *TestLicenseFiles
- func LoadThreeNodeLicenseFiles() *TestLicenseFiles
- func LoadTrialLicenseFiles() *TestLicenseFiles
- type TestNetwork
- func (tn *TestNetwork) APIBaseURL() string
- func (tn *TestNetwork) APIBaseURLHTTPS() string
- func (tn *TestNetwork) Cleanup()
- func (tn *TestNetwork) DNSServerAddr() string
- func (tn *TestNetwork) GetClientNS() netns.NsHandle
- func (tn *TestNetwork) GetNeuwerkNS() netns.NsHandle
- func (tn *TestNetwork) GetUpstreamNS() netns.NsHandle
- func (tn *TestNetwork) HealthURL() string
- func (tn *TestNetwork) MetricsURL() string
- func (tn *TestNetwork) NATSAddr() string
- func (tn *TestNetwork) RaftAddr() string
- type VXLANClient
- type VXLANPacket
- type VXLANValidator
Constants ¶
const ( GENEVEPort = 6081 GENEVEVersion = 0 GENEVEProtoEther = 0x6558 // Transparent Ethernet Bridging (inner Ethernet frame) GENEVEProtoIPv4 = 0x0800 // IPv4 inner packet AWSGWLBOptClass = 0x0108 // AWS GWLB option class )
GENEVE protocol constants
const ( DefaultEventuallyTimeout = 15 * time.Second DefaultEventuallyInterval = 500 * time.Millisecond DefaultBlockedTimeout = 2 * time.Second )
Default timeouts for connection assertions
Variables ¶
This section is empty.
Functions ¶
func AssertCertificateIsValid ¶
func AssertCertificateIsValid(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string)
AssertCertificateIsValid asserts basic certificate validity (not expired, not future).
func AssertCertificateValidity ¶
func AssertCertificateValidity(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string, description string)
AssertCertificateValidity asserts that a certificate file is valid with default options.
func AssertCertificateValidityWithOptions ¶
func AssertCertificateValidityWithOptions(t testing.TB, r *require.Assertions, a *assert.Assertions, certPath string, description string, opts CertificateValidityOptions)
AssertCertificateValidityWithOptions asserts that a certificate file is valid with custom options.
func AssertConnectionBlocked ¶
func AssertConnectionBlocked(t testing.TB, r *require.Assertions, client *Client, ip string, port int, msgAndArgs ...interface{})
AssertConnectionBlocked asserts that a connection to ip:port is blocked (times out or errors).
func AssertConnectionBlockedWithTimeout ¶
func AssertConnectionBlockedWithTimeout(t testing.TB, r *require.Assertions, client *Client, ip string, port int, timeout time.Duration, msgAndArgs ...interface{})
AssertConnectionBlockedWithTimeout asserts that a connection is blocked with custom timeout.
func AssertConnectionSucceeds ¶
func AssertConnectionSucceeds(t testing.TB, r *require.Assertions, client *Client, ip string, port int, msgAndArgs ...interface{})
AssertConnectionSucceeds asserts that a connection to ip:port succeeds immediately.
func AssertDNSResolution ¶
func AssertDNSResolution(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, hostname string, msgAndArgs ...interface{})
AssertDNSResolution asserts that DNS resolution succeeds for the given hostname.
func AssertDNSResolutionFails ¶
func AssertDNSResolutionFails(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, hostname string, msgAndArgs ...interface{})
AssertDNSResolutionFails asserts that DNS resolution fails for the given hostname.
func AssertEventuallyConnects ¶
func AssertEventuallyConnects(t testing.TB, r *require.Assertions, client *Client, ip string, port int, msgAndArgs ...interface{})
AssertEventuallyConnects asserts that a connection to ip:port eventually succeeds.
func AssertEventuallyConnectsWithTimeout ¶
func AssertEventuallyConnectsWithTimeout(t testing.TB, r *require.Assertions, client *Client, ip string, port int, timeout, interval time.Duration, msgAndArgs ...interface{})
AssertEventuallyConnectsWithTimeout asserts that a connection eventually succeeds with custom timeout.
func AssertEventuallyDNSResolves ¶
func AssertEventuallyDNSResolves(t testing.TB, r *require.Assertions, client *Client, tn *TestNetwork, hostname string, msgAndArgs ...interface{})
AssertEventuallyDNSResolves asserts that DNS resolution eventually succeeds.
func AssertEventuallyFileExists ¶
func AssertEventuallyFileExists(t testing.TB, r *require.Assertions, path string, msgAndArgs ...interface{})
AssertEventuallyFileExists asserts that a file eventually exists at the given path.
func AssertFileExists ¶
func AssertFileExists(t testing.TB, r *require.Assertions, path string, msgAndArgs ...interface{})
AssertFileExists asserts that a file exists at the given path.
func AssertFilePermissions ¶
func AssertFilePermissions(t testing.TB, r *require.Assertions, path string, expectedMode os.FileMode, description string)
AssertFilePermissions asserts that a file exists and has the expected permissions.
func AssertHTTPBodyContains ¶
func AssertHTTPBodyContains(t testing.TB, a *assert.Assertions, resp *HTTPResponse, expected string, msgAndArgs ...interface{})
AssertHTTPBodyContains asserts that an HTTP response body contains the expected string.
func AssertHTTPStatus ¶
func AssertHTTPStatus(t testing.TB, r *require.Assertions, resp *HTTPResponse, expectedStatus int, msgAndArgs ...interface{})
AssertHTTPStatus asserts that an HTTP response has the expected status code.
func CheckHealthEndpoint ¶
CheckHealthEndpoint verifies health endpoint HTTP status code Used by all cloud lifecycle tests to verify /health endpoint behavior
func CheckNodeHealth ¶
func CheckNodeHealth(testNet *TestNetwork) bool
CheckNodeHealth checks if a Neuwerk node is healthy by querying its /readyz endpoint. Returns true if the node responds with HTTP 200, false otherwise.
func CleanupStaleBPFMaps ¶
func CleanupStaleBPFMaps()
CleanupStaleBPFMaps removes any leftover BPF maps from previous test runs. This is critical for preventing memory leaks when tests are interrupted (Ctrl+C) or fail before cleanup. BPF maps are pinned to /sys/fs/bpf/ and persist in kernel memory even after the process exits.
Each Neuwerk test instance allocates ~350MB of BPF maps (flow_state, session_map, audit_ringbuf), so leftover maps can quickly exhaust system memory.
func ExecInNS ¶
ExecInNS executes a function in a specific network namespace This is a shared utility function used across the testenv package
func GetAllGCPNodeIPs ¶
GetAllGCPNodeIPs returns all Neuwerk instance IPs in the cluster
func GetAllGCPNodeNames ¶
GetAllGCPNodeNames returns all Neuwerk instance names in the cluster
func GetCertificateSerial ¶
GetCertificateSerial reads a certificate and returns its serial number as a string.
func GetGCPBackendHealth ¶
func GetGCPBackendHealth(ctx context.Context, projectID, region, backendServiceName string) ([]string, error)
GetGCPBackendHealth queries backend service health status
func GetGCPInstanceNameByIP ¶
GetGCPInstanceNameByIP retrieves instance name from internal IP
func GetGCPManagementIP ¶
GetGCPManagementIP retrieves Neuwerk instance internal IP via gcloud
func PolicyFixture ¶
PolicyFixture returns the path to a policy fixture file.
func StartNeuwerkWithClient ¶
func StartNeuwerkWithClient(t testing.TB, tn *TestNetwork, policyFile string) (*NeuwerkInstance, *Client)
StartNeuwerkWithClient starts Neuwerk with the given options and returns both the instance and a pre-configured client for the test network. The client is automatically configured with the root token for API authentication.
func StartNeuwerkWithClientAndOptions ¶
func StartNeuwerkWithClientAndOptions(t testing.TB, tn *TestNetwork, opts NeuwerkOptions) (*NeuwerkInstance, *Client)
StartNeuwerkWithClientAndOptions starts Neuwerk with extended options and returns both the instance and a pre-configured client. The client is automatically configured with the root token for API authentication.
func TestPublicKeyFile ¶
func TestPublicKeyFile() string
TestPublicKeyFile returns the path to the test public key file
Types ¶
type AzureClient ¶
type AzureClient struct {
// contains filtered or unexported fields
}
AzureClient wraps Azure SDK clients for testing
func NewAzureClient ¶
func NewAzureClient(ctx context.Context, subscriptionID, resourceGroup string) (*AzureClient, error)
NewAzureClient creates Azure SDK client using Workload Identity
func (*AzureClient) ExecuteRemoteCommand ¶
func (c *AzureClient) ExecuteRemoteCommand(ctx context.Context, vmName, command string) (string, error)
ExecuteRemoteCommand runs command on Azure VM via Run Command (Azure equivalent of SSM)
func (*AzureClient) GetAzureVMIPs ¶
GetAzureVMIPs returns private IPs for all VMs with cluster-name tag
func (*AzureClient) GetAzureVMNames ¶
GetAzureVMNames returns VM names for all VMs with cluster-name tag
func (*AzureClient) GetGWLBBackendHealth ¶
func (c *AzureClient) GetGWLBBackendHealth(ctx context.Context, lbName, backendPoolName string) (map[string]string, error)
GetGWLBBackendHealth returns health status of GWLB backend pool targets
func (*AzureClient) GetNodeStatsViaRunCommand ¶
func (c *AzureClient) GetNodeStatsViaRunCommand(ctx context.Context, vmName, rootToken string) (map[string]interface{}, error)
GetNodeStatsViaRunCommand gets node stats by executing curl via Azure Run Command
func (*AzureClient) GetVMByName ¶
func (c *AzureClient) GetVMByName(ctx context.Context, vmName string) (*armcompute.VirtualMachine, error)
GetVMByName retrieves a VM by name for status checks
func (*AzureClient) StopVM ¶
func (c *AzureClient) StopVM(ctx context.Context, vmName string) error
StopVM stops an Azure VM (for multi-node failover testing)
func (*AzureClient) WaitForGWLBHealthy ¶
func (c *AzureClient) WaitForGWLBHealthy(ctx context.Context, lbName, backendPoolName string, timeout time.Duration) error
WaitForGWLBHealthy polls until all backends are healthy or timeout
func (*AzureClient) WaitForVMRunning ¶
func (c *AzureClient) WaitForVMRunning(ctx context.Context, vmName string, timeout time.Duration) error
WaitForVMRunning polls until VM is in running state
type CertificateValidityOptions ¶
type CertificateValidityOptions struct {
MinValidityDuration time.Duration
MaxValidityDuration time.Duration
BackdateTolerance time.Duration
}
CertificateValidityOptions configures certificate validity checks.
func DefaultCertificateValidityOptions ¶
func DefaultCertificateValidityOptions() CertificateValidityOptions
DefaultCertificateValidityOptions returns sensible defaults for certificate validation.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a test client in a network namespace
func (*Client) ConnectWithTimeout ¶
ConnectWithTimeout attempts to connect with a custom timeout
func (*Client) HTTPDelete ¶
func (c *Client) HTTPDelete(url string) (*HTTPResponse, error)
HTTPDelete performs an HTTP DELETE request from within the client's namespace Uses raw TCP connection to avoid Go HTTP client goroutine namespace issues
func (*Client) HTTPGet ¶
func (c *Client) HTTPGet(url string) (*HTTPResponse, error)
HTTPGet performs an HTTP GET request from within the client's namespace Uses raw TCP connection to avoid Go HTTP client goroutine namespace issues
func (*Client) HTTPPost ¶
func (c *Client) HTTPPost(url, contentType string, body []byte) (*HTTPResponse, error)
HTTPPost performs an HTTP POST request from within the client's namespace Uses raw TCP connection to avoid Go HTTP client goroutine namespace issues
func (*Client) HTTPPut ¶
func (c *Client) HTTPPut(url, contentType string, body []byte) (*HTTPResponse, error)
HTTPPut performs an HTTP PUT request from within the client's namespace Uses raw TCP connection to avoid Go HTTP client goroutine namespace issues
func (*Client) ResolveDNS ¶
ResolveDNS resolves a hostname using the system resolver
func (*Client) ResolveDNSWithServer ¶
ResolveDNSWithServer resolves a hostname using a specific DNS server Uses miekg/dns directly to avoid goroutine/namespace issues with net.Resolver
func (*Client) SSEConnect ¶
func (c *Client) SSEConnect(url string) (*SSEConnection, *HTTPResponse, error)
SSEConnect establishes an SSE connection to the specified URL Returns the connection and initial response headers for verification
func (*Client) SetAuthToken ¶
SetAuthToken sets the JWT token for API authentication. The token will be included as Authorization: Bearer <token> in all HTTP requests.
func (*Client) TriggerReconcile ¶
TriggerReconcile calls the /api/v1/reconcile endpoint to trigger immediate BPF map sync
type DNSRecords ¶
DNSRecords is a map of hostname to IP addresses for mock DNS configuration.
type GCPDiscoveryOutput ¶
type GCPDiscoveryOutput struct {
ProducerVPCID string `json:"producer_vpc_id"`
ConsumerVPCID string `json:"consumer_vpc_id"`
BackendServiceID string `json:"backend_service_id"`
ConsumerInstanceName string `json:"consumer_instance_name"`
ProjectID string `json:"gcp_project_id"`
Region string `json:"gcp_region"`
Zone string `json:"gcp_zone"`
}
GCPDiscoveryOutput holds Terraform output values for GCP
func DiscoverGCPInfrastructure ¶
func DiscoverGCPInfrastructure(ctx context.Context, terraformDir string) (*GCPDiscoveryOutput, error)
DiscoverGCPInfrastructure queries Terraform outputs for GCP resources
type GENEVEClient ¶
type GENEVEClient struct {
// contains filtered or unexported fields
}
GENEVEClient can send GENEVE-encapsulated traffic for testing
func NewGENEVEClient ¶
func NewGENEVEClient(ns netns.NsHandle, clientIP, tunnelSrcIP, tunnelDstIP net.IP, tunnelDstPort uint16, vni uint32) *GENEVEClient
NewGENEVEClient creates a new GENEVE test client
func (*GENEVEClient) ConnectViaGENEVE ¶
func (c *GENEVEClient) ConnectViaGENEVE(innerDstIP string, innerDstPort int) error
ConnectViaGENEVE sends a GENEVE-encapsulated TCP SYN to test policy enforcement The inner packet is a TCP connection to the specified address Returns nil if the connection succeeds (traffic allowed), error if blocked
type HTTPResponse ¶
HTTPResponse wraps the response from an HTTP request
type MockDNSServer ¶
type MockDNSServer struct {
// contains filtered or unexported fields
}
MockDNSServer provides controlled DNS responses for testing
func NewMockDNSServer ¶
func NewMockDNSServer(ip string, port int) *MockDNSServer
NewMockDNSServer creates a new mock DNS server
func NewMockDNSServerInNS ¶
func NewMockDNSServerInNS(ns netns.NsHandle, ip string, port int) *MockDNSServer
NewMockDNSServerInNS creates a new mock DNS server that runs in a specific namespace
func StartMockDNS ¶
func StartMockDNS(t testing.TB, tn *TestNetwork, records DNSRecords) *MockDNSServer
StartMockDNS creates, configures, and starts a mock DNS server in the given namespace. It registers cleanup automatically and returns the started server.
func StartMockDNSMultiNode ¶
func StartMockDNSMultiNode(t testing.TB, tn *TestNetwork, records DNSRecords) *MockDNSServer
StartMockDNSMultiNode creates a mock DNS server for multi-node setups. It binds to 0.0.0.0 to be accessible from all nodes.
func (*MockDNSServer) AddRecord ¶
func (m *MockDNSServer) AddRecord(hostname string, ips []string)
AddRecord adds a DNS A record mapping hostname to IP addresses
func (*MockDNSServer) GetListenAddr ¶
func (m *MockDNSServer) GetListenAddr() string
GetListenAddr returns the listen address of the DNS server
func (*MockDNSServer) RemoveRecord ¶
func (m *MockDNSServer) RemoveRecord(hostname string)
RemoveRecord removes a DNS record
func (*MockDNSServer) SetDelay ¶
func (m *MockDNSServer) SetDelay(d time.Duration)
SetDelay sets the response delay to simulate latency
type MockHTTPServer ¶
type MockHTTPServer struct {
// contains filtered or unexported fields
}
MockHTTPServer provides a simple HTTP server for testing
func NewMockHTTPServer ¶
NewMockHTTPServer creates a new mock HTTP server
func StartMockHTTPServer ¶
func StartMockHTTPServer(t testing.TB, tn *TestNetwork, ip string, port int) *MockHTTPServer
StartMockHTTPServer creates and starts a mock HTTP server in the given namespace. It registers cleanup automatically and returns the started server.
func (*MockHTTPServer) GetListenAddr ¶
func (m *MockHTTPServer) GetListenAddr() string
GetListenAddr returns the listen address
func (*MockHTTPServer) Start ¶
func (m *MockHTTPServer) Start() error
Start starts the HTTP server in the specified namespace
type NeuwerkInstance ¶
type NeuwerkInstance struct {
Cmd *exec.Cmd
PID int
Config string
TestNet *TestNetwork
StopChan chan struct{}
DoneChan chan error
Peers []string
APIURL string // API base URL (e.g., "10.100.1.10:3000") for HTTP requests
PrivateKey interface{} // *rsa.PrivateKey for JWT signing
RootToken string // Root admin token derived from bootstrap token
// contains filtered or unexported fields
}
NeuwerkInstance represents a running Neuwerk instance in a test environment
func StartNeuwerk ¶
func StartNeuwerk(t interface{ Cleanup(func()) }, testNet *TestNetwork, policyFileOrOpts interface{}) (*NeuwerkInstance, error)
StartNeuwerk starts a Neuwerk instance in the test network Supports both old signature (policyFile string) and new signature (NeuwerkOptions)
func StartNeuwerkHA ¶
func StartNeuwerkHA(t interface{ Cleanup(func()) }, testNet *TestNetwork, policyFile string, peers []string, licenseFiles *TestLicenseFiles) (*NeuwerkInstance, error)
StartNeuwerkHA starts a Neuwerk instance in HA mode with peers licenseFiles must be provided for HA mode to work (pass nil for non-HA tests)
func StartNeuwerkVXLAN ¶
func StartNeuwerkVXLAN(t interface{ Cleanup(func()) }, testNet *TestNetwork, policyFile string, peers []string, licenseFiles *TestLicenseFiles) (*NeuwerkInstance, error)
StartNeuwerkVXLAN starts a Neuwerk instance in HA mode with VXLAN tunnel mode enabled. This is used for testing VXLAN encapsulation/decapsulation with policy enforcement.
func (*NeuwerkInstance) GetBpffsPath ¶
func (ni *NeuwerkInstance) GetBpffsPath() string
GetBpffsPath returns the bpffs path for this instance.
func (*NeuwerkInstance) GetRootToken ¶
func (ni *NeuwerkInstance) GetRootToken() string
GetRootToken returns the root admin JWT token for API authentication. Returns empty string if token derivation failed.
func (*NeuwerkInstance) GetStorageDir ¶
func (ni *NeuwerkInstance) GetStorageDir() string
GetStorageDir returns the storage directory path for this instance. Used when restarting a node to preserve state.
func (*NeuwerkInstance) IsRunning ¶
func (ni *NeuwerkInstance) IsRunning() bool
IsRunning checks if the instance is still running
func (*NeuwerkInstance) Stop ¶
func (ni *NeuwerkInstance) Stop() error
Stop stops the Neuwerk instance and cleans up all resources
func (*NeuwerkInstance) StopForRestart ¶
func (ni *NeuwerkInstance) StopForRestart() error
StopForRestart stops the Neuwerk instance but preserves storage for restart. Use this when testing node restart scenarios where state should be preserved.
func (*NeuwerkInstance) WaitForReady ¶
func (ni *NeuwerkInstance) WaitForReady(timeout time.Duration) error
WaitForReady polls the /readyz endpoint until it returns HTTP 200 or timeout
type NeuwerkOptions ¶
type NeuwerkOptions struct {
PolicyFile string // Path to policy YAML file
Peers []string // List of peer addresses for HA mode
LicenseFile string // Path to license file (required for HA mode)
PublicKeyFile string // Path to license public key file (for test licenses)
BootstrapTokenFile string // Path to bootstrap token file (enables TLS)
CertDir string // Certificate storage directory (default /var/lib/neuwerk/certs)
RaftBindAddr string // Raft listener address for bootstrap (e.g., "10.100.1.10:7000")
OIDCConfigFile string // Path to OIDC configuration file for SSO (optional)
StorageDir string // Existing storage directory to reuse (for restart scenarios)
SkipBootstrap bool // Skip TLS bootstrap (certificates already exist from previous run)
TunnelMode string // Tunnel protocol mode: "geneve" (AWS), "vxlan" (Azure), or "" (none)
EnableAuth bool // Enable authentication (JWT required for API calls)
}
NeuwerkOptions holds configuration for starting a Neuwerk instance
type SSEConnection ¶
type SSEConnection struct {
// contains filtered or unexported fields
}
SSEConnection represents a Server-Sent Events connection
type TestLicenseFiles ¶
TestLicenseFiles contains paths to both the license file and public key file
func CreateHALicenseFiles ¶
func CreateHALicenseFiles(t interface{ Cleanup(func()) }) (*TestLicenseFiles, error)
CreateHALicenseFiles returns paths to HA-enabled test license files This is a compatibility wrapper - no longer generates keys at runtime
func CreateLicenseFilesWithoutHA ¶
func CreateLicenseFilesWithoutHA(t interface{ Cleanup(func()) }) (*TestLicenseFiles, error)
CreateLicenseFilesWithoutHA returns paths to license files without HA feature This is a compatibility wrapper - no longer generates keys at runtime
func LoadAllFeaturesLicenseFiles ¶
func LoadAllFeaturesLicenseFiles() *TestLicenseFiles
LoadAllFeaturesLicenseFiles returns paths to a license with all features enabled
func LoadExpiredLicenseFiles ¶
func LoadExpiredLicenseFiles() *TestLicenseFiles
LoadExpiredLicenseFiles returns paths to an expired license (30 days ago)
func LoadExpiredLongAgoLicenseFiles ¶
func LoadExpiredLongAgoLicenseFiles() *TestLicenseFiles
LoadExpiredLongAgoLicenseFiles returns paths to a license expired 1 year ago
func LoadExpiresSoonLicenseFiles ¶
func LoadExpiresSoonLicenseFiles() *TestLicenseFiles
LoadExpiresSoonLicenseFiles returns paths to a license expiring in 3 days
func LoadGracePeriodLicenseFiles ¶
func LoadGracePeriodLicenseFiles() *TestLicenseFiles
LoadGracePeriodLicenseFiles returns paths to a license in grace period (expired 5 days ago)
func LoadHALicenseFiles ¶
func LoadHALicenseFiles() *TestLicenseFiles
LoadHALicenseFiles returns paths to a valid HA-enabled test license
func LoadKubernetesOnlyLicenseFiles ¶
func LoadKubernetesOnlyLicenseFiles() *TestLicenseFiles
LoadKubernetesOnlyLicenseFiles returns paths to a license with only Kubernetes feature
func LoadNoHALicenseFiles ¶
func LoadNoHALicenseFiles() *TestLicenseFiles
LoadNoHALicenseFiles returns paths to a license without HA feature
func LoadSingleNodeLicenseFiles ¶
func LoadSingleNodeLicenseFiles() *TestLicenseFiles
LoadSingleNodeLicenseFiles returns paths to a license limited to 1 node
func LoadThreeNodeLicenseFiles ¶
func LoadThreeNodeLicenseFiles() *TestLicenseFiles
LoadThreeNodeLicenseFiles returns paths to a license limited to 3 nodes
func LoadTrialLicenseFiles ¶
func LoadTrialLicenseFiles() *TestLicenseFiles
LoadTrialLicenseFiles returns paths to a 14-day trial license
type TestNetwork ¶
type TestNetwork struct {
// Network namespaces
NeuwerkNS netns.NsHandle
ClientNS netns.NsHandle
UpstreamNS netns.NsHandle
// Network namespace names (for nsenter)
NeuwerkNSName string
ClientNSName string
UpstreamNSName string
// veth pairs
NeuwerkIngressVeth *netlink.Veth
NeuwerkEgressVeth *netlink.Veth
ClientVeth *netlink.Veth
UpstreamVeth *netlink.Veth
// IP addresses
NeuwerkIngressIP net.IP
NeuwerkEgressIP net.IP
ClientIP net.IP
UpstreamIP net.IP
// BPF filesystem mount point
BPFFSPath string
// Management bridge name (for multi-node HA tests)
ManagementBridgeName string
// contains filtered or unexported fields
}
TestNetwork represents an isolated test network using network namespaces
func SetupMultiNode ¶
func SetupMultiNode(t interface{ Cleanup(func()) }, nodeCount int) []*TestNetwork
SetupMultiNode creates isolated network environments for multi-node HA tests
func SetupMultiNodeWithCleanup ¶
func SetupMultiNodeWithCleanup(t testing.TB, nodeCount int) []*TestNetwork
SetupMultiNodeWithCleanup creates multiple test networks and registers cleanup automatically.
func SetupSingleNode ¶
func SetupSingleNode(t interface{ Cleanup(func()) }) *TestNetwork
SetupSingleNode creates an isolated network environment for single-node tests Returns the test network and registers cleanup function
func SetupSingleNodeWithCleanup ¶
func SetupSingleNodeWithCleanup(t testing.TB) *TestNetwork
SetupSingleNodeWithCleanup creates a test network and registers cleanup automatically. This is the recommended way to create a single-node test environment.
func (*TestNetwork) APIBaseURL ¶
func (tn *TestNetwork) APIBaseURL() string
APIBaseURL returns the base URL for the Neuwerk API (HTTP on port 3000).
func (*TestNetwork) APIBaseURLHTTPS ¶
func (tn *TestNetwork) APIBaseURLHTTPS() string
APIBaseURLHTTPS returns the base URL for the Neuwerk API over HTTPS (port 8443).
func (*TestNetwork) Cleanup ¶
func (tn *TestNetwork) Cleanup()
Cleanup removes all network namespaces and resources
func (*TestNetwork) DNSServerAddr ¶
func (tn *TestNetwork) DNSServerAddr() string
DNSServerAddr returns the address of the DNS server (Neuwerk ingress IP on port 53).
func (*TestNetwork) GetClientNS ¶
func (tn *TestNetwork) GetClientNS() netns.NsHandle
GetClientNS returns the client namespace handle
func (*TestNetwork) GetNeuwerkNS ¶
func (tn *TestNetwork) GetNeuwerkNS() netns.NsHandle
GetNeuwerkNS returns the Neuwerk namespace handle
func (*TestNetwork) GetUpstreamNS ¶
func (tn *TestNetwork) GetUpstreamNS() netns.NsHandle
GetUpstreamNS returns the upstream namespace handle
func (*TestNetwork) HealthURL ¶
func (tn *TestNetwork) HealthURL() string
HealthURL returns the URL for the health endpoint.
func (*TestNetwork) MetricsURL ¶
func (tn *TestNetwork) MetricsURL() string
MetricsURL returns the URL for the metrics endpoint.
func (*TestNetwork) NATSAddr ¶
func (tn *TestNetwork) NATSAddr() string
NATSAddr returns the address of the NATS server (Neuwerk ingress IP on port 3320).
func (*TestNetwork) RaftAddr ¶
func (tn *TestNetwork) RaftAddr() string
RaftAddr returns the address for Raft communication (Neuwerk ingress IP on port 3322).
type VXLANClient ¶
type VXLANClient struct {
// contains filtered or unexported fields
}
VXLANClient can send VXLAN-encapsulated traffic for testing
func NewVXLANClient ¶
func NewVXLANClient(ns netns.NsHandle, clientIP, tunnelSrcIP, tunnelDstIP net.IP, tunnelDstPort uint16, vni uint32) *VXLANClient
NewVXLANClient creates a new VXLAN test client
func (*VXLANClient) ConnectViaVXLAN ¶
func (c *VXLANClient) ConnectViaVXLAN(innerDstIP string, innerDstPort int) error
ConnectViaVXLAN sends a VXLAN-encapsulated TCP SYN to test policy enforcement The inner packet is a TCP connection to the specified address Returns nil if the connection succeeds (traffic allowed), error if blocked
type VXLANPacket ¶
VXLANPacket represents a captured VXLAN packet
type VXLANValidator ¶
type VXLANValidator struct {
// contains filtered or unexported fields
}
VXLANValidator provides VXLAN packet inspection helpers
func NewVXLANValidator ¶
func NewVXLANValidator(client *AzureClient) *VXLANValidator
func (*VXLANValidator) CaptureVXLANPackets ¶
func (v *VXLANValidator) CaptureVXLANPackets(ctx context.Context, vmName string, port int, duration time.Duration) ([]VXLANPacket, error)
CaptureVXLANPackets captures VXLAN packets on specified port using tcpdump
func (*VXLANValidator) VerifyVXLANEncapsulation ¶
func (v *VXLANValidator) VerifyVXLANEncapsulation(ctx context.Context, vmName string) error
VerifyVXLANEncapsulation validates VXLAN traffic exists on both tunnels