@Test @SuppressWarnings("unchecked") public void ensureUpdatesAreIgnoredAfterResetIsCalled() throws IOException { MetricName metricName = MetricName.parse(SOME_METRIC_NAME); TypeHandler<CustomType> customTypeTypeHandler = mock(TypeHandler.class); PcpMetricInfo pcpMetricInfo = mock(PcpMetricInfo.class); when(customTypeTypeHandler.getMetricType()).thenReturn(MmvMetricType.DOUBLE); when(metricInfoStore.byName(SOME_METRIC_NAME)).thenReturn(pcpMetricInfo); doReturn(customTypeTypeHandler).when(pcpMetricInfo).getTypeHandler(); when(byteBuffer.slice()).thenReturn(mock(ByteBuffer.class)); pcpMmvWriter.registerType(CustomType.class, customTypeTypeHandler); pcpMmvWriter.start(); pcpMmvWriter.reset(); Mockito.reset(customTypeTypeHandler); pcpMmvWriter.addMetric(metricName, Semantics.COUNTER, ONE, new CustomType()); pcpMmvWriter.updateMetric(metricName, new CustomType()); verify(customTypeTypeHandler, never()).putBytes(any(ByteBuffer.class), any(CustomType.class)); }
@Test public void ensureSetPerMetricLockIsAllowedAfterResetIsCalled() throws IOException { pcpMmvWriter.start(); pcpMmvWriter.reset(); pcpMmvWriter.setPerMetricLock(true); }
@Test public void bothMmvVersionsShouldSupportAddingAMetric() throws Exception { pcpMmvWriterV1.reset(); pcpMmvWriterV1.addMetric(MetricName.parse("v1.integer"), Semantics.COUNTER, ONE, 3); pcpMmvWriterV1.start(); pcpMmvWriterV2.reset(); pcpMmvWriterV2.addMetric(MetricName.parse("v2.integer"), Semantics.COUNTER, ONE, 3); pcpMmvWriterV2.start(); waitForReload(); assertMetric("mmv.v1.integer", is("3.000")); assertMetric("mmv.v2.integer", is("3.000")); }
@Test public void mmvVersion2ShouldSupportInstanceNamesOver63Characters() throws Exception { pcpMmvWriterV2.reset(); pcpMmvWriterV2.addMetric(MetricName.parse("v2.integer[instance_name_over_63_characters_instance_name_over_63_characters_instance]"), Semantics.COUNTER, ONE, 11); pcpMmvWriterV2.start(); waitForReload(); assertMetric("mmv.v2.integer[instance_name_over_63_characters_instance_name_over_63_characters_instance]", is("11.000")); }
@Test public void mmvVersion2ShouldSupportMetricNamesOver63Characters() throws Exception { pcpMmvWriterV2.reset(); pcpMmvWriterV2.addMetric(MetricName.parse("v2.metric.that.is.longer.than.63.characters.v2.metric.that.is.longer.than.63.characters"), Semantics.COUNTER, ONE, 10); pcpMmvWriterV2.start(); waitForReload(); assertMetric("mmv.v2.metric.that.is.longer.than.63.characters.v2.metric.that.is.longer.than.63.characters", is("10.000")); }