Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ConfigureNetwork(ctx context.Context, config *Config) (err error)
- func (c *Client) GetDataNetworkIP() (net.IP, error)
- func (c *Client) MustConfigureNetwork(ctx context.Context, config *Config)
- func (c *Client) MustGetDataNetworkIP() net.IP
- func (c *Client) MustWaitNetworkInitialized(ctx context.Context)
- func (c *Client) WaitNetworkInitialized(ctx context.Context) error
- type Config
- type FilterAction
- type LinkRule
- type LinkShape
- type RoutingPolicyType
Constants ¶
const ( // magic values that we monitor on the Testground runner side to detect when Testground // testplan instances are initialised and at the stage of actually running a test // check cluster_k8s.go for more information InitialisationSuccessful = "network initialisation successful" InitialisationFailed = "network initialisation failed" )
const ( AllowAll = RoutingPolicyType("allow_all") DenyAll = RoutingPolicyType("deny_all") )
const ( // The `data` network that Testground currently configures. In the future we might want to have // multiple `data` networks, and shape the network traffic on them differently. DefaultDataNetwork = "default" )
Variables ¶
var ErrNoTrafficShaping = fmt.Errorf("no traffic shaping available with this runner")
ErrNoTrafficShaping is returned from functions in this package when traffic shaping is not available, such as when using the local:exec runner.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient returns a new network client. Use this client to request network changes, such as setting latencies, jitter, packet loss, connectedness, etc.
func (*Client) ConfigureNetwork ¶
ConfigureNetwork asks the sidecar to configure the network, and returns either when the sidecar signals back to us, or when the context expires.
func (*Client) GetDataNetworkIP ¶ added in v0.2.1
GetDataNetworkIP examines the local network interfaces, and tries to find our assigned IP within the data network.
This function returns the IP and a nil error if found. If running in a sidecar-less environment, the error ErrNoTrafficShaping is returned.
func (*Client) MustConfigureNetwork ¶
MustConfigureNetwork calls ConfigureNetwork, and panics if it errors. It is suitable to use with runner.Invoke/InvokeMap, as long as this method is called from the main goroutine of the test plan.
func (*Client) MustGetDataNetworkIP ¶ added in v0.2.1
MustGetDataNetworkIP calls GetDataNetworkIP, and panics if it errors. It is suitable to use with runner.Invoke/InvokeMap, as long as this method is called from the main goroutine of the test plan.
func (*Client) MustWaitNetworkInitialized ¶
MustWaitNetworkInitialized calls WaitNetworkInitialized, and panics if it errors. It is suitable to use with runner.Invoke/InvokeMap, as long as this method is called from the main goroutine of the test plan.
type Config ¶
type Config struct { // Network is the name of the network to configure Network string `json:"network"` // IPv4 and IPv6 set the IP addresses of this network device. If // unspecified, the sidecar will leave them alone. // // Your test-case will be assigned a B block in the range // 16.0.0.1-32.0.0.0. X.Y.0.1 will always be reserved for the gateway // and shouldn't be used by the test. // // TODO: IPv6 is currently not supported. IPv4, IPv6 *ptypes.IPNet // Enable enables this network device. Enable bool `json:"enable"` // Default is the default link shaping rule. Default LinkShape `json:"default"` // Rules defines how traffic should be shaped to different subnets. // // TODO: This is not implemented. Rules []LinkRule `json:"rules"` // CallbackState will be signalled when the link changes are applied. // // Nodes can use the same state to wait for _all_ or a subset of nodes to // enter the desired network state. See CallbackTarget. CallbackState sync.State `json:"callback_state"` // CallbackTarget is the amount of instances that will have needed to signal // on the Callback state to consider the configuration operation a success. // // A zero value falls back to runenv.TestInstanceCount (i.e. all instances // participating in the test run). CallbackTarget int `json:"-"` // RoutingPolicy defines the data routing policy of a certain node. This affects // external networks other than the network 'Default', e.g., external Internet // access. RoutingPolicy RoutingPolicyType `json:"routing_policy"` }
NetworkConfig specifies how a node's network should be configured.
type LinkShape ¶
type LinkShape struct { // Latency is the egress latency Latency time.Duration `json:"latency"` // Jitter is the egress jitter Jitter time.Duration `json:"jitter"` // Bandwidth is egress bytes per second Bandwidth uint64 `json:"bandwidth"` // Drop all inbound traffic. // TODO: Not implemented Filter FilterAction `json:"filter"` // Loss is the egress packet loss (%) Loss float32 `json:"loss"` // Corrupt is the egress packet corruption probability (%) Corrupt float32 `json:"corrupt"` // Corrupt is the egress packet corruption correlation (%) CorruptCorr float32 `json:"corrupt_corr"` // Reorder is the probability that an egress packet will be reordered (%) // // Reordered packets will skip the latency delay and be sent // immediately. You must specify a non-zero Latency for this option to // make sense. Reorder float32 `json:"reorder"` // ReorderCorr is the egress packet reordering correlation (%) ReorderCorr float32 `json:"reorder_corr"` // Duplicate is the percentage of packets that are duplicated (%) Duplicate float32 `json:"duplicate"` // DuplicateCorr is the correlation between egress packet duplication (%) DuplicateCorr float32 `json:"duplicate_corr"` }
LinkShape defines how traffic should be shaped.
type RoutingPolicyType ¶ added in v0.2.4
type RoutingPolicyType string
RoutingPolicyType defines a certain routing policy to a network.