You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: doh_internal_test.go
    path of file: ./repos/dnsproxy/upstream
    
    the code of the file until where you have to start completion: package upstream

import (
	"context"
	"crypto/tls"
	"crypto/x509"
	"encodin
    
func TestUpstreamDoH_serverRestart(t *testing.T) {
	testCases := []struct {
		name         string
		httpVersions []HTTPVersion
	}{
		{
			name:         "http2",
			httpVersions: []HTTPVersion{HTTPVersion11, HTTPVersion2},
		},
		{
			name:         "http3",
			httpVersions: []HTTPVersion{HTTPVersion3},
		},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			// Run the first server instance.
			srv := startDoHServer(t, testDoHServerOptions{
				http3Enabled: true,
			})

			// Create a DNS-over-HTTPS upstream.
			address := fmt.Sprintf("https://%s/dns-query", srv.addr)
			u, err := AddressToUpstream(
				address,
				&Options{
					InsecureSkipVerify: true,
					HTTPVersions:       tc.httpVersions,
					Timeout:            time.Second,
				},
			)
			require.NoError(t, err)
			testutil.CleanupAndRequireSuccess(t, u.Close)

			// Test that the upstream works properly.
			checkUpstream(t, u, address)

			// Now let's restart the server on the same address.
			_, portStr, err := net.SplitHostPort(srv.addr)
			require.NoError(t, err)
			port, err := strconv.Atoi(portStr)
			require.NoError(t, err)

			// Shutdown the first server.
			srv.Shutdown()

			// Start the new one on the same port.
			srv = startDoHServer(t, testDoHServerOptions{
				http3Enabled: true,
				port:         port,
			})

			// Check that everything works after restart.
			checkUpstream(t, u, address)

			// Stop the server again.
			srv.Shutdown()

			// Now try to send a message and make sure that it returns an error.
			_, err = u.Exchange(createTestMessage())
			require.Error(t, err)

			// Start the server one more time.
			srv = startDoHServer(t, testDoHServerOptions{
				http3Enabled: true,
				port:         port,
			})
			defer srv.Shutdown()

			// Check that everything works after the second restart.
			checkUpstream(t, u, address)
		})
	}
}