Search in sources :

Example 1 with LogFileStream

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

the class LogStreamPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    List<File> files = new ArrayList<>();
    files.add(new File("/opt/storageos/logs/testData/controllersvc.log"));
    files.add(new File("/opt/storageos/logs/testData/controllersvc.log.20131120-163817.gz"));
    LogRequest req = new LogRequest.Builder().build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream("", files, req, status);
    long startTime = 0;
    long endTime = 0;
    startTime = System.nanoTime();
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            endTime = System.nanoTime();
            break;
        }
    }
    double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
    double speed = 1510.8 / elapsedTime;
    System.out.println("Total read 1510.8 MB; Used " + elapsedTime + " sec; Average " + speed + " MB/sec.");
}
Also used : LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogFileStream(com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 2 with LogFileStream

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

the class LogStreamTest method testGetFilePathTimeFilter.

/**
 * Test if LogStream can find all files need to read correctly with time
 * range filter
 * This test can only be tested on root@10.10.191.121
 */
@Test
@Ignore
public void testGetFilePathTimeFilter() {
    String svcName = "controllersvc";
    List<File> files = new ArrayList<File>();
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140110-231105.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140114-151216.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140112-175108.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140116-031010.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140109-101159.gz"));
    Calendar calendar = Calendar.getInstance();
    calendar.set(2014, 0, 10, 0, 0);
    Date startTimeFilter = calendar.getTime();
    calendar.set(2014, 0, 14, 16, 38);
    Date endTimeFilter = calendar.getTime();
    LogRequest req = new LogRequest.Builder().startTime(startTimeFilter).endTime(endTimeFilter).build();
    LogFileStream stream = new LogFileStream(svcName, files, req, null);
    List<String> paths = stream.getLogPaths();
    List<String> result = new ArrayList<String>();
    result.add(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140110-231105.gz");
    result.add(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140112-175108.gz");
    result.add(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140114-151216.gz");
    result.add(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140116-031010.gz");
    int i = 0;
    assertTrue("Time range and svc filters are not correct", paths.size() == result.size());
    for (String str : paths) {
        assertEquals("Time range and svc filters are not correct", str, result.get(i));
        i++;
    }
}
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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with LogFileStream

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

the class LogStreamTest method testMultipleFilesTimeRangeFilter.

/**
 * Test if logs read from files are in time range specified in LogRequest
 * This test can only be tested on root@10.10.191.121
 */
@Test
@Ignore
public void testMultipleFilesTimeRangeFilter() throws Exception {
    List<File> files = new ArrayList<File>();
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140110-231105.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140114-151216.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140112-175108.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140116-031010.gz"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log"));
    files.add(new File(HARD_CODE_PATH + "/src/main/data/streamData/controllersvc.log.20140109-101159.gz"));
    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();
        assertTrue("Lines read from LogStream should in time range(multiple files)", 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with LogFileStream

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

the class LogStreamTest method testSmallFileLevelFilter.

/**
 * Test if logs read from LogStream match level specified in LogRequest
 */
@Test
public void testSmallFileLevelFilter() throws Exception {
    File file = new File(timeRangeFilePath);
    List<File> files = new ArrayList<File>();
    files.add(file);
    // "WARN"
    int level = 5;
    LogRequest req = new LogRequest.Builder().logLevel(level).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream("", files, req, status);
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            break;
        }
        assertTrue("Log level should match", LogSeverity.toLevel(new String(log.getLevel())) <= level);
    }
}
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) Test(org.junit.Test)

Example 5 with LogFileStream

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

the class LogStreamTest method testSmallFilePatternFilter.

/**
 * Test if logs read from LogStream match pattern(keywords) specified in
 * LogRequest
 */
@Test
public void testSmallFilePatternFilter() throws Exception {
    File file = new File(timeRangeFilePath);
    List<File> files = new ArrayList<File>();
    files.add(file);
    String pattern = "reset";
    LogRequest req = new LogRequest.Builder().regex(pattern).build();
    LogStatusInfo status = new LogStatusInfo();
    LogFileStream stream = new LogFileStream("", files, req, status);
    while (true) {
        LogMessage log = stream.readNextLogMessage();
        if (log == null) {
            break;
        }
        assertTrue("log should have the keywords", toStringOriginalFormatStr(log).indexOf(pattern) >= 0);
    }
}
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) 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