5 commented on code in PR #204:
URL: https://github.com/apache/cassandra-sidecar/pull/204#discussion_r1994313632
##########
server/src/test/integration/org/apache/cassandra/sidecar/datahub/SchemaReporterIntegrationTest.java:
##########
@@ -97,21 +124,31 @@ void testSchemaConverter() throws IOException
JsonEmitter emitter = new JsonEmitter();
try (Session session = maybeGetSession())
{
- new SchemaReporter(IDENTIFIERS, () -> emitter)
- .process(session.getCluster());
+ new SchemaReporter(IDENTIFIERS, () -> emitter, metrics)
+ .processScheduled(session.getCluster());
}
String actualJson = normalizeNames(emitter.content());
String expectedJson =
IOUtils.readFully("/datahub/integration_test.json");
-
assertThat(actualJson)
.isEqualToNormalizingWhitespace(expectedJson);
- // Finally, make sure the returned schema produces the same tree of
+ // Second, make sure the returned schema produces the same tree of
// DataHub objects after having been normalized and deserialized
DataList actualData = CODEC.readList(new StringReader(actualJson));
DataList expectedData = CODEC.readList(new StringReader(expectedJson));
-
assertThat(actualData)
.isEqualTo(expectedData);
+
+ // Third, validate the captured metrics: one execution triggered by
the schedule and
+ // completed successfully, with thirteen aspects produced in zero or
more milliseconds
+ SchemaReportingMetrics metrics =
this.metrics.server().schemaReporting();
+ assertEquals(0L, metrics.startedRequest.metric.getValue());
+ assertEquals(1L, metrics.startedSchedule.metric.getValue());
+ assertEquals(1L, metrics.finishedSuccess.metric.getValue());
+ assertEquals(0L, metrics.finishedFailure.metric.getValue());
+ assertEquals(1L, metrics.sizeAspects.metric.getCount());
+ assertEquals(13L,
metrics.sizeAspects.metric.getSnapshot().getValues()[0]);
+ assertEquals(1L, metrics.durationMilliseconds.metric.getCount());
+ assertTrue(0L <=
metrics.durationMilliseconds.metric.getSnapshot().getValues()[0]);
Review Comment:
Switched to the new syntax.
##########
server/src/test/java/org/apache/cassandra/sidecar/datahub/SchemaReporterTest.java:
##########
@@ -261,12 +311,21 @@ void testUserTypes() throws IOException
when(udt2c2.getType()).thenReturn(DataType.cboolean());
JsonEmitter emitter = new JsonEmitter();
- new SchemaReporter(IDENTIFIERS, () -> emitter)
- .process(cluster);
+ new SchemaReporter(IDENTIFIERS, () -> emitter, metrics)
+ .processScheduled(cluster);
String actual = emitter.content();
String expected = IOUtils.readFully("/datahub/user_types.json");
-
assertEquals(expected, actual);
+
+ SchemaReportingMetrics metrics =
this.metrics.server().schemaReporting(); // Validate captured
metrics:
+ assertEquals(0L, metrics.startedRequest.metric.getValue());
// * zero executions triggered by request
+ assertEquals(1L, metrics.startedSchedule.metric.getValue());
// * one execution triggered by schedule
+ assertEquals(1L, metrics.finishedSuccess.metric.getValue());
// * one execution resulted in success
+ assertEquals(0L, metrics.finishedFailure.metric.getValue());
// * zero executions resulted in failure
+ assertEquals(1L, metrics.sizeAspects.metric.getCount());
// * single number of aspects,
+ assertEquals(13L,
metrics.sizeAspects.metric.getSnapshot().getValues()[0]); // equal
to thirteen
+ assertEquals(1L, metrics.durationMilliseconds.metric.getCount());
// * single duration of execution,
+ assertTrue(0L <=
metrics.durationMilliseconds.metric.getSnapshot().getValues()[0]); // that
is non-negative
Review Comment:
Switched to the new syntax.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]