Ver código fonte

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>
Flavio Crisciani 7 anos atrás
pai
commit
e4f3bcb696
1 arquivos alterados com 24 adições e 0 exclusões
  1. 24 0
      libnetwork/service_common_test.go

+ 24 - 0
libnetwork/service_common_test.go

@@ -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])
+}