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: conn_migration_test.go
    path of file: ./repos/cockroach/pkg/ccl/sqlproxyccl
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
//     https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package sqlproxyccl

import (
	"bytes"
	"context"
	"io"
	"net"
	"testing"
	"time"

	"github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/balancer"
	"github.com/cockroachdb/cockroach/pkg/ccl/sqlproxyccl/interceptor"
	"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirebase"
	"github.com/cockroachdb/cockroach/pkg/testutils"
	"github.com/cockroachdb/cockroach/pkg/util/leaktest"
	"github.com/cockroachdb/errors"
	"github.com/jackc/pgproto3/v2"
	"github.com/stretchr/testify/require"
)

func TestTransferContext(t *testing.T) {
	defer leaktest.AfterTest(t)()

	t.Run("new_context", func(t *testing.T) {
		ctx, cancel := newTransferContext(context.Background())
		defer cancel()

		require.True(t, ctx.isRecoverable())

		ctx.markRecoverable(false)
		require.False(t, ctx.isRecoverable())

		ctx.markRecoverable(true)
		require.True(t, ctx.isRecoverable())
	})

	t.Run("timeout", func(t *testing.T) {
		defer testutils.TestingHook(&defaultTransferTimeout, 2*time.Second)()

		ctx, cancel := newTransferContext(context.Background())
		defer cancel()

		require.Eventually(t, func() bool {
			return ctx.Err() != nil
		}, 5*time.Second, 100*time.Millisecond)
		require.True(t, ctx.isRecoverable())
	})
}

func TestForwarder_tryBeginTransfer(t *testing.T) {
	defer leaktest.AfterTest(t)()

	t.Run("not_initialized", func(t *testing.T) {
		defer testutils.TestingHook(&isSafeTransferPointLocked,
			func(req *processor, res *processor) bool {
				return false
			},
		)()

		f := &forwarder{}

		started, cleanupFn := f.tryBeginTransfer()
		require.False(t, started)
		require.Nil(t, cleanupFn)
	})

	t.Run("isTransferring=true", func(t *testing.T) {
		f := &forwarder{}
		f.m
    
func TestWaitForSmallRowDescription(t *testing.T) {
	defer leaktest.AfterTest(t)()
	ctx := context.Background()

	t.Run("context_cancelled", func(t *testing.T) {
		tCtx, cancel := context.WithCancel(ctx)
		cancel()

		err := waitForSmallRowDescription(tCtx, nil, nil, nil)
		require.EqualError(t, err, context.Canceled.Error())
	})

	t.Run("peek_error", func(t *testing.T) {
		r, w := net.Pipe()
		r.Close()
		w.Close()

		err := waitForSmallRowDescription(ctx, interceptor.NewFrontendConn(r), nil, nil)
		require.Regexp(t, "peeking message", err)
	})

	t.Run("ambiguous_error", func(t *testing.T) {
		r, w := net.Pipe()
		defer r.Close()
		defer w.Close()

		go func() {
			writeServerMsg(w, &pgproto3.ErrorResponse{})
		}()

		err := waitForSmallRowDescription(ctx, interceptor.NewFrontendConn(r), nil, nil)
		require.Regexp(t, "ambiguous ErrorResponse.*ErrorResponse", err)
	})

	t.Run("successful", func(t *testing.T) {
		serverProxy, server := net.Pipe()
		defer serverProxy.Close()
		defer server.Close()

		clientProxy, client := net.Pipe()
		defer clientProxy.Close()
		defer client.Close()

		go func() {
			// Not RowDescription.
			writeServerMsg(server, &pgproto3.BackendKeyData{ProcessID: 42})
			// Too large (> 4k bytes).
			writeServerMsg(server, &pgproto3.RowDescription{
				Fields: []pgproto3.FieldDescription{
					{Name: []byte("foo1")},
					{Name: make([]byte, 1<<13 /* 8K */)},
				},
			})
			// Mismatch.
			writeServerMsg(server, &pgproto3.RowDescription{
				Fields: []pgproto3.FieldDescription{
					{Name: []byte("foo2")},
					{Name: []byte("foo3")},
				},
			})
			// Match.
			writeServerMsg(server, &pgproto3.RowDescription{
				Fields: []pgproto3.FieldDescription{
					{Name: []byte("foo1")},
				},
			})
		}()

		msgCh := make(chan pgproto3.BackendMessage, 10)
		go func() {
			fi := interceptor.NewFrontendConn(client)
			for {
				msg, err := fi.ReadMsg()
				if err != nil {
					return
				}
				msgCh <- msg
			}
		}()

		err := waitForSmallRowDescription(
			ctx,
			interceptor.NewFrontendConn(serverProxy),
			clientProxy,
			func(m *pgproto3.RowDescription) bool {
				return len(m.Fields) == 1 && string(m.Fields[0].Name) == "foo1"
			},
		)
		require.Nil(t, err)

		// Verify that forwarding was correct.
		expectMsg(t, msgCh, `"Type":"BackendKeyData".*"ProcessID":42`)
		expectMsg(t, msgCh, `"Type":"RowDescription".*"Name":"foo1"`)
		expectMsg(t, msgCh, `"Type":"RowDescription".*"Name":"foo2".*"Name":"foo3"`)
	})
}