def testTtlCommon(self): """ 配置ttl时间,put 10条时序数据,sleep直到t0-t4过期,scan结果 """ jobHelper = JobHelper() put_time = long(time.time() * 1000) jobHelper.append(jobHelper.rtidbClient.create_table, ttl=10) jobHelper.append(jobHelper.rtidbClient.put, time=put_time) jobHelper.append(jobHelper.rtidbClient.put, time=put_time - 20l) jobHelper.append(jobHelper.rtidbClient.put, time=put_time - 11l * 60 * 1000) jobHelper.append(jobHelper.rtidbClient.scan, stime=put_time, etime=put_time - 12l * 60 * 1000) jobHelper.run(autoidentity=False) retStatus, retMsg = jobHelper.identify( jobHelper.input_message(), jobHelper.scanout_message(), inputJunkFunc=lambda x: x['time'] > put_time - 11l * 60 * 1000) self.assertTrue(retStatus, retMsg)
def testScanTimeEqual(self): """ timestamp_start = timestamp_end """ jobHelper = JobHelper() jobHelper.append(jobHelper.rtidbClient.create_table) jobHelper.append(jobHelper.rtidbClient.put, time=1494496520) jobHelper.append(jobHelper.rtidbClient.put, time=1494496521) jobHelper.append(jobHelper.rtidbClient.put, time=1494496522) jobHelper.append(jobHelper.rtidbClient.put, time=1494496523) jobHelper.append(jobHelper.rtidbClient.scan, stime=1494496521, etime=1494496521) jobHelper.run(autoidentity=False) retStatus, retMsg = jobHelper.identify( jobHelper.input_message(), jobHelper.scanout_message(), inputJunkFunc=lambda x: x['time'] == 1494496521) self.assertFalse(retStatus, retMsg)
def testScanTimeLongYear(self): """ timestamp_start ,timestamp_end之间跨越100年 """ jobHelper = JobHelper() jobHelper.append(jobHelper.rtidbClient.create_table) jobHelper.append(jobHelper.rtidbClient.put, time=1494496520) jobHelper.append(jobHelper.rtidbClient.put, time=1494496521) jobHelper.append(jobHelper.rtidbClient.put, time=1494496522) jobHelper.append(jobHelper.rtidbClient.put, time=1494496523) jobHelper.append(jobHelper.rtidbClient.scan, stime=1494496521 + 10 * 365 * 24 * 3600, etime=1494496521) retStatus = jobHelper.run(autoidentity=False) self.assertTrue(retStatus) retStatus, retMsg = jobHelper.identify( jobHelper.input_message(), jobHelper.scanout_message(), inputJunkFunc=lambda x: x['time'] > 1494496521) self.assertTrue(retStatus, retMsg)
def testDisorderPut(self): """ 乱序put,scan结果时序正确 """ jobHelper = JobHelper() jobHelper.append(jobHelper.rtidbClient.create_table) jobHelper.append(jobHelper.rtidbClient.put, time=1494496522) jobHelper.append(jobHelper.rtidbClient.put, time=1494496520) jobHelper.append(jobHelper.rtidbClient.put, time=1494496521) jobHelper.append(jobHelper.rtidbClient.put, time=1494496525) jobHelper.append(jobHelper.rtidbClient.put, time=1494496526) jobHelper.append(jobHelper.rtidbClient.put, time=1494496524) jobHelper.append(jobHelper.rtidbClient.put, time=1494496523) jobHelper.append(jobHelper.rtidbClient.scan, stime=1494496525, etime=1494496521) jobHelper.run(autoidentity=False) retStatus, retMsg = jobHelper.identify( jobHelper.input_message(), jobHelper.scanout_message(), inputJunkFunc=lambda x: 1494496521 < x['time'] <= 1494496525) self.assertTrue(retStatus, retMsg)