aromanenko-dev commented on code in PR #22260:
URL: https://github.com/apache/beam/pull/22260#discussion_r943610732
##########
sdks/java/testing/nexmark/src/main/java/org/apache/beam/sdk/nexmark/Main.java:
##########
@@ -208,38 +195,24 @@ private static InfluxDBSettings getInfluxSettings(final
NexmarkOptions options)
.get();
}
- private static String produceMeasurement(
- final NexmarkOptions options, Map.Entry<NexmarkConfiguration,
NexmarkPerf> entry) {
+ private static String measurementName(final NexmarkOptions options,
NexmarkConfiguration config) {
Review Comment:
nit: `generateMeasurementName()`
##########
sdks/java/testing/test-utils/src/test/java/org/apache/beam/sdk/testutils/publishing/InfluxDBPublisherTest.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.testutils.publishing;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.beam.sdk.testutils.NamedTestResult;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+import org.junit.Test;
+
+public final class InfluxDBPublisherTest {
+
+ @Test
+ public void testNexmarkDataPoints() {
+ Map<String, Object> measurement =
+ ImmutableMap.<String, Object>builder()
+ .put("measurement", "name")
+ .put("timestamp", 9999L)
+ .put("runtimeMs", "1000i")
+ .put("numResults", "10i")
+ .build();
+ List<Map<String, Object>> measurements =
+ ImmutableList.of(measurement, measurement, measurement);
Review Comment:
nit: create a list of measurements with different values
##########
sdks/java/testing/nexmark/src/main/java/org/apache/beam/sdk/nexmark/Main.java:
##########
@@ -208,38 +195,24 @@ private static InfluxDBSettings getInfluxSettings(final
NexmarkOptions options)
.get();
}
- private static String produceMeasurement(
- final NexmarkOptions options, Map.Entry<NexmarkConfiguration,
NexmarkPerf> entry) {
+ private static String measurementName(final NexmarkOptions options,
NexmarkConfiguration config) {
final String queryName =
- NexmarkUtils.fullQueryName(
- options.getQueryLanguage(),
entry.getKey().query.getNumberOrName());
+ NexmarkUtils.fullQueryName(options.getQueryLanguage(),
config.query.getNumberOrName());
return String.format(
"%s_%s_%s",
options.getBaseInfluxMeasurement(), queryName,
processingMode(options.isStreaming()));
}
- private static Map<String, Object> getResultsFromSchema(
- final NexmarkPerf results,
- final Map<String, String> schema,
- final long timestamp,
- final String runner,
- final String measurement) {
- final Map<String, Object> schemaResults =
- results.toMap().entrySet().stream()
- .filter(element -> schema.containsKey(element.getKey()))
- .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
- final int runtimeMs =
- (int) ((double) schemaResults.get("runtimeSec") * 1000); // change sec
to ms
- schemaResults.put("timestamp", timestamp);
- schemaResults.put("runner", runner);
- schemaResults.put("measurement", measurement);
-
- // By default, InfluxDB treats all number values as floats. We need to add
'i' suffix to
- // interpret the value as an integer.
- schemaResults.put("runtimeMs", runtimeMs + "i");
- schemaResults.put("numResults", schemaResults.get("numResults") + "i");
-
- return schemaResults;
+ private static InfluxDBPublisher.DataPoint influxDBDataPoint(
Review Comment:
nit: `createInfluxDBDataPoint()`
##########
sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/publishing/InfluxDBPublisher.java:
##########
@@ -83,73 +138,48 @@ private static void publishWithCheck(
}
}
- private static void publishNexmark(
- final Collection<Map<String, Object>> results,
- final InfluxDBSettings settings,
- final Map<String, String> tags)
- throws Exception {
-
- final HttpClientBuilder builder = provideHttpBuilder(settings);
- final HttpPost postRequest = providePOSTRequest(settings);
- final StringBuilder metricBuilder = new StringBuilder();
-
+ @VisibleForTesting
+ static String nexmarkDataPoints(
Review Comment:
Should we extract this method into specific Nexmark class?
--
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]