From a9014e795052012fdfb4a35a8a276eeea852dfbe Mon Sep 17 00:00:00 2001 From: kelmenhorst <45046038+kelmenhorst@users.noreply.github.com> Date: Fri, 20 Aug 2021 16:09:21 +0200 Subject: [PATCH] cli: websteps: fix DNSDo (#447) This fixes an inattention bug in the websteps code. --- internal/engine/experiment/websteps/control.go | 4 ++-- internal/engine/experiment/websteps/dns.go | 4 ++-- internal/engine/experiment/websteps/websteps.go | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/engine/experiment/websteps/control.go b/internal/engine/experiment/websteps/control.go index 4db7d7b..da3fc9b 100644 --- a/internal/engine/experiment/websteps/control.go +++ b/internal/engine/experiment/websteps/control.go @@ -11,7 +11,7 @@ import ( // Control performs the control request and returns the response. func Control( ctx context.Context, sess model.ExperimentSession, - thAddr string, creq CtrlRequest) (out CtrlResponse, err error) { + thAddr string, resourcePath string, creq CtrlRequest) (out CtrlResponse, err error) { clnt := httpx.Client{ BaseURL: thAddr, HTTPClient: sess.DefaultHTTPClient(), @@ -19,7 +19,7 @@ func Control( } // make sure error is wrapped err = errorsx.SafeErrWrapperBuilder{ - Error: clnt.PostJSON(ctx, "/", creq, &out), + Error: clnt.PostJSON(ctx, resourcePath, creq, &out), Operation: errorsx.TopLevelOperation, }.MaybeBuild() return diff --git a/internal/engine/experiment/websteps/dns.go b/internal/engine/experiment/websteps/dns.go index 00b298f..80615e9 100644 --- a/internal/engine/experiment/websteps/dns.go +++ b/internal/engine/experiment/websteps/dns.go @@ -20,8 +20,8 @@ func DNSDo(ctx context.Context, config DNSConfig) ([]string, error) { if resolver == nil { childResolver, err := netx.NewDNSClient(netx.Config{Logger: log.Log}, "doh://google") runtimex.PanicOnError(err, "NewDNSClient failed") - var resolver netxlite.Resolver = childResolver + resolver = childResolver resolver = &netxlite.ResolverIDNA{Resolver: resolver} } - return config.Resolver.LookupHost(ctx, config.Domain) + return resolver.LookupHost(ctx, config.Domain) } diff --git a/internal/engine/experiment/websteps/websteps.go b/internal/engine/experiment/websteps/websteps.go index 2cd285e..c5c412a 100644 --- a/internal/engine/experiment/websteps/websteps.go +++ b/internal/engine/experiment/websteps/websteps.go @@ -110,6 +110,7 @@ func (m Measurer) Run( addrs, err := DNSDo(ctx, DNSConfig{Domain: URL.Hostname()}) endpoints := makeEndpoints(addrs, URL) // 3. Find the testhelper + // TODO(kelmenhorst,bassosimone): this is not used at the moment, but the hardcoded local address testhelpers, _ := sess.GetTestHelpersByName("web-connectivity") var testhelper *model.Service for _, th := range testhelpers { @@ -125,7 +126,8 @@ func (m Measurer) Run( "backend": testhelper, } // 4. Query the testhelper - resp, err := Control(ctx, sess, testhelper.Address, CtrlRequest{ + // TODO(kelmenhorst,bassosimone): remove hardcoded version here, this is only for testing purposes + resp, err := Control(ctx, sess, "http://localhost:8080", "/api/unstable/websteps", CtrlRequest{ URL: URL.String(), Headers: map[string][]string{ "Accept": {httpheader.Accept()},