diff options
Diffstat (limited to 'model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast')
5 files changed, 420 insertions, 0 deletions
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/CommitSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/CommitSmokeTest.java new file mode 100644 index 00000000..5c340090 --- /dev/null +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/CommitSmokeTest.java | |||
@@ -0,0 +1,79 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | ||
2 | |||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | |||
5 | import java.util.Random; | ||
6 | import java.util.stream.Stream; | ||
7 | |||
8 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | ||
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | ||
14 | import org.junit.jupiter.api.Timeout; | ||
15 | import org.junit.jupiter.params.ParameterizedTest; | ||
16 | import org.junit.jupiter.params.provider.Arguments; | ||
17 | import org.junit.jupiter.params.provider.MethodSource; | ||
18 | |||
19 | public class CommitSmokeTest { | ||
20 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | ||
21 | boolean evilHash) { | ||
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
24 | |||
25 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
26 | VersionedMapImpl<Integer, String> sut = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
27 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<Integer, String>(sut); | ||
28 | |||
29 | Random r = new Random(seed); | ||
30 | |||
31 | iterativeRandomPutsAndCommits(scenario, steps, maxKey, values, e, r, commitFrequency); | ||
32 | } | ||
33 | |||
34 | private void iterativeRandomPutsAndCommits(String scenario, int steps, int maxKey, String[] values, | ||
35 | MapTestEnvironment<Integer, String> e, Random r, int commitFrequency) { | ||
36 | int stopAt = -1; | ||
37 | for (int i = 0; i < steps; i++) { | ||
38 | int index = i + 1; | ||
39 | int nextKey = r.nextInt(maxKey); | ||
40 | String nextValue = values[r.nextInt(values.length)]; | ||
41 | if (index == stopAt) { | ||
42 | System.out.println("issue!"); | ||
43 | System.out.println("State before:"); | ||
44 | e.printComparison(); | ||
45 | e.sut.prettyPrint(); | ||
46 | System.out.println("Next: put(" + nextKey + "," + nextValue + ")"); | ||
47 | } | ||
48 | try { | ||
49 | e.put(nextKey, nextValue); | ||
50 | if (index == stopAt) { | ||
51 | e.sut.prettyPrint(); | ||
52 | } | ||
53 | e.checkEquivalence(scenario + ":" + index); | ||
54 | } catch (Exception exception) { | ||
55 | exception.printStackTrace(); | ||
56 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
57 | } | ||
58 | MapTestEnvironment.printStatus(scenario, index, steps, null); | ||
59 | if (index % commitFrequency == 0) { | ||
60 | e.sut.commit(); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | |||
65 | @ParameterizedTest(name = "Immutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
66 | @MethodSource | ||
67 | @Timeout(value = 10) | ||
68 | public void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
69 | boolean evilHash) { | ||
70 | runSmokeTest("SmokeCommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | ||
71 | commitFrequency, evilHash); | ||
72 | } | ||
73 | |||
74 | public static Stream<Arguments> parametrizedSmoke() { | ||
75 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | ||
76 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, | ||
77 | new Object[] { false, true }); | ||
78 | } | ||
79 | } | ||
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/DiffCursorSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/DiffCursorSmokeTest.java new file mode 100644 index 00000000..ef51d05e --- /dev/null +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/DiffCursorSmokeTest.java | |||
@@ -0,0 +1,101 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | ||
2 | |||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | |||
5 | import java.util.Random; | ||
6 | import java.util.stream.Stream; | ||
7 | |||
8 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
9 | import org.eclipse.viatra.solver.data.map.DiffCursor; | ||
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
11 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
12 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
13 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | ||
14 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | ||
15 | import org.junit.jupiter.api.Timeout; | ||
16 | import org.junit.jupiter.params.ParameterizedTest; | ||
17 | import org.junit.jupiter.params.provider.Arguments; | ||
18 | import org.junit.jupiter.params.provider.MethodSource; | ||
19 | |||
20 | public class DiffCursorSmokeTest { | ||
21 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | ||
22 | boolean evilHash) { | ||
23 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
24 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
25 | |||
26 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
27 | iterativeRandomPutsAndCommitsThenDiffcursor(scenario, store, steps, maxKey, values, seed, commitFrequency); | ||
28 | } | ||
29 | |||
30 | void iterativeRandomPutsAndCommitsThenDiffcursor(String scenario, VersionedMapStore<Integer, String> store, | ||
31 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { | ||
32 | // 1. build a map with versions | ||
33 | Random r = new Random(seed); | ||
34 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
35 | int largestCommit = -1; | ||
36 | |||
37 | for (int i = 0; i < steps; i++) { | ||
38 | int index = i + 1; | ||
39 | int nextKey = r.nextInt(maxKey); | ||
40 | String nextValue = values[r.nextInt(values.length)]; | ||
41 | try { | ||
42 | versioned.put(nextKey, nextValue); | ||
43 | } catch (Exception exception) { | ||
44 | exception.printStackTrace(); | ||
45 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
46 | } | ||
47 | if (index % commitFrequency == 0) { | ||
48 | long version = versioned.commit(); | ||
49 | largestCommit = (int) version; | ||
50 | } | ||
51 | if (index % 10000 == 0) | ||
52 | System.out.println(scenario + ":" + index + "/" + steps + " building finished"); | ||
53 | } | ||
54 | // 2. create a non-versioned map, | ||
55 | VersionedMapImpl<Integer, String> moving = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
56 | Random r2 = new Random(seed + 1); | ||
57 | |||
58 | final int diffTravelFrequency = commitFrequency * 2; | ||
59 | for (int i = 0; i < steps; i++) { | ||
60 | int index = i + 1; | ||
61 | if (index % diffTravelFrequency == 0) { | ||
62 | // difftravel | ||
63 | long travelToVersion = r2.nextInt(largestCommit + 1); | ||
64 | DiffCursor<Integer, String> diffCursor = moving.getDiffCursor(travelToVersion); | ||
65 | moving.putAll(diffCursor); | ||
66 | |||
67 | } else { | ||
68 | // random puts | ||
69 | int nextKey = r2.nextInt(maxKey); | ||
70 | String nextValue = values[r2.nextInt(values.length)]; | ||
71 | try { | ||
72 | moving.put(nextKey, nextValue); | ||
73 | } catch (Exception exception) { | ||
74 | exception.printStackTrace(); | ||
75 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
76 | } | ||
77 | if (index % commitFrequency == 0) { | ||
78 | versioned.commit(); | ||
79 | } | ||
80 | if (index % 10000 == 0) | ||
81 | System.out.println(scenario + ":" + index + "/" + steps + " building finished"); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | } | ||
86 | |||
87 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
88 | @MethodSource | ||
89 | @Timeout(value = 10) | ||
90 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
91 | boolean evilHash) { | ||
92 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
93 | noKeys, noValues, commitFrequency, evilHash); | ||
94 | } | ||
95 | |||
96 | public static Stream<Arguments> parametrizedSmoke() { | ||
97 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | ||
98 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, | ||
99 | new Object[] { false, true }); | ||
100 | } | ||
101 | } | ||
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableImmutableCompareSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableImmutableCompareSmokeTest.java new file mode 100644 index 00000000..ac5571b3 --- /dev/null +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableImmutableCompareSmokeTest.java | |||
@@ -0,0 +1,72 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | ||
2 | |||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | |||
5 | import java.util.Random; | ||
6 | import java.util.stream.Stream; | ||
7 | |||
8 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | ||
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | ||
14 | import org.junit.jupiter.api.Timeout; | ||
15 | import org.junit.jupiter.params.ParameterizedTest; | ||
16 | import org.junit.jupiter.params.provider.Arguments; | ||
17 | import org.junit.jupiter.params.provider.MethodSource; | ||
18 | |||
19 | public class MutableImmutableCompareSmokeTest { | ||
20 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | ||
21 | boolean evilHash) { | ||
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
24 | |||
25 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
26 | VersionedMapImpl<Integer, String> immutable = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
27 | VersionedMapImpl<Integer, String> mutable = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
28 | |||
29 | Random r = new Random(seed); | ||
30 | |||
31 | iterativeRandomPutsAndCommitsAndCompare(scenario, immutable, mutable, steps, maxKey, values, r, | ||
32 | commitFrequency); | ||
33 | } | ||
34 | |||
35 | void iterativeRandomPutsAndCommitsAndCompare(String scenario, VersionedMapImpl<Integer, String> immutable, | ||
36 | VersionedMapImpl<Integer, String> mutable, int steps, int maxKey, String[] values, Random r, | ||
37 | int commitFrequency) { | ||
38 | for (int i = 0; i < steps; i++) { | ||
39 | int index = i + 1; | ||
40 | int nextKey = r.nextInt(maxKey); | ||
41 | String nextValue = values[r.nextInt(values.length)]; | ||
42 | try { | ||
43 | immutable.put(nextKey, nextValue); | ||
44 | mutable.put(nextKey, nextValue); | ||
45 | } catch (Exception exception) { | ||
46 | exception.printStackTrace(); | ||
47 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
48 | } | ||
49 | if (index % commitFrequency == 0) { | ||
50 | immutable.commit(); | ||
51 | } | ||
52 | MapTestEnvironment.compareTwoMaps(scenario + ":" + index, immutable, mutable); | ||
53 | |||
54 | MapTestEnvironment.printStatus(scenario, index, steps, null); | ||
55 | } | ||
56 | } | ||
57 | |||
58 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
59 | @MethodSource | ||
60 | @Timeout(value = 10) | ||
61 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
62 | boolean evilHash) { | ||
63 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
64 | noKeys, noValues, commitFrequency, evilHash); | ||
65 | } | ||
66 | |||
67 | public static Stream<Arguments> parametrizedSmoke() { | ||
68 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | ||
69 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, | ||
70 | new Object[] { false, true }); | ||
71 | } | ||
72 | } | ||
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableSmokeTest.java new file mode 100644 index 00000000..c24c220d --- /dev/null +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/MutableSmokeTest.java | |||
@@ -0,0 +1,76 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | ||
2 | |||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | |||
5 | import java.util.Random; | ||
6 | import java.util.stream.Stream; | ||
7 | |||
8 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | ||
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | ||
14 | import org.junit.jupiter.api.Timeout; | ||
15 | import org.junit.jupiter.params.ParameterizedTest; | ||
16 | import org.junit.jupiter.params.provider.Arguments; | ||
17 | import org.junit.jupiter.params.provider.MethodSource; | ||
18 | |||
19 | public class MutableSmokeTest { | ||
20 | |||
21 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean evilHash) { | ||
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
24 | |||
25 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
26 | VersionedMapImpl<Integer, String> sut = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
27 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<Integer, String>(sut); | ||
28 | |||
29 | Random r = new Random(seed); | ||
30 | |||
31 | iterativeRandomPuts(scenario, steps, maxKey, values, e, r); | ||
32 | } | ||
33 | |||
34 | void iterativeRandomPuts(String scenario, int steps, int maxKey, String[] values, | ||
35 | MapTestEnvironment<Integer, String> e, Random r) { | ||
36 | int stopAt = -1; | ||
37 | for (int i = 0; i < steps; i++) { | ||
38 | int index = i + 1; | ||
39 | int nextKey = r.nextInt(maxKey); | ||
40 | String nextValue = values[r.nextInt(values.length)]; | ||
41 | if (index == stopAt) { | ||
42 | System.out.println("issue!"); | ||
43 | System.out.println("State before:"); | ||
44 | e.printComparison(); | ||
45 | e.sut.prettyPrint(); | ||
46 | System.out.println("Next: put(" + nextKey + "," + nextValue + ")"); | ||
47 | } | ||
48 | try { | ||
49 | e.put(nextKey, nextValue); | ||
50 | if (index == stopAt) { | ||
51 | e.sut.prettyPrint(); | ||
52 | } | ||
53 | e.checkEquivalence(scenario + ":" + index); | ||
54 | } catch (Exception exception) { | ||
55 | exception.printStackTrace(); | ||
56 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
57 | } | ||
58 | MapTestEnvironment.printStatus(scenario, index, steps, null); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | @ParameterizedTest(name = "Mutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} seed={4} evil-hash={5}") | ||
63 | @MethodSource | ||
64 | @Timeout(value = 10) | ||
65 | void parametrizedSmoke(int test, int steps, int noKeys, int noValues, int seed, boolean evilHash) { | ||
66 | runSmokeTest( | ||
67 | "SmokeS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), | ||
68 | seed, steps, noKeys, noValues, evilHash); | ||
69 | } | ||
70 | |||
71 | public static Stream<Arguments> parametrizedSmoke() { | ||
72 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, | ||
73 | new Object[] { 3, 32, 32 * 32, 32 * 32 * 32 * 32 }, new Object[] { 2, 3 }, new Object[] { 1, 2, 3 }, | ||
74 | new Object[] { false, true }); | ||
75 | } | ||
76 | } | ||
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/RestoreSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/RestoreSmokeTest.java new file mode 100644 index 00000000..4ca9b088 --- /dev/null +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/fast/RestoreSmokeTest.java | |||
@@ -0,0 +1,92 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | ||
2 | |||
3 | import static org.junit.jupiter.api.Assertions.fail; | ||
4 | |||
5 | import java.util.HashMap; | ||
6 | import java.util.Map; | ||
7 | import java.util.Random; | ||
8 | import java.util.stream.Stream; | ||
9 | |||
10 | import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | ||
11 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | ||
12 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | ||
13 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | ||
14 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | ||
15 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | ||
16 | import org.junit.jupiter.api.Timeout; | ||
17 | import org.junit.jupiter.params.ParameterizedTest; | ||
18 | import org.junit.jupiter.params.provider.Arguments; | ||
19 | import org.junit.jupiter.params.provider.MethodSource; | ||
20 | |||
21 | public class RestoreSmokeTest { | ||
22 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | ||
23 | boolean evilHash) { | ||
24 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
25 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
26 | |||
27 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
28 | |||
29 | iterativeRandomPutsAndCommitsThenRestore(scenario, store, steps, maxKey, values, seed, commitFrequency); | ||
30 | } | ||
31 | |||
32 | void iterativeRandomPutsAndCommitsThenRestore(String scenario, VersionedMapStore<Integer, String> store, int steps, | ||
33 | int maxKey, String[] values, int seed, int commitFrequency) { | ||
34 | // 1. build a map with versions | ||
35 | Random r = new Random(seed); | ||
36 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
37 | Map<Integer, Long> index2Version = new HashMap<>(); | ||
38 | |||
39 | for (int i = 0; i < steps; i++) { | ||
40 | int index = i + 1; | ||
41 | int nextKey = r.nextInt(maxKey); | ||
42 | String nextValue = values[r.nextInt(values.length)]; | ||
43 | try { | ||
44 | versioned.put(nextKey, nextValue); | ||
45 | } catch (Exception exception) { | ||
46 | exception.printStackTrace(); | ||
47 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
48 | } | ||
49 | if (index % commitFrequency == 0) { | ||
50 | long version = versioned.commit(); | ||
51 | index2Version.put(i, version); | ||
52 | } | ||
53 | MapTestEnvironment.printStatus(scenario, index, steps, "building"); | ||
54 | } | ||
55 | // 2. create a non-versioned and | ||
56 | VersionedMapImpl<Integer, String> reference = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
57 | r = new Random(seed); | ||
58 | |||
59 | for (int i = 0; i < steps; i++) { | ||
60 | int index = i + 1; | ||
61 | int nextKey = r.nextInt(maxKey); | ||
62 | String nextValue = values[r.nextInt(values.length)]; | ||
63 | try { | ||
64 | reference.put(nextKey, nextValue); | ||
65 | } catch (Exception exception) { | ||
66 | exception.printStackTrace(); | ||
67 | fail(scenario + ":" + index + ": exception happened: " + exception); | ||
68 | } | ||
69 | if (index % commitFrequency == 0) { | ||
70 | versioned.restore(index2Version.get(i)); | ||
71 | MapTestEnvironment.compareTwoMaps(scenario + ":" + index, reference, versioned); | ||
72 | } | ||
73 | MapTestEnvironment.printStatus(scenario, index, steps, "comparison"); | ||
74 | } | ||
75 | |||
76 | } | ||
77 | |||
78 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
79 | @MethodSource | ||
80 | @Timeout(value = 10) | ||
81 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
82 | boolean evilHash) { | ||
83 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
84 | noKeys, noValues, commitFrequency, evilHash); | ||
85 | } | ||
86 | |||
87 | public static Stream<Arguments> parametrizedSmoke() { | ||
88 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | ||
89 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, | ||
90 | new Object[] { false, true }); | ||
91 | } | ||
92 | } | ||