diff options
author | 2021-07-29 19:55:46 +0200 | |
---|---|---|
committer | 2021-07-29 19:55:46 +0200 | |
commit | 4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413 (patch) | |
tree | d69e8e5c9c7f621b3109c28939091d07982d91dc /model-data/src | |
parent | Add new data structure for backend (diff) | |
download | refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.tar.gz refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.tar.zst refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.zip |
Data structure cleanup with Sonar
Diffstat (limited to 'model-data/src')
13 files changed, 171 insertions, 224 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java index c551ffe7..7b69ae54 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/VersionedMapStoreImpl.java | |||
@@ -12,67 +12,50 @@ import org.eclipse.viatra.solver.data.map.internal.MapDiffCursor; | |||
12 | import org.eclipse.viatra.solver.data.map.internal.Node; | 12 | import org.eclipse.viatra.solver.data.map.internal.Node; |
13 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 13 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
14 | 14 | ||
15 | public class VersionedMapStoreImpl<KEY,VALUE> implements VersionedMapStore<KEY, VALUE> { | 15 | public class VersionedMapStoreImpl<KEY, VALUE> implements VersionedMapStore<KEY, VALUE> { |
16 | // Configuration | 16 | // Configuration |
17 | final private boolean immutableWhenCommiting; | 17 | private final boolean immutableWhenCommiting; |
18 | 18 | ||
19 | // Static data | 19 | // Static data |
20 | protected final ContinousHashProvider<? super KEY> hashProvider; | 20 | protected final ContinousHashProvider<? super KEY> hashProvider; |
21 | protected final VALUE defaultValue; | 21 | protected final VALUE defaultValue; |
22 | 22 | ||
23 | // Dynamic data | 23 | // Dynamic data |
24 | final protected Map<Long, ImmutableNode<KEY,VALUE>> states; | 24 | protected final Map<Long, ImmutableNode<KEY, VALUE>> states = new HashMap<>(); |
25 | final protected Map<Node<KEY,VALUE>, ImmutableNode<KEY,VALUE>> nodeCache; | 25 | protected final Map<Node<KEY, VALUE>, ImmutableNode<KEY, VALUE>> nodeCache; |
26 | protected long nextID; | 26 | protected long nextID = 0; |
27 | 27 | ||
28 | public VersionedMapStoreImpl( | 28 | public VersionedMapStoreImpl(ContinousHashProvider<? super KEY> hashProvider, VALUE defaultValue, |
29 | ContinousHashProvider<? super KEY> hashProvider, | 29 | VersionedMapStoreConfiguration config) { |
30 | VALUE defaultValue, | ||
31 | VersionedMapStoreConfiguration config) | ||
32 | { | ||
33 | this.immutableWhenCommiting = config.immutableWhenCommiting; | 30 | this.immutableWhenCommiting = config.immutableWhenCommiting; |
34 | |||
35 | this.hashProvider = hashProvider; | 31 | this.hashProvider = hashProvider; |
36 | this.defaultValue = defaultValue; | 32 | this.defaultValue = defaultValue; |
37 | 33 | if (config.sharedNodeCacheInStore) { | |
38 | states = new HashMap<>(); | ||
39 | nextID = 0; | ||
40 | if(config.sharedNodeCacheInStore) { | ||
41 | nodeCache = new HashMap<>(); | 34 | nodeCache = new HashMap<>(); |
42 | } else { | 35 | } else { |
43 | nodeCache = null; | 36 | nodeCache = null; |
44 | } | 37 | } |
45 | } | 38 | } |
46 | private VersionedMapStoreImpl( | 39 | |
47 | ContinousHashProvider<? super KEY> hashProvider, | 40 | private VersionedMapStoreImpl(ContinousHashProvider<? super KEY> hashProvider, VALUE defaultValue, |
48 | VALUE defaultValue, | 41 | Map<Node<KEY, VALUE>, ImmutableNode<KEY, VALUE>> nodeCache, VersionedMapStoreConfiguration config) { |
49 | Map<Node<KEY,VALUE>, ImmutableNode<KEY,VALUE>> nodeCache, | ||
50 | VersionedMapStoreConfiguration config) | ||
51 | { | ||
52 | this.immutableWhenCommiting = config.immutableWhenCommiting; | 42 | this.immutableWhenCommiting = config.immutableWhenCommiting; |
53 | |||
54 | this.hashProvider = hashProvider; | 43 | this.hashProvider = hashProvider; |
55 | this.defaultValue = defaultValue; | 44 | this.defaultValue = defaultValue; |
56 | |||
57 | states = new HashMap<>(); | ||
58 | nextID = 0; | ||
59 | this.nodeCache = nodeCache; | 45 | this.nodeCache = nodeCache; |
60 | } | 46 | } |
61 | 47 | ||
62 | public VersionedMapStoreImpl(ContinousHashProvider<KEY> hashProvider, VALUE defaultValue) { | 48 | public VersionedMapStoreImpl(ContinousHashProvider<KEY> hashProvider, VALUE defaultValue) { |
63 | this(hashProvider,defaultValue,new VersionedMapStoreConfiguration()); | 49 | this(hashProvider, defaultValue, new VersionedMapStoreConfiguration()); |
64 | } | 50 | } |
65 | 51 | ||
66 | public static <MAP,KEY,VALUE> List<VersionedMapStore<KEY,VALUE>> createSharedVersionedMapStores( | 52 | public static <KEY, VALUE> List<VersionedMapStore<KEY, VALUE>> createSharedVersionedMapStores(int amount, |
67 | int amount, | 53 | ContinousHashProvider<? super KEY> hashProvider, VALUE defaultValue, |
68 | ContinousHashProvider<? super KEY> hashProvider, | 54 | VersionedMapStoreConfiguration config) { |
69 | VALUE defaultValue, | 55 | List<VersionedMapStore<KEY, VALUE>> result = new ArrayList<>(amount); |
70 | VersionedMapStoreConfiguration config) | 56 | if (config.sharedNodeCacheInStoreGroups) { |
71 | { | 57 | Map<Node<KEY, VALUE>, ImmutableNode<KEY, VALUE>> nodeCache; |
72 | List<VersionedMapStore<KEY,VALUE>> result = new ArrayList<>(amount); | 58 | if (config.sharedNodeCacheInStore) { |
73 | if(config.sharedNodeCacheInStoreGroups) { | ||
74 | Map<Node<KEY,VALUE>, ImmutableNode<KEY,VALUE>> nodeCache; | ||
75 | if(config.sharedNodeCacheInStore) { | ||
76 | nodeCache = new HashMap<>(); | 59 | nodeCache = new HashMap<>(); |
77 | } else { | 60 | } else { |
78 | nodeCache = null; | 61 | nodeCache = null; |
@@ -87,69 +70,55 @@ public class VersionedMapStoreImpl<KEY,VALUE> implements VersionedMapStore<KEY, | |||
87 | } | 70 | } |
88 | return result; | 71 | return result; |
89 | } | 72 | } |
90 | public static <MAP,KEY,VALUE> List<VersionedMapStore<KEY,VALUE>> createSharedVersionedMapStores( | 73 | |
91 | int amount, | 74 | public static <KEY, VALUE> List<VersionedMapStore<KEY, VALUE>> createSharedVersionedMapStores(int amount, |
92 | ContinousHashProvider<? super KEY> hashProvider, | 75 | ContinousHashProvider<? super KEY> hashProvider, VALUE defaultValue) { |
93 | VALUE defaultValue) | 76 | return createSharedVersionedMapStores(amount, hashProvider, defaultValue, new VersionedMapStoreConfiguration()); |
94 | { | ||
95 | return createSharedVersionedMapStores(amount,hashProvider,defaultValue,new VersionedMapStoreConfiguration()); | ||
96 | } | 77 | } |
97 | 78 | ||
98 | synchronized Set<Long> getStates() { | 79 | synchronized Set<Long> getStates() { |
99 | return states.keySet(); | 80 | return states.keySet(); |
100 | } | 81 | } |
101 | 82 | ||
102 | @Override | 83 | @Override |
103 | public VersionedMap<KEY,VALUE> createMap() { | 84 | public VersionedMap<KEY, VALUE> createMap() { |
104 | return new VersionedMapImpl<KEY,VALUE>(this,hashProvider,defaultValue); | 85 | return new VersionedMapImpl<KEY, VALUE>(this, hashProvider, defaultValue); |
105 | } | 86 | } |
87 | |||
106 | @Override | 88 | @Override |
107 | public VersionedMap<KEY,VALUE> createMap(long state) { | 89 | public VersionedMap<KEY, VALUE> createMap(long state) { |
108 | ImmutableNode<KEY, VALUE> data = revert(state); | 90 | ImmutableNode<KEY, VALUE> data = revert(state); |
109 | return new VersionedMapImpl<KEY,VALUE>(this,hashProvider,defaultValue,data); | 91 | return new VersionedMapImpl<KEY, VALUE>(this, hashProvider, defaultValue, data); |
110 | } | 92 | } |
111 | 93 | ||
112 | synchronized public ImmutableNode<KEY,VALUE> revert(long state) { | 94 | public synchronized ImmutableNode<KEY, VALUE> revert(long state) { |
113 | if(states.containsKey(state)) { | 95 | if (states.containsKey(state)) { |
114 | return states.get(state); | 96 | return states.get(state); |
115 | } else { | 97 | } else { |
116 | ArrayList<Long> existingKeys = new ArrayList<Long>(states.keySet()); | 98 | ArrayList<Long> existingKeys = new ArrayList<Long>(states.keySet()); |
117 | Collections.sort(existingKeys); | 99 | Collections.sort(existingKeys); |
118 | throw new IllegalArgumentException( | 100 | throw new IllegalArgumentException("Store does not contain state " + state + "! Avaliable states: " |
119 | "Store does not contain state "+state+"! Avaliable states: "+existingKeys.toArray().toString()); | 101 | + existingKeys.toArray().toString()); |
120 | } | 102 | } |
121 | } | 103 | } |
122 | synchronized public long commit(Node<KEY,VALUE> data, VersionedMapImpl<KEY, VALUE> mapToUpdateRoot) { | 104 | |
123 | ImmutableNode<KEY,VALUE> immutable; | 105 | public synchronized long commit(Node<KEY, VALUE> data, VersionedMapImpl<KEY, VALUE> mapToUpdateRoot) { |
124 | if(data != null) { | 106 | ImmutableNode<KEY, VALUE> immutable; |
125 | if(this.nodeCache != null) { | 107 | if (data != null) { |
126 | immutable = data.toImmutable(this.nodeCache); | 108 | immutable = data.toImmutable(this.nodeCache); |
127 | } else { | ||
128 | immutable = data.toImmutable(); | ||
129 | } | ||
130 | } else { | 109 | } else { |
131 | immutable = null; | 110 | immutable = null; |
132 | } | 111 | } |
133 | 112 | ||
134 | 113 | if (nextID == Long.MAX_VALUE) | |
135 | if(nextID == Long.MAX_VALUE) throw new IllegalStateException( | 114 | throw new IllegalStateException("Map store run out of Id-s"); |
136 | "Map store run out of Id-s"); | ||
137 | long id = nextID++; | 115 | long id = nextID++; |
138 | this.states.put(id, immutable); | 116 | this.states.put(id, immutable); |
139 | if(this.immutableWhenCommiting) { | 117 | if (this.immutableWhenCommiting) { |
140 | mapToUpdateRoot.setRoot(immutable); | 118 | mapToUpdateRoot.setRoot(immutable); |
141 | } | 119 | } |
142 | return id; | 120 | return id; |
143 | } | 121 | } |
144 | |||
145 | // public Map<Node<KEY,VALUE>, ImmutableNode<KEY,VALUE>> getStore() { | ||
146 | // return this.nodeCache; | ||
147 | // } | ||
148 | // public long addState(ImmutableNode<KEY,VALUE> data) { | ||
149 | // | ||
150 | // states.put(id,data); | ||
151 | // return id; | ||
152 | // } | ||
153 | 122 | ||
154 | @Override | 123 | @Override |
155 | public DiffCursor<KEY, VALUE> getDiffCursor(long fromState, long toState) { | 124 | public DiffCursor<KEY, VALUE> getDiffCursor(long fromState, long toState) { |
@@ -157,6 +126,6 @@ public class VersionedMapStoreImpl<KEY,VALUE> implements VersionedMapStore<KEY, | |||
157 | VersionedMap<KEY, VALUE> map2 = createMap(toState); | 126 | VersionedMap<KEY, VALUE> map2 = createMap(toState); |
158 | Cursor<KEY, VALUE> cursor1 = map1.getCursor(); | 127 | Cursor<KEY, VALUE> cursor1 = map1.getCursor(); |
159 | Cursor<KEY, VALUE> cursor2 = map2.getCursor(); | 128 | Cursor<KEY, VALUE> cursor2 = map2.getCursor(); |
160 | return new MapDiffCursor<KEY, VALUE>(this.hashProvider,this.defaultValue,cursor1,cursor2); | 129 | return new MapDiffCursor<KEY, VALUE>(this.hashProvider, this.defaultValue, cursor1, cursor2); |
161 | } | 130 | } |
162 | } | 131 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java index 087c12a1..832742d0 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/ImmutableNode.java | |||
@@ -202,11 +202,6 @@ public class ImmutableNode<KEY, VALUE> extends Node<KEY, VALUE> { | |||
202 | protected MutableNode<KEY,VALUE> toMutable() { | 202 | protected MutableNode<KEY,VALUE> toMutable() { |
203 | return new MutableNode<KEY,VALUE>(this); | 203 | return new MutableNode<KEY,VALUE>(this); |
204 | } | 204 | } |
205 | |||
206 | @Override | ||
207 | public ImmutableNode<KEY,VALUE> toImmutable() { | ||
208 | return this; | ||
209 | } | ||
210 | 205 | ||
211 | @Override | 206 | @Override |
212 | public ImmutableNode<KEY, VALUE> toImmutable( | 207 | public ImmutableNode<KEY, VALUE> toImmutable( |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java index 963ce111..d32e5fc9 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/MutableNode.java | |||
@@ -127,8 +127,6 @@ public class MutableNode<KEY,VALUE> extends Node<KEY,VALUE> { | |||
127 | } | 127 | } |
128 | } | 128 | } |
129 | } | 129 | } |
130 | |||
131 | |||
132 | 130 | ||
133 | private Node<KEY, VALUE> addEntry(KEY key, VALUE value, int selectedHashFragment) { | 131 | private Node<KEY, VALUE> addEntry(KEY key, VALUE value, int selectedHashFragment) { |
134 | content[2*selectedHashFragment] = key; | 132 | content[2*selectedHashFragment] = key; |
@@ -255,11 +253,6 @@ public class MutableNode<KEY,VALUE> extends Node<KEY,VALUE> { | |||
255 | } | 253 | } |
256 | 254 | ||
257 | @Override | 255 | @Override |
258 | public ImmutableNode<KEY,VALUE> toImmutable() { | ||
259 | return ImmutableNode.constructImmutable(this,null); | ||
260 | } | ||
261 | |||
262 | @Override | ||
263 | public ImmutableNode<KEY, VALUE> toImmutable(Map<Node<KEY, VALUE>, ImmutableNode<KEY, VALUE>> cache) { | 256 | public ImmutableNode<KEY, VALUE> toImmutable(Map<Node<KEY, VALUE>, ImmutableNode<KEY, VALUE>> cache) { |
264 | return ImmutableNode.constructImmutable(this,cache); | 257 | return ImmutableNode.constructImmutable(this,cache); |
265 | } | 258 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java index 3695825d..f19ca06f 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/map/internal/Node.java | |||
@@ -62,7 +62,6 @@ public abstract class Node<KEY,VALUE>{ | |||
62 | abstract public long getSize(); | 62 | abstract public long getSize(); |
63 | 63 | ||
64 | abstract MutableNode<KEY, VALUE> toMutable(); | 64 | abstract MutableNode<KEY, VALUE> toMutable(); |
65 | public abstract ImmutableNode<KEY, VALUE> toImmutable(); | ||
66 | public abstract ImmutableNode<KEY, VALUE> toImmutable( | 65 | public abstract ImmutableNode<KEY, VALUE> toImmutable( |
67 | Map<Node<KEY, VALUE>,ImmutableNode<KEY, VALUE>> cache); | 66 | Map<Node<KEY, VALUE>,ImmutableNode<KEY, VALUE>> cache); |
68 | 67 | ||
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/CommitSmokeTest.java index 5c340090..25ad81d2 100644 --- 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/CommitSmokeTest.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | 3 | import static org.junit.jupiter.api.Assertions.fail; |
4 | 4 | ||
@@ -9,15 +9,16 @@ import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | |||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | 9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; |
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | 12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.SmokeTestUtils; |
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | 13 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; |
14 | import org.junit.jupiter.api.Tag; | ||
14 | import org.junit.jupiter.api.Timeout; | 15 | import org.junit.jupiter.api.Timeout; |
15 | import org.junit.jupiter.params.ParameterizedTest; | 16 | import org.junit.jupiter.params.ParameterizedTest; |
16 | import org.junit.jupiter.params.provider.Arguments; | 17 | import org.junit.jupiter.params.provider.Arguments; |
17 | import org.junit.jupiter.params.provider.MethodSource; | 18 | import org.junit.jupiter.params.provider.MethodSource; |
18 | 19 | ||
19 | public class CommitSmokeTest { | 20 | class CommitSmokeTest { |
20 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | 21 | private void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, |
21 | boolean evilHash) { | 22 | boolean evilHash) { |
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | 23 | String[] values = MapTestEnvironment.prepareValues(maxValue); |
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 24 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); |
@@ -65,15 +66,30 @@ public class CommitSmokeTest { | |||
65 | @ParameterizedTest(name = "Immutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | 66 | @ParameterizedTest(name = "Immutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") |
66 | @MethodSource | 67 | @MethodSource |
67 | @Timeout(value = 10) | 68 | @Timeout(value = 10) |
68 | public void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | 69 | @Tag("smoke") |
70 | void parametrizedFastSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
69 | boolean evilHash) { | 71 | boolean evilHash) { |
70 | runSmokeTest("SmokeCommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | 72 | runSmokeTest("SmokeCommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
71 | commitFrequency, evilHash); | 73 | commitFrequency, evilHash); |
72 | } | 74 | } |
73 | 75 | ||
74 | public static Stream<Arguments> parametrizedSmoke() { | 76 | static Stream<Arguments> parametrizedFastSmoke() { |
75 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | 77 | return SmokeTestUtils.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 }, | 78 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, |
77 | new Object[] { false, true }); | 79 | new Object[] { false, true }); |
78 | } | 80 | } |
81 | |||
82 | @ParameterizedTest(name = "Immutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
83 | @MethodSource | ||
84 | @Tag("smoke") | ||
85 | @Tag("slow") | ||
86 | void parametrizedSlowSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
87 | boolean evilHash) { | ||
88 | runSmokeTest("SmokeCommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | ||
89 | commitFrequency, evilHash); | ||
90 | } | ||
91 | |||
92 | static Stream<Arguments> parametrizedSlowSmoke() { | ||
93 | return SmokeTestUtils.changeStepCount(parametrizedFastSmoke(), 1); | ||
94 | } | ||
79 | } | 95 | } |
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/DiffCursorSmokeTest.java index ef51d05e..c36fac47 100644 --- 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/DiffCursorSmokeTest.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | 3 | import static org.junit.jupiter.api.Assertions.fail; |
4 | 4 | ||
@@ -10,15 +10,16 @@ import org.eclipse.viatra.solver.data.map.DiffCursor; | |||
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | 10 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; |
11 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 11 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
12 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 12 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
13 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | 13 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.SmokeTestUtils; |
14 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | 14 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; |
15 | import org.junit.jupiter.api.Tag; | ||
15 | import org.junit.jupiter.api.Timeout; | 16 | import org.junit.jupiter.api.Timeout; |
16 | import org.junit.jupiter.params.ParameterizedTest; | 17 | import org.junit.jupiter.params.ParameterizedTest; |
17 | import org.junit.jupiter.params.provider.Arguments; | 18 | import org.junit.jupiter.params.provider.Arguments; |
18 | import org.junit.jupiter.params.provider.MethodSource; | 19 | import org.junit.jupiter.params.provider.MethodSource; |
19 | 20 | ||
20 | public class DiffCursorSmokeTest { | 21 | class DiffCursorSmokeTest { |
21 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | 22 | private void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, |
22 | boolean evilHash) { | 23 | boolean evilHash) { |
23 | String[] values = MapTestEnvironment.prepareValues(maxValue); | 24 | String[] values = MapTestEnvironment.prepareValues(maxValue); |
24 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 25 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); |
@@ -27,7 +28,7 @@ public class DiffCursorSmokeTest { | |||
27 | iterativeRandomPutsAndCommitsThenDiffcursor(scenario, store, steps, maxKey, values, seed, commitFrequency); | 28 | iterativeRandomPutsAndCommitsThenDiffcursor(scenario, store, steps, maxKey, values, seed, commitFrequency); |
28 | } | 29 | } |
29 | 30 | ||
30 | void iterativeRandomPutsAndCommitsThenDiffcursor(String scenario, VersionedMapStore<Integer, String> store, | 31 | private void iterativeRandomPutsAndCommitsThenDiffcursor(String scenario, VersionedMapStore<Integer, String> store, |
31 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { | 32 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { |
32 | // 1. build a map with versions | 33 | // 1. build a map with versions |
33 | Random r = new Random(seed); | 34 | Random r = new Random(seed); |
@@ -87,14 +88,15 @@ public class DiffCursorSmokeTest { | |||
87 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | 88 | @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 | @MethodSource |
89 | @Timeout(value = 10) | 90 | @Timeout(value = 10) |
91 | @Tag("smoke") | ||
90 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | 92 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, |
91 | boolean evilHash) { | 93 | boolean evilHash) { |
92 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | 94 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, |
93 | noKeys, noValues, commitFrequency, evilHash); | 95 | noKeys, noValues, commitFrequency, evilHash); |
94 | } | 96 | } |
95 | 97 | ||
96 | public static Stream<Arguments> parametrizedSmoke() { | 98 | static Stream<Arguments> parametrizedSmoke() { |
97 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | 99 | return SmokeTestUtils.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 }, | 100 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, |
99 | new Object[] { false, true }); | 101 | new Object[] { false, true }); |
100 | } | 102 | } |
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/MutableImmutableCompareSmokeTest.java index ac5571b3..115b1fec 100644 --- 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/MutableImmutableCompareSmokeTest.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | 3 | import static org.junit.jupiter.api.Assertions.fail; |
4 | 4 | ||
@@ -9,15 +9,16 @@ import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | |||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | 9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; |
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | 12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.SmokeTestUtils; |
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | 13 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; |
14 | import org.junit.jupiter.api.Tag; | ||
14 | import org.junit.jupiter.api.Timeout; | 15 | import org.junit.jupiter.api.Timeout; |
15 | import org.junit.jupiter.params.ParameterizedTest; | 16 | import org.junit.jupiter.params.ParameterizedTest; |
16 | import org.junit.jupiter.params.provider.Arguments; | 17 | import org.junit.jupiter.params.provider.Arguments; |
17 | import org.junit.jupiter.params.provider.MethodSource; | 18 | import org.junit.jupiter.params.provider.MethodSource; |
18 | 19 | ||
19 | public class MutableImmutableCompareSmokeTest { | 20 | class MutableImmutableCompareSmokeTest { |
20 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | 21 | private void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, |
21 | boolean evilHash) { | 22 | boolean evilHash) { |
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | 23 | String[] values = MapTestEnvironment.prepareValues(maxValue); |
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 24 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); |
@@ -32,7 +33,7 @@ public class MutableImmutableCompareSmokeTest { | |||
32 | commitFrequency); | 33 | commitFrequency); |
33 | } | 34 | } |
34 | 35 | ||
35 | void iterativeRandomPutsAndCommitsAndCompare(String scenario, VersionedMapImpl<Integer, String> immutable, | 36 | private void iterativeRandomPutsAndCommitsAndCompare(String scenario, VersionedMapImpl<Integer, String> immutable, |
36 | VersionedMapImpl<Integer, String> mutable, int steps, int maxKey, String[] values, Random r, | 37 | VersionedMapImpl<Integer, String> mutable, int steps, int maxKey, String[] values, Random r, |
37 | int commitFrequency) { | 38 | int commitFrequency) { |
38 | for (int i = 0; i < steps; i++) { | 39 | for (int i = 0; i < steps; i++) { |
@@ -58,15 +59,30 @@ public class MutableImmutableCompareSmokeTest { | |||
58 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | 59 | @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 | @MethodSource |
60 | @Timeout(value = 10) | 61 | @Timeout(value = 10) |
61 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | 62 | @Tag("smoke") |
63 | void parametrizedFastSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
62 | boolean evilHash) { | 64 | boolean evilHash) { |
63 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | 65 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, |
64 | noKeys, noValues, commitFrequency, evilHash); | 66 | noKeys, noValues, commitFrequency, evilHash); |
65 | } | 67 | } |
66 | 68 | ||
67 | public static Stream<Arguments> parametrizedSmoke() { | 69 | static Stream<Arguments> parametrizedFastSmoke() { |
68 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | 70 | return SmokeTestUtils.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 }, | 71 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, |
70 | new Object[] { false, true }); | 72 | new Object[] { false, true }); |
71 | } | 73 | } |
74 | |||
75 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
76 | @MethodSource | ||
77 | @Tag("smoke") | ||
78 | @Tag("slow") | ||
79 | void parametrizedSlowSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
80 | boolean evilHash) { | ||
81 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
82 | noKeys, noValues, commitFrequency, evilHash); | ||
83 | } | ||
84 | |||
85 | static Stream<Arguments> parametrizedSlowSmoke() { | ||
86 | return SmokeTestUtils.changeStepCount(MutableImmutableCompareSmokeTest.parametrizedSlowSmoke(), 1); | ||
87 | } | ||
72 | } | 88 | } |
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/MutableSmokeTest.java index c24c220d..999325f0 100644 --- 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/MutableSmokeTest.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | 3 | import static org.junit.jupiter.api.Assertions.fail; |
4 | 4 | ||
@@ -9,16 +9,16 @@ import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | |||
9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | 9 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; |
10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 10 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 11 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | 12 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.SmokeTestUtils; |
13 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | 13 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; |
14 | import org.junit.jupiter.api.Tag; | ||
14 | import org.junit.jupiter.api.Timeout; | 15 | import org.junit.jupiter.api.Timeout; |
15 | import org.junit.jupiter.params.ParameterizedTest; | 16 | import org.junit.jupiter.params.ParameterizedTest; |
16 | import org.junit.jupiter.params.provider.Arguments; | 17 | import org.junit.jupiter.params.provider.Arguments; |
17 | import org.junit.jupiter.params.provider.MethodSource; | 18 | import org.junit.jupiter.params.provider.MethodSource; |
18 | 19 | ||
19 | public class MutableSmokeTest { | 20 | class MutableSmokeTest { |
20 | 21 | private void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean evilHash) { | |
21 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean evilHash) { | ||
22 | String[] values = MapTestEnvironment.prepareValues(maxValue); | 22 | String[] values = MapTestEnvironment.prepareValues(maxValue); |
23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 23 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); |
24 | 24 | ||
@@ -31,7 +31,7 @@ public class MutableSmokeTest { | |||
31 | iterativeRandomPuts(scenario, steps, maxKey, values, e, r); | 31 | iterativeRandomPuts(scenario, steps, maxKey, values, e, r); |
32 | } | 32 | } |
33 | 33 | ||
34 | void iterativeRandomPuts(String scenario, int steps, int maxKey, String[] values, | 34 | private void iterativeRandomPuts(String scenario, int steps, int maxKey, String[] values, |
35 | MapTestEnvironment<Integer, String> e, Random r) { | 35 | MapTestEnvironment<Integer, String> e, Random r) { |
36 | int stopAt = -1; | 36 | int stopAt = -1; |
37 | for (int i = 0; i < steps; i++) { | 37 | for (int i = 0; i < steps; i++) { |
@@ -62,14 +62,15 @@ public class MutableSmokeTest { | |||
62 | @ParameterizedTest(name = "Mutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} seed={4} evil-hash={5}") | 62 | @ParameterizedTest(name = "Mutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} seed={4} evil-hash={5}") |
63 | @MethodSource | 63 | @MethodSource |
64 | @Timeout(value = 10) | 64 | @Timeout(value = 10) |
65 | @Tag("smoke") | ||
65 | void parametrizedSmoke(int test, int steps, int noKeys, int noValues, int seed, boolean evilHash) { | 66 | void parametrizedSmoke(int test, int steps, int noKeys, int noValues, int seed, boolean evilHash) { |
66 | runSmokeTest( | 67 | runSmokeTest( |
67 | "SmokeS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), | 68 | "SmokeS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), |
68 | seed, steps, noKeys, noValues, evilHash); | 69 | seed, steps, noKeys, noValues, evilHash); |
69 | } | 70 | } |
70 | 71 | ||
71 | public static Stream<Arguments> parametrizedSmoke() { | 72 | static Stream<Arguments> parametrizedSmoke() { |
72 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, | 73 | return SmokeTestUtils.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[] { 3, 32, 32 * 32, 32 * 32 * 32 * 32 }, new Object[] { 2, 3 }, new Object[] { 1, 2, 3 }, |
74 | new Object[] { false, true }); | 75 | 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/RestoreSmokeTest.java index 4ca9b088..fa96f0c1 100644 --- 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/RestoreSmokeTest.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.fast; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.fail; | 3 | import static org.junit.jupiter.api.Assertions.fail; |
4 | 4 | ||
@@ -11,15 +11,16 @@ import org.eclipse.viatra.solver.data.map.ContinousHashProvider; | |||
11 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; | 11 | import org.eclipse.viatra.solver.data.map.VersionedMapStore; |
12 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; | 12 | import org.eclipse.viatra.solver.data.map.VersionedMapStoreImpl; |
13 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; | 13 | import org.eclipse.viatra.solver.data.map.internal.VersionedMapImpl; |
14 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.TestPermuter; | 14 | import org.eclipse.viatra.solver.data.map.tests.smoke.utils.SmokeTestUtils; |
15 | import org.eclipse.viatra.solver.data.map.tests.support.MapTestEnvironment; | 15 | import org.eclipse.viatra.solver.data.map.tests.utils.MapTestEnvironment; |
16 | import org.junit.jupiter.api.Tag; | ||
16 | import org.junit.jupiter.api.Timeout; | 17 | import org.junit.jupiter.api.Timeout; |
17 | import org.junit.jupiter.params.ParameterizedTest; | 18 | import org.junit.jupiter.params.ParameterizedTest; |
18 | import org.junit.jupiter.params.provider.Arguments; | 19 | import org.junit.jupiter.params.provider.Arguments; |
19 | import org.junit.jupiter.params.provider.MethodSource; | 20 | import org.junit.jupiter.params.provider.MethodSource; |
20 | 21 | ||
21 | public class RestoreSmokeTest { | 22 | class RestoreSmokeTest { |
22 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, | 23 | private void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, int commitFrequency, |
23 | boolean evilHash) { | 24 | boolean evilHash) { |
24 | String[] values = MapTestEnvironment.prepareValues(maxValue); | 25 | String[] values = MapTestEnvironment.prepareValues(maxValue); |
25 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | 26 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); |
@@ -29,8 +30,8 @@ public class RestoreSmokeTest { | |||
29 | iterativeRandomPutsAndCommitsThenRestore(scenario, store, steps, maxKey, values, seed, commitFrequency); | 30 | iterativeRandomPutsAndCommitsThenRestore(scenario, store, steps, maxKey, values, seed, commitFrequency); |
30 | } | 31 | } |
31 | 32 | ||
32 | void iterativeRandomPutsAndCommitsThenRestore(String scenario, VersionedMapStore<Integer, String> store, int steps, | 33 | private void iterativeRandomPutsAndCommitsThenRestore(String scenario, VersionedMapStore<Integer, String> store, |
33 | int maxKey, String[] values, int seed, int commitFrequency) { | 34 | int steps, int maxKey, String[] values, int seed, int commitFrequency) { |
34 | // 1. build a map with versions | 35 | // 1. build a map with versions |
35 | Random r = new Random(seed); | 36 | Random r = new Random(seed); |
36 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); | 37 | VersionedMapImpl<Integer, String> versioned = (VersionedMapImpl<Integer, String>) store.createMap(); |
@@ -75,18 +76,33 @@ public class RestoreSmokeTest { | |||
75 | 76 | ||
76 | } | 77 | } |
77 | 78 | ||
78 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | 79 | @ParameterizedTest(name = "Restore Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") |
79 | @MethodSource | 80 | @MethodSource |
80 | @Timeout(value = 10) | 81 | @Timeout(value = 10) |
81 | void parametrizedSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | 82 | @Tag("smoke") |
83 | void parametrizedFastSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
82 | boolean evilHash) { | 84 | boolean evilHash) { |
83 | runSmokeTest("SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | 85 | runSmokeTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, |
84 | noKeys, noValues, commitFrequency, evilHash); | 86 | commitFrequency, evilHash); |
85 | } | 87 | } |
86 | 88 | ||
87 | public static Stream<Arguments> parametrizedSmoke() { | 89 | static Stream<Arguments> parametrizedFastSmoke() { |
88 | return TestPermuter.permutationWithSize(new Object[] { 1000 }, new Object[] { 3, 32, 32 * 32 }, | 90 | return SmokeTestUtils.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 }, | 91 | new Object[] { 2, 3 }, new Object[] { 1, 10, 100 }, new Object[] { 1, 2, 3 }, |
90 | new Object[] { false, true }); | 92 | new Object[] { false, true }); |
91 | } | 93 | } |
94 | |||
95 | @ParameterizedTest(name = "Restore Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
96 | @MethodSource | ||
97 | @Tag("smoke") | ||
98 | @Tag("slow") | ||
99 | void parametrizedSlowSmoke(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, | ||
100 | boolean evilHash) { | ||
101 | runSmokeTest("RestoreS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, | ||
102 | commitFrequency, evilHash); | ||
103 | } | ||
104 | |||
105 | static Stream<Arguments> parametrizedSlowSmoke() { | ||
106 | return SmokeTestUtils.changeStepCount(RestoreSmokeTest.parametrizedFastSmoke(), 1); | ||
107 | } | ||
92 | } | 108 | } |
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/slow/SlowSmokeTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/slow/SlowSmokeTest.java deleted file mode 100644 index 004d30d9..00000000 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/slow/SlowSmokeTest.java +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.slow; | ||
2 | |||
3 | import java.util.Arrays; | ||
4 | import java.util.stream.Stream; | ||
5 | |||
6 | import org.eclipse.viatra.solver.data.map.tests.smoke.fast.CommitSmokeTest; | ||
7 | import org.eclipse.viatra.solver.data.map.tests.smoke.fast.MutableImmutableCompareSmokeTest; | ||
8 | import org.eclipse.viatra.solver.data.map.tests.smoke.fast.MutableSmokeTest; | ||
9 | import org.eclipse.viatra.solver.data.map.tests.smoke.fast.RestoreSmokeTest; | ||
10 | import org.junit.jupiter.api.Disabled; | ||
11 | import org.junit.jupiter.params.ParameterizedTest; | ||
12 | import org.junit.jupiter.params.provider.Arguments; | ||
13 | import org.junit.jupiter.params.provider.MethodSource; | ||
14 | |||
15 | @Disabled | ||
16 | public class SlowSmokeTest { | ||
17 | |||
18 | private static int slowStepCount = 32 * 32 * 32 * 32; | ||
19 | |||
20 | private static Stream<Arguments> changeStepCount(Stream<Arguments> arguments) { | ||
21 | return arguments.map(x -> Arguments.of(updatedStepCount(x.get()))); | ||
22 | |||
23 | } | ||
24 | |||
25 | private static Object[] updatedStepCount(Object[] arguments) { | ||
26 | Object[] copy = Arrays.copyOf(arguments, arguments.length); | ||
27 | copy[1] = slowStepCount; | ||
28 | return copy; | ||
29 | } | ||
30 | |||
31 | @ParameterizedTest(name = "Mutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} seed={4} evil-hash={5}") | ||
32 | @MethodSource | ||
33 | void smoke1(int test, int steps, int noKeys, int noValues, int seed, boolean evilHash) { | ||
34 | (new MutableSmokeTest()).runSmokeTest( | ||
35 | "SmokeS" + steps + "K" + noKeys + "V" + noValues + "s" + seed + "H" + (evilHash ? "Evil" : "Normal"), | ||
36 | seed, steps, noKeys, noValues, evilHash); | ||
37 | } | ||
38 | |||
39 | private static Stream<Arguments> smoke1() { | ||
40 | return changeStepCount(MutableSmokeTest.parametrizedSmoke()); | ||
41 | } | ||
42 | |||
43 | @ParameterizedTest(name = "Immutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
44 | @MethodSource | ||
45 | void smoke2(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, boolean evilHash) { | ||
46 | (new CommitSmokeTest()).runSmokeTest("SmokeCommitS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, | ||
47 | steps, noKeys, noValues, commitFrequency, evilHash); | ||
48 | } | ||
49 | |||
50 | private static Stream<Arguments> smoke2() { | ||
51 | return changeStepCount(CommitSmokeTest.parametrizedSmoke()); | ||
52 | } | ||
53 | |||
54 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
55 | @MethodSource | ||
56 | void smoke3(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, boolean evilHash) { | ||
57 | (new MutableImmutableCompareSmokeTest()).runSmokeTest( | ||
58 | "SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
59 | noKeys, noValues, commitFrequency, evilHash); | ||
60 | } | ||
61 | |||
62 | private static Stream<Arguments> smoke3() { | ||
63 | return changeStepCount(MutableImmutableCompareSmokeTest.parametrizedSmoke()); | ||
64 | } | ||
65 | |||
66 | @ParameterizedTest(name = "Mutable-Immutable Compare Smoke {index}/{0} Steps={1} Keys={2} Values={3} commit frequency={4} seed={5} evil-hash={6}") | ||
67 | @MethodSource | ||
68 | void smoke4(int tests, int steps, int noKeys, int noValues, int commitFrequency, int seed, boolean evilHash) { | ||
69 | (new RestoreSmokeTest()).runSmokeTest( | ||
70 | "SmokeMutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, | ||
71 | noKeys, noValues, commitFrequency, evilHash); | ||
72 | } | ||
73 | |||
74 | private static Stream<Arguments> smoke4() { | ||
75 | return changeStepCount(RestoreSmokeTest.parametrizedSmoke()); | ||
76 | } | ||
77 | } | ||
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java index 0f7b4642..9eab854f 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmokeTestUtils.java | |||
@@ -1,12 +1,29 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.utils; | 1 | package org.eclipse.viatra.solver.data.map.tests.smoke.utils; |
2 | 2 | ||
3 | import java.util.Arrays; | ||
3 | import java.util.LinkedList; | 4 | import java.util.LinkedList; |
4 | import java.util.List; | 5 | import java.util.List; |
5 | import java.util.stream.Stream; | 6 | import java.util.stream.Stream; |
6 | 7 | ||
7 | import org.junit.jupiter.params.provider.Arguments; | 8 | import org.junit.jupiter.params.provider.Arguments; |
8 | 9 | ||
9 | public class TestPermuter { | 10 | public final class SmokeTestUtils { |
11 | private static final int SLOW_STEP_COUNT = 32 * 32 * 32 * 32; | ||
12 | |||
13 | private SmokeTestUtils() { | ||
14 | throw new IllegalStateException("This is a static utility class and should not be instantiated directly"); | ||
15 | } | ||
16 | |||
17 | public static Stream<Arguments> changeStepCount(Stream<Arguments> arguments, int parameterIndex) { | ||
18 | return arguments.map(x -> Arguments.of(updatedStepCount(x.get(), parameterIndex))); | ||
19 | } | ||
20 | |||
21 | public static Object[] updatedStepCount(Object[] arguments, int parameterIndex) { | ||
22 | Object[] copy = Arrays.copyOf(arguments, arguments.length); | ||
23 | copy[parameterIndex] = SLOW_STEP_COUNT; | ||
24 | return copy; | ||
25 | } | ||
26 | |||
10 | static List<List<Object>> permutationInternal(int from, Object[]... valueOption) { | 27 | static List<List<Object>> permutationInternal(int from, Object[]... valueOption) { |
11 | if (valueOption.length == from) { | 28 | if (valueOption.length == from) { |
12 | return List.of(List.of()); | 29 | return List.of(List.of()); |
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuterTest.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmoteTestUtilsTest.java index 91f1c2e0..376b3e50 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuterTest.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/SmoteTestUtilsTest.java | |||
@@ -6,24 +6,24 @@ import java.util.List; | |||
6 | 6 | ||
7 | import org.junit.jupiter.api.Test; | 7 | import org.junit.jupiter.api.Test; |
8 | 8 | ||
9 | class TestPermuterTest { | 9 | class SmoteTestUtilsTest { |
10 | @Test | 10 | @Test |
11 | void permutationInternalTest() { | 11 | void permutationInternalTest() { |
12 | List<List<Object>> res = TestPermuter.permutationInternal(0, new Object[] { 1, 2, 3 }, | 12 | List<List<Object>> res = SmokeTestUtils.permutationInternal(0, new Object[] { 1, 2, 3 }, |
13 | new Object[] { 'a', 'b', 'c' }, new Object[] { "alpha", "beta", "gamma", "delta" }); | 13 | new Object[] { 'a', 'b', 'c' }, new Object[] { "alpha", "beta", "gamma", "delta" }); |
14 | assertEquals(3 * 3 * 4, res.size()); | 14 | assertEquals(3 * 3 * 4, res.size()); |
15 | } | 15 | } |
16 | 16 | ||
17 | @Test | 17 | @Test |
18 | void permutationTest1() { | 18 | void permutationTest1() { |
19 | var res = TestPermuter.permutation(new Object[] { 1, 2, 3 }, new Object[] { 'a', 'b', 'c' }, | 19 | var res = SmokeTestUtils.permutation(new Object[] { 1, 2, 3 }, new Object[] { 'a', 'b', 'c' }, |
20 | new Object[] { "alpha", "beta", "gamma", "delta" }); | 20 | new Object[] { "alpha", "beta", "gamma", "delta" }); |
21 | assertEquals(3 * 3 * 4, res.count()); | 21 | assertEquals(3 * 3 * 4, res.count()); |
22 | } | 22 | } |
23 | 23 | ||
24 | @Test | 24 | @Test |
25 | void permutationTest2() { | 25 | void permutationTest2() { |
26 | var res = TestPermuter.permutation(new Object[] { 1, 2, 3 }, new Object[] { 'a', 'b', 'c' }, | 26 | var res = SmokeTestUtils.permutation(new Object[] { 1, 2, 3 }, new Object[] { 'a', 'b', 'c' }, |
27 | new Object[] { "alpha", "beta", "gamma", "delta" }); | 27 | new Object[] { "alpha", "beta", "gamma", "delta" }); |
28 | var arguments = res.findFirst().get().get(); | 28 | var arguments = res.findFirst().get().get(); |
29 | assertEquals(1, arguments[0]); | 29 | assertEquals(1, arguments[0]); |
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/support/MapTestEnvironment.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java index 6c55be62..59e5e913 100644 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/support/MapTestEnvironment.java +++ b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/utils/MapTestEnvironment.java | |||
@@ -1,4 +1,4 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.support; | 1 | package org.eclipse.viatra.solver.data.map.tests.utils; |
2 | 2 | ||
3 | import static org.junit.jupiter.api.Assertions.assertEquals; | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | import static org.junit.jupiter.api.Assertions.fail; | 4 | import static org.junit.jupiter.api.Assertions.fail; |