Skip to content

Commit 26561dd

Browse files
committed
parse ip cleanup
1 parent f7aad62 commit 26561dd

File tree

1 file changed

+44
-35
lines changed

1 file changed

+44
-35
lines changed

tailnet/controllers_test.go

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,15 +1557,19 @@ func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) {
15571557
require.Contains(t, adds, w2a1ID)
15581558
require.Contains(t, adds, w2a2ID)
15591559

1560+
ws1a1IP := netip.MustParseAddr("fd60:627a:a42b:0101::")
1561+
w2a1IP := netip.MustParseAddr("fd60:627a:a42b:0201::")
1562+
w2a2IP := netip.MustParseAddr("fd60:627a:a42b:0202::")
1563+
15601564
// Also triggers setting DNS hosts
15611565
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1562-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1563-
"w2a1.w2.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0201::")},
1564-
"w2a2.w2.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0202::")},
1565-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1566-
"w2a1.w2.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0201::")},
1567-
"w2a2.w2.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0202::")},
1568-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1566+
"w1a1.w1.me.coder.": {ws1a1IP},
1567+
"w2a1.w2.me.coder.": {w2a1IP},
1568+
"w2a2.w2.me.coder.": {w2a2IP},
1569+
"w1a1.w1.testy.coder.": {ws1a1IP},
1570+
"w2a1.w2.testy.coder.": {w2a1IP},
1571+
"w2a2.w2.testy.coder.": {w2a2IP},
1572+
"w1.coder.": {ws1a1IP},
15691573
}
15701574
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
15711575
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1580,23 +1584,23 @@ func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) {
15801584
{
15811585
ID: w1a1ID, Name: "w1a1", WorkspaceID: w1ID,
15821586
Hosts: map[dnsname.FQDN][]netip.Addr{
1583-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1584-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1585-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1587+
"w1.coder.": {ws1a1IP},
1588+
"w1a1.w1.me.coder.": {ws1a1IP},
1589+
"w1a1.w1.testy.coder.": {ws1a1IP},
15861590
},
15871591
},
15881592
{
15891593
ID: w2a1ID, Name: "w2a1", WorkspaceID: w2ID,
15901594
Hosts: map[dnsname.FQDN][]netip.Addr{
1591-
"w2a1.w2.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0201::")},
1592-
"w2a1.w2.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0201::")},
1595+
"w2a1.w2.me.coder.": {w2a1IP},
1596+
"w2a1.w2.testy.coder.": {w2a1IP},
15931597
},
15941598
},
15951599
{
15961600
ID: w2a2ID, Name: "w2a2", WorkspaceID: w2ID,
15971601
Hosts: map[dnsname.FQDN][]netip.Addr{
1598-
"w2a2.w2.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0202::")},
1599-
"w2a2.w2.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0202::")},
1602+
"w2a2.w2.me.coder.": {w2a2IP},
1603+
"w2a2.w2.testy.coder.": {w2a2IP},
16001604
},
16011605
},
16021606
},
@@ -1635,6 +1639,9 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
16351639
w1ID := testUUID(1)
16361640
w1a1ID := testUUID(1, 1)
16371641
w1a2ID := testUUID(1, 2)
1642+
ws1a1IP := netip.MustParseAddr("fd60:627a:a42b:0101::")
1643+
ws1a2IP := netip.MustParseAddr("fd60:627a:a42b:0102::")
1644+
16381645
initUp := &proto.WorkspaceUpdate{
16391646
UpsertedWorkspaces: []*proto.Workspace{
16401647
{Id: w1ID[:], Name: "w1"},
@@ -1654,9 +1661,9 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
16541661

16551662
// DNS for w1a1
16561663
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1657-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1658-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1659-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1664+
"w1a1.w1.testy.coder.": {ws1a1IP},
1665+
"w1a1.w1.me.coder.": {ws1a1IP},
1666+
"w1.coder.": {ws1a1IP},
16601667
}
16611668
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
16621669
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1668,9 +1675,9 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
16681675
},
16691676
UpsertedAgents: []*tailnet.Agent{
16701677
{ID: w1a1ID, Name: "w1a1", WorkspaceID: w1ID, Hosts: map[dnsname.FQDN][]netip.Addr{
1671-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1672-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1673-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1678+
"w1a1.w1.testy.coder.": {ws1a1IP},
1679+
"w1a1.w1.me.coder.": {ws1a1IP},
1680+
"w1.coder.": {ws1a1IP},
16741681
}},
16751682
},
16761683
DeletedWorkspaces: []*tailnet.Workspace{},
@@ -1709,9 +1716,9 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
17091716

17101717
// DNS contains only w1a2
17111718
expectedDNS = map[dnsname.FQDN][]netip.Addr{
1712-
"w1a2.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1713-
"w1a2.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1714-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1719+
"w1a2.w1.testy.coder.": {ws1a2IP},
1720+
"w1a2.w1.me.coder.": {ws1a2IP},
1721+
"w1.coder.": {ws1a2IP},
17151722
}
17161723
dnsCall = testutil.RequireRecvCtx(ctx, t, fDNS.calls)
17171724
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1722,17 +1729,17 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
17221729
UpsertedWorkspaces: []*tailnet.Workspace{},
17231730
UpsertedAgents: []*tailnet.Agent{
17241731
{ID: w1a2ID, Name: "w1a2", WorkspaceID: w1ID, Hosts: map[dnsname.FQDN][]netip.Addr{
1725-
"w1a2.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1726-
"w1a2.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1727-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1732+
"w1a2.w1.testy.coder.": {ws1a2IP},
1733+
"w1a2.w1.me.coder.": {ws1a2IP},
1734+
"w1.coder.": {ws1a2IP},
17281735
}},
17291736
},
17301737
DeletedWorkspaces: []*tailnet.Workspace{},
17311738
DeletedAgents: []*tailnet.Agent{
17321739
{ID: w1a1ID, Name: "w1a1", WorkspaceID: w1ID, Hosts: map[dnsname.FQDN][]netip.Addr{
1733-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1734-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1735-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1740+
"w1a1.w1.testy.coder.": {ws1a1IP},
1741+
"w1a1.w1.me.coder.": {ws1a1IP},
1742+
"w1.coder.": {ws1a1IP},
17361743
}},
17371744
},
17381745
}
@@ -1746,9 +1753,9 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
17461753
},
17471754
UpsertedAgents: []*tailnet.Agent{
17481755
{ID: w1a2ID, Name: "w1a2", WorkspaceID: w1ID, Hosts: map[dnsname.FQDN][]netip.Addr{
1749-
"w1a2.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1750-
"w1a2.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1751-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0102::")},
1756+
"w1a2.w1.testy.coder.": {ws1a2IP},
1757+
"w1a2.w1.me.coder.": {ws1a2IP},
1758+
"w1.coder.": {ws1a2IP},
17521759
}},
17531760
},
17541761
DeletedWorkspaces: []*tailnet.Workspace{},
@@ -1776,6 +1783,8 @@ func TestTunnelAllWorkspaceUpdatesController_DNSError(t *testing.T) {
17761783

17771784
w1ID := testUUID(1)
17781785
w1a1ID := testUUID(1, 1)
1786+
ws1a1IP := netip.MustParseAddr("fd60:627a:a42b:0101::")
1787+
17791788
initUp := &proto.WorkspaceUpdate{
17801789
UpsertedWorkspaces: []*proto.Workspace{
17811790
{Id: w1ID[:], Name: "w1"},
@@ -1789,9 +1798,9 @@ func TestTunnelAllWorkspaceUpdatesController_DNSError(t *testing.T) {
17891798

17901799
// DNS for w1a1
17911800
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1792-
"w1a1.w1.me.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1793-
"w1a1.w1.testy.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1794-
"w1.coder.": {netip.MustParseAddr("fd60:627a:a42b:0101::")},
1801+
"w1a1.w1.me.coder.": {ws1a1IP},
1802+
"w1a1.w1.testy.coder.": {ws1a1IP},
1803+
"w1.coder.": {ws1a1IP},
17951804
}
17961805
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
17971806
require.Equal(t, expectedDNS, dnsCall.hosts)

0 commit comments

Comments
 (0)