def __init__(self, topic: str): topic_dir = create_dir('log/{}'.format(topic)) self.log_file = create_file(os.path.join(topic_dir, 'msg.log')) self.index_file = create_file(os.path.join(topic_dir, 'index.log')) self.offsets_file = create_offset_file(topic_dir) self.ts_file = create_file(os.path.join(topic_dir, 'ts.log')) self.load()
def setUp(self): self.topic_name = 'test' path = lambda filename: os.path.join(os.getcwd( ) + '/var/log/{}/{}.log'.format(self.topic_name, filename)) self.msg = path('msg') self.index = path('index') self.offsets = path('offsets') self.ts = path('ts') create_dir('log/{}'.format(self.topic_name)) create_file('log/{}/msg.log'.format(self.topic_name)) create_file('log/{}/index.log'.format(self.topic_name)) # create_file('log/{}/ts.log'.format(self.topic_name)) create_offset_file('test')
def setUp(self): # todo : self.topic_name = 'test' self.path = lambda filename :os.path.join(os.getcwd() + '/var/log/{}/{}.log'.format(self.topic_name,filename)) self.msg = self.path('msg') self.index = self.path('index') self.offset = self.path('offsets') self.ts = self.path('ts') create_dir('log/{}'.format(self.topic_name)) create_file('log/{}/index.log'.format(self.topic_name)) create_file('log/{}/ts.log'.format(self.topic_name)) create_offset_file('test') self.app = main.app.test_client() self.app.post('/v2/push',data=dict(path=['path/1','path/2','path/3']))
def test_create_file(self): _dir = create_dir('log_test/test') create_file(_dir + '/index.log') create_file(_dir + '/msg.log') create_file(_dir + '/ts.log') index_log = os.getcwd() + '/var/log_test/{}/index.log'.format( self.topic_name) msg_log = os.getcwd() + '/var/log_test/{}/msg.log'.format( self.topic_name) ts_log = os.getcwd() + '/var/log_test/{}/ts.log'.format( self.topic_name) self.assertTrue(os.path.isfile(index_log)) self.assertTrue(os.path.isfile(msg_log)) self.assertTrue(os.path.isfile(ts_log))