提交 e3df9ac2 编写于 作者: wu-sheng's avatar wu-sheng

add a test case for DataFile write and read

上级 24f133d8
package com.a.eye.skywalking.storage.data.file;
import com.a.eye.skywalking.network.grpc.RequestSpan;
import com.a.eye.skywalking.storage.data.index.IndexMetaInfo;
import com.a.eye.skywalking.storage.data.spandata.RequestSpanData;
import com.a.eye.skywalking.storage.data.spandata.SpanDataBuilder;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by wusheng on 2016/11/29.
*/
public class DataFileTest {
@Test
public void testWriteFile(){
DataFile dataFile = new DataFile();
IndexMetaInfo info = null;
for (int i = 0; i < 100; i++) {
RequestSpan span = RequestSpan.newBuilder().setUserId("1").setApplicationId("app").build();
try {
info = dataFile.write(new RequestSpanData(span));
} finally {
dataFile.flush();
}
RequestSpan newSpan = SpanDataBuilder.buildRequestSpan(dataFile.read(info.getOffset(), info.getLength()));
Assert.assertEquals("1", newSpan.getUserId());
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册