Skip to content

Commit

Permalink
Add test for dns options
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Flavio Crisciani committed Oct 23, 2017
1 parent 2c75c71 commit 4cc7af5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions service_common_test.go
Expand Up @@ -4,6 +4,9 @@ import (
"net"
"testing"

"github.com/Sirupsen/logrus"
"github.com/docker/libnetwork/resolvconf"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -43,3 +46,26 @@ func TestCleanupServiceDiscovery(t *testing.T) {
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)
logrus.Errorf("%s", dnsOptionsList)
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])
}

0 comments on commit 4cc7af5

Please sign in to comment.