(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestDynamicResolution(t *testing.T) { |
| 124 | t.Parallel() |
| 125 | h := NewHarness(t) |
| 126 | |
| 127 | dnsIP := GetIP(h.Subnet, 100) |
| 128 | node1IP := GetIP(h.Subnet, 2) |
| 129 | node2IP_A := GetIP(h.Subnet, 3) |
| 130 | node2IP_B := GetIP(h.Subnet, 4) |
| 131 | |
| 132 | // Initial DNS setup |
| 133 | corefile := ` |
| 134 | . { |
| 135 | file /etc/coredns/example.com.db example.com { |
| 136 | reload 2s |
| 137 | } |
| 138 | log |
| 139 | errors |
| 140 | } |
| 141 | ` |
| 142 | zoneFileA := fmt.Sprintf(` |
| 143 | example.com. 0 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 0 |
| 144 | node2.example.com. 0 IN A %s |
| 145 | `, node2IP_A) |
| 146 | h.StartDNS("dns", dnsIP, corefile, map[string]string{"example.com.db": zoneFileA}) |
| 147 | |
| 148 | key1 := state.GenerateKey() |
| 149 | key2 := state.GenerateKey() |
| 150 | |
| 151 | centralCfg := state.CentralCfg{ |
| 152 | Routers: []state.RouterCfg{ |
| 153 | { |
| 154 | NodeCfg: state.NodeCfg{ |
| 155 | Id: "node-1", |
| 156 | PubKey: key1.Pubkey(), |
| 157 | Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.1")}, |
| 158 | }, |
| 159 | }, |
| 160 | { |
| 161 | NodeCfg: state.NodeCfg{ |
| 162 | Id: "node-2", |
| 163 | PubKey: key2.Pubkey(), |
| 164 | Addresses: []netip.Addr{netip.MustParseAddr("10.0.0.2")}, |
| 165 | }, |
| 166 | // Node 2's endpoint is a hostname |
| 167 | Endpoints: []*state.DynamicEndpoint{ |
| 168 | state.NewDynamicEndpoint("node2.example.com"), |
| 169 | }, |
| 170 | }, |
| 171 | }, |
| 172 | Graph: []string{"node-1, node-2"}, |
| 173 | } |
| 174 | |
| 175 | testDir := h.SetupTestDir() |
| 176 | centralPath := h.WriteConfig(testDir, "central.yaml", centralCfg) |
| 177 | |
| 178 | node1Cfg := SimpleLocal("node-1", key1) |
| 179 | node1Cfg.DnsResolvers = []string{dnsIP + ":53"} |
| 180 | node1Path := h.WriteConfig(testDir, "node1.yaml", node1Cfg) |
nothing calls this directly
no test coverage detected