Search in sources :

Example 11 with LogFileStream

use of com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream in project coprhd-controller by CoprHD.

the class LogStreamTest method testReadNextLogMaxCountFilterLessThanMAXCOUNTOVERFLOW.

/**
 * Test max count filter totalCount < maxCount + MAX_OVERFLOW
 *
 * @throws Exception
 */
@Test
@Ignore
public void testReadNextLogMaxCountFilterLessThanMAXCOUNTOVERFLOW() throws Exception {
    List<File> files = new ArrayList<File>();
    files.add(new File(timeStampFilePath));
    // should get 5 log Messages
    long maxCount = 1;
    int count = 0;
    LogRequest req = new LogRequest.Builder().maxCont(maxCount).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream("", files, req, status);
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            assertEquals("Total line number should match max count limit", 5, count);
            break;
        }
        count++;
    }
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) ArrayList(java.util.ArrayList) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with LogFileStream

use of com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream in project coprhd-controller by CoprHD.

the class LogStreamTest method testSmallFileTimeRangeFilter.

/**
 * Test if logs read from one file are in time range specified in LogRequest
 */
@Test
public void testSmallFileTimeRangeFilter() throws Exception {
    File file = new File(timeRangeFilePath);
    List<File> files = new ArrayList<File>();
    files.add(file);
    Calendar calendar = Calendar.getInstance();
    calendar.set(2013, 10, 20, 16, 38);
    Date startTime = calendar.getTime();
    long startTimeLong = startTime.getTime();
    calendar.set(2014, 0, 16, 16, 38);
    Date endTime = calendar.getTime();
    long endTimeLong = endTime.getTime();
    LogRequest req = new LogRequest.Builder().startTime(startTime).endTime(endTime).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream("", files, req, status);
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            break;
        }
        long time = log.getTime();
        // System.out.println(startTimeLong + " " + endTimeLong + " " +
        // time);
        assertTrue("Lines read from LogStream should in time range(one file)", time >= startTimeLong && time <= endTimeLong);
    }
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 13 with LogFileStream

use of com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream in project coprhd-controller by CoprHD.

the class LogStreamTest method testReadLineNoFilter.

/**
 * Test if logCounter in LogStream can record number of logs correctly And
 * test if sizeCounter in LogStream can record count of total file size
 * correctly Test if fileCounter in LogStream can record file count
 * correctly
 *
 * @throws Exception
 *             This test can only be tested on root@10.10.191.121
 */
@Test
@Ignore
public void testReadLineNoFilter() throws Exception {
    String svcName = "dbsvc-";
    // dbsvc-0.log + dbsvc-1.log + dbsvc-2.log
    final long LINE_NUMBER = 500000 + 500000 + 10;
    File f1 = new File(HARD_CODE_PATH + "/src/main/data/streamData/dbsvc-0.log");
    File f2 = new File(HARD_CODE_PATH + "/src/main/data/streamData/dbsvc-1.log");
    File f3 = new File(HARD_CODE_PATH + "/src/main/data/streamData/dbsvc-2.log");
    List<File> files = new ArrayList<File>();
    files.add(f1);
    files.add(f2);
    files.add(f3);
    final long TOTAL_BYTES = f1.length() + f2.length() + f3.length();
    LogStatusInfo status = new LogStatusInfo();
    LogRequest req = new LogRequest.Builder().build();
    LogFileStream stream = new LogFileStream(svcName, files, req, status);
    // file count
    final int FILE_NUMBER = stream.getLogPaths().size();
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            assertEquals("Total logs number should match", LINE_NUMBER, stream.getTotalLogCount());
            assertEquals("Total file size should match", TOTAL_BYTES, stream.getTotalSizeCount());
            assertEquals("Total file number should match", FILE_NUMBER, stream.getFileCount());
            break;
        }
    }
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) ArrayList(java.util.ArrayList) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

LogFileStream (com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream)13 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)13 File (java.io.File)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)10 Ignore (org.junit.Ignore)9 Calendar (java.util.Calendar)5 Date (java.util.Date)5 LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)4 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)4