Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin committed Jun 2, 2022
1 parent 0b6b475 commit 4790781
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/networkservice/chains/nsmgr/vl3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux
// +build linux

package nsmgr_test

import (
Expand All @@ -37,6 +40,7 @@ import (
)

func Test_NSC_ConnectsTo_vl3NSE(t *testing.T) {

t.Cleanup(func() { goleak.VerifyNone(t) })

ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
Expand Down Expand Up @@ -65,14 +69,14 @@ func Test_NSC_ConnectsTo_vl3NSE(t *testing.T) {
nseReg,
sandbox.GenerateTestToken,
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}.")),
vl3dns.NewServer(ctx, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."), vl3dns.WithDNSPort(40053)),
)

resolver := net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
var dialer net.Dialer
return dialer.DialContext(ctx, network, "127.0.0.1:53")
return dialer.DialContext(ctx, network, "127.0.0.1:40053")
},
}

Expand Down Expand Up @@ -135,7 +139,7 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) {

records.Store("nsc1.vl3.", []net.IP{net.ParseIP("1.1.1.1")})

dnsutils.ListenAndServe(ctx, dnsServer, ":53")
dnsutils.ListenAndServe(ctx, dnsServer, ":40053")

nsRegistryClient := domain.NewNSRegistryClient(ctx, sandbox.GenerateTestToken)

Expand All @@ -156,7 +160,7 @@ func Test_vl3NSE_ConnectsTo_vl3NSE(t *testing.T) {
vl3.NewServer(ctx, serverPrefixCh),
vl3dns.NewServer(ctx, vl3dns.WithDomainSchemes("{{ index .Labels \"podName\" }}.{{ .NetworkService }}."), vl3dns.WithDNSListenAndServeFunc(func(ctx context.Context, handler dnsutils.Handler, listenOn string) {
dnsutils.ListenAndServe(ctx, handler, ":50053")
})),
}), vl3dns.WithDNSPort(40053)),
)

resolver := net.Resolver{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,10 @@ func WithDNSListenAndServeFunc(listenAndServeDNS func(ctx context.Context, handl
vd.listenAndServeDNS = listenAndServeDNS
}
}

// WithDNSPort replaces default dns port for the inner dns server.
func WithDNSPort(dnsPort int) Option {
return func(vd *vl3DNSServer) {
vd.dnsPort = dnsPort
}
}

0 comments on commit 4790781

Please sign in to comment.