Example #1
0
// realMain is the real main function, which returns the value to pass to
// os.Exit(). We have to do this so we can use defer.
func realMain(m *testing.M) int {
	flag.Parse()
	defer glog.Flush()

	DNSAddr = util.GetFreePort()

	// Test http server.
	httpsrv := httptest.NewServer(http.HandlerFunc(DNSHandler))

	// DNS to HTTPS server.
	r := dnstox.NewHTTPSResolver(httpsrv.URL, "")
	dth := dnstox.New(DNSAddr, r, "")
	go dth.ListenAndServe()

	// Wait for the servers to start up.
	err := util.WaitForDNSServer(DNSAddr)
	if err != nil {
		fmt.Printf("Error waiting for the test servers to start: %v\n", err)
		fmt.Printf("Check the INFO logs for more details\n")
		return 1
	}

	return m.Run()
}
Example #2
0
func init() {
	dnsToGrpcAddr = util.GetFreePort()
	grpcToDnsAddr = util.GetFreePort()
	dnsSrvAddr = util.GetFreePort()
}