4 #define DATA_SEQUENTIAL TEST_DATASOURCE_SEQUENCE
5 #define DATA_RANDOM TEST_DATASOURCE_RANDOM
7 typedef struct Datatest4 Datatest4
;
12 ** 1. Insert (Datatest4.nRec) records into a database.
14 ** 2. Repeat (Datatest4.nRepeat) times:
16 ** 2a. Delete 2/3 of the records in the database.
18 ** 2b. Run lsm_work(nMerge=1).
20 ** 2c. Insert as many records as were deleted in 2a.
22 ** 2d. Check database content is as expected.
24 ** 2e. If (Datatest4.bReopen) is true, close and reopen the database.
27 /* Datasource definition */
35 static void doDataTest4(
36 const char *zSystem
, /* Database system to test */
37 Datatest4
*p
, /* Structure containing test parameters */
38 int *pRc
/* OUT: Error code */
47 int bMultiThreaded
= 0; /* True for MT LSM database */
49 int nRecOn3
= (p
->nRec
/ 3);
52 /* Start the test case, open a database and allocate the datasource. */
53 rc
= testControlDb(&pControl
);
54 pDb
= testOpen(zSystem
, 1, &rc
);
55 pData
= testDatasourceNew(&p
->defn
);
58 bMultiThreaded
= tdb_lsm_multithread(pDb
);
61 testWriteDatasourceRange(pControl
, pData
, iData
, nRecOn3
*3, &rc
);
62 testWriteDatasourceRange(pDb
, pData
, iData
, nRecOn3
*3, &rc
);
64 for(i
=0; rc
==0 && i
<p
->nRepeat
; i
++){
66 testDeleteDatasourceRange(pControl
, pData
, iData
, nRecOn3
*2, &rc
);
67 testDeleteDatasourceRange(pDb
, pData
, iData
, nRecOn3
*2, &rc
);
72 fprintf(stderr
, "lsm_work() start...\n"); fflush(stderr
);
76 rc
= lsm_work(db
, 1, (1<<30), &nDone
);
77 }while( rc
==0 && nDone
>0 );
78 if( bMultiThreaded
&& rc
==LSM_BUSY
) rc
= LSM_OK
;
80 fprintf(stderr
, "lsm_work() done...\n"); fflush(stderr
);
86 testWriteDatasourceRange(pControl
, pData
, iData
+nRecOn3
, nRecOn3
*2, &rc
);
87 testWriteDatasourceRange(pDb
, pData
, iData
+nRecOn3
, nRecOn3
*2, &rc
);
89 testCompareDb(pData
, nRecOn3
*3, iData
, pControl
, pDb
, &rc
);
91 /* If Datatest4.bReopen is true, close and reopen the database */
93 testReopen(&pDb
, &rc
);
94 if( rc
==0 ) db
= tdb_lsm(pDb
);
98 /* Update the progress dots... */
99 testCaseProgress(i
, p
->nRepeat
, testCaseNDot(), &iDot
);
103 testClose(&pControl
);
104 testDatasourceFree(pData
);
109 static char *getName4(const char *zSystem
, Datatest4
*pTest
){
112 zData
= testDatasourceName(&pTest
->defn
);
113 zRet
= testMallocPrintf("data4.%s.%s.%d.%d.%d",
114 zSystem
, zData
, pTest
->nRec
, pTest
->nRepeat
, pTest
->bReopen
121 const char *zSystem
, /* Database system name */
122 const char *zPattern
, /* Run test cases that match this pattern */
123 int *pRc
/* IN/OUT: Error code */
125 Datatest4 aTest
[] = {
126 /* defn, nRec, nRepeat, bReopen */
127 { {DATA_RANDOM
, 20,25, 500,600}, 10000, 10, 0 },
128 { {DATA_RANDOM
, 20,25, 500,600}, 10000, 10, 1 },
133 for(i
=0; *pRc
==LSM_OK
&& i
<ArraySize(aTest
); i
++){
134 char *zName
= getName4(zSystem
, &aTest
[i
]);
135 if( testCaseBegin(pRc
, zPattern
, "%s", zName
) ){
136 doDataTest4(zSystem
, &aTest
[i
], pRc
);