internal: add do-not-insert-new-documentation to tests

All tests that affect the documentation table are updated so that
experiment do-not-insert-new-documentation is active.

Change-Id: I3672a7b18e50bc1cbe4820efe0e6e13ff9687596
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/310811
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
diff --git a/internal/frontend/fetch_test.go b/internal/frontend/fetch_test.go
index 4023753..f3af66c 100644
--- a/internal/frontend/fetch_test.go
+++ b/internal/frontend/fetch_test.go
@@ -14,6 +14,7 @@
 	"github.com/google/go-cmp/cmp"
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/postgres"
 	"golang.org/x/pkgsite/internal/proxy"
 	"golang.org/x/pkgsite/internal/testing/sample"
@@ -79,10 +80,11 @@
 		},
 	} {
 		t.Run(test.name, func(t *testing.T) {
-			s, _, teardown := newTestServer(t, testModulesForProxy, nil)
+			s, _, teardown := newTestServer(t, testModulesForProxy, nil, internal.ExperimentDoNotInsertNewDocumentation)
 			defer teardown()
 
 			ctx, cancel := context.WithTimeout(context.Background(), testFetchTimeout)
+			ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 			defer cancel()
 
 			status, responseText := s.fetchAndPoll(ctx, s.getDataSource(ctx), testModulePath, test.fullPath, test.version)
@@ -141,9 +143,10 @@
 				test.fetchTimeout = testFetchTimeout
 			}
 			ctx, cancel := context.WithTimeout(context.Background(), test.fetchTimeout)
+			ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 			defer cancel()
 
-			s, _, teardown := newTestServer(t, testModulesForProxy, nil)
+			s, _, teardown := newTestServer(t, testModulesForProxy, nil, internal.ExperimentDoNotInsertNewDocumentation)
 			defer teardown()
 			got, err := s.fetchAndPoll(ctx, s.getDataSource(ctx), test.modulePath, test.fullPath, test.version)
 
diff --git a/internal/frontend/versions_test.go b/internal/frontend/versions_test.go
index 8ae465a..a5c5f5b 100644
--- a/internal/frontend/versions_test.go
+++ b/internal/frontend/versions_test.go
@@ -161,7 +161,10 @@
 	} {
 		t.Run(tc.name, func(t *testing.T) {
 			ctx, cancel := context.WithTimeout(context.Background(), testTimeout*2)
-			ctx = experiment.NewContext(ctx, internal.ExperimentSymbolHistoryVersionsPage)
+			ctx = experiment.NewContext(ctx,
+				internal.ExperimentDoNotInsertNewDocumentation,
+				internal.ExperimentSymbolHistoryVersionsPage,
+			)
 			defer cancel()
 			defer postgres.ResetTestDB(testDB, t)
 
diff --git a/internal/postgres/insert_module_test.go b/internal/postgres/insert_module_test.go
index 6478f16..977a90e 100644
--- a/internal/postgres/insert_module_test.go
+++ b/internal/postgres/insert_module_test.go
@@ -24,6 +24,7 @@
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/database"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/licenses"
 	"golang.org/x/pkgsite/internal/source"
 	"golang.org/x/pkgsite/internal/stdlib"
@@ -208,6 +209,7 @@
 func TestInsertModuleErrors(t *testing.T) {
 	t.Parallel()
 	ctx := context.Background()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 
 	testCases := []struct {
 		name string
@@ -366,6 +368,7 @@
 	testDB, release := acquire(t)
 	defer release()
 	ctx := context.Background()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 
 	// These tests are cumulative: actions of earlier tests may affect later ones.
 	for _, test := range []struct {
diff --git a/internal/postgres/symbol_test.go b/internal/postgres/symbol_test.go
index 7c713c5..b87a6fc 100644
--- a/internal/postgres/symbol_test.go
+++ b/internal/postgres/symbol_test.go
@@ -12,6 +12,7 @@
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"golang.org/x/pkgsite/internal"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/testing/sample"
 )
 
@@ -304,6 +305,7 @@
 	if err != nil {
 		t.Fatal(err)
 	}
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	buildToSymbols, err := getUnitSymbols(ctx, testDB.db, unitID)
 	if err != nil {
 		t.Fatal(err)
@@ -336,6 +338,7 @@
 func comparePackageSymbols(ctx context.Context, t *testing.T, testDB *DB,
 	path, modulePath, version string, want map[string]map[string]*internal.UnitSymbol) {
 	t.Helper()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	got, err := testDB.GetPackageSymbols(ctx, path, modulePath)
 	if err != nil {
 		t.Fatal(err)
diff --git a/internal/postgres/test_helper.go b/internal/postgres/test_helper.go
index 2c359fa..96772fe 100644
--- a/internal/postgres/test_helper.go
+++ b/internal/postgres/test_helper.go
@@ -20,6 +20,7 @@
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/database"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/testing/dbtest"
 	"golang.org/x/pkgsite/internal/testing/sample"
 	"golang.org/x/pkgsite/internal/testing/testhelper"
@@ -207,6 +208,7 @@
 
 func MustInsertModuleGoMod(ctx context.Context, t *testing.T, db *DB, m *internal.Module, goMod string) {
 	t.Helper()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	var lmv *internal.LatestModuleVersions
 	if goMod == "-" {
 		if err := db.UpdateLatestModuleVersionsStatus(ctx, m.ModulePath, 404); err != nil {
diff --git a/internal/testing/integration/fetch_test.go b/internal/testing/integration/fetch_test.go
index d42603b..7d8aead 100644
--- a/internal/testing/integration/fetch_test.go
+++ b/internal/testing/integration/fetch_test.go
@@ -10,6 +10,8 @@
 	"net/http"
 	"testing"
 
+	"golang.org/x/pkgsite/internal"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/postgres"
 )
 
@@ -19,7 +21,8 @@
 	// Add a module to the database.
 	// Check that GET of the module's path returns a 200.
 	ctx := context.Background()
-	q, teardown := setupQueue(ctx, t, testModules[:1])
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
+	q, teardown := setupQueue(ctx, t, testModules[:1], internal.ExperimentDoNotInsertNewDocumentation)
 	const modulePath = "example.com/basic"
 	defer teardown()
 	ts := setupFrontend(ctx, t, q, nil)
diff --git a/internal/testing/integration/frontend_main_test.go b/internal/testing/integration/frontend_main_test.go
index 6c4e4a5..ef1d0d1 100644
--- a/internal/testing/integration/frontend_main_test.go
+++ b/internal/testing/integration/frontend_main_test.go
@@ -26,7 +26,10 @@
 func TestFrontendMainPage(t *testing.T) {
 	defer postgres.ResetTestDB(testDB, t)
 
-	exps := []string{internal.ExperimentSymbolHistoryMainPage}
+	exps := []string{
+		internal.ExperimentSymbolHistoryMainPage,
+		internal.ExperimentDoNotInsertNewDocumentation,
+	}
 	processVersions(
 		experiment.NewContext(context.Background(), exps...),
 		t, testModules)
diff --git a/internal/testing/integration/frontend_versions_test.go b/internal/testing/integration/frontend_versions_test.go
index 0723af3..bfc4ea6 100644
--- a/internal/testing/integration/frontend_versions_test.go
+++ b/internal/testing/integration/frontend_versions_test.go
@@ -20,7 +20,10 @@
 func TestFrontendVersionsPage(t *testing.T) {
 	defer postgres.ResetTestDB(testDB, t)
 
-	exps := []string{internal.ExperimentSymbolHistoryVersionsPage}
+	exps := []string{
+		internal.ExperimentSymbolHistoryVersionsPage,
+		internal.ExperimentDoNotInsertNewDocumentation,
+	}
 	processVersions(
 		experiment.NewContext(context.Background(), exps...),
 		t, testModules)
diff --git a/internal/testing/integration/integration_test.go b/internal/testing/integration/integration_test.go
index 4c447ca..aee7b2a 100644
--- a/internal/testing/integration/integration_test.go
+++ b/internal/testing/integration/integration_test.go
@@ -18,6 +18,7 @@
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/safehtml/template"
 	"golang.org/x/pkgsite/internal"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/godoc/dochtml"
 	"golang.org/x/pkgsite/internal/index"
 	"golang.org/x/pkgsite/internal/middleware"
@@ -38,6 +39,7 @@
 
 func TestEndToEndProcessing(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
diff --git a/internal/testing/integration/worker_test.go b/internal/testing/integration/worker_test.go
index 3970063..0353b62 100644
--- a/internal/testing/integration/worker_test.go
+++ b/internal/testing/integration/worker_test.go
@@ -14,6 +14,7 @@
 	"github.com/alicebob/miniredis/v2"
 	"github.com/go-redis/redis/v8"
 	"github.com/google/safehtml/template"
+	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/cache"
 	"golang.org/x/pkgsite/internal/config"
 	"golang.org/x/pkgsite/internal/index"
@@ -35,10 +36,11 @@
 	}
 	// TODO: it would be better if InMemory made http requests
 	// back to worker, rather than calling fetch itself.
-	queue := queue.NewInMemory(ctx, 10, nil, func(ctx context.Context, mpath, version string) (int, error) {
-		code, _, err := fetcher.FetchAndUpdateState(ctx, mpath, version, "test")
-		return code, err
-	})
+	queue := queue.NewInMemory(ctx, 10, []string{internal.ExperimentDoNotInsertNewDocumentation},
+		func(ctx context.Context, mpath, version string) (int, error) {
+			code, _, err := fetcher.FetchAndUpdateState(ctx, mpath, version, "test")
+			return code, err
+		})
 
 	workerServer, err := worker.NewServer(&config.Config{}, worker.ServerConfig{
 		DB:               testDB,
diff --git a/internal/worker/fetch.go b/internal/worker/fetch.go
index e7ca98d..cef94a5 100644
--- a/internal/worker/fetch.go
+++ b/internal/worker/fetch.go
@@ -54,6 +54,7 @@
 func (f *Fetcher) FetchAndUpdateState(ctx context.Context, modulePath, requestedVersion, appVersionLabel string) (_ int, resolvedVersion string, err error) {
 	defer derrors.Wrap(&err, "FetchAndUpdateState(%q, %q, %q)", modulePath, requestedVersion, appVersionLabel)
 	tctx, span := trace.StartSpan(ctx, "FetchAndUpdateState")
+	fmt.Println(experiment.FromContext(ctx).Active())
 	ctx = experiment.NewContext(tctx, experiment.FromContext(ctx).Active()...)
 	ctx = log.NewContextWithLabel(ctx, "fetch", modulePath+"@"+requestedVersion)
 	if !utf8.ValidString(modulePath) {
diff --git a/internal/worker/fetch_test.go b/internal/worker/fetch_test.go
index 7bc45bf..87933ea 100644
--- a/internal/worker/fetch_test.go
+++ b/internal/worker/fetch_test.go
@@ -14,6 +14,7 @@
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"golang.org/x/pkgsite/internal"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/godoc"
 	"golang.org/x/pkgsite/internal/licenses"
 	"golang.org/x/pkgsite/internal/postgres"
@@ -40,6 +41,7 @@
 
 func TestFetchAndUpdateState(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	stdlib.UseTestData = true
@@ -373,6 +375,7 @@
 	// proxy can be set up with a small cache for the last downloaded zip. This
 	// test confirms that that feature works.
 	ctx := context.Background()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer postgres.ResetTestDB(testDB, t)
 	proxyServer := proxy.NewServer([]*proxy.Module{
 		{
@@ -416,6 +419,7 @@
 
 func TestFetchAndUpdateLatest(t *testing.T) {
 	ctx := context.Background()
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	prox, teardown := proxy.SetupTestClient(t, testModules)
 	defer teardown()
 
diff --git a/internal/worker/fetcherror_test.go b/internal/worker/fetcherror_test.go
index d875b6f..9330f34 100644
--- a/internal/worker/fetcherror_test.go
+++ b/internal/worker/fetcherror_test.go
@@ -18,6 +18,7 @@
 	"golang.org/x/mod/semver"
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/fetch"
 	"golang.org/x/pkgsite/internal/godoc"
 	"golang.org/x/pkgsite/internal/postgres"
@@ -31,6 +32,7 @@
 // we delete it from the database.
 func TestFetchAndUpdateState_NotFound(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	defer postgres.ResetTestDB(testDB, t)
 
@@ -92,6 +94,7 @@
 func TestFetchAndUpdateState_Excluded(t *testing.T) {
 	// Check that an excluded module is not processed, and is marked excluded in module_version_states.
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
@@ -108,6 +111,7 @@
 
 func TestFetchAndUpdateState_BadRequestedVersion(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
@@ -123,6 +127,7 @@
 func TestFetchAndUpdateState_Incomplete(t *testing.T) {
 	// Check that we store the special "incomplete" status in module_version_states.
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
@@ -150,6 +155,7 @@
 func TestFetchAndUpdateState_Mismatch(t *testing.T) {
 	// Check that an excluded module is not processed, and is marked excluded in module_version_states.
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
@@ -175,6 +181,7 @@
 	// Check that fetching an alternative module deletes all older versions of that
 	// module from search_documents (but not versions).
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 
 	defer postgres.ResetTestDB(testDB, t)
@@ -219,6 +226,7 @@
 
 func TestFetchAndUpdateState_SkipIncompletePackage(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	defer postgres.ResetTestDB(testDB, t)
 	badModule := map[string]string{
@@ -255,6 +263,7 @@
 	defer teardownProxy()
 
 	ctx, cancel := context.WithTimeout(context.Background(), 0)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	fetchAndCheckStatus(ctx, t, proxyClient, sample.ModulePath, sample.VersionString, http.StatusInternalServerError)
 }
@@ -263,6 +272,7 @@
 // that we automatically try to fetch it again later.
 func TestFetchAndUpdateState_ProxyTimedOut(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	defer postgres.ResetTestDB(testDB, t)
 
@@ -288,6 +298,7 @@
 // would otherwise exceed HTML size limit and not get shown at all.
 func TestTrimLargeCode(t *testing.T) {
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout*3)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	defer postgres.ResetTestDB(testDB, t)
 	trimmedModule := map[string]string{
diff --git a/internal/worker/refetch_test.go b/internal/worker/refetch_test.go
index 0b746dc..1088dea 100644
--- a/internal/worker/refetch_test.go
+++ b/internal/worker/refetch_test.go
@@ -14,6 +14,7 @@
 	"github.com/google/go-cmp/cmp/cmpopts"
 	"golang.org/x/pkgsite/internal"
 	"golang.org/x/pkgsite/internal/derrors"
+	"golang.org/x/pkgsite/internal/experiment"
 	"golang.org/x/pkgsite/internal/licenses"
 	"golang.org/x/pkgsite/internal/postgres"
 	"golang.org/x/pkgsite/internal/proxy"
@@ -28,6 +29,7 @@
 	// of the (fake) proxy, though in reality the most likely cause of changes to
 	// a version is updates to our data model or fetch logic.
 	ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
+	ctx = experiment.NewContext(ctx, internal.ExperimentDoNotInsertNewDocumentation)
 	defer cancel()
 	defer postgres.ResetTestDB(testDB, t)
 
diff --git a/internal/worker/server_test.go b/internal/worker/server_test.go
index 3b0609c..d09834d 100644
--- a/internal/worker/server_test.go
+++ b/internal/worker/server_test.go
@@ -182,10 +182,11 @@
 			f := &Fetcher{proxyClient, source.NewClient(sourceTimeout), testDB, nil}
 
 			// Use 10 workers to have parallelism consistent with the worker binary.
-			q := queue.NewInMemory(ctx, 10, nil, func(ctx context.Context, mpath, version string) (int, error) {
-				code, _, err := f.FetchAndUpdateState(ctx, mpath, version, "")
-				return code, err
-			})
+			q := queue.NewInMemory(ctx, 10, []string{internal.ExperimentDoNotInsertNewDocumentation},
+				func(ctx context.Context, mpath, version string) (int, error) {
+					code, _, err := f.FetchAndUpdateState(ctx, mpath, version, "")
+					return code, err
+				})
 
 			s, err := NewServer(&config.Config{}, ServerConfig{
 				DB:           testDB,