[TEST] introduce more intermediate variables in NodeStatsTests to prevent too much line wrapping

This commit is contained in:
javanna 2016-09-06 16:12:49 +02:00 committed by Luca Cavanna
parent a035ca102f
commit 1a2c7e0d25
1 changed files with 79 additions and 87 deletions

View File

@ -88,45 +88,42 @@ public class NodeStatsTests extends ESTestCase {
assertEquals(nodeStats.getProcess().getOpenFileDescriptors(), assertEquals(nodeStats.getProcess().getOpenFileDescriptors(),
deserializedNodeStats.getProcess().getOpenFileDescriptors()); deserializedNodeStats.getProcess().getOpenFileDescriptors());
} }
if (nodeStats.getJvm() == null) { JvmStats jvm = nodeStats.getJvm();
assertNull(deserializedNodeStats.getJvm()); JvmStats deserializedJvm = deserializedNodeStats.getJvm();
if (jvm == null) {
assertNull(deserializedJvm);
} else { } else {
assertEquals(nodeStats.getJvm().getTimestamp(), deserializedNodeStats.getJvm().getTimestamp()); JvmStats.Mem mem = jvm.getMem();
assertEquals(nodeStats.getJvm().getMem().getHeapUsedPercent(), JvmStats.Mem deserializedMem = deserializedJvm.getMem();
deserializedNodeStats.getJvm().getMem().getHeapUsedPercent()); assertEquals(jvm.getTimestamp(), deserializedJvm.getTimestamp());
assertEquals(nodeStats.getJvm().getMem().getHeapUsed(), deserializedNodeStats.getJvm().getMem().getHeapUsed()); assertEquals(mem.getHeapUsedPercent(), deserializedMem.getHeapUsedPercent());
assertEquals(nodeStats.getJvm().getMem().getHeapCommitted(), assertEquals(mem.getHeapUsed(), deserializedMem.getHeapUsed());
deserializedNodeStats.getJvm().getMem().getHeapCommitted()); assertEquals(mem.getHeapCommitted(), deserializedMem.getHeapCommitted());
assertEquals(nodeStats.getJvm().getMem().getNonHeapCommitted(), assertEquals(mem.getNonHeapCommitted(), deserializedMem.getNonHeapCommitted());
deserializedNodeStats.getJvm().getMem().getNonHeapCommitted()); assertEquals(mem.getNonHeapUsed(), deserializedMem.getNonHeapUsed());
assertEquals(nodeStats.getJvm().getMem().getNonHeapUsed(), deserializedNodeStats.getJvm().getMem().getNonHeapUsed()); assertEquals(mem.getHeapMax(), deserializedMem.getHeapMax());
assertEquals(nodeStats.getJvm().getMem().getHeapMax(), deserializedNodeStats.getJvm().getMem().getHeapMax()); JvmStats.Classes classes = jvm.getClasses();
assertEquals(nodeStats.getJvm().getClasses().getLoadedClassCount(), assertEquals(classes.getLoadedClassCount(), deserializedJvm.getClasses().getLoadedClassCount());
deserializedNodeStats.getJvm().getClasses().getLoadedClassCount()); assertEquals(classes.getTotalLoadedClassCount(), deserializedJvm.getClasses().getTotalLoadedClassCount());
assertEquals(nodeStats.getJvm().getClasses().getTotalLoadedClassCount(), assertEquals(classes.getUnloadedClassCount(), deserializedJvm.getClasses().getUnloadedClassCount());
deserializedNodeStats.getJvm().getClasses().getTotalLoadedClassCount()); assertEquals(jvm.getGc().getCollectors().length, deserializedJvm.getGc().getCollectors().length);
assertEquals(nodeStats.getJvm().getClasses().getUnloadedClassCount(), for (int i = 0; i < jvm.getGc().getCollectors().length; i++) {
deserializedNodeStats.getJvm().getClasses().getUnloadedClassCount()); JvmStats.GarbageCollector garbageCollector = jvm.getGc().getCollectors()[i];
assertEquals(nodeStats.getJvm().getGc().getCollectors().length, JvmStats.GarbageCollector deserializedGarbageCollector = deserializedJvm.getGc().getCollectors()[i];
deserializedNodeStats.getJvm().getGc().getCollectors().length);
for (int i = 0; i < nodeStats.getJvm().getGc().getCollectors().length; i++) {
JvmStats.GarbageCollector garbageCollector = nodeStats.getJvm().getGc().getCollectors()[i];
JvmStats.GarbageCollector deserializedGarbageCollector = deserializedNodeStats.getJvm().getGc().getCollectors()[i];
assertEquals(garbageCollector.getName(), deserializedGarbageCollector.getName()); assertEquals(garbageCollector.getName(), deserializedGarbageCollector.getName());
assertEquals(garbageCollector.getCollectionCount(), deserializedGarbageCollector.getCollectionCount()); assertEquals(garbageCollector.getCollectionCount(), deserializedGarbageCollector.getCollectionCount());
assertEquals(garbageCollector.getCollectionTime(), deserializedGarbageCollector.getCollectionTime()); assertEquals(garbageCollector.getCollectionTime(), deserializedGarbageCollector.getCollectionTime());
} }
assertEquals(nodeStats.getJvm().getThreads().getCount(), deserializedNodeStats.getJvm().getThreads().getCount()); assertEquals(jvm.getThreads().getCount(), deserializedJvm.getThreads().getCount());
assertEquals(nodeStats.getJvm().getThreads().getPeakCount(), assertEquals(jvm.getThreads().getPeakCount(), deserializedJvm.getThreads().getPeakCount());
deserializedNodeStats.getJvm().getThreads().getPeakCount()); assertEquals(jvm.getUptime(), deserializedJvm.getUptime());
assertEquals(nodeStats.getJvm().getUptime(), deserializedNodeStats.getJvm().getUptime()); if (jvm.getBufferPools() == null) {
if (nodeStats.getJvm().getBufferPools() == null) { assertNull(deserializedJvm.getBufferPools());
assertNull(deserializedNodeStats.getJvm().getBufferPools());
} else { } else {
assertEquals(nodeStats.getJvm().getBufferPools().size(), deserializedNodeStats.getJvm().getBufferPools().size()); assertEquals(jvm.getBufferPools().size(), deserializedJvm.getBufferPools().size());
for (int i = 0; i < nodeStats.getJvm().getBufferPools().size(); i++) { for (int i = 0; i < jvm.getBufferPools().size(); i++) {
JvmStats.BufferPool bufferPool = nodeStats.getJvm().getBufferPools().get(i); JvmStats.BufferPool bufferPool = jvm.getBufferPools().get(i);
JvmStats.BufferPool deserializedBufferPool = deserializedNodeStats.getJvm().getBufferPools().get(i); JvmStats.BufferPool deserializedBufferPool = deserializedJvm.getBufferPools().get(i);
assertEquals(bufferPool.getName(), deserializedBufferPool.getName()); assertEquals(bufferPool.getName(), deserializedBufferPool.getName());
assertEquals(bufferPool.getCount(), deserializedBufferPool.getCount()); assertEquals(bufferPool.getCount(), deserializedBufferPool.getCount());
assertEquals(bufferPool.getTotalCapacity(), deserializedBufferPool.getTotalCapacity()); assertEquals(bufferPool.getTotalCapacity(), deserializedBufferPool.getTotalCapacity());
@ -151,32 +148,30 @@ public class NodeStatsTests extends ESTestCase {
assertEquals(stats.getRejected(), deserializedStats.getRejected()); assertEquals(stats.getRejected(), deserializedStats.getRejected());
} }
} }
if (nodeStats.getFs() == null) { FsInfo fs = nodeStats.getFs();
assertNull(deserializedNodeStats.getFs()); FsInfo deserializedFs = deserializedNodeStats.getFs();
if (fs == null) {
assertNull(deserializedFs);
} else { } else {
assertEquals(nodeStats.getFs().getTimestamp(), deserializedNodeStats.getFs().getTimestamp()); assertEquals(fs.getTimestamp(), deserializedFs.getTimestamp());
assertEquals(nodeStats.getFs().getTotal().getAvailable(), deserializedNodeStats.getFs().getTotal().getAvailable()); assertEquals(fs.getTotal().getAvailable(), deserializedFs.getTotal().getAvailable());
assertEquals(nodeStats.getFs().getTotal().getTotal(), deserializedNodeStats.getFs().getTotal().getTotal()); assertEquals(fs.getTotal().getTotal(), deserializedFs.getTotal().getTotal());
assertEquals(nodeStats.getFs().getTotal().getFree(), deserializedNodeStats.getFs().getTotal().getFree()); assertEquals(fs.getTotal().getFree(), deserializedFs.getTotal().getFree());
assertEquals(nodeStats.getFs().getTotal().getMount(), deserializedNodeStats.getFs().getTotal().getMount()); assertEquals(fs.getTotal().getMount(), deserializedFs.getTotal().getMount());
assertEquals(nodeStats.getFs().getTotal().getPath(), deserializedNodeStats.getFs().getTotal().getPath()); assertEquals(fs.getTotal().getPath(), deserializedFs.getTotal().getPath());
assertEquals(nodeStats.getFs().getTotal().getSpins(), deserializedNodeStats.getFs().getTotal().getSpins()); assertEquals(fs.getTotal().getSpins(), deserializedFs.getTotal().getSpins());
assertEquals(nodeStats.getFs().getTotal().getType(), deserializedNodeStats.getFs().getTotal().getType()); assertEquals(fs.getTotal().getType(), deserializedFs.getTotal().getType());
assertEquals(nodeStats.getFs().getIoStats().getTotalOperations(), FsInfo.IoStats ioStats = fs.getIoStats();
deserializedNodeStats.getFs().getIoStats().getTotalOperations()); FsInfo.IoStats deserializedIoStats = deserializedFs.getIoStats();
assertEquals(nodeStats.getFs().getIoStats().getTotalReadKilobytes(), assertEquals(ioStats.getTotalOperations(), deserializedIoStats.getTotalOperations());
deserializedNodeStats.getFs().getIoStats().getTotalReadKilobytes()); assertEquals(ioStats.getTotalReadKilobytes(), deserializedIoStats.getTotalReadKilobytes());
assertEquals(nodeStats.getFs().getIoStats().getTotalReadOperations(), assertEquals(ioStats.getTotalReadOperations(), deserializedIoStats.getTotalReadOperations());
deserializedNodeStats.getFs().getIoStats().getTotalReadOperations()); assertEquals(ioStats.getTotalWriteKilobytes(), deserializedIoStats.getTotalWriteKilobytes());
assertEquals(nodeStats.getFs().getIoStats().getTotalWriteKilobytes(), assertEquals(ioStats.getTotalWriteOperations(), deserializedIoStats.getTotalWriteOperations());
deserializedNodeStats.getFs().getIoStats().getTotalWriteKilobytes()); assertEquals(ioStats.getDevicesStats().length, deserializedIoStats.getDevicesStats().length);
assertEquals(nodeStats.getFs().getIoStats().getTotalWriteOperations(), for (int i = 0; i < ioStats.getDevicesStats().length; i++) {
deserializedNodeStats.getFs().getIoStats().getTotalWriteOperations()); FsInfo.DeviceStats deviceStats = ioStats.getDevicesStats()[i];
assertEquals(nodeStats.getFs().getIoStats().getDevicesStats().length, FsInfo.DeviceStats deserializedDeviceStats = deserializedIoStats.getDevicesStats()[i];
deserializedNodeStats.getFs().getIoStats().getDevicesStats().length);
for (int i = 0; i < nodeStats.getFs().getIoStats().getDevicesStats().length; i++) {
FsInfo.DeviceStats deviceStats = nodeStats.getFs().getIoStats().getDevicesStats()[i];
FsInfo.DeviceStats deserializedDeviceStats = deserializedNodeStats.getFs().getIoStats().getDevicesStats()[i];
assertEquals(deviceStats.operations(), deserializedDeviceStats.operations()); assertEquals(deviceStats.operations(), deserializedDeviceStats.operations());
assertEquals(deviceStats.readKilobytes(), deserializedDeviceStats.readKilobytes()); assertEquals(deviceStats.readKilobytes(), deserializedDeviceStats.readKilobytes());
assertEquals(deviceStats.readOperations(), deserializedDeviceStats.readOperations()); assertEquals(deviceStats.readOperations(), deserializedDeviceStats.readOperations());
@ -213,44 +208,41 @@ public class NodeStatsTests extends ESTestCase {
assertEquals(circuitBreakerStats.getTrippedCount(), deserializedCircuitBreakerStats.getTrippedCount(), 0); assertEquals(circuitBreakerStats.getTrippedCount(), deserializedCircuitBreakerStats.getTrippedCount(), 0);
} }
} }
if (nodeStats.getScriptStats() == null) { ScriptStats scriptStats = nodeStats.getScriptStats();
if (scriptStats == null) {
assertNull(deserializedNodeStats.getScriptStats()); assertNull(deserializedNodeStats.getScriptStats());
} else { } else {
assertEquals(nodeStats.getScriptStats().getCacheEvictions(), assertEquals(scriptStats.getCacheEvictions(), deserializedNodeStats.getScriptStats().getCacheEvictions());
deserializedNodeStats.getScriptStats().getCacheEvictions()); assertEquals(scriptStats.getCompilations(), deserializedNodeStats.getScriptStats().getCompilations());
assertEquals(nodeStats.getScriptStats().getCompilations(), deserializedNodeStats.getScriptStats().getCompilations());
} }
if (nodeStats.getDiscoveryStats() == null) { DiscoveryStats discoveryStats = nodeStats.getDiscoveryStats();
assertNull(deserializedNodeStats.getDiscoveryStats()); DiscoveryStats deserializedDiscoveryStats = deserializedNodeStats.getDiscoveryStats();
if (discoveryStats == null) {
assertNull(deserializedDiscoveryStats);
} else { } else {
if (nodeStats.getDiscoveryStats().getQueueStats() == null) { PendingClusterStateStats queueStats = discoveryStats.getQueueStats();
assertNull(deserializedNodeStats.getDiscoveryStats().getQueueStats()); if (queueStats == null) {
assertNull(deserializedDiscoveryStats.getQueueStats());
} else { } else {
assertEquals(nodeStats.getDiscoveryStats().getQueueStats().getCommitted(), assertEquals(queueStats.getCommitted(), deserializedDiscoveryStats.getQueueStats().getCommitted());
deserializedNodeStats.getDiscoveryStats().getQueueStats().getCommitted()); assertEquals(queueStats.getTotal(), deserializedDiscoveryStats.getQueueStats().getTotal());
assertEquals(nodeStats.getDiscoveryStats().getQueueStats().getTotal(), assertEquals(queueStats.getPending(), deserializedDiscoveryStats.getQueueStats().getPending());
deserializedNodeStats.getDiscoveryStats().getQueueStats().getTotal());
assertEquals(nodeStats.getDiscoveryStats().getQueueStats().getPending(),
deserializedNodeStats.getDiscoveryStats().getQueueStats().getPending());
} }
} }
if (nodeStats.getIngestStats() == null) { IngestStats ingestStats = nodeStats.getIngestStats();
assertNull(deserializedNodeStats.getIngestStats()); IngestStats deserializedIngestStats = deserializedNodeStats.getIngestStats();
if (ingestStats == null) {
assertNull(deserializedIngestStats);
} else { } else {
assertEquals(nodeStats.getIngestStats().getTotalStats().getIngestCount(), IngestStats.Stats totalStats = ingestStats.getTotalStats();
deserializedNodeStats.getIngestStats().getTotalStats().getIngestCount()); assertEquals(totalStats.getIngestCount(), deserializedIngestStats.getTotalStats().getIngestCount());
assertEquals(nodeStats.getIngestStats().getTotalStats().getIngestCurrent(), assertEquals(totalStats.getIngestCurrent(), deserializedIngestStats.getTotalStats().getIngestCurrent());
deserializedNodeStats.getIngestStats().getTotalStats().getIngestCurrent()); assertEquals(totalStats.getIngestFailedCount(), deserializedIngestStats.getTotalStats().getIngestFailedCount());
assertEquals(nodeStats.getIngestStats().getTotalStats().getIngestFailedCount(), assertEquals(totalStats.getIngestTimeInMillis(), deserializedIngestStats.getTotalStats().getIngestTimeInMillis());
deserializedNodeStats.getIngestStats().getTotalStats().getIngestFailedCount()); assertEquals(ingestStats.getStatsPerPipeline().size(), deserializedIngestStats.getStatsPerPipeline().size());
assertEquals(nodeStats.getIngestStats().getTotalStats().getIngestTimeInMillis(), for (Map.Entry<String, IngestStats.Stats> entry : ingestStats.getStatsPerPipeline().entrySet()) {
deserializedNodeStats.getIngestStats().getTotalStats().getIngestTimeInMillis());
assertEquals(nodeStats.getIngestStats().getStatsPerPipeline().size(),
deserializedNodeStats.getIngestStats().getStatsPerPipeline().size());
for (Map.Entry<String, IngestStats.Stats> entry : nodeStats.getIngestStats().getStatsPerPipeline().entrySet()) {
IngestStats.Stats stats = entry.getValue(); IngestStats.Stats stats = entry.getValue();
IngestStats.Stats deserializedStats = deserializedNodeStats.getIngestStats() IngestStats.Stats deserializedStats = deserializedIngestStats.getStatsPerPipeline().get(entry.getKey());
.getStatsPerPipeline().get(entry.getKey());
assertEquals(stats.getIngestFailedCount(), deserializedStats.getIngestFailedCount()); assertEquals(stats.getIngestFailedCount(), deserializedStats.getIngestFailedCount());
assertEquals(stats.getIngestTimeInMillis(), deserializedStats.getIngestTimeInMillis()); assertEquals(stats.getIngestTimeInMillis(), deserializedStats.getIngestTimeInMillis());
assertEquals(stats.getIngestCurrent(), deserializedStats.getIngestCurrent()); assertEquals(stats.getIngestCurrent(), deserializedStats.getIngestCurrent());