diff options
author | OszkarSemerath <semerath@mit.bme.hu> | 2023-02-14 00:46:26 +0100 |
---|---|---|
committer | OszkarSemerath <semerath@mit.bme.hu> | 2023-02-14 00:46:26 +0100 |
commit | 189d1181052fc014830ac53d0090d7f3cfbc36aa (patch) | |
tree | 8debeae513ca334993a16bb96995b687a64b5333 /subprojects/store/src | |
parent | Test environment cannot rely upon the order of elements in a map since Versio... (diff) | |
download | refinery-189d1181052fc014830ac53d0090d7f3cfbc36aa.tar.gz refinery-189d1181052fc014830ac53d0090d7f3cfbc36aa.tar.zst refinery-189d1181052fc014830ac53d0090d7f3cfbc36aa.zip |
Fuzz test environment is parametrized by VersionedMapStoreBuilder configurations
Diffstat (limited to 'subprojects/store/src')
10 files changed, 161 insertions, 135 deletions
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java index b61152f5..14a9e2e0 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java | |||
@@ -11,10 +11,8 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
11 | import org.junit.jupiter.params.provider.Arguments; | 11 | import org.junit.jupiter.params.provider.Arguments; |
12 | import org.junit.jupiter.params.provider.MethodSource; | 12 | import org.junit.jupiter.params.provider.MethodSource; |
13 | 13 | ||
14 | import tools.refinery.store.map.ContinousHashProvider; | ||
15 | import tools.refinery.store.map.VersionedMapStore; | 14 | import tools.refinery.store.map.VersionedMapStore; |
16 | import tools.refinery.store.map.VersionedMapStoreImpl; | 15 | import tools.refinery.store.map.VersionedMapStoreBuilder; |
17 | import tools.refinery.store.map.internal.VersionedMapImpl; | ||
18 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 16 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
19 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 17 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
20 | 18 | ||
@@ -23,13 +21,11 @@ import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; | |||
23 | class CommitFuzzTest { | 21 | class CommitFuzzTest { |
24 | 22 | ||
25 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 23 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, |
26 | boolean nullDefault, int commitFrequency, | 24 | boolean nullDefault, int commitFrequency, VersionedMapStoreBuilder<Integer, String> builder) { |
27 | boolean evilHash) { | ||
28 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 25 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
29 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
30 | 26 | ||
31 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<>(chp, values[0]); | 27 | VersionedMapStore<Integer, String> store = builder.setDefaultValue(values[0]).buildOne(); |
32 | VersionedMapImpl<Integer, String> sut = (VersionedMapImpl<Integer, String>) store.createMap(); | 28 | var sut = store.createMap(); |
33 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<>(sut); | 29 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<>(sut); |
34 | 30 | ||
35 | Random r = new Random(seed); | 31 | Random r = new Random(seed); |
@@ -52,37 +48,37 @@ class CommitFuzzTest { | |||
52 | } | 48 | } |
53 | MapTestEnvironment.printStatus(scenario, index, steps, null); | 49 | MapTestEnvironment.printStatus(scenario, index, steps, null); |
54 | if (index % commitFrequency == 0) { | 50 | if (index % commitFrequency == 0) { |
55 | e.sut.commit(); | 51 | e.commit(); |
56 | } | 52 | } |
57 | } | 53 | } |
58 | } | 54 | } |
59 | 55 | ||
60 | @ParameterizedTest(name = "Commit {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5} " + | 56 | public static final String title = "Commit {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5} " + |
61 | "seed={6} evil-hash={7}") | 57 | "seed={6} config={7}"; |
58 | |||
59 | @ParameterizedTest(name = title) | ||
62 | @MethodSource | 60 | @MethodSource |
63 | @Timeout(value = 10) | 61 | @Timeout(value = 10) |
64 | @Tag("fuzz") | 62 | @Tag("fuzz") |
65 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 63 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
66 | int seed, | 64 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
67 | boolean evilHash) { | ||
68 | runFuzzTest("CommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 65 | runFuzzTest("CommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
69 | nullDefault, commitFrequency, evilHash); | 66 | nullDefault, commitFrequency, builder); |
70 | } | 67 | } |
71 | 68 | ||
72 | static Stream<Arguments> parametrizedFastFuzz() { | 69 | static Stream<Arguments> parametrizedFastFuzz() { |
73 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 70 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
74 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 71 | commitFrequencyOptions, randomSeedOptions, storeConfigs); |
75 | } | 72 | } |
76 | 73 | ||
77 | @ParameterizedTest(name = "Commit {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5} " + | 74 | @ParameterizedTest(name = title) |
78 | "seed={6} evil-hash={7}") | ||
79 | @MethodSource | 75 | @MethodSource |
80 | @Tag("fuzz") | 76 | @Tag("fuzz") |
81 | @Tag("slow") | 77 | @Tag("slow") |
82 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 78 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
83 | int seed, boolean evilHash) { | 79 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
84 | runFuzzTest("CommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 80 | runFuzzTest("CommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
85 | nullDefault, commitFrequency, evilHash); | 81 | nullDefault, commitFrequency, builder); |
86 | } | 82 | } |
87 | 83 | ||
88 | static Stream<Arguments> parametrizedSlowFuzz() { | 84 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java index c17b0a95..b462ed40 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java | |||
@@ -6,7 +6,6 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
6 | import org.junit.jupiter.params.provider.Arguments; | 6 | import org.junit.jupiter.params.provider.Arguments; |
7 | import org.junit.jupiter.params.provider.MethodSource; | 7 | import org.junit.jupiter.params.provider.MethodSource; |
8 | import tools.refinery.store.map.*; | 8 | import tools.refinery.store.map.*; |
9 | import tools.refinery.store.map.internal.VersionedMapImpl; | ||
10 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 9 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
11 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 10 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
12 | 11 | ||
@@ -22,20 +21,19 @@ import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; | |||
22 | 21 | ||
23 | class ContentEqualsFuzzTest { | 22 | class ContentEqualsFuzzTest { |
24 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 23 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, |
25 | boolean nullDefault, int commitFrequency, | 24 | boolean nullDefault, int commitFrequency, VersionedMapStoreBuilder<Integer, String> builder) { |
26 | boolean evilHash) { | ||
27 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 25 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
28 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 26 | |
29 | 27 | ||
30 | Random r = new Random(seed); | 28 | Random r = new Random(seed); |
31 | 29 | ||
32 | iterativeRandomPutsAndCommitsThenCompare(scenario, chp, steps, maxKey, values, r, commitFrequency); | 30 | iterativeRandomPutsAndCommitsThenCompare(scenario, builder, steps, maxKey, values, r, commitFrequency); |
33 | } | 31 | } |
34 | 32 | ||
35 | private void iterativeRandomPutsAndCommitsThenCompare(String scenario, ContinousHashProvider<Integer> chp, | 33 | private void iterativeRandomPutsAndCommitsThenCompare(String scenario, VersionedMapStoreBuilder<Integer, String> builder, |
36 | int steps, int maxKey, String[] values, Random r, | 34 | int steps, int maxKey, String[] values, Random r, |
37 | int commitFrequency) { | 35 | int commitFrequency) { |
38 | VersionedMapStore<Integer, String> store1 = new VersionedMapStoreImpl<>(chp, values[0]); | 36 | VersionedMapStore<Integer, String> store1 = builder.setDefaultValue(values[0]).buildOne(); |
39 | VersionedMap<Integer, String> sut1 = store1.createMap(); | 37 | VersionedMap<Integer, String> sut1 = store1.createMap(); |
40 | 38 | ||
41 | // Fill one map | 39 | // Fill one map |
@@ -65,7 +63,7 @@ class ContentEqualsFuzzTest { | |||
65 | // Randomize the order of the content | 63 | // Randomize the order of the content |
66 | Collections.shuffle(content, r); | 64 | Collections.shuffle(content, r); |
67 | 65 | ||
68 | VersionedMapStore<Integer, String> store2 = new VersionedMapStoreImpl<>(chp, values[0]); | 66 | VersionedMapStore<Integer, String> store2 = builder.setDefaultValue(values[0]).buildOne(); |
69 | VersionedMap<Integer, String> sut2 = store2.createMap(); | 67 | VersionedMap<Integer, String> sut2 = store2.createMap(); |
70 | int index2 = 1; | 68 | int index2 = 1; |
71 | for (SimpleEntry<Integer, String> entry : content) { | 69 | for (SimpleEntry<Integer, String> entry : content) { |
@@ -75,38 +73,39 @@ class ContentEqualsFuzzTest { | |||
75 | } | 73 | } |
76 | 74 | ||
77 | // Check the integrity of the maps | 75 | // Check the integrity of the maps |
78 | ((VersionedMapImpl<Integer, String>) sut1).checkIntegrity(); | 76 | sut1.checkIntegrity(); |
79 | ((VersionedMapImpl<Integer, String>) sut2).checkIntegrity(); | 77 | sut2.checkIntegrity(); |
80 | 78 | ||
81 | // Compare the two maps | 79 | // Compare the two maps |
82 | MapTestEnvironment.compareTwoMaps(scenario, sut1, sut2); | 80 | MapTestEnvironment.compareTwoMaps(scenario, sut1, sut2); |
83 | } | 81 | } |
84 | 82 | ||
85 | @ParameterizedTest(name = "Compare {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit frequency={5}" + | 83 | public static final String title = "Compare {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit frequency={5}" + |
86 | "seed={6} evil-hash={7}") | 84 | "seed={6} config={7}"; |
85 | |||
86 | @ParameterizedTest(name = title) | ||
87 | @MethodSource | 87 | @MethodSource |
88 | @Timeout(value = 10) | 88 | @Timeout(value = 10) |
89 | @Tag("fuzz") | 89 | @Tag("fuzz") |
90 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 90 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
91 | int seed, boolean evilHash) { | 91 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
92 | runFuzzTest("CompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 92 | runFuzzTest("CompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
93 | nullDefault, commitFrequency, evilHash); | 93 | nullDefault, commitFrequency, builder); |
94 | } | 94 | } |
95 | 95 | ||
96 | static Stream<Arguments> parametrizedFastFuzz() { | 96 | static Stream<Arguments> parametrizedFastFuzz() { |
97 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 97 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
98 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 98 | commitFrequencyOptions, randomSeedOptions, storeConfigs); |
99 | } | 99 | } |
100 | 100 | ||
101 | @ParameterizedTest(name = "Compare {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit frequency={5}" + | 101 | @ParameterizedTest(name = title) |
102 | "seed={6} evil-hash={7}") | ||
103 | @MethodSource | 102 | @MethodSource |
104 | @Tag("fuzz") | 103 | @Tag("fuzz") |
105 | @Tag("slow") | 104 | @Tag("slow") |
106 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, int commitFrequency, | 105 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, int commitFrequency, |
107 | int seed, boolean evilHash) { | 106 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
108 | runFuzzTest("CompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 107 | runFuzzTest("CompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
109 | defaultNull, commitFrequency, evilHash); | 108 | defaultNull, commitFrequency, builder); |
110 | } | 109 | } |
111 | 110 | ||
112 | static Stream<Arguments> parametrizedSlowFuzz() { | 111 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java index 90aa8e01..bf409a74 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java | |||
@@ -1,33 +1,26 @@ | |||
1 | package tools.refinery.store.map.tests.fuzz; | 1 | package tools.refinery.store.map.tests.fuzz; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; | ||
5 | |||
6 | import java.util.Random; | ||
7 | import java.util.stream.Stream; | ||
8 | |||
9 | import org.junit.jupiter.api.Tag; | 3 | import org.junit.jupiter.api.Tag; |
10 | import org.junit.jupiter.api.Timeout; | 4 | import org.junit.jupiter.api.Timeout; |
11 | import org.junit.jupiter.params.ParameterizedTest; | 5 | import org.junit.jupiter.params.ParameterizedTest; |
12 | import org.junit.jupiter.params.provider.Arguments; | 6 | import org.junit.jupiter.params.provider.Arguments; |
13 | import org.junit.jupiter.params.provider.MethodSource; | 7 | import org.junit.jupiter.params.provider.MethodSource; |
14 | 8 | import tools.refinery.store.map.*; | |
15 | import tools.refinery.store.map.ContinousHashProvider; | ||
16 | import tools.refinery.store.map.DiffCursor; | ||
17 | import tools.refinery.store.map.VersionedMapStore; | ||
18 | import tools.refinery.store.map.VersionedMapStoreImpl; | ||
19 | import tools.refinery.store.map.internal.VersionedMapImpl; | ||
20 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 9 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
21 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 10 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
22 | 11 | ||
12 | import java.util.Random; | ||
13 | import java.util.stream.Stream; | ||
14 | |||
15 | import static org.junit.jupiter.api.Assertions.fail; | ||
16 | import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; | ||
17 | |||
23 | class DiffCursorFuzzTest { | 18 | class DiffCursorFuzzTest { |
24 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 19 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, |
25 | boolean nullDefault, int commitFrequency, | 20 | boolean nullDefault, int commitFrequency, VersionedMapStoreBuilder<Integer, String> builder) { |
26 | boolean evilHash) { | ||
27 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 21 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
28 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
29 | 22 | ||
30 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<>(chp, values[0]); | 23 | VersionedMapStore<Integer, String> store = builder.setDefaultValue(values[0]).buildOne(); |
31 | iterativeRandomPutsAndCommitsThenDiffCursor(scenario, store, steps, maxKey, values, seed, commitFrequency); | 24 | iterativeRandomPutsAndCommitsThenDiffCursor(scenario, store, steps, maxKey, values, seed, commitFrequency); |
32 | } | 25 | } |
33 | 26 | ||
@@ -35,7 +28,7 @@ class DiffCursorFuzzTest { | |||
35 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { | 28 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { |
36 | // 1. build a map with versions | 29 | // 1. build a map with versions |
37 | Random r = new Random(seed); | 30 | Random r = new Random(seed); |
38 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | 31 | VersionedMap<Integer, String> versioned = store.createMap(); |
39 | int largestCommit = -1; | 32 | int largestCommit = -1; |
40 | 33 | ||
41 | for (int i = 0; i < steps; i++) { | 34 | for (int i = 0; i < steps; i++) { |
@@ -56,7 +49,7 @@ class DiffCursorFuzzTest { | |||
56 | System.out.println(scenario + ":" + index + "/" + steps + " building finished"); | 49 | System.out.println(scenario + ":" + index + "/" + steps + " building finished"); |
57 | } | 50 | } |
58 | // 2. create a non-versioned map, | 51 | // 2. create a non-versioned map, |
59 | VersionedMapImpl<Integer, String> moving = (VersionedMapImpl<Integer, String>) store.createMap(); | 52 | VersionedMap<Integer, String> moving = store.createMap(); |
60 | Random r2 = new Random(seed + 1); | 53 | Random r2 = new Random(seed + 1); |
61 | 54 | ||
62 | final int diffTravelFrequency = commitFrequency * 2; | 55 | final int diffTravelFrequency = commitFrequency * 2; |
@@ -88,31 +81,32 @@ class DiffCursorFuzzTest { | |||
88 | 81 | ||
89 | } | 82 | } |
90 | 83 | ||
91 | @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + | 84 | public static final String title = "DiffCursor {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + |
92 | "commit frequency={5} seed={6} evil-hash={7}") | 85 | "commit frequency={5} seed={6} config={7}"; |
86 | |||
87 | @ParameterizedTest(name = title) | ||
93 | @MethodSource | 88 | @MethodSource |
94 | @Timeout(value = 10) | 89 | @Timeout(value = 10) |
95 | @Tag("fuzz") | 90 | @Tag("fuzz") |
96 | void parametrizedFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 91 | void parametrizedFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
97 | int seed, boolean evilHash) { | 92 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
98 | runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | 93 | runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, |
99 | noKeys, noValues, nullDefault, commitFrequency, evilHash); | 94 | noKeys, noValues, nullDefault, commitFrequency, builder); |
100 | } | 95 | } |
101 | 96 | ||
102 | static Stream<Arguments> parametrizedFuzz() { | 97 | static Stream<Arguments> parametrizedFuzz() { |
103 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 98 | return FuzzTestUtils.permutationWithSize(new Object[]{100}, keyCounts, valueCounts, nullDefaultOptions, |
104 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 99 | commitFrequencyOptions, randomSeedOptions, storeConfigs); |
105 | } | 100 | } |
106 | 101 | ||
107 | @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + | 102 | @ParameterizedTest(name = title) |
108 | "commit frequency={5} seed={6} evil-hash={7}") | ||
109 | @MethodSource | 103 | @MethodSource |
110 | @Tag("fuzz") | 104 | @Tag("fuzz") |
111 | @Tag("slow") | 105 | @Tag("slow") |
112 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 106 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
113 | int seed, boolean evilHash) { | 107 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
114 | runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 108 | runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
115 | nullDefault, commitFrequency, evilHash); | 109 | nullDefault, commitFrequency, builder); |
116 | } | 110 | } |
117 | 111 | ||
118 | static Stream<Arguments> parametrizedSlowFuzz() { | 112 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java index 9325a938..ec2224b4 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java | |||
@@ -15,27 +15,24 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
15 | import org.junit.jupiter.params.provider.Arguments; | 15 | import org.junit.jupiter.params.provider.Arguments; |
16 | import org.junit.jupiter.params.provider.MethodSource; | 16 | import org.junit.jupiter.params.provider.MethodSource; |
17 | 17 | ||
18 | import tools.refinery.store.map.ContinousHashProvider; | ||
19 | import tools.refinery.store.map.VersionedMapStore; | 18 | import tools.refinery.store.map.VersionedMapStore; |
20 | import tools.refinery.store.map.VersionedMapStoreImpl; | 19 | import tools.refinery.store.map.VersionedMapStoreBuilder; |
21 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 20 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
22 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 21 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
23 | 22 | ||
24 | class MultiThreadFuzzTest { | 23 | class MultiThreadFuzzTest { |
25 | public static final int noThreads = 32; | 24 | public static final int noThreads = 10; |
26 | 25 | ||
27 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 26 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean nullDefault, int commitFrequency, VersionedMapStoreBuilder<Integer, String> builder) { |
28 | boolean nullDefault, int commitFrequency, | ||
29 | boolean evilHash) { | ||
30 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 27 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
31 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
32 | 28 | ||
33 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<>(chp, values[0]); | 29 | VersionedMapStore<Integer, String> store = builder.setDefaultValue(values[0]).buildOne(); |
34 | 30 | ||
35 | // initialize runnables | 31 | // initialize runnables |
36 | MultiThreadTestRunnable[] runnables = new MultiThreadTestRunnable[noThreads]; | 32 | MultiThreadTestRunnable[] runnables = new MultiThreadTestRunnable[noThreads]; |
37 | for (int i = 0; i < noThreads; i++) { | 33 | for (int i = 0; i < noThreads; i++) { |
38 | runnables[i] = new MultiThreadTestRunnable(scenario + "-T" + (i + 1), store, steps, maxKey, values, seed, commitFrequency); | 34 | runnables[i] = new MultiThreadTestRunnable(scenario + "-T" + (i + 1), store, steps, maxKey, values, seed |
35 | , commitFrequency); | ||
39 | } | 36 | } |
40 | 37 | ||
41 | // initialize threads | 38 | // initialize threads |
@@ -46,7 +43,8 @@ class MultiThreadFuzzTest { | |||
46 | 43 | ||
47 | // start threads; | 44 | // start threads; |
48 | for (int i = 0; i < noThreads; i++) { | 45 | for (int i = 0; i < noThreads; i++) { |
49 | threads[i].start(); | 46 | runnables[i].run(); |
47 | //threads[i].start(); | ||
50 | } | 48 | } |
51 | 49 | ||
52 | // wait all the threads; | 50 | // wait all the threads; |
@@ -67,32 +65,32 @@ class MultiThreadFuzzTest { | |||
67 | assertEquals(Collections.EMPTY_LIST, errors); | 65 | assertEquals(Collections.EMPTY_LIST, errors); |
68 | } | 66 | } |
69 | 67 | ||
70 | @ParameterizedTest(name = "MultiThread {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit " + | 68 | static final String title = "MultiThread {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit " + |
71 | "frequency={5} seed={6} evil-hash={7}") | 69 | "frequency={5} seed={6} config={7}"; |
70 | |||
71 | @ParameterizedTest(name = title) | ||
72 | @MethodSource | 72 | @MethodSource |
73 | @Timeout(value = 10) | 73 | @Timeout(value = 10) |
74 | @Tag("fuzz") | 74 | @Tag("fuzz") |
75 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, int commitFrequency, | 75 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, |
76 | int seed, boolean evilHash) { | 76 | int commitFrequency, int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
77 | runFuzzTest("MultiThreadS" + steps + "K" + noKeys + "V" + noValues + defaultNull + "CF" + commitFrequency + | 77 | runFuzzTest("MultiThreadS" + steps + "K" + noKeys + "V" + noValues + defaultNull + "CF" + commitFrequency + |
78 | "s" + seed, seed, steps, noKeys, noValues, defaultNull, commitFrequency, evilHash); | 78 | "s" + seed, seed, steps, noKeys, noValues, defaultNull, commitFrequency, builder); |
79 | } | 79 | } |
80 | 80 | ||
81 | static Stream<Arguments> parametrizedFastFuzz() { | 81 | static Stream<Arguments> parametrizedFastFuzz() { |
82 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 82 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
83 | new Object[]{10, 100}, randomSeedOptions, | 83 | new Object[]{10, 100}, randomSeedOptions, storeConfigs); |
84 | evilHashOptions); | ||
85 | } | 84 | } |
86 | 85 | ||
87 | @ParameterizedTest(name = "MultiThread {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit " + | 86 | @ParameterizedTest(name = title) |
88 | "frequency={5} seed={6} evil-hash={7}") | ||
89 | @MethodSource | 87 | @MethodSource |
90 | @Tag("fuzz") | 88 | @Tag("fuzz") |
91 | @Tag("slow") | 89 | @Tag("slow") |
92 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, int seed, | 90 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, |
93 | boolean evilHash) { | 91 | int commitFrequency, int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
94 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 92 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
95 | nullDefault, commitFrequency, evilHash); | 93 | nullDefault, commitFrequency, builder); |
96 | } | 94 | } |
97 | 95 | ||
98 | static Stream<Arguments> parametrizedSlowFuzz() { | 96 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadTestRunnable.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadTestRunnable.java index 4415e4e5..f449ca97 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadTestRunnable.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadTestRunnable.java | |||
@@ -8,8 +8,8 @@ import java.util.List; | |||
8 | import java.util.Map; | 8 | import java.util.Map; |
9 | import java.util.Random; | 9 | import java.util.Random; |
10 | 10 | ||
11 | import tools.refinery.store.map.VersionedMap; | ||
11 | import tools.refinery.store.map.VersionedMapStore; | 12 | import tools.refinery.store.map.VersionedMapStore; |
12 | import tools.refinery.store.map.internal.VersionedMapImpl; | ||
13 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 13 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
14 | 14 | ||
15 | public class MultiThreadTestRunnable implements Runnable { | 15 | public class MultiThreadTestRunnable implements Runnable { |
@@ -45,9 +45,17 @@ public class MultiThreadTestRunnable implements Runnable { | |||
45 | 45 | ||
46 | @Override | 46 | @Override |
47 | public void run() { | 47 | public void run() { |
48 | try{ | ||
49 | task(); | ||
50 | } catch(Exception e) { | ||
51 | e.printStackTrace(); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | private void task() { | ||
48 | // 1. build a map with versions | 56 | // 1. build a map with versions |
49 | Random r = new Random(seed); | 57 | Random r = new Random(seed); |
50 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | 58 | VersionedMap<Integer, String> versioned = store.createMap(); |
51 | Map<Integer, Long> index2Version = new HashMap<>(); | 59 | Map<Integer, Long> index2Version = new HashMap<>(); |
52 | 60 | ||
53 | for (int i = 0; i < steps; i++) { | 61 | for (int i = 0; i < steps; i++) { |
@@ -67,7 +75,7 @@ public class MultiThreadTestRunnable implements Runnable { | |||
67 | MapTestEnvironment.printStatus(scenario, index, steps, "building"); | 75 | MapTestEnvironment.printStatus(scenario, index, steps, "building"); |
68 | } | 76 | } |
69 | // 2. create a non-versioned | 77 | // 2. create a non-versioned |
70 | VersionedMapImpl<Integer, String> reference = (VersionedMapImpl<Integer, String>) store.createMap(); | 78 | VersionedMap<Integer, String> reference = store.createMap(); |
71 | r = new Random(seed); | 79 | r = new Random(seed); |
72 | Random r2 = new Random(seed + 1); | 80 | Random r2 = new Random(seed + 1); |
73 | 81 | ||
@@ -84,13 +92,17 @@ public class MultiThreadTestRunnable implements Runnable { | |||
84 | // go back to an existing state and compare to the reference | 92 | // go back to an existing state and compare to the reference |
85 | if (index % (commitFrequency) == 0) { | 93 | if (index % (commitFrequency) == 0) { |
86 | versioned.restore(index2Version.get(i)); | 94 | versioned.restore(index2Version.get(i)); |
87 | MapTestEnvironment.compareTwoMaps(scenario + ":" + index, reference, versioned, errors); | 95 | MapTestEnvironment.compareTwoMaps(scenario + ":" + index, reference, versioned, null); |
88 | 96 | ||
89 | // go back to a random state (probably created by another thread) | 97 | // go back to a random state (probably created by another thread) |
90 | List<Long> states = new ArrayList<>(store.getStates()); | 98 | List<Long> states = new ArrayList<>(store.getStates()); |
99 | states.sort(Long::compare); | ||
91 | Collections.shuffle(states, r2); | 100 | Collections.shuffle(states, r2); |
92 | for (Long state : states.subList(0, Math.min(states.size(), 100))) { | 101 | for (Long state : states.subList(0, Math.min(states.size(), 100))) { |
93 | versioned.restore(state); | 102 | long x = state; |
103 | versioned.restore(x); | ||
104 | var clean = store.createMap(x); | ||
105 | MapTestEnvironment.compareTwoMaps(scenario + ":" + index, clean, versioned, null); | ||
94 | } | 106 | } |
95 | versioned.restore(index2Version.get(i)); | 107 | versioned.restore(index2Version.get(i)); |
96 | } | 108 | } |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java index ab37ef83..bdf72ce4 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java | |||
@@ -12,21 +12,17 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
12 | import org.junit.jupiter.params.provider.Arguments; | 12 | import org.junit.jupiter.params.provider.Arguments; |
13 | import org.junit.jupiter.params.provider.MethodSource; | 13 | import org.junit.jupiter.params.provider.MethodSource; |
14 | 14 | ||
15 | import tools.refinery.store.map.ContinousHashProvider; | 15 | import tools.refinery.store.map.*; |
16 | import tools.refinery.store.map.VersionedMapStore; | ||
17 | import tools.refinery.store.map.VersionedMapStoreImpl; | ||
18 | import tools.refinery.store.map.internal.VersionedMapImpl; | ||
19 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 16 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
20 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 17 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
21 | 18 | ||
22 | class MutableFuzzTest { | 19 | class MutableFuzzTest { |
23 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 20 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, |
24 | boolean nullDefault, boolean evilHash) { | 21 | boolean nullDefault, VersionedMapStoreBuilder<Integer, String> builder) { |
25 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 22 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
26 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
27 | 23 | ||
28 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<>(chp, values[0]); | 24 | VersionedMapStore<Integer, String> store = builder.setDefaultValue(values[0]).buildOne(); |
29 | VersionedMapImpl<Integer, String> sut = (VersionedMapImpl<Integer, String>) store.createMap(); | 25 | VersionedMap<Integer, String> sut = store.createMap(); |
30 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<>(sut); | 26 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<>(sut); |
31 | 27 | ||
32 | Random r = new Random(seed); | 28 | Random r = new Random(seed); |
@@ -52,33 +48,34 @@ class MutableFuzzTest { | |||
52 | } | 48 | } |
53 | } | 49 | } |
54 | 50 | ||
55 | @ParameterizedTest(name = "Mutable {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} seed={5} " + | 51 | final String title = "Mutable {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} seed={5} " + |
56 | "evil-hash={6}") | 52 | "config={6}"; |
53 | |||
54 | @ParameterizedTest(name = title) | ||
57 | @MethodSource | 55 | @MethodSource |
58 | @Timeout(value = 10) | 56 | @Timeout(value = 10) |
59 | @Tag("fuzz") | 57 | @Tag("fuzz") |
60 | void parametrizedFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, int seed, | 58 | void parametrizedFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean defaultNull, int seed, |
61 | boolean evilHash) { | 59 | VersionedMapStoreBuilder<Integer, String> builder) { |
62 | runFuzzTest( | 60 | runFuzzTest( |
63 | "MutableS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), | 61 | "MutableS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, |
64 | seed, steps, noKeys, noValues, defaultNull, evilHash); | 62 | seed, steps, noKeys, noValues, defaultNull, builder); |
65 | } | 63 | } |
66 | 64 | ||
67 | static Stream<Arguments> parametrizedFuzz() { | 65 | static Stream<Arguments> parametrizedFuzz() { |
68 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 66 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
69 | randomSeedOptions, evilHashOptions); | 67 | randomSeedOptions, storeConfigs); |
70 | } | 68 | } |
71 | 69 | ||
72 | @ParameterizedTest(name = "Mutable {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} seed={5} " + | 70 | @ParameterizedTest(name = title) |
73 | "evil-hash={6}") | ||
74 | @MethodSource | 71 | @MethodSource |
75 | @Tag("fuzz") | 72 | @Tag("fuzz") |
76 | @Tag("slow") | 73 | @Tag("slow") |
77 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int seed, | 74 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int seed, |
78 | boolean evilHash) { | 75 | VersionedMapStoreBuilder<Integer, String> builder) { |
79 | runFuzzTest( | 76 | runFuzzTest( |
80 | "MutableS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), | 77 | "MutableS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, |
81 | seed, steps, noKeys, noValues, nullDefault, evilHash); | 78 | seed, steps, noKeys, noValues, nullDefault, builder); |
82 | } | 79 | } |
83 | 80 | ||
84 | static Stream<Arguments> parametrizedSlowFuzz() { | 81 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java index b58b06f9..cee15fe1 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java | |||
@@ -71,7 +71,7 @@ class MutableImmutableCompareFuzzTest { | |||
71 | 71 | ||
72 | static Stream<Arguments> parametrizedFastFuzz() { | 72 | static Stream<Arguments> parametrizedFastFuzz() { |
73 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 73 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
74 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 74 | commitFrequencyOptions, randomSeedOptions, new Object[]{false, true}); |
75 | } | 75 | } |
76 | 76 | ||
77 | @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + | 77 | @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java index 77b26c41..568aaac9 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java | |||
@@ -14,9 +14,7 @@ import org.junit.jupiter.params.ParameterizedTest; | |||
14 | import org.junit.jupiter.params.provider.Arguments; | 14 | import org.junit.jupiter.params.provider.Arguments; |
15 | import org.junit.jupiter.params.provider.MethodSource; | 15 | import org.junit.jupiter.params.provider.MethodSource; |
16 | 16 | ||
17 | import tools.refinery.store.map.ContinousHashProvider; | 17 | import tools.refinery.store.map.*; |
18 | import tools.refinery.store.map.VersionedMapStore; | ||
19 | import tools.refinery.store.map.VersionedMapStoreImpl; | ||
20 | import tools.refinery.store.map.internal.VersionedMapImpl; | 18 | import tools.refinery.store.map.internal.VersionedMapImpl; |
21 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; | 19 | import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; |
22 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | 20 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; |
@@ -24,11 +22,10 @@ import tools.refinery.store.map.tests.utils.MapTestEnvironment; | |||
24 | class RestoreFuzzTest { | 22 | class RestoreFuzzTest { |
25 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, | 23 | private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, |
26 | boolean nullDefault, int commitFrequency, | 24 | boolean nullDefault, int commitFrequency, |
27 | boolean evilHash) { | 25 | VersionedMapStoreBuilder<Integer, String> builder) { |
28 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); | 26 | String[] values = MapTestEnvironment.prepareValues(maxValue, nullDefault); |
29 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
30 | 27 | ||
31 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<>(chp, values[0]); | 28 | VersionedMapStore<Integer, String> store = builder.setDefaultValue(values[0]).buildOne(); |
32 | 29 | ||
33 | iterativeRandomPutsAndCommitsThenRestore(scenario, store, steps, maxKey, values, seed, commitFrequency); | 30 | iterativeRandomPutsAndCommitsThenRestore(scenario, store, steps, maxKey, values, seed, commitFrequency); |
34 | } | 31 | } |
@@ -37,7 +34,7 @@ class RestoreFuzzTest { | |||
37 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { | 34 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { |
38 | // 1. build a map with versions | 35 | // 1. build a map with versions |
39 | Random r = new Random(seed); | 36 | Random r = new Random(seed); |
40 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | 37 | VersionedMap<Integer, String> versioned = store.createMap(); |
41 | Map<Integer, Long> index2Version = new HashMap<>(); | 38 | Map<Integer, Long> index2Version = new HashMap<>(); |
42 | 39 | ||
43 | for (int i = 0; i < steps; i++) { | 40 | for (int i = 0; i < steps; i++) { |
@@ -57,7 +54,7 @@ class RestoreFuzzTest { | |||
57 | MapTestEnvironment.printStatus(scenario, index, steps, "building"); | 54 | MapTestEnvironment.printStatus(scenario, index, steps, "building"); |
58 | } | 55 | } |
59 | // 2. create a non-versioned and | 56 | // 2. create a non-versioned and |
60 | VersionedMapImpl<Integer, String> reference = (VersionedMapImpl<Integer, String>) store.createMap(); | 57 | VersionedMap<Integer, String> reference = store.createMap(); |
61 | r = new Random(seed); | 58 | r = new Random(seed); |
62 | 59 | ||
63 | for (int i = 0; i < steps; i++) { | 60 | for (int i = 0; i < steps; i++) { |
@@ -79,31 +76,32 @@ class RestoreFuzzTest { | |||
79 | 76 | ||
80 | } | 77 | } |
81 | 78 | ||
82 | @ParameterizedTest(name = "Restore {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5}" + | 79 | public static final String title = "Commit {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5} " + |
83 | " seed={6} evil-hash={7}") | 80 | "seed={6} config={7}"; |
81 | |||
82 | @ParameterizedTest(name = title) | ||
84 | @MethodSource | 83 | @MethodSource |
85 | @Timeout(value = 10) | 84 | @Timeout(value = 10) |
86 | @Tag("smoke") | 85 | @Tag("smoke") |
87 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 86 | void parametrizedFastFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
88 | int seed, boolean evilHash) { | 87 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
89 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 88 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
90 | nullDefault, commitFrequency, evilHash); | 89 | nullDefault, commitFrequency, builder); |
91 | } | 90 | } |
92 | 91 | ||
93 | static Stream<Arguments> parametrizedFastFuzz() { | 92 | static Stream<Arguments> parametrizedFastFuzz() { |
94 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 93 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
95 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 94 | commitFrequencyOptions, randomSeedOptions, storeConfigs); |
96 | } | 95 | } |
97 | 96 | ||
98 | @ParameterizedTest(name = "Restore {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5}" + | 97 | @ParameterizedTest(name = title) |
99 | " seed={6} evil-hash={7}") | ||
100 | @MethodSource | 98 | @MethodSource |
101 | @Tag("smoke") | 99 | @Tag("smoke") |
102 | @Tag("slow") | 100 | @Tag("slow") |
103 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, | 101 | void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, |
104 | int seed, boolean evilHash) { | 102 | int seed, VersionedMapStoreBuilder<Integer, String> builder) { |
105 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 103 | runFuzzTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
106 | nullDefault, commitFrequency, evilHash); | 104 | nullDefault, commitFrequency, builder); |
107 | } | 105 | } |
108 | 106 | ||
109 | static Stream<Arguments> parametrizedSlowFuzz() { | 107 | static Stream<Arguments> parametrizedSlowFuzz() { |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java index 4462c55b..0544687a 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java | |||
@@ -96,7 +96,7 @@ class SharedStoreFuzzTest { | |||
96 | 96 | ||
97 | static Stream<Arguments> parametrizedFastFuzz() { | 97 | static Stream<Arguments> parametrizedFastFuzz() { |
98 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, | 98 | return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, |
99 | commitFrequencyOptions, randomSeedOptions, evilHashOptions); | 99 | commitFrequencyOptions, randomSeedOptions, new Object[]{false, true}); |
100 | } | 100 | } |
101 | 101 | ||
102 | @ParameterizedTest(name = "Shared Store {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit " + | 102 | @ParameterizedTest(name = "Shared Store {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit " + |
diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java index add4ca5d..fb6b28d8 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java | |||
@@ -1,11 +1,43 @@ | |||
1 | package tools.refinery.store.map.tests.fuzz.utils; | 1 | package tools.refinery.store.map.tests.fuzz.utils; |
2 | 2 | ||
3 | import tools.refinery.store.map.VersionedMapStoreBuilder; | ||
4 | import tools.refinery.store.map.tests.utils.MapTestEnvironment; | ||
5 | |||
3 | public final class FuzzTestCollections { | 6 | public final class FuzzTestCollections { |
4 | public static final Object[] stepCounts = {FuzzTestUtils.FAST_STEP_COUNT}; | 7 | public static final Object[] stepCounts = {FuzzTestUtils.FAST_STEP_COUNT}; |
5 | public static final Object[] keyCounts = {3, 32, 32 * 32}; | 8 | public static final Object[] keyCounts = {1, 32, 32 * 32}; |
6 | public static final Object[] valueCounts = {2, 3}; | 9 | public static final Object[] valueCounts = {2, 3}; |
7 | public static final Object[] nullDefaultOptions = {false, true}; | 10 | public static final Object[] nullDefaultOptions = {false, true}; |
8 | public static final Object[] commitFrequencyOptions = {1, 10, 100}; | 11 | public static final Object[] commitFrequencyOptions = {10, 10, 100}; |
9 | public static final Object[] randomSeedOptions = {1, 2, 3}; | 12 | public static final Object[] randomSeedOptions = {1/*, 2, 3*/}; |
10 | public static final Object[] evilHashOptions = {false, true}; | 13 | public static final Object[] storeConfigs = { |
14 | // State based | ||
15 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
16 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.STATE) | ||
17 | .setStateBasedImmutableWhenCommitting(true) | ||
18 | .setHashProvider(MapTestEnvironment.prepareHashProvider(false)) | ||
19 | .setStateBasedNodeSharingStrategy(VersionedMapStoreBuilder.StateStorageStrategy.SHARED_NODE_CACHE), | ||
20 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
21 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.STATE) | ||
22 | .setStateBasedImmutableWhenCommitting(true) | ||
23 | .setHashProvider(MapTestEnvironment.prepareHashProvider(true)) | ||
24 | .setStateBasedNodeSharingStrategy(VersionedMapStoreBuilder.StateStorageStrategy.SHARED_NODE_CACHE), | ||
25 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
26 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.STATE) | ||
27 | .setStateBasedImmutableWhenCommitting(false) | ||
28 | .setHashProvider(MapTestEnvironment.prepareHashProvider(false)) | ||
29 | .setStateBasedNodeSharingStrategy(VersionedMapStoreBuilder.StateStorageStrategy.SHARED_NODE_CACHE), | ||
30 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
31 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.STATE) | ||
32 | .setStateBasedImmutableWhenCommitting(false) | ||
33 | .setHashProvider(MapTestEnvironment.prepareHashProvider(false)) | ||
34 | .setStateBasedNodeSharingStrategy(VersionedMapStoreBuilder.StateStorageStrategy.NO_NODE_CACHE), | ||
35 | // Delta based | ||
36 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
37 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.DELTA) | ||
38 | .setDeltaStorageStrategy(VersionedMapStoreBuilder.DeltaStorageStrategy.SET), | ||
39 | VersionedMapStoreBuilder.<Integer,String>builder() | ||
40 | .setStrategy(VersionedMapStoreBuilder.StoreStrategy.DELTA) | ||
41 | .setDeltaStorageStrategy(VersionedMapStoreBuilder.DeltaStorageStrategy.LIST) | ||
42 | }; | ||
11 | } | 43 | } |