forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
57650: migration: introduce various other bells and whistles... r=irfansharif a=irfansharif ...to pave the way for real migrations This PR cannibalizes most of our prototype in cockroachdb#57445 and shimmies in a few interfaces to make it all unit-testable. While here, we: - parallelize the execution of the EveryNode primitive - introduce the IterateRangeDescriptors primitive - re-write the migration registration process for better ergonomics - introduce a more structured Migration type, to annotate it with migration specific metadata (it also paves the way for logging the progress of an ongoing migration to a system table). See individual commits for details. 58036: roachtest: add test_9_6_diagnostics to psycopg blocklist r=rafiss a=arulajmani Previously, this test was skipped as our pg server version (9.5) did not meet the threshold (9.6) for this test to run. After the pg server version bump to 13 this is no longer the case. A change to explicitly skip this test for CRDB has been merged upstream, but it won't apply until the next release (psycopg_2_8_7) comes out and we switch to testing against that. Until then, this test lives in the blocklist. Closes cockroachdb#57986 Release note: None Co-authored-by: irfan sharif <[email protected]> Co-authored-by: arulajmani <[email protected]>
- Loading branch information
Showing
13 changed files
with
1,007 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
package migration_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/clusterversion" | ||
"github.com/cockroachdb/cockroach/pkg/kv/kvserver" | ||
"github.com/cockroachdb/cockroach/pkg/migration" | ||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/sql/tests" | ||
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
) | ||
|
||
func TestHelperIterateRangeDescriptors(t *testing.T) { | ||
defer leaktest.AfterTest(t) | ||
|
||
cv := clusterversion.ClusterVersion{} | ||
ctx := context.Background() | ||
const numNodes = 1 | ||
|
||
params, _ := tests.CreateTestServerParams() | ||
server, _, kvDB := serverutils.StartServer(t, params) | ||
defer server.Stopper().Stop(context.Background()) | ||
|
||
var numRanges int | ||
if err := server.GetStores().(*kvserver.Stores).VisitStores(func(s *kvserver.Store) error { | ||
numRanges = s.ReplicaCount() | ||
return nil | ||
}); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
c := migration.TestingNewCluster(numNodes, migration.TestingWithKV(kvDB)) | ||
h := migration.TestingNewHelper(c, cv) | ||
|
||
for _, blockSize := range []int{1, 5, 10, 50} { | ||
var numDescs int | ||
init := func() { numDescs = 0 } | ||
if err := h.IterateRangeDescriptors(ctx, blockSize, init, func(descriptors ...roachpb.RangeDescriptor) error { | ||
numDescs += len(descriptors) | ||
return nil | ||
}); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if numDescs != numRanges { | ||
t.Fatalf("expected to find %d ranges, found %d", numRanges+1, numDescs) | ||
} | ||
} | ||
} |
Oops, something went wrong.