v3.1.0 d676137

l4_roundtrip_test.go RawHistoryFolder

1package traffic
2
3import (
4	"context"
5	"testing"
6	"time"
7
8	"github.com/stretchr/testify/assert"
9	"github.com/stretchr/testify/require"
10
11	"github.com/bnema/gordon/internal/domain"
12)
13
14// TestAppL4TCPUdpRoundTrip proves one applied graph relays TCP and UDP
15// simultaneously through distinct entrypoints to distinct loopback
16// backends: the app-plane shape (service:<app>--<svc>:<kind>-<port>)
17// round-trips end to end on both protocols.
18func TestAppL4TCPUdpRoundTrip(t *testing.T) {
19	tcpBackend := startTCPEchoServer(t, 0)
20	udpBackend := startUDPEchoServer(t)
21
22	tcpAddr, err := backendFromAddress("game--server", tcpBackend.address)
23	require.NoError(t, err)
24	udpAddr, err := backendFromAddress("game--server", udpBackend.address)
25	require.NoError(t, err)
26	udpAddr.Protocol = domain.NetworkProtocolUDP
27
28	graph := domain.TrafficGraph{
29		Options: domain.TrafficOptions{
30			TCP: domain.TCPOptions{DialTimeout: time.Second, IdleTimeout: time.Minute, DrainTimeout: 50 * time.Millisecond},
31			UDP: domain.UDPOptions{IdleTimeout: time.Minute, DrainTimeout: 50 * time.Millisecond},
32		},
33		EntryPoints: []domain.EntryPoint{
34			{Name: "tcp", Address: freeTCPAddress(t), Protocol: domain.EntryPointProtocolTCP},
35			{Name: "udp", Address: freeUDPAddress(t), Protocol: domain.EntryPointProtocolUDP},
36		},
37		Routers: []domain.TrafficRouter{
38			{Name: "app-game--server--tcp-9000", EntryPoint: "tcp", Protocol: domain.RouterProtocolTCP, Service: "service:game--server:tcp-9000"},
39			{Name: "app-game--server--udp-9000", EntryPoint: "udp", Protocol: domain.RouterProtocolUDP, Service: "service:game--server:udp-9000"},
40		},
41		Services: []domain.TrafficService{
42			{Name: "service:game--server:tcp-9000", Backends: []domain.TrafficBackend{tcpAddr}},
43			{Name: "service:game--server:udp-9000", Backends: []domain.TrafficBackend{udpAddr}},
44		},
45	}
46	require.NoError(t, graph.Validate())
47
48	manager := NewManager()
49	require.NoError(t, manager.Apply(context.Background(), &graph))
50	defer shutdownManager(t, manager)
51
52	tcpConn := dialTCP(t, graph.EntryPoints[0].Address)
53	defer tcpConn.Close()
54	assertRoundTrip(t, tcpConn, "hello tcp")
55
56	udpConn := dialUDP(t, graph.EntryPoints[1].Address)
57	defer udpConn.Close()
58	assertUDPRoundTrip(t, udpConn, "hello udp")
59
60	status := manager.Status()
61	assert.Equal(t, "ok", status.LastReloadStatus)
62	assert.Len(t, status.Routers, 2)
63}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close