diff options
author | 2021-07-26 15:01:23 +0200 | |
---|---|---|
committer | 2021-07-26 15:01:23 +0200 | |
commit | 1527e27f36762a5e3a1cdbb84467f67322cb7cba (patch) | |
tree | c076fb8117180a15989535743bd3bab32db01c71 /Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java | |
parent | better progress logging in smoke tests (diff) | |
download | VIATRA-Generator-1527e27f36762a5e3a1cdbb84467f67322cb7cba.tar.gz VIATRA-Generator-1527e27f36762a5e3a1cdbb84467f67322cb7cba.tar.zst VIATRA-Generator-1527e27f36762a5e3a1cdbb84467f67322cb7cba.zip |
Smoketest refactor splitting fast and slow smoke tests
Diffstat (limited to 'Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java')
-rw-r--r-- | Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java new file mode 100644 index 00000000..a1d37241 --- /dev/null +++ b/Solvers/VIATRA-Solver/org.eclipse.viatra.solver.data/tests/org/eclipse/viatra/solver/data/map/test/smoke/fast/SmokeTest1Mutable.java | |||
@@ -0,0 +1,115 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.test.smoke.fast; | ||
2 | |||
3 | import static org.junit.Assert.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.test.smoke.TestPermuter; | ||
13 | import org.eclipse.viatra.solver.data.map.test.support.MapTestEnvironment; | ||
14 | import org.junit.jupiter.params.ParameterizedTest; | ||
15 | import org.junit.jupiter.params.provider.Arguments; | ||
16 | import org.junit.jupiter.params.provider.MethodSource; | ||
17 | |||
18 | public class SmokeTest1Mutable { | ||
19 | |||
20 | public void runSmokeTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean evilHash) { | ||
21 | String[] values = MapTestEnvironment.prepareValues(maxValue); | ||
22 | ContinousHashProvider<Integer> chp = MapTestEnvironment.prepareHashProvider(evilHash); | ||
23 | |||
24 | VersionedMapStore<Integer, String> store = new VersionedMapStoreImpl<Integer, String>(chp, values[0]); | ||
25 | VersionedMapImpl<Integer, String> sut = (VersionedMapImpl<Integer, String>) store.createMap(); | ||
26 | MapTestEnvironment<Integer, String> e = new MapTestEnvironment<Integer, String>(sut); | ||
27 | |||
28 | Random r = new Random(seed); | ||
29 | |||
30 | iterativeRandomPuts(scenario, steps, maxKey, values, e, r); | ||
31 | } | ||
32 | |||
33 | void iterativeRandomPuts( | ||
34 | String scenario, | ||
35 | int steps, | ||
36 | int maxKey, | ||
37 | String[] values, | ||
38 | MapTestEnvironment<Integer, String> e, | ||
39 | Random r) | ||
40 | { | ||
41 | int stopAt = -1; | ||
42 | for(int i=0; i<steps; i++) { | ||
43 | int index = i+1; | ||
44 | int nextKey = r.nextInt(maxKey); | ||
45 | String nextValue = values[r.nextInt(values.length)]; | ||
46 | if(index == stopAt) { | ||
47 | System.out.println("issue!"); | ||
48 | System.out.println("State before:"); | ||
49 | e.printComparison(); | ||
50 | e.sut.prettyPrint(); | ||
51 | System.out.println("Next: put("+nextKey+","+nextValue+")"); | ||
52 | } | ||
53 | try { | ||
54 | e.put(nextKey, nextValue); | ||
55 | if(index == stopAt) { | ||
56 | e.sut.prettyPrint(); | ||
57 | } | ||
58 | e.checkEquivalence(scenario+":"+index); | ||
59 | } catch (Exception exception) { | ||
60 | exception.printStackTrace(); | ||
61 | fail(scenario+":"+index+": exception happened: "+exception); | ||
62 | } | ||
63 | if(index%10000==0) System.out.println(scenario+":"+index+"/"+steps+" finished"); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | @ParameterizedTest(name = "Mutable Smoke {index}/{0} Steps={1} Keys={2} Values={3} seed={4} evil-hash={5}") | ||
68 | @MethodSource | ||
69 | void parametrizedSmoke(int test, int steps, int noKeys, int noValues, int seed, boolean evilHash) { | ||
70 | runSmokeTest("SmokeS"+steps+"K"+noKeys+"V"+noValues+"s"+seed+"H"+(evilHash?"Evil":"Normal"),seed,steps,noKeys,noValues,evilHash); | ||
71 | } | ||
72 | |||
73 | public static Stream<Arguments> parametrizedSmoke(){ | ||
74 | return TestPermuter.permutationWithSize( | ||
75 | new Object[] {1000}, | ||
76 | new Object[] {3,32, 32*32, 32*32*32*32}, | ||
77 | new Object[] {2,3}, | ||
78 | new Object[] {1,2,3}, | ||
79 | new Object[] {false,true} | ||
80 | ); | ||
81 | } | ||
82 | |||
83 | |||
84 | |||
85 | // @Test | ||
86 | // void MiniSmokeK3V2v1() { | ||
87 | // runSmokeTest("MiniSmokeK3V2v1",0, 1000, 3, 2); | ||
88 | // } | ||
89 | // @Test | ||
90 | // void MiniSmokeK3V2v2() { | ||
91 | // runSmokeTest("MiniSmokeK3V2v2",1, 1000, 3, 2); | ||
92 | // } | ||
93 | // @Test | ||
94 | // void MiniSmokeK3V2v3() { | ||
95 | // runSmokeTest("MiniSmokeK3V2v3",3, 1000, 3, 2); | ||
96 | // } | ||
97 | // @Test | ||
98 | // void MediumSmokeK3V2v1() { | ||
99 | // runSmokeTest("MediumSmokeK3V2v1",1, 1000, 32, 2); | ||
100 | // } | ||
101 | // @Test | ||
102 | // void MediumSmokeK3V2v2() { | ||
103 | // runSmokeTest("MediumSmokeK3V2v2",2, 1000, 32, 2); | ||
104 | // } | ||
105 | // @Test | ||
106 | // void MediumSmokeK3V2v3() { | ||
107 | // runSmokeTest("MediumSmokeK3V2v3",3, 1000, 32, 2); | ||
108 | // } | ||
109 | // @Test | ||
110 | // void SmokeLarge() { | ||
111 | // var milis = System.currentTimeMillis(); | ||
112 | // runSmokeTest("SmokeLarge",0, 32*32*32*32, 32*32-1, 2); | ||
113 | // System.out.println(System.currentTimeMillis()-milis); | ||
114 | // } | ||
115 | } | ||