mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add test for dns options
Validate that passing an option into the daemon config does not corrupt the option set into the container resolv.conf Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
This commit is contained in:
parent
78627b6f14
commit
e4f3bcb696
1 changed files with 24 additions and 0 deletions
|
@ -4,6 +4,8 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/docker/libnetwork/resolvconf"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -43,3 +45,25 @@ func TestCleanupServiceDiscovery(t *testing.T) {
|
||||||
t.Fatalf("Service record not cleaned correctly:%v", c.(*controller).svcRecords)
|
t.Fatalf("Service record not cleaned correctly:%v", c.(*controller).svcRecords)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDNSOptions(t *testing.T) {
|
||||||
|
c, err := New()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
sb, err := c.(*controller).NewSandbox("cnt1", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
defer sb.Delete()
|
||||||
|
sb.(*sandbox).startResolver(false)
|
||||||
|
|
||||||
|
sb.(*sandbox).config.dnsOptionsList = []string{"ndots:5"}
|
||||||
|
err = sb.(*sandbox).setupDNS()
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = sb.(*sandbox).rebuildDNS()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
currRC, err := resolvconf.GetSpecific(sb.(*sandbox).config.resolvConfPath)
|
||||||
|
require.NoError(t, err)
|
||||||
|
dnsOptionsList := resolvconf.GetOptions(currRC.Content)
|
||||||
|
assert.Equal(t, 1, len(dnsOptionsList), "There should be only 1 option instead:", dnsOptionsList)
|
||||||
|
assert.Equal(t, "ndots:0", dnsOptionsList[0], "The option must be ndots:0 instead:", dnsOptionsList[0])
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue