1
1
package ldbc .snb .datagen .test ;
2
2
3
+ import ldbc .snb .datagen .dictionary .Dictionaries ;
4
+ import ldbc .snb .datagen .generator .DatagenParams ;
5
+ import ldbc .snb .datagen .generator .LDBCDatagen ;
3
6
import ldbc .snb .datagen .test .csv .*;
7
+ import ldbc .snb .datagen .util .ConfigParser ;
8
+ import org .apache .hadoop .conf .Configuration ;
4
9
import org .junit .BeforeClass ;
5
10
import org .junit .Test ;
6
11
@@ -31,6 +36,11 @@ public static void generateData() {
31
36
}catch (Exception e ) {
32
37
System .err .println (e .getMessage ());
33
38
}
39
+
40
+ Configuration conf = ConfigParser .initialize ();
41
+ ConfigParser .readConfig (conf , "./test_params.ini" );
42
+ ConfigParser .readConfig (conf , LDBCDatagen .class .getResourceAsStream ("/params.ini" ));
43
+ LDBCDatagen .init (conf );
34
44
}
35
45
36
46
@ Test
@@ -41,6 +51,7 @@ public void personTest() {
41
51
@ Test
42
52
public void postTest () {
43
53
testIdUniqueness (dir +"/post_0_0.csv" , 0 );
54
+ testLongBetween (dir +"/post_0_0.csv" ,7 ,0 ,2001 );
44
55
}
45
56
46
57
@ Test
@@ -51,6 +62,7 @@ public void forumTest() {
51
62
@ Test
52
63
public void commentTest () {
53
64
testIdUniqueness (dir +"/comment_0_0.csv" , 0 );
65
+ testLongBetween (dir +"/comment_0_0.csv" ,5 ,0 ,2001 );
54
66
}
55
67
56
68
@ Test
@@ -178,6 +190,7 @@ public void personLikesCommentCheck() {
178
190
testPairUniquenessPlusExistance (dir +"/person_likes_comment_0_0.csv" ,0 ,1 ,dir +"/person_0_0.csv" ,0 ,dir +"/comment_0_0.csv" ,0 );
179
191
}
180
192
193
+
181
194
@ Test
182
195
public void personLikesPostCheck () {
183
196
testPairUniquenessPlusExistance (dir +"/person_likes_post_0_0.csv" ,0 ,1 ,dir +"/person_0_0.csv" ,0 ,dir +"/post_0_0.csv" ,0 );
@@ -191,6 +204,8 @@ public void updateStreamForumsConsistencyCheck() {
191
204
192
205
@ Test
193
206
public void queryParamsTest () {
207
+
208
+ //Creating person id check
194
209
LongParser parser = new LongParser ();
195
210
ColumnSet <Long > persons = new ColumnSet <Long >(parser ,new File (dir +"/person_0_0.csv" ),0 ,1 );
196
211
persons .initialize ();
@@ -200,6 +215,7 @@ public void queryParamsTest() {
200
215
personIndex .add (0 );
201
216
ExistsCheck <Long > existsPersonCheck = new ExistsCheck <Long >(parser ,personIndex , personsRef );
202
217
218
+ //Creating name check
203
219
StringParser strParser = new StringParser ();
204
220
ColumnSet <String > names = new ColumnSet <String >(strParser ,new File (dir +"/person_0_0.csv" ),1 ,1 );
205
221
names .initialize ();
@@ -209,29 +225,60 @@ public void queryParamsTest() {
209
225
namesIndex .add (1 );
210
226
ExistsCheck <String > existsNameCheck = new ExistsCheck <String >(strParser ,namesIndex , namesRef );
211
227
228
+
229
+
212
230
FileChecker fileChecker = new FileChecker (sdir +"/query_1_param.txt" );
213
231
fileChecker .addCheck (existsPersonCheck );
214
232
fileChecker .addCheck (existsNameCheck );
215
233
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 1 PERSON AND NAME EXISTS " ,true , false );
216
234
235
+ //Crating date interval check
217
236
fileChecker = new FileChecker (sdir +"/query_2_param.txt" );
218
237
fileChecker .addCheck (existsPersonCheck );
219
238
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 2 PERSON EXISTS " ,true , false );
239
+ testLongBetween (sdir +"/query_2_param.txt" ,1 , Dictionaries .dates .getStartDateTime (), Dictionaries .dates .getEndDateTime ());
240
+
241
+ //Creating country check
242
+ ColumnSet <String > places = new ColumnSet <String >(strParser ,new File (dir +"/place_0_0.csv" ),1 ,1 );
243
+ places .initialize ();
244
+ List <ColumnSet <String >> placesRef = new ArrayList <ColumnSet <String >>();
245
+ placesRef .add (places );
246
+ List <Integer > countriesIndex = new ArrayList <Integer >();
247
+ countriesIndex .add (3 );
248
+ countriesIndex .add (4 );
249
+ ExistsCheck <String > countryExists = new ExistsCheck <String >(strParser ,countriesIndex , placesRef );
250
+
251
+ //Date duration check
252
+ DateDurationCheck dateDurationCheck = new DateDurationCheck ("Date duration check" ,1 ,2 ,Dictionaries .dates .getStartDateTime (), Dictionaries .dates .getEndDateTime ());
220
253
221
254
fileChecker = new FileChecker (sdir +"/query_3_param.txt" );
222
255
fileChecker .addCheck (existsPersonCheck );
256
+ fileChecker .addCheck (countryExists );
257
+ fileChecker .addCheck (dateDurationCheck );
223
258
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 3 PERSON EXISTS " ,true , false );
224
259
225
260
fileChecker = new FileChecker (sdir +"/query_4_param.txt" );
226
261
fileChecker .addCheck (existsPersonCheck );
262
+ fileChecker .addCheck (dateDurationCheck );
227
263
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 4 PERSON EXISTS " ,true , false );
228
264
229
265
fileChecker = new FileChecker (sdir +"/query_5_param.txt" );
230
266
fileChecker .addCheck (existsPersonCheck );
231
267
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 5 PERSON EXISTS " ,true , false );
268
+ testLongBetween (sdir +"/query_5_param.txt" ,1 , Dictionaries .dates .getStartDateTime (), Dictionaries .dates .getEndDateTime ());
269
+
270
+ //Creating tag check
271
+ ColumnSet <String > tags = new ColumnSet <String >(strParser ,new File (dir +"/tag_0_0.csv" ),1 ,1 );
272
+ tags .initialize ();
273
+ List <ColumnSet <String >> tagsRef = new ArrayList <ColumnSet <String >>();
274
+ tagsRef .add (tags );
275
+ List <Integer > tagsIndex = new ArrayList <Integer >();
276
+ tagsIndex .add (1 );
277
+ ExistsCheck <String > tagExists = new ExistsCheck <String >(strParser ,tagsIndex , tagsRef );
232
278
233
279
fileChecker = new FileChecker (sdir +"/query_6_param.txt" );
234
280
fileChecker .addCheck (existsPersonCheck );
281
+ fileChecker .addCheck (tagExists );
235
282
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 6 PERSON EXISTS " ,true , false );
236
283
237
284
fileChecker = new FileChecker (sdir +"/query_7_param.txt" );
@@ -245,17 +292,35 @@ public void queryParamsTest() {
245
292
fileChecker = new FileChecker (sdir +"/query_9_param.txt" );
246
293
fileChecker .addCheck (existsPersonCheck );
247
294
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 9 PERSON EXISTS " ,true , false );
295
+ testLongBetween (sdir +"/query_9_param.txt" ,1 , Dictionaries .dates .getStartDateTime (), Dictionaries .dates .getEndDateTime ());
248
296
249
297
fileChecker = new FileChecker (sdir +"/query_10_param.txt" );
250
298
fileChecker .addCheck (existsPersonCheck );
251
299
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 10 PERSON EXISTS " ,true , false );
300
+ testLongBetween (sdir +"/query_10_param.txt" ,1 , 1 , 13 );
301
+
302
+ //Creating country check
303
+ countriesIndex .clear ();
304
+ countriesIndex .add (1 );
305
+ countryExists = new ExistsCheck <String >(strParser ,countriesIndex , placesRef );
252
306
253
307
fileChecker = new FileChecker (sdir +"/query_11_param.txt" );
254
308
fileChecker .addCheck (existsPersonCheck );
309
+ fileChecker .addCheck (countryExists );
255
310
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 11 PERSON EXISTS " ,true , false );
256
311
312
+ //Creating tagClass check
313
+ ColumnSet <String > tagClass = new ColumnSet <String >(strParser ,new File (dir +"/tagclass_0_0.csv" ),1 ,1 );
314
+ tagClass .initialize ();
315
+ List <ColumnSet <String >> tagClassRef = new ArrayList <ColumnSet <String >>();
316
+ tagClassRef .add (tagClass );
317
+ List <Integer > tagClassIndex = new ArrayList <Integer >();
318
+ tagClassIndex .add (1 );
319
+ ExistsCheck <String > tagClassExists = new ExistsCheck <String >(strParser ,tagClassIndex , tagClassRef );
320
+
257
321
fileChecker = new FileChecker (sdir +"/query_12_param.txt" );
258
322
fileChecker .addCheck (existsPersonCheck );
323
+ fileChecker .addCheck (tagClassExists );
259
324
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 12 PERSON EXISTS " ,true , false );
260
325
261
326
personIndex .add (1 );
@@ -269,23 +334,7 @@ public void queryParamsTest() {
269
334
fileChecker .addCheck (exists2PersonCheck );
270
335
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST QUERY 14 PERSON EXISTS " ,true , false );
271
336
272
-
273
337
}
274
- // test query parameters correctness
275
- // query 1, check person id existance and name existance
276
- // query 2, check person id existance and date time within simulation interval
277
- // query 3, check person id existance, country X and Y existance, startData + duration within simulation interval
278
- // query 4, check person id existance and startDate + duration within simulation interval
279
- // query 5, check person id and date within simulation interval
280
- // query 6, check person id and tag name existance
281
- // query 7, check person id existance
282
- // query 8, check person id existance
283
- // query 9, check person id and date within simulation interval
284
- // query 10, check person id existance and month between 1 and 12
285
- // query 11, check person id existance, Country existance and year something reasonable
286
- // query 12, check person id existance and tagclass existance
287
- // query 13, check persons id existance
288
- // query 14, check persons id existance
289
338
290
339
public void testLongPair (String fileName , Integer columnA , Integer columnB , NumericPairCheck .NumericCheckType type , long offsetA , long offsetB ) {
291
340
FileChecker fileChecker = new FileChecker (fileName );
@@ -302,6 +351,14 @@ public void testIdUniqueness(String fileName, int column) {
302
351
if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING TEST ID UNIQUENESS FOR FILE " +fileName ,true , false );
303
352
}
304
353
354
+ public void testLongBetween (String fileName , int column , long a , long b ) {
355
+ FileChecker fileChecker = new FileChecker (fileName );
356
+ LongParser parser = new LongParser ();
357
+ LongCheck longcheck = new LongCheck (parser , "Date Test" ,column , NumericCheck .NumericCheckType .BETWEEN , a ,b );
358
+ fileChecker .addCheck (longcheck );
359
+ if (!fileChecker .run (1 )) assertEquals ("ERROR PASSING BETWEENS TEST FOR FILE " +fileName +" column " +column +" between " +a +" and " +b ,true , false );
360
+ }
361
+
305
362
public void testPairUniquenessPlusExistance (String relationFileName , int columnA , int columnB , String entityFileNameA , int entityColumnA , String entityFileNameB , int entityColumnB ) {
306
363
LongParser parser = new LongParser ();
307
364
ColumnSet <Long > entitiesA = new ColumnSet <Long >(parser ,new File (entityFileNameA ),entityColumnA ,1 );
0 commit comments