mirror of
https://github.com/juanfont/headscale.git
synced 2025-07-22 13:48:40 +02:00
make traceroute func
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
911da48fd5
commit
ca9d37ed9a
@ -1036,6 +1036,10 @@ func assertNodeRouteCount(t *testing.T, node *v1.Node, announced, approved, subn
|
|||||||
assert.Len(t, node.GetSubnetRoutes(), subnet)
|
assert.Len(t, node.GetSubnetRoutes(), subnet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestSubnetRouterMultiNetwork is an evolution of the subnet router test.
|
||||||
|
// This test will set up multiple docker networks and use two isolated tailscale
|
||||||
|
// clients and a service available in one of the networks to validate that a
|
||||||
|
// subnet router is working as expected.
|
||||||
func TestSubnetRouterMultiNetwork(t *testing.T) {
|
func TestSubnetRouterMultiNetwork(t *testing.T) {
|
||||||
IntegrationSkip(t)
|
IntegrationSkip(t)
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
@ -1130,8 +1134,7 @@ func TestSubnetRouterMultiNetwork(t *testing.T) {
|
|||||||
assert.Len(t, nodes, 2)
|
assert.Len(t, nodes, 2)
|
||||||
assertNodeRouteCount(t, nodes[0], 1, 1, 1)
|
assertNodeRouteCount(t, nodes[0], 1, 1, 1)
|
||||||
|
|
||||||
// Verify that no routes has been sent to the client,
|
// Verify that the routes have been sent to the client.
|
||||||
// they are not yet enabled.
|
|
||||||
status, err = user2c.Status()
|
status, err = user2c.Status()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -1159,8 +1162,8 @@ func TestSubnetRouterMultiNetwork(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, result, 13)
|
assert.Len(t, result, 13)
|
||||||
|
|
||||||
stdout, stderr, err := user2c.Execute([]string{"traceroute", webip.String()})
|
tr, err := user2c.Traceroute(webip)
|
||||||
assert.Contains(t, stdout+stderr, user1c.MustIPv4().String())
|
assert.Contains(t, tr, user1c.MustIPv4().String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// requirePeerSubnetRoutes asserts that the peer has the expected subnet routes.
|
// requirePeerSubnetRoutes asserts that the peer has the expected subnet routes.
|
||||||
|
@ -41,6 +41,7 @@ type TailscaleClient interface {
|
|||||||
WaitForPeers(expected int) error
|
WaitForPeers(expected int) error
|
||||||
Ping(hostnameOrIP string, opts ...tsic.PingOption) error
|
Ping(hostnameOrIP string, opts ...tsic.PingOption) error
|
||||||
Curl(url string, opts ...tsic.CurlOption) (string, error)
|
Curl(url string, opts ...tsic.CurlOption) (string, error)
|
||||||
|
Traceroute(netip.Addr) (string, error)
|
||||||
ID() string
|
ID() string
|
||||||
ReadFile(path string) ([]byte, error)
|
ReadFile(path string) ([]byte, error)
|
||||||
|
|
||||||
|
@ -1130,6 +1130,21 @@ func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, err
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TailscaleInContainer) Traceroute(ip netip.Addr) (string, error) {
|
||||||
|
command := []string{
|
||||||
|
"traceroute",
|
||||||
|
ip.String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var result string
|
||||||
|
result, _, err := t.Execute(command)
|
||||||
|
if err != nil {
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// WriteFile save file inside the Tailscale container.
|
// WriteFile save file inside the Tailscale container.
|
||||||
func (t *TailscaleInContainer) WriteFile(path string, data []byte) error {
|
func (t *TailscaleInContainer) WriteFile(path string, data []byte) error {
|
||||||
return integrationutil.WriteFileToContainer(t.pool, t.container, path, data)
|
return integrationutil.WriteFileToContainer(t.pool, t.container, path, data)
|
||||||
|
Loading…
Reference in New Issue
Block a user