jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [jmeter] ham1 commented on a change in pull request #544: Add BackendListener that sends "raw" results to InfluxDB
Date Mon, 28 Sep 2020 18:28:20 GMT

ham1 commented on a change in pull request #544:
URL: https://github.com/apache/jmeter/pull/544#discussion_r496150447



##########
File path: src/components/src/test/groovy/org/apache/jmeter/visualizers/backend/influxdb/InfluxDBRawBackendListenerClientSpec.groovy
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.jmeter.visualizers.backend.influxdb
+
+import org.apache.jmeter.samplers.SampleResult
+import org.apache.jmeter.visualizers.backend.BackendListenerContext
+
+import spock.lang.Specification
+
+class InfluxDBRawBackendListenerClientSpec extends Specification {
+
+    def sut = new InfluxDBRawBackendListenerClient()
+    def defaultContext = new BackendListenerContext(sut.getDefaultParameters())
+
+    def createOkSample() {
+        def now = System.currentTimeMillis()
+        def okSample = SampleResult.createTestSample(now - 100, now)
+        okSample.setLatency(42)
+        okSample.setConnectTime(7)
+        okSample.setSampleLabel("myLabel")
+        okSample.setResponseOK()
+        return okSample
+    }
+
+    def "Default parameters contain minimum required options"() {
+        expect:
+            sut.getDefaultParameters()
+                    .getArgumentsAsMap()
+                    .keySet()
+                    .containsAll([
+                            "influxdbMetricsSender", "influxdbUrl",
+                            "influxdbToken", "measurement"])
+    }
+
+    def "Provided args are used during setup"() {
+        when:
+            sut.setupTest(defaultContext)
+        then:
+            sut.measurement == sut.DEFAULT_MEASUREMENT
+            sut.influxDBMetricsManager.class.isAssignableFrom(HttpMetricsSender.class)
+    }
+
+    def "OK sample data is mapped correctly to InfluxDB tags and fields"() {
+        given:
+            def okSample = createOkSample()
+        when:
+            def tags = sut.createTags(okSample)
+            def fields = sut.createFields(okSample)
+        then:
+            tags == "status=ok,transaction=myLabel"
+            fields == "duration=100,ttfb=42,connectTime=7"
+    }
+
+    def "Failed sample data is mapped correctly to InfluxDB tags and fields"() {
+        given:
+            def koSample = new SampleResult()
+            koSample.setSampleLabel("myLabel")
+        expect:
+            sut.createTags(koSample) == "status=ko,transaction=myLabel"

Review comment:
       It is, I'd be interested in any ideas you have to test this, would it be better to
make the method public marked with `@PublicForTesting`?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message