maedhroz commented on code in PR #2299:
URL: https://github.com/apache/cassandra/pull/2299#discussion_r1187647624


##########
test/unit/org/apache/cassandra/db/CorruptPrimaryIndexTest.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.cassandra.db;
+
+import org.junit.Test;
+
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.cql3.UntypedResultSet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class CorruptPrimaryIndexTest extends CQLTester.InMemory
+{
+    @Test
+    public void bigPrimaryIndexDoesNotDetectDiskCorruption()
+    {
+        // Set listener early, before the file is opened; mmap access can not 
be listened to, so need to observe the open, which happens on flush
+        fs.onPostRead(isCurrentTableIndexFile(keyspace()), (path, channel, 
position, dst, read) -> {
+            // Reading the Primary index for the test!
+            // format
+            // 2 bytes: length of bytes for PK
+            // 4 bytes: pk as an int32
+            // variable bytes (see 
org.apache.cassandra.io.sstable.format.big.RowIndexEntry.IndexSerializer.deserialize(org.apache.cassandra.io.util.FileDataInput))
+            assertThat(position).describedAs("Unexpected access, should start 
read from start of file").isEqualTo(0);
+
+            // simulate bit rot by having 1 byte change... but make sure its 
the pk!

Review Comment:
   ```suggestion
               // simulate bit rot by having 1 byte change... but make sure 
it's the pk!
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to