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.
The check was sitting at evaluation time, where it is useless. It needs to sit in the below-Raft code that actually computes the checksums. This flew under the radar for quite some time, but was found in: cockroachdb#37737 (comment) thanks to the aggressive consistency checks we run in version/mixed/nodes=3. Release note: None
- Loading branch information
Showing
7 changed files
with
216 additions
and
140 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,62 @@ | ||
// Copyright 2019 The Cockroach Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package storage | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/storage/batcheval" | ||
"github.com/cockroachdb/cockroach/pkg/storage/storagepb" | ||
"github.com/cockroachdb/cockroach/pkg/testutils" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/stop" | ||
"github.com/cockroachdb/cockroach/pkg/util/uuid" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestReplicaChecksumVersion(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
|
||
ctx := context.TODO() | ||
tc := testContext{} | ||
stopper := stop.NewStopper() | ||
defer stopper.Stop(ctx) | ||
tc.Start(t, stopper) | ||
|
||
testutils.RunTrueAndFalse(t, "matchingVersion", func(t *testing.T, matchingVersion bool) { | ||
cc := storagepb.ComputeChecksum{ | ||
ChecksumID: uuid.FastMakeV4(), | ||
Mode: roachpb.ChecksumMode_CHECK_FULL, | ||
} | ||
if matchingVersion { | ||
cc.Version = batcheval.ReplicaChecksumVersion | ||
} else { | ||
cc.Version = 1 | ||
} | ||
tc.repl.computeChecksumPostApply(ctx, cc) | ||
rc, err := tc.repl.getChecksum(ctx, cc.ChecksumID) | ||
if !matchingVersion { | ||
if !testutils.IsError(err, "no checksum found") { | ||
t.Fatal(err) | ||
} | ||
require.Nil(t, rc.Checksum) | ||
} else { | ||
require.NoError(t, err) | ||
require.NotNil(t, rc.Checksum) | ||
} | ||
}) | ||
} |
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
Oops, something went wrong.