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");
}
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");
}
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.");
}
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.");
}
}
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.");
}
Aggregations