GaugeManager { public void shutdown() { this.isRunning = false; this.gaugeManager.interrupt(); } GaugeManager(ZooKeeperManager zkManager, int sleepSeconds); void shutdown(); static double calcOverallOnlinePercentageGauge(ZooKeeperManager zkManager);  }
@Test public void testGaugeManagerRunnable() { String fileSet = "file-set"; when(mockZKManager.getFileSetInfoMap()).thenReturn(ImmutableMap.of(fileSet, mockFileSetInfo)); when(mockZKManager.getFileSetInfo(eq(fileSet))).thenReturn(mockFileSetInfo); when(mockZKManager.getViewInfo(eq(fileSet))).thenReturn(mockViewInfo); when(mockViewInfo.getNumOnlinePartitions()).thenReturn(3); mockServingInfo.helixResource = fileSet; mockServingInfo.numPartitions = 12; GaugeManager gaugeManager = new GaugeManager(mockZKManager, 1); try { Thread.sleep(1500); Option<Object> value = Stats.getGauge("terrapin-controller-fileset-file-set-online-pct"); assertEquals(0.25, value.get()); } catch (InterruptedException e) { gaugeManager.shutdown(); fail("test failed for interruption"); } gaugeManager.shutdown(); }