Feature: more robust updater DNS resolution
- Parallel resolver to resolve multiple hosts - Repeat resolver to repeat resolution for a single host - Additional parameters for fault toleration - Do not update servers if e.g. > 10% DNS resolutions failed - resolver package in updater package
This commit is contained in:
41
internal/updater/resolver/ips_test.go
Normal file
41
internal/updater/resolver/ips_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_uniqueIPsToSlice(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := map[string]struct {
|
||||
inputIPs map[string]struct{}
|
||||
outputIPs []net.IP
|
||||
}{
|
||||
"nil": {
|
||||
inputIPs: nil,
|
||||
outputIPs: []net.IP{},
|
||||
},
|
||||
"empty": {
|
||||
inputIPs: map[string]struct{}{},
|
||||
outputIPs: []net.IP{},
|
||||
},
|
||||
"single IPv4": {
|
||||
inputIPs: map[string]struct{}{"1.1.1.1": {}},
|
||||
outputIPs: []net.IP{{1, 1, 1, 1}},
|
||||
},
|
||||
"two IPv4s": {
|
||||
inputIPs: map[string]struct{}{"1.1.1.1": {}, "1.1.2.1": {}},
|
||||
outputIPs: []net.IP{{1, 1, 1, 1}, {1, 1, 2, 1}},
|
||||
},
|
||||
}
|
||||
for name, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
outputIPs := uniqueIPsToSlice(testCase.inputIPs)
|
||||
assert.Equal(t, testCase.outputIPs, outputIPs)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user