A Go testing framework for distributed applications
Gont is a Go package to support the development networked and distributed applications.
It can construct a virtual network using Linux network spaces, to simulate switches, routers, NAT and endpoints, on a single machine (VM, cloud or native). In addition, it supports developers with tooling for tracing and debugger tooling for investigating distributed applications.
Gont is heavily inspired by Mininet. It allows the user to build virtual network topologies defined Go code. Under the hood the network is then constructed using Linux virtual bridges and network namespaces.
Gont runs on all moderatly recent Linux versions and requires NET_ADMIN
capabilities (or root access).
Using Gont, developers can test complex distributed peer-to-peer and federated applications like routing daemons or social networks and messaging. Integration tests can be automated and executed in CI environments like GitHub actions (which are in fact used to test Gont itself).
Have a look at our slide set to get you started.
Various common network nodes:
Hostname resolution for test nodes (/etc/hosts overlay)
Execution of sub-processes, Go code & functions in the network namespace of test nodes
Simultaneous setup of multiple isolated networks
Ideal for Golang unit tests
Can run in workflows powered by GitHub's runners
Lean code thanks to functional options
Full IPv6 support
Per link network emulation and bandwidth limiting via for Netem and TBF queuing disciplines
Use of existing network namespaces as nodes
Configuration of per-host nftables firewall rules
Built-in Ping & Traceroute diagnostic tools
Built-in packet tracing with PCAPng output
SSLKEYLOGFILE
environment variable
Distributed tracing of events
slog.Handler
to emit structured log records as trace eventszapcore.Core
to emit zap log messages as trace eventsBuilt-in Delve debugger
Have a look at the unit tests for usage examples:
traceroute
(for testing)libpcap
(for compiling BPF filter expressions of packet tracing feature) The development of Gont has been supported by the ERIGrid 2.0 project
of the H2020 Programme under Grant Agreement No. 870620
Gont is licensed under the Apache 2.0 license.