-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for set and map type state resharding
- Loading branch information
Showing
10 changed files
with
141 additions
and
22 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
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
47 changes: 47 additions & 0 deletions
47
hollow/src/test/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadStateTest.java
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,47 @@ | ||
package com.netflix.hollow.core.read.engine.map; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
import com.netflix.hollow.core.read.engine.HollowTypeReshardingStrategy; | ||
import java.util.Random; | ||
import org.junit.Test; | ||
|
||
public class HollowMapTypeReadStateTest extends AbstractHollowMapTypeDataElementsSplitJoinTest { | ||
|
||
@Test | ||
public void testResharding() throws Exception { | ||
|
||
for (int shardingFactor : new int[]{2, 4, 8, 16}) // , 32, 64, 128, 256, 512, 1024 | ||
{ | ||
for(int numRecords=1;numRecords<=10000;numRecords+=new Random().nextInt(1000)) | ||
{ | ||
int[][][] listContents = generateListContents(numRecords); | ||
HollowMapTypeReadState mapTypeReadState = populateTypeStateWith(listContents); | ||
assertDataUnchanged(mapTypeReadState, listContents); | ||
HollowTypeReshardingStrategy reshardingStrategy = HollowTypeReshardingStrategy.getInstance(mapTypeReadState); | ||
|
||
// Splitting shards | ||
{ | ||
int prevShardCount = mapTypeReadState.numShards(); | ||
int newShardCount = shardingFactor * prevShardCount; | ||
reshardingStrategy.reshard(mapTypeReadState, mapTypeReadState.numShards(), newShardCount); | ||
|
||
assertEquals(newShardCount, mapTypeReadState.numShards()); | ||
assertEquals(newShardCount, shardingFactor * prevShardCount); | ||
} | ||
assertDataUnchanged(mapTypeReadState, listContents); | ||
|
||
// Joining shards | ||
{ | ||
int prevShardCount = mapTypeReadState.numShards(); | ||
int newShardCount = prevShardCount / shardingFactor; | ||
reshardingStrategy.reshard(mapTypeReadState, mapTypeReadState.numShards(), newShardCount); | ||
|
||
assertEquals(newShardCount, mapTypeReadState.numShards()); | ||
assertEquals(shardingFactor * newShardCount, prevShardCount); | ||
} | ||
assertDataUnchanged(mapTypeReadState, listContents); | ||
} | ||
} | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
hollow/src/test/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadStateTest.java
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,47 @@ | ||
package com.netflix.hollow.core.read.engine.set; | ||
|
||
import static junit.framework.TestCase.assertEquals; | ||
|
||
import com.netflix.hollow.core.read.engine.HollowTypeReshardingStrategy; | ||
import java.util.Random; | ||
import org.junit.Test; | ||
|
||
public class HollowSetTypeReadStateTest extends AbstractHollowSetTypeDataElementsSplitJoinTest { | ||
|
||
@Test | ||
public void testResharding() throws Exception { | ||
|
||
for (int shardingFactor : new int[]{2, 4, 8, 16}) // , 32, 64, 128, 256, 512, 1024 | ||
{ | ||
for(int numRecords=1;numRecords<=1000;numRecords+=new Random().nextInt(100)) | ||
{ | ||
int[][] listContents = generateListContents(numRecords); | ||
HollowSetTypeReadState setTypeReadState = populateTypeStateWith(listContents); | ||
assertDataUnchanged(setTypeReadState, listContents); | ||
HollowTypeReshardingStrategy reshardingStrategy = HollowTypeReshardingStrategy.getInstance(setTypeReadState); | ||
|
||
// Splitting shards | ||
{ | ||
int prevShardCount = setTypeReadState.numShards(); | ||
int newShardCount = shardingFactor * prevShardCount; | ||
reshardingStrategy.reshard(setTypeReadState, setTypeReadState.numShards(), newShardCount); | ||
|
||
assertEquals(newShardCount, setTypeReadState.numShards()); | ||
assertEquals(newShardCount, shardingFactor * prevShardCount); | ||
} | ||
assertDataUnchanged(setTypeReadState, listContents); | ||
|
||
// Joining shards | ||
{ | ||
int prevShardCount = setTypeReadState.numShards(); | ||
int newShardCount = prevShardCount / shardingFactor; | ||
reshardingStrategy.reshard(setTypeReadState, setTypeReadState.numShards(), newShardCount); | ||
|
||
assertEquals(newShardCount, setTypeReadState.numShards()); | ||
assertEquals(shardingFactor * newShardCount, prevShardCount); | ||
} | ||
assertDataUnchanged(setTypeReadState, listContents); | ||
} | ||
} | ||
} | ||
} |