1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import dataShare from '@ohos.data.dataShare';
17import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from 'deccjsunit/index';
18
19const URI_CALLLOG = 'datashare:///com.ohos.calllogability';
20const calllogUri = 'datashare:///com.ohos.calllogability/calls/calllog';
21
22const URI_VOICEMAIL = 'datashare:///com.ohos.voicemailability';
23const voicemailUri = 'datashare:///com.ohos.voicemailability/calls/voicemail';
24
25const URI_CONTACTS = 'datashare:///com.ohos.contactsdataability';
26const rawContactUri = 'datashare:///com.ohos.contactsdataability/contacts/raw_contact';
27const contactDataUri = 'datashare:///com.ohos.contactsdataability/contacts/contact_data';
28const deletedUri = 'datashare:///com.ohos.contactsdataability/contacts/deleted_raw_contact';
29const SLEEP_ONE_SECOND = 1000;
30const SLEEP_TWO_SECOND = 2000;
31const SLEEP_FIVE_SECOND = 5000;
32const ROW_COUNT = 10000;
33
34describe('PerformanceTest', function () {
35  console.log(' PerformanceTest is start');
36  function sleep(numberMillis) {
37    let now = new Date();
38    let exitTime = now.getTime() + numberMillis;
39    while (true) {
40      now = new Date();
41      if (now.getTime() > exitTime) {
42        return;
43      }
44    }
45  }
46
47  /**
48   * @tc.number  raw_contact_insert_stability_test_900
49   * @tc.name    Add 10000 pieces of data to the raw_contact table to see if they can be successfully inserted
50   * @tc.desc    Function test
51   */
52  it('raw_contact_insert_stability_test_900', 0, async function (done) {
53    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
54    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
55    let cycleIndex = 1000;
56    let listAddBluk = [];
57    for (let i = 0; i < cycleIndex; i++) {
58      let add = { 'display_name': 'xiaoli' + i, 'company': 'testCompany' + i, 'position': 'testPosition' + i };
59      listAddBluk[i] = add;
60    }
61    try {
62      let batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
63      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
64      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
65      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
66      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
67      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
68      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
69      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
70      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
71      batchInsertCode = await dataShareHelper.batchInsert(rawContactUri, listAddBluk);
72      sleep(SLEEP_ONE_SECOND);
73      console.info('logMessage raw_contact_insert_stability_test_900: contactDataId1 = ' + batchInsertCode);
74      expect(batchInsertCode === 0).assertTrue();
75      done();
76    } catch (error) {
77      console.info('logMessage raw_contact_insert_stability_test_900:  insert error = ' + error);
78      done();
79    }
80  });
81
82  /**
83   * @tc.number  raw_contact_update_stability_test_1000
84   * @tc.name    The raw_contact table updates the data whose ID is not equal to 0 to see whether they can be updated
85   * successfully
86   * @tc.desc    Function test
87   */
88  it('raw_contact_update_stability_test_1000', 0, async function (done) {
89    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
90    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
91    let updateValues = { 'favorite': 1 };
92    let condition = new dataShare.DataSharePredicates();
93    condition.greaterThan('id', '0');
94    condition.and();
95    condition.equalTo('is_deleted', '0');
96    try {
97      let updateCode = await dataShareHelper.update(rawContactUri, updateValues, condition);
98      sleep(SLEEP_ONE_SECOND);
99      console.info('logMessage raw_contact_update_stability_test_1000: updateCode = ' + updateCode);
100      expect(updateCode === 0).assertTrue();
101      done();
102    } catch (error) {
103      console.info('logMessage raw_contact_update_stability_test_1000: update error = ' + error);
104      done();
105    }
106  });
107
108  /**
109   * @tc.number  raw_contact_query_stability_test_1100
110   * @tc.name    The raw_contact table queries 10000 pieces of data to see whether they can be queried successfully
111   * @tc.desc    Function test
112   */
113  it('raw_contact_query_stability_test_1100', 0, async function (done) {
114    let tag = 'raw_contact_query_stability_test_1100';
115    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
116    console.info(tag + ': start ! dataShareHelper = ' + dataShareHelper);
117    let resultColumns = ['id'];
118    let condition = new dataShare.DataSharePredicates();
119    condition.greaterThan('id', '0');
120    condition.and();
121    condition.equalTo('is_deleted', '0');
122    try {
123      let resultSet = await dataShareHelper.query(rawContactUri, resultColumns, condition);
124      sleep(SLEEP_ONE_SECOND);
125      console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount);
126      expect(resultSet.rowCount === ROW_COUNT).assertTrue();
127      resultSet.close();
128      done();
129    } catch (error) {
130      console.info(tag + ' :logMessage : error = ' + error);
131      done();
132    }
133  });
134
135  /**
136   * @tc.number  raw_contact_delete_stability_test_1200
137   * @tc.name    Delete 10000 pieces of data in raw_contact table to see if they can be deleted successfully
138   * @tc.desc    Function test
139   */
140  it('raw_contact_delete_stability_test_1200', 0, async function (done) {
141    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
142    console.info('raw_contact_delete_stability_test_1200 : start ! dataShareHelper = ' + dataShareHelper);
143    let condition = new dataShare.DataSharePredicates();
144    condition.greaterThan('id', '0');
145    condition.and();
146    condition.equalTo('is_deleted', '0');
147    try {
148      let deleteCode = await dataShareHelper.delete(rawContactUri, condition);
149      sleep(SLEEP_ONE_SECOND);
150      console.info('logMessage raw_contact_delete_stability_test_1200: deleteCode = ' + deleteCode);
151      expect(deleteCode === 0).assertTrue();
152      done();
153    } catch (error) {
154      console.info('logMessage raw_contact_delete_stability_test_1200: delete error = ' + error);
155      done();
156    }
157  });
158
159  /**
160   * @tc.number  contact_data_insert_stability_test_1300
161   * @tc.name    Add 10000 pieces of data to the contact_data table to see if they can be successfully inserted
162   * @tc.desc    Function test
163   */
164  it('contact_data_insert_stability_test_1300', 0, async function (done) {
165    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
166    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
167
168    let rawContactValues = {
169      'display_name': 'xiaoli'
170    };
171    try {
172      let rawContactId = await dataShareHelper.insert(rawContactUri, rawContactValues);
173      sleep(SLEEP_ONE_SECOND);
174      console.info('logMessage contact_data_insert_stability_test_1300: rawContactId = ' + rawContactId);
175    } catch (error) {
176      console.info('logMessage contact_data_insert_stability_test_1300: raw_contact insert error = ' + error);
177    }
178
179    let condition = new dataShare.DataSharePredicates();
180    condition.equalTo('id', rawContactId.toString());
181    let deleteCode = await dataShareHelper.delete(rawContactUri, condition);
182    sleep(SLEEP_ONE_SECOND);
183    console.info('logMessage contact_data_insert_stability_test_1300: deleteCode = ' + deleteCode);
184    let cycleIndex = 1000;
185    let listAddBluk = [];
186    for (let i = 0; i < cycleIndex; i++) {
187      let add = { 'raw_contact_id': rawContactId, 'detail_info': 'xxx' + i, 'content_type': 'name' };
188      listAddBluk[i] = add;
189    }
190    try {
191      let batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
192      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
193      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
194      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
195      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
196      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
197      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
198      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
199      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
200      batchInsertCode = await dataShareHelper.batchInsert(contactDataUri, listAddBluk);
201      sleep(SLEEP_TWO_SECOND);
202      console.info('logMessage contact_data_insert_stability_test_1300: batchInsertCode = ' + batchInsertCode);
203      expect(batchInsertCode === 0).assertTrue();
204      done();
205    } catch (error) {
206      console.info('logMessage contact_data_insert_stability_test_1300:  insert error = ' + error);
207      done();
208    }
209  });
210
211  /**
212   * @tc.number  contact_data_update_stability_test_1400
213   * @tc.name    The contact_data table updates the data whose ID is not equal to 0 to see whether they can be updated
214   * successfully
215   * @tc.desc    Function test
216   */
217  it('contact_data_update_stability_test_1400', 0, async function (done) {
218    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
219    console.info(
220      'logMessage contact_data_update_stability_test_1400 dataShareHelper success! dataShareHelper = ' + dataShareHelper
221    );
222    let updateValues = { 'syn_1': 'test' };
223    let condition = new dataShare.DataSharePredicates();
224    condition.greaterThan('id', '0');
225    try {
226      let updateCode = await dataShareHelper.update(contactDataUri, updateValues, condition);
227      sleep(SLEEP_TWO_SECOND);
228      console.info('logMessage contact_data_update_stability_test_1400: updateCode = ' + updateCode);
229      expect(updateCode === 0).assertTrue();
230      done();
231    } catch (error) {
232      console.info('logMessage contact_data_update_stability_test_1400: update error = ' + error);
233      done();
234    }
235  });
236
237  /**
238   * @tc.number  contact_data_query_stability_test_1500
239   * @tc.name    The contact_data table queries 10000 pieces of data to see whether they can be queried successfully
240   * @tc.desc    Function test
241   */
242  it('contact_data_query_stability_test_1500', 0, async function (done) {
243    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
244    console.info('contact_data_query_stability_test_1500 start ! dataShareHelper = ' + dataShareHelper);
245    let resultColumns = ['id'];
246    let condition = new dataShare.DataSharePredicates();
247    condition.greaterThan('id', '0');
248    try {
249      let resultSet = await dataShareHelper.query(contactDataUri, resultColumns, condition);
250      sleep(SLEEP_TWO_SECOND);
251      console.info(' contact_data_query_stability_test_1500 :  resultSet.rowCount = ' + resultSet.rowCount);
252      expect(resultSet.rowCount === ROW_COUNT).assertEqual(true);
253      resultSet.close();
254      done();
255    } catch (error) {
256      console.info('logMessage contact_data_query_stability_test_1500: error = ' + error);
257      done();
258    }
259  });
260
261  /**
262   * @tc.number  contact_data_delete_stability_test_1600
263   * @tc.name    Delete 10000 pieces of data in contact_data table to see if they can be deleted successfully
264   * @tc.desc    Function test
265   */
266  it('contact_data_delete_stability_test_1600', 0, async function (done) {
267    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
268    console.info('contact_data_delete_stability_test_1600 : start ! dataShareHelper = ' + dataShareHelper);
269    let condition = new dataShare.DataSharePredicates();
270    condition.greaterThan('id', '0');
271    try {
272      let deleteCode = await dataShareHelper.delete(contactDataUri, condition);
273      sleep(SLEEP_TWO_SECOND);
274      console.info('logMessage contact_data_delete_stability_test_1600: deleteCode = ' + deleteCode);
275      expect(deleteCode === 0).assertTrue();
276      done();
277    } catch (error) {
278      console.info('logMessage contact_data_delete_stability_test_1600: delete error = ' + error);
279      done();
280    }
281  });
282
283  /**
284   * @tc.number  calllog_insert_stability_test_100
285   * @tc.name    Add 10000 pieces of data to the callog table to see if they can be successfully inserted
286   * @tc.desc    Function test
287   */
288  it('calllog_insert_stability_test_100', 0, async function (done) {
289    console.info('---------logMessage calllog_insert_stability_test_100 is starting!----------');
290    let dataShareHelper = dataShare.createDataShareHelper(URI_CALLLOG);
291    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
292    let phoneNumberLenSix = 6;
293    let cycleIndex = 1000;
294    let listAddBluk = [];
295    let phoneNumber = randomNum(phoneNumberLenSix);
296    for (let i = 0; i < cycleIndex; i++) {
297      let add = { 'phone_number': phoneNumber + i };
298      listAddBluk[i] = add;
299    }
300    try {
301      let batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
302      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
303      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
304      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
305      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
306      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
307      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
308      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
309      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
310      batchInsertCode = await dataShareHelper.batchInsert(calllogUri, listAddBluk);
311      sleep(SLEEP_ONE_SECOND);
312      console.info('logMessage calllog_insert_stability_test_100: batchInsertCode = ' + batchInsertCode);
313      expect(batchInsertCode === 0).assertTrue();
314      done();
315    } catch (error) {
316      console.info('logMessage calllog_insert_stability_test_100: batchInsert error = ' + error);
317      done();
318    }
319  });
320
321  /**
322   * @tc.number  calllog_update_stability_test_200
323   * @tc.name    The callog table updates the data whose ID is not equal to 0 to see whether they can be updated
324   * successfully
325   * @tc.desc    Function test
326   */
327  it('calllog_update_stability_test_200', 0, async function (done) {
328    let dataShareHelper = dataShare.createDataShareHelper(URI_CALLLOG);
329    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
330    let updateValues = { 'answer_state': '1' };
331    try {
332      let condition = new dataShare.DataSharePredicates();
333      condition.greaterThan('id', '0');
334      let updateCode = await dataShareHelper.update(calllogUri, updateValues, condition);
335      sleep(SLEEP_ONE_SECOND);
336      console.info('logMessage calllog_update_stability_test_200: updateCode = ' + updateCode);
337      expect(updateCode === 0).assertTrue();
338      done();
339    } catch (error) {
340      console.info('logMessage calllog_update_stability_test_200: update error = ' + error);
341      done();
342    }
343  });
344
345  /**
346   * @tc.number  calllog_query_stability_test_300
347   * @tc.name    The callog table queries 10000 pieces of data to see whether they can be queried successfully
348   * @tc.desc    Function test
349   */
350  it('calllog_query_stability_test_300', 0, async function (done) {
351    let tag = 'calllog_query_stability_test_300';
352    let dataShareHelper = dataShare.createDataShareHelper(URI_CALLLOG);
353    console.info(tag + ': start ! dataShareHelper = ' + dataShareHelper);
354    let resultColumns = ['id'];
355    let condition = new dataShare.DataSharePredicates();
356    condition.notEqualTo('id', 0);
357
358    try {
359      let resultSet = await dataShareHelper.query(calllogUri, resultColumns, condition);
360      sleep(SLEEP_FIVE_SECOND);
361      console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount);
362      expect(resultSet.rowCount === ROW_COUNT).assertTrue();
363      resultSet.close();
364      done();
365    } catch (error) {
366      console.info('logMessage calllog_query_stability_test_300: error = ' + error);
367      done();
368    }
369  });
370
371  /**
372   * @tc.number  calllog_delete_stability_test_400
373   * @tc.name    Delete 10000 pieces of data in callog table to see if they can be deleted successfully
374   * @tc.desc    Function test
375   */
376  it('calllog_delete_stability_test_400', 0, async function (done) {
377    let tag = 'calllog_delete_stability_test_400';
378    let dataShareHelper = dataShare.createDataShareHelper(URI_CALLLOG);
379    console.info(tag + ': start ! dataShareHelper = ' + dataShareHelper);
380    let condition = new dataShare.DataSharePredicates();
381    condition.greaterThan('id', '0');
382    let deleteCode = await dataShareHelper.delete(calllogUri, condition);
383    sleep(SLEEP_FIVE_SECOND);
384    console.info(tag + ' : logMessage : deleteCode = ' + deleteCode);
385    expect(deleteCode === 0).assertTrue();
386    done();
387  });
388
389  /**
390   * @tc.number  voicemail_insert_stability_test_500
391   * @tc.name    Add 10000 pieces of data to the voicemail table to see if they can be successfully inserted
392   * @tc.desc    Function test
393   */
394  it('voicemail_insert_stability_test_500', 0, async function (done) {
395    console.info('---------logMessage voicemail_insert_stability_test_500 is starting!----------');
396    let dataShareHelper = dataShare.createDataShareHelper(URI_VOICEMAIL);
397    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
398    let cycleIndex = 1000;
399    let phoneNumberLenFour = 4;
400    let listAddBluk = [];
401    let phoneNumber = randomNum(phoneNumberLenFour);
402    for (let i = 0; i < cycleIndex; i++) {
403      let add = { 'phone_number': phoneNumber + i };
404      listAddBluk[i] = add;
405    }
406    try {
407      let batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
408      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
409      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
410      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
411      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
412      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
413      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
414      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
415      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
416      batchInsertCode = await dataShareHelper.batchInsert(voicemailUri, listAddBluk);
417      sleep(SLEEP_ONE_SECOND);
418      console.info('logMessage voicemail_insert_stability_test_500: batchInsertCode = ' + batchInsertCode);
419      expect(batchInsertCode === 0).assertTrue();
420      done();
421    } catch (error) {
422      console.info('logMessage voicemail_insert_stability_test_500: batchInsert error = ' + error);
423      done();
424    }
425  });
426
427  /**
428   * @tc.number  voicemail_update_stability_test_600
429   * @tc.name    The voicemail table updates the data whose ID is not equal to 0 to see whether they can be updated
430   * successfully
431   * @tc.desc    Function test
432   */
433  it('voicemail_update_stability_test_600', 0, async function (done) {
434    let dataShareHelper = dataShare.createDataShareHelper(URI_VOICEMAIL);
435    console.info('logMessage get dataShareHelper success! dataShareHelper = ' + dataShareHelper);
436    let updateValues = { 'origin_type': 'test' };
437    try {
438      let condition = new dataShare.DataSharePredicates();
439      condition.notEqualTo('id', 0);
440      let updateCode = await dataShareHelper.update(voicemailUri, updateValues, condition);
441      sleep(SLEEP_ONE_SECOND);
442      console.info('logMessage voicemail_update_stability_test_600: updateCode = ' + updateCode);
443      expect(updateCode === 0).assertTrue();
444      done();
445    } catch (error) {
446      console.info('logMessage voicemail_update_stability_test_600: update error = ' + error);
447      done();
448    }
449  });
450
451  /**
452   * @tc.number  voicemail_query_stability_test_700
453   * @tc.name    The voicemail table queries 10000 pieces of data to see whether they can be queried successfully
454   * @tc.desc    Function test
455   */
456  it('voicemail_query_stability_test_700', 0, async function (done) {
457    let tag = 'voicemail_query_stability_test_700';
458    let dataShareHelper = dataShare.createDataShareHelper(URI_VOICEMAIL);
459    console.info(tag + ': start ! dataShareHelper = ' + dataShareHelper);
460    let resultColumns = ['id'];
461    let condition = new dataShare.DataSharePredicates();
462    condition.greaterThan('id', '0');
463    try {
464      let resultSet = await dataShareHelper.query(voicemailUri, resultColumns, condition);
465      sleep(SLEEP_ONE_SECOND);
466      console.info(tag + ' : resultSet.rowCount = ' + resultSet.rowCount);
467      expect(resultSet.rowCount === ROW_COUNT).assertEqual(true);
468      resultSet.close();
469      done();
470    } catch (error) {
471      console.info('logMessage voicemail_query_stability_test_700: error = ' + error);
472      done();
473    }
474  });
475
476  /**
477   * @tc.number  voicemail_delete_stability_test_800
478   * @tc.name    Delete 10000 pieces of data in voicemail table to see if they can be deleted successfully
479   * @tc.desc    Function test
480   */
481  it('voicemail_delete_stability_test_800', 0, async function (done) {
482    let tag = 'voicemail_delete_stability_test_800';
483    let dataShareHelper = dataShare.createDataShareHelper(URI_VOICEMAIL);
484    console.info(tag + ': start ! dataShareHelper = ' + dataShareHelper);
485    let condition = new dataShare.DataSharePredicates();
486    condition.greaterThan('id', '0');
487    try {
488      let deleteCode = await dataShareHelper.delete(voicemailUri, condition);
489      sleep(SLEEP_TWO_SECOND);
490      console.info(tag + ' : logMessage : deleteCode = ' + deleteCode);
491      expect(deleteCode === 0).assertTrue();
492      done();
493    } catch (error) {
494      console.info('logMessage voicemail_delete_stability_test_800: error = ' + error);
495      done();
496    }
497  });
498
499  afterAll(async function () {
500    let dataShareHelper = dataShare.createDataShareHelper(URI_CONTACTS);
501    console.info('Stability : start ! dataShareHelper = ' + dataShareHelper);
502    let condition = new dataShare.DataSharePredicates();
503    condition.notEqualTo('id', '0');
504    try {
505      let resultColumns = ['id'];
506      let conditionDelete = new dataShare.DataSharePredicates();
507      conditionDelete.greaterThan('id', '0');
508      let count = 0;
509      let deleteCount = 9999;
510      while (count < deleteCount) {
511        let result = await dataShareHelper.query(deletedUri, resultColumns, conditionDelete);
512        console.info('Stability : result.rowCount = ' + result.rowCount);
513        count = result.rowCount;
514        result.close();
515        sleep(SLEEP_FIVE_SECOND);
516      }
517      let deleteCode = await dataShareHelper.delete(deletedUri, condition);
518      console.info('Stability afterAll logMessage DeleteContact: deleteCode = ' + deleteCode);
519    } catch (error) {
520      console.info('Stability afterAll logMessage DeleteContact: delete error = ' + error);
521    }
522  });
523});
524
525function randomNum(num) {
526  let baseNumNine = 9;
527  let baseNumTen = 10;
528  let number = toString(Math.floor(Math.random() * (baseNumNine * Math.pow(baseNumTen, num))) + 1 *
529    Math.pow(baseNumTen, num));
530  return number;
531}
532