Skip to content

Commit

Permalink
Merge pull request #39 from jenkinsci/change_sla_field_type
Browse files Browse the repository at this point in the history
Change sla field type
  • Loading branch information
weisun10 authored Nov 15, 2022
2 parents bf1ca5e + 1cd6b1b commit 9e061b3
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<url>https://github.com/${gitHubRepo}</url>
</scm>
<properties>
<revision>5.0.0-</revision>
<revision>5.0.1-</revision>
<changelist>-SNAPSHOT</changelist>

<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. -->
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/microfocus/lrc/core/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class ApiClient internal constructor(
.newBuilder()
.addPathSegments(apiPath)

if (!this.serverConfiguration.tenantId.equals("")) {
urlBuilder.addQueryParameter("projectId", this.serverConfiguration.projectId.toString())
if (!this.serverConfiguration.tenantId.isNullOrEmpty()) {
urlBuilder.addQueryParameter("TENANTID", this.serverConfiguration.tenantId)
}

Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/microfocus/lrc/core/entity/ApiResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ class TestRunTransactionsResponse(
val name: String,
val loadTestScriptId: Int,
val scriptName: String,
val minTRT: Float,
val maxTRT: Float,
val avgTRT: Float,
val percentileTRT: Float,
val breakers: Float,
val minTRT: Double,
val maxTRT: Double,
val avgTRT: Double,
val percentileTRT: Double,
val breakers: Double,
val slaStatus: String,
val slaThreshold: Int,
val stdDeviation: Float,
val slaThreshold: Double,
val stdDeviation: Double,
val passed: Int,
val failed: Int,
val slaTrend: Float,
val slaTrend: Double,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package com.microfocus.lrc.core.entity

import com.google.gson.JsonObject
import java.io.InputStream
import java.io.Serializable

class LoadTestRun(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* © Copyright 2022 Micro Focus or one of its affiliates.
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
*
* 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 com.microfocus.lrc.core.entity

import com.google.gson.Gson
import org.junit.Test
import kotlin.math.abs

class TestRunTransactionsResponseTest {
fun DoubleEqual(a: Double, b: Double) : Boolean {
return abs(a - b) < 0.000001;
}

@Test
fun parseTXResponseJSON() {
val body =
" {\n" +
" \"name\": \"Visit Home Page\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 3.2703374264473153,\n" +
" \"slaStatus\": \"Passed\",\n" +
" \"slaThreshold\": 10,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 401243,\n" +
" \"failed\": 28,\n" +
" \"avgTRT\": 2.707237459818728,\n" +
" \"minTRT\": 0.3170619010925293,\n" +
" \"maxTRT\": 51.61132001876831,\n" +
" \"percentileTRT\": 5.472877685611247,\n" +
" \"stdDeviation\": 3.2573858691456974\n" +
" }";
val ret = Gson().fromJson(body, TestRunTransactionsResponse::class.java);
assert(DoubleEqual(ret.slaThreshold, 10.0));
}

@Test
fun parseTXResponseJSONArray() {
val body =
"[\n" +
" {\n" +
" \"name\": \"Visit Home Page\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 3.2703374264473153,\n" +
" \"slaStatus\": \"Passed\",\n" +
" \"slaThreshold\": 10,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 401243,\n" +
" \"failed\": 28,\n" +
" \"avgTRT\": 2.707237459818728,\n" +
" \"minTRT\": 0.3170619010925293,\n" +
" \"maxTRT\": 51.61132001876831,\n" +
" \"percentileTRT\": 5.472877685611247,\n" +
" \"stdDeviation\": 3.2573858691456974\n" +
" },\n" +
" {\n" +
" \"name\": \"Action_Transaction\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 0,\n" +
" \"slaStatus\": \"N/A\",\n" +
" \"slaThreshold\": null,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 401235,\n" +
" \"failed\": 28,\n" +
" \"avgTRT\": 5.707923019197213,\n" +
" \"minTRT\": 3.316663980484009,\n" +
" \"maxTRT\": 54.610921144485474,\n" +
" \"percentileTRT\": 8.46955207698463,\n" +
" \"stdDeviation\": 3.2574520378192484\n" +
" },\n" +
" {\n" +
" \"name\": \"Search and Buy\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 13.204730394905727,\n" +
" \"slaStatus\": \"Failed\",\n" +
" \"slaThreshold\": 10,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 401235,\n" +
" \"failed\": 28,\n" +
" \"avgTRT\": 5.707911945601833,\n" +
" \"minTRT\": 3.316663980484009,\n" +
" \"maxTRT\": 54.610921144485474,\n" +
" \"percentileTRT\": 8.469539964851833,\n" +
" \"stdDeviation\": 3.2574568514573947\n" +
" },\n" +
" {\n" +
" \"name\": \"vuser_init_Transaction\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 0,\n" +
" \"slaStatus\": \"N/A\",\n" +
" \"slaThreshold\": null,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 1000,\n" +
" \"failed\": 0,\n" +
" \"avgTRT\": 0.0004114634990692139,\n" +
" \"minTRT\": 0,\n" +
" \"maxTRT\": 0.003629922866821289,\n" +
" \"percentileTRT\": 0.00044494602415296765,\n" +
" \"stdDeviation\": 0.00035359262363640945\n" +
" },\n" +
" {\n" +
" \"name\": \"vuser_end_Transaction\",\n" +
" \"loadTestScriptId\": 1,\n" +
" \"scriptName\": \"Peaceful App V2\",\n" +
" \"breakers\": 0,\n" +
" \"slaStatus\": \"N/A\",\n" +
" \"slaThreshold\": null,\n" +
" \"slaTrend\": null,\n" +
" \"passed\": 1000,\n" +
" \"failed\": 0,\n" +
" \"avgTRT\": 0,\n" +
" \"minTRT\": 0,\n" +
" \"maxTRT\": 0,\n" +
" \"percentileTRT\": 0,\n" +
" \"stdDeviation\": 0\n" +
" }\n" +
"]";
val ret = Gson().fromJson(body, Array<TestRunTransactionsResponse>::class.java)
assert(ret.size == 5);
assert(DoubleEqual(ret[0].slaThreshold, 10.0));
assert(DoubleEqual(ret[4].slaThreshold, 0.0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,17 @@ class ReportDownloaderTest {
"Peacefull_FF",
-1,
"TC_peacefull_12.56_FF_20_pacing",
0.44700024F,
0.59299994F,
0.50877136F,
0.58499986F,
0.0F,
0.44700024,
0.59299994,
0.50877136,
0.58499986,
0.0,
"N/A",
3,
0.11051371F,
3.0,
0.11051371,
90,
0,
-0.013767751F
-0.013767751
)
val csvBytes = ReportDownloader.writeCsvBytesArray(arrayOf(tx))
println(csvBytes.toString(Charsets.UTF_8))
Expand Down

0 comments on commit 9e061b3

Please sign in to comment.