Skip to content

Commit

Permalink
CNDB-11434: Refactor tests to mitigate https://openjdk.org/jeps/416 (#…
Browse files Browse the repository at this point in the history
…1386)

* CNDB-11434: Refactor TrieMemtableIndexTest

* CNDB-11434: Refactor TinySegmentFlushingFailureTest

* CNDB-11434: Make all tests in TrieMemtableIndexTest to be run with both offheap and onheap to improve test coverage
  • Loading branch information
ekaterinadimitrova2 authored Oct 30, 2024
1 parent 5ae9066 commit f9e44c8
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 364 deletions.
4 changes: 4 additions & 0 deletions test/unit/org/apache/cassandra/cql3/CQLTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
Expand Down Expand Up @@ -2449,6 +2450,7 @@ protected static Gauge<Integer> getPausedConnectionsGauge()
return metrics.get(metricName);
}

@Ignore // Check TinySegmentFlushingFailureTest for details why this annotation is needed here despite this is not a test
public static class Vector<T> extends AbstractList<T>
{
private final T[] values;
Expand Down Expand Up @@ -2656,6 +2658,7 @@ public String toString()
}
}

@Ignore // Check TinySegmentFlushingFailureTest for details why this annotation is needed here despite this is not a test
public static class Randomization
{
private long seed;
Expand Down Expand Up @@ -2752,6 +2755,7 @@ public void nextBytes(byte[] bytes)
}
}

@Ignore // Check TinySegmentFlushingFailureTest for details why this annotation is needed here despite this is not a test
public static class FailureWatcher extends TestWatcher
{
@Override
Expand Down
15 changes: 0 additions & 15 deletions test/unit/org/apache/cassandra/index/sai/SAITester.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,21 +848,6 @@ protected Set<File> componentFiles(Collection<File> indexFiles, IndexComponentTy
return indexFiles.stream().filter(c -> c.name().endsWith(componentName)).collect(Collectors.toSet());
}

protected static void setSegmentWriteBufferSpace(final int segmentSize) throws Exception
{
NamedMemoryLimiter limiter = (NamedMemoryLimiter) V1OnDiskFormat.class.getDeclaredField("SEGMENT_BUILD_MEMORY_LIMITER").get(null);
Field limitBytes = limiter.getClass().getDeclaredField("limitBytes");
limitBytes.setAccessible(true);
Field modifiersField = ReflectionUtils.getField(Field.class, "modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(limitBytes, limitBytes.getModifiers() & ~Modifier.FINAL);
limitBytes.set(limiter, segmentSize);
limitBytes = V1OnDiskFormat.class.getDeclaredField("SEGMENT_BUILD_MEMORY_LIMIT");
limitBytes.setAccessible(true);
modifiersField.setInt(limitBytes, limitBytes.getModifiers() & ~Modifier.FINAL);
limitBytes.set(limiter, segmentSize);
}

/**
* Run repeated verification task concurrently with target test
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.index.sai.memory;

import org.junit.BeforeClass;

import org.apache.cassandra.config.Config;
import org.apache.cassandra.db.memtable.TrieMemtable;
import org.apache.cassandra.io.compress.BufferType;

import static org.junit.Assert.assertEquals;

public class TrieMemtableIndexAllocationsHeapBuffersTest extends TrieMemtableIndexTestBase
{
@BeforeClass
public static void setUpClass()
{
System.setProperty("cassandra.trie.memtable.shard.count", "8");
setup(Config.MemtableAllocationType.heap_buffers);
assertEquals(TrieMemtable.BUFFER_TYPE, BufferType.ON_HEAP);
}
}
Loading

0 comments on commit f9e44c8

Please sign in to comment.