Search in sources :

Example 1 with LogStatusInfo

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

the class SysLogReaderTest method testLogCountSysParser.

/**
 * Test if reader could recognize the correct count of system logs
 */
@Test
public void testLogCountSysParser() throws Exception {
    System.out.println("starting testLogCountSysParser");
    LogStatusInfo status = new LogStatusInfo();
    final int WARN = 5;
    // four kinds of different patterns in file
    String filePath = "src/main/data/testReaderData/testSyslogParser.log";
    long logCount = 47;
    LogReader reader = null;
    LogRequest req = new LogRequest.Builder().logLevel(WARN).build();
    reader = new LogReader(filePath, req, status, null);
    while (true) {
        LogMessage log = reader.readNextLogMessage();
        if (log == null) {
            assertEquals("Log count should match", logCount, reader.getLogCount());
            break;
        }
    }
    System.out.println("done testLogCountSysParser");
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) Test(org.junit.Test)

Example 2 with LogStatusInfo

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

the class SysLogReaderTest method testLogStatusInfo.

/**
 * Test if reader could record correct status information
 */
@Test
public void testLogStatusInfo() throws Exception {
    System.out.println("starting testLogStatusInfo");
    LogStatusInfo status = new LogStatusInfo();
    String filePath = "src/main/data/testReaderData/testStatus.log";
    long logCount = 42;
    LogReader reader = null;
    LogRequest req = new LogRequest.Builder().build();
    reader = new LogReader(filePath, req, status, null);
    while (true) {
        LogMessage log = reader.readNextLogMessage();
        if (log == null) {
            assertEquals("Log count should match", logCount, reader.getLogCount());
            break;
        }
    }
    BufferedReader br = new BufferedReader(new FileReader("src/main/data/testReaderData/testStatusResult.log"));
    String line = br.readLine();
    int index = 0;
    while (line != null) {
        assertTrue("status's size is not correct!", status.getStatus().size() > index);
        assertEquals("status's contect is not correct!", line, status.getStatus().get(index));
        index++;
        line = br.readLine();
    }
    assertEquals("status's size is not correct!", status.getStatus().size(), index);
    br.close();
    System.out.println("done testLogStatusInfo");
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 3 with LogStatusInfo

use of com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo 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 4 with LogStatusInfo

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

the class LogNetworkReaderPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    List<String> svcs = new ArrayList<String>() {

        {
            add("controllersvc");
            add("coordinatorsvc");
            add("apisvc");
        }
    };
    int bufSize = 1024 * 64;
    LogRequest req = new LogRequest.Builder().baseNames(svcs).build();
    final LogNetworkWriter writer = new LogNetworkWriter(req, propertiesLoader);
    try (final PipedOutputStream out = new PipedOutputStream();
        final BufferedOutputStream outputStream = new BufferedOutputStream(out, bufSize);
        final PipedInputStream inputStream = new PipedInputStream(out)) {
        LogNetworkReader reader = new LogNetworkReader("vipr1", "vipr1", inputStream, new LogStatusInfo());
        long totalSize = 0;
        long startTime = System.nanoTime();
        new Thread(new Runnable() {

            public void run() {
                try {
                    writer.write(outputStream);
                } catch (Exception e) {
                    // NOSONAR
                    e.printStackTrace();
                // ("squid:S1148 suppress sonar warning on printStackTrace. It's a test case and exceptions are meant to be printed to stdout/stderr")
                }
            }
        }).start();
        LogMessage log = null;
        while ((log = reader.readNextLogMessage()) != null) {
            totalSize += log.toStringOriginalFormat().getBytes().length;
        }
        long endTime = System.nanoTime();
        totalSize /= (1024L * 1024L);
        double elapsedTime = (double) (endTime - startTime) / 1000000000.0;
        System.out.println("Total read " + totalSize + " MB;" + " Used " + elapsedTime + " sec; Average " + (totalSize / elapsedTime) + " MB/sec.");
    }
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogNetworkReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader) ArrayList(java.util.ArrayList) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogNetworkWriter(com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) BufferedOutputStream(java.io.BufferedOutputStream) Test(org.junit.Test)

Example 5 with LogStatusInfo

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

the class LogReaderPerfTest method testPerformance.

@Test
public void testPerformance() throws Exception {
    LogStatusInfo status = new LogStatusInfo();
    String filePath = PATH;
    File file = new File(filePath);
    double fileSize = (double) file.length() / (1024L * 1024L);
    LogRequest req = new LogRequest.Builder().build();
    // empty service list
    LogReader reader = new LogReader(filePath, req, status, null);
    long startTime = System.nanoTime();
    while (true) {
        LogMessage log = reader.readNextLogMessage();
        if (log == null) {
            break;
        }
    }
    double elapsedTime = (double) (System.nanoTime() - startTime) / 1000000000.0;
    double speed = fileSize / elapsedTime;
    System.out.println("Performance for LogReader");
    System.out.println("Total read " + fileSize + " MB;" + " Used " + elapsedTime + " sec; Average " + speed + " MB/sec.");
}
Also used : LogStatusInfo(com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo) LogRequest(com.emc.vipr.model.sys.logging.LogRequest) LogMessage(com.emc.storageos.systemservices.impl.logsvc.LogMessage) LogReader(com.emc.storageos.systemservices.impl.logsvc.stream.LogReader) File(java.io.File) Test(org.junit.Test)

Aggregations

LogMessage (com.emc.storageos.systemservices.impl.logsvc.LogMessage)12 LogStatusInfo (com.emc.storageos.systemservices.impl.logsvc.LogStatusInfo)12 LogRequest (com.emc.vipr.model.sys.logging.LogRequest)12 Test (org.junit.Test)12 LogReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogReader)7 File (java.io.File)5 LogFileStream (com.emc.storageos.systemservices.impl.logsvc.stream.LogFileStream)4 Calendar (java.util.Calendar)4 Date (java.util.Date)4 Ignore (org.junit.Ignore)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 ArrayList (java.util.ArrayList)2 LogNetworkWriter (com.emc.storageos.systemservices.impl.logsvc.LogNetworkWriter)1 LogNetworkReader (com.emc.storageos.systemservices.impl.logsvc.stream.LogNetworkReader)1 BufferedOutputStream (java.io.BufferedOutputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1