(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestEndpointResolution(t *testing.T) { |
| 18 | t.Parallel() |
| 19 | h := NewHarness(t) |
| 20 | |
| 21 | dnsIP := GetIP(h.Subnet, 100) |
| 22 | node1IP := GetIP(h.Subnet, 2) |
| 23 | node2IP := GetIP(h.Subnet, 3) |
| 24 | |
| 25 | // example.com -> node1IP |
| 26 | // srv.example.com -> SRV _nylon._udp.srv.example.com -> 57175 node2.example.com |
| 27 | // node2.example.com -> node2IP |
| 28 | corefile := ` |
| 29 | . { |
| 30 | file /etc/coredns/example.com.db example.com |
| 31 | log |
| 32 | errors |
| 33 | } |
| 34 | ` |
| 35 | zoneFile := fmt.Sprintf(` |
| 36 | example.com. 0 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 0 |
| 37 | example.com. 0 IN A %s |
| 38 | node2.example.com. 0 IN A %s |
| 39 | _nylon._udp.srv.example.com. 0 IN SRV 10 10 57175 node2.example.com. |
| 40 | `, node1IP, node2IP) |
| 41 | h.StartDNS("dns", dnsIP, corefile, map[string]string{"example.com.db": zoneFile}) |
| 42 | |
| 43 | key1 := state.GenerateKey() |
| 44 | key2 := state.GenerateKey() |
| 45 | |
| 46 | centralCfg := state.CentralCfg{ |
| 47 | Routers: []state.RouterCfg{ |
| 48 | { |
| 49 | NodeCfg: state.NodeCfg{ |
| 50 | Id: "node-1", |
| 51 | PubKey: key1.Pubkey(), |
| 52 | Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.1")}, |
| 53 | }, |
| 54 | // Node 1's endpoint is a hostname |
| 55 | Endpoints: []*state.DynamicEndpoint{ |
| 56 | state.NewDynamicEndpoint("example.com"), |
| 57 | }, |
| 58 | }, |
| 59 | { |
| 60 | NodeCfg: state.NodeCfg{ |
| 61 | Id: "node-2", |
| 62 | PubKey: key2.Pubkey(), |
| 63 | Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.2")}, |
| 64 | }, |
| 65 | // Node 2's endpoint is an SRV record |
| 66 | Endpoints: []*state.DynamicEndpoint{ |
| 67 | state.NewDynamicEndpoint("srv.example.com"), |
| 68 | }, |
| 69 | }, |
| 70 | }, |
| 71 | Graph: []string{"node-1, node-2"}, |
| 72 | } |
| 73 | |
| 74 | testDir := h.SetupTestDir() |
nothing calls this directly
no test coverage detected