git » dnss » commit c95a73e

test: Move /debug/flags test to external.sh

author Alberto Bertogli
2019-06-22 00:51:10 UTC
committer Alberto Bertogli
2019-06-22 00:51:10 UTC
parent b46dad83a09479f68390c7ad41166c9d5222304e

test: Move /debug/flags test to external.sh

Today, we test /debug/flags via a Go test. Unfortunately it's
technically inherently racy, since we need to modify the flags after
they've been parsed. Normally this doesn't manifest, but upcoming Go
versions will make the race detector catch this.

Instead of doing hacky things to try to work around the detector, this
patch moves the test to the external test suite, where it's also more
end to end.

dnss_test.go +0 -11
tests/external.sh +11 -1

diff --git a/dnss_test.go b/dnss_test.go
index f70e059..971cd7b 100644
--- a/dnss_test.go
+++ b/dnss_test.go
@@ -7,7 +7,6 @@ import (
 	"net/http"
 	"net/url"
 	"os"
-	"strings"
 	"sync"
 	"testing"
 
@@ -241,16 +240,6 @@ func TestProxyServerDomain(t *testing.T) {
 	}
 }
 
-func TestDumpFlags(t *testing.T) {
-	flag.Parse()
-	flag.Set("https_upstream", "https://montoto/xyz")
-
-	f := dumpFlags()
-	if !strings.Contains(f, "-https_upstream=https://montoto/xyz\n") {
-		t.Errorf("Flags string missing canary value: %v", f)
-	}
-}
-
 func TestMonitoringServer(t *testing.T) {
 	addr := testutil.GetFreePort()
 	launchMonitoringServer(addr)
diff --git a/tests/external.sh b/tests/external.sh
index fd80ec6..902c32f 100755
--- a/tests/external.sh
+++ b/tests/external.sh
@@ -86,7 +86,7 @@ function resolve() {
 function get() {
 	URL=$1
 
-	wget -O/dev/null $URL > .wget.log 2>&1
+	wget -O.wget.out $URL > .wget.log 2>&1
 }
 
 echo "## Misc"
@@ -106,6 +106,16 @@ mv .dnss.log .dnss.http.log
 
 wait_until_ready tcp 1999
 
+echo "## Checking /debug/flags"
+if ! get "http://localhost:1900/debug/flags"; then
+	echo "Failed to get /debug/flags"
+	exit 1
+fi
+if ! grep -q "testing__insecure_http=true" .wget.out; then
+	echo "/debug/flags did not contain expected flags (see .wget.out)"
+	exit 1
+fi
+
 echo "## Autodetect against dnss"
 dnss -enable_dns_to_https -dns_listen_addr "localhost:1053" \
 	-testing__insecure_http \