Skip to content

Commit

Permalink
Support for disabling of order verification for simple collection (#160)
Browse files Browse the repository at this point in the history
Support for disabling of order verification for simple collection
  • Loading branch information
lumber1000 authored Aug 30, 2022
1 parent 6a0fc5b commit 0b8e211
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 115 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# th2 check1 (3.9.1)
# th2 check1 (3.10.0)

## Overview

Expand Down Expand Up @@ -192,6 +192,11 @@ The `th2_check1_active_tasks_number` metric separate rules with label `rule_type

## Release Notes

### 3.10.0

#### Added:
+ Support for disabling of order verification for simple collection

### 3.9.1

#### Changed:
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'com.palantir.docker' version '0.25.0'
id 'org.jetbrains.kotlin.jvm' version '1.5.30'
id 'org.jetbrains.kotlin.jvm' version '1.5.32'
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id 'signing'
id 'java-library'
Expand All @@ -10,7 +10,7 @@ plugins {

ext {
sharedDir = file("${project.rootDir}/shared")
sailfishVersion = '3.2.1752'
sailfishVersion = '3.2.1877'
}

group = 'com.exactpro.th2'
Expand Down Expand Up @@ -165,23 +165,23 @@ signing {
}

dependencies {
api platform('com.exactpro.th2:bom:3.0.0')
implementation 'com.exactpro.th2:grpc-check1:3.5.1'
implementation 'com.exactpro.th2:common:3.31.3'
implementation 'com.exactpro.th2:sailfish-utils:3.12.3'
api platform('com.exactpro.th2:bom:3.2.0')
implementation 'com.exactpro.th2:grpc-check1:3.6.1-dev-2918727534-SNAPSHOT'
implementation 'com.exactpro.th2:common:3.41.0-dev-2918529806-SNAPSHOT'
implementation 'com.exactpro.th2:sailfish-utils:3.12.4'
implementation "org.slf4j:slf4j-log4j12"
implementation "org.slf4j:slf4j-api"

implementation "com.exactpro.sf:sailfish-core:${sailfishVersion}"

implementation "io.reactivex.rxjava2:rxjava:2.2.19" // https://github.com/salesforce/reactive-grpc/issues/202
implementation "io.reactivex.rxjava2:rxjava:2.2.21" // https://github.com/salesforce/reactive-grpc/issues/202

implementation('io.prometheus:simpleclient') {
because('metrics from messages and rules')
}
implementation 'org.jetbrains.kotlin:kotlin-reflect'

testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
release_version = 3.9.1
release_version = 3.10.0

description = 'th2 check1 box'

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2020-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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 com.exactpro.th2.check1.configuration

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonPropertyDescription
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.datatype.jsr310.deser.DurationDeserializer
import java.time.Duration
import java.time.temporal.ChronoUnit

class Check1Configuration(
@field:JsonProperty(value = "message-cache-size", defaultValue = "1000")
val messageCacheSize: Int = 1000,

@field:JsonProperty(value = "cleanup-older-than", defaultValue = "60")
val cleanupOlderThan: Long = 60L,

@field:JsonProperty(value = "max-event-batch-content-size", defaultValue = "1048576")
val maxEventBatchContentSize: Int = 1048576,

@field:JsonProperty(value = "cleanup-time-unit", defaultValue = "SECONDS")
val cleanupTimeUnit: ChronoUnit = ChronoUnit.SECONDS,

@field:JsonProperty(value = "rule-execution-timeout", defaultValue = "5000")
val ruleExecutionTimeout: Long = 5000L,

@field:JsonProperty("auto-silence-check-after-sequence-rule")
@field:JsonPropertyDescription("The default behavior in case the SequenceCheckRule does not have silenceCheck parameter specified")
val isAutoSilenceCheckAfterSequenceRule: Boolean = false,

@field:JsonProperty(value = "decimal-precision", defaultValue = "0.00001")
val decimalPrecision: Double = 0.00001,

@field:JsonProperty(value = "time-precision", defaultValue = "PT0.000000001S")
@field:JsonDeserialize(using = DurationDeserializer::class)
@field:JsonPropertyDescription("The default time precision value uses java duration format")
val timePrecision: Duration = Duration.parse("PT0.000000001S"),

@field:JsonProperty(value = "check-null-value-as-empty")
val isCheckNullValueAsEmpty: Boolean = false,

@field:JsonProperty(value = "default-check-simple-collections-order", defaultValue = "true")
val isDefaultCheckSimpleCollectionsOrder: Boolean = true
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand All @@ -21,7 +21,8 @@ data class RuleConfiguration(
val timePrecision: Duration,
val decimalPrecision: Double,
val maxEventBatchContentSize: Int,
val isCheckNullValueAsEmpty: Boolean
val isCheckNullValueAsEmpty: Boolean,
val defaultCheckSimpleCollectionsOrder: Boolean
) {
init {
require(!timePrecision.isNegative) { "Time precision cannot be negative" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2020-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand Down Expand Up @@ -548,6 +548,13 @@ abstract class AbstractCheckTask(
ComparatorSettings().also {
it.metaContainer = VerificationUtil.toMetaContainer(this.messageFilter, false)
it.ignoredFields = this.comparisonSettings.ignoreFieldsList.toSet()

it.isCheckSimpleCollectionsOrder = if (comparisonSettings.hasCheckSimpleCollectionsOrder()) {
comparisonSettings.checkSimpleCollectionsOrder.value
} else {
ruleConfiguration.defaultCheckSimpleCollectionsOrder
}

if (this.comparisonSettings.checkRepeatingGroupOrder) {
it.isCheckGroupsOrder = true
} else {
Expand Down
17 changes: 11 additions & 6 deletions src/main/kotlin/com/exactpro/th2/check1/rule/RuleFactory.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand Down Expand Up @@ -54,6 +54,7 @@ class RuleFactory(
private val timePrecision = configuration.timePrecision
private val decimalPrecision = configuration.decimalPrecision
private val isCheckNullValueAsEmpty = configuration.isCheckNullValueAsEmpty
private val defaultCheckSimpleCollectionsOrder = configuration.isDefaultCheckSimpleCollectionsOrder

fun createCheckRule(request: CheckRuleRequest, isChainIdExist: Boolean): CheckRuleTask =
ruleCreation(request.parentEventId) {
Expand All @@ -79,7 +80,8 @@ class RuleFactory(
timePrecision,
decimalPrecision,
maxEventBatchContentSize,
isCheckNullValueAsEmpty
isCheckNullValueAsEmpty,
defaultCheckSimpleCollectionsOrder
)

CheckRuleTask(
Expand All @@ -89,7 +91,7 @@ class RuleFactory(
filter,
request.parentEventId,
streamObservable,
eventBatchRouter
eventBatchRouter,
)
}
onErrorEvent {
Expand Down Expand Up @@ -123,7 +125,8 @@ class RuleFactory(
timePrecision,
decimalPrecision,
maxEventBatchContentSize,
isCheckNullValueAsEmpty
isCheckNullValueAsEmpty,
defaultCheckSimpleCollectionsOrder
)

SequenceCheckRuleTask(
Expand Down Expand Up @@ -161,7 +164,8 @@ class RuleFactory(
timePrecision,
decimalPrecision,
maxEventBatchContentSize,
isCheckNullValueAsEmpty
isCheckNullValueAsEmpty,
defaultCheckSimpleCollectionsOrder
)

NoMessageCheckTask(
Expand Down Expand Up @@ -197,7 +201,8 @@ class RuleFactory(
timePrecision,
decimalPrecision,
maxEventBatchContentSize,
isCheckNullValueAsEmpty
isCheckNullValueAsEmpty,
defaultCheckSimpleCollectionsOrder
)

SilenceCheckTask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RuleConfigurationTest {
TaskTimeout(0, 0), null, Duration.ofSeconds(-1),
0.005,
1,
true,
true
)
}
Expand All @@ -40,6 +41,7 @@ class RuleConfigurationTest {
TaskTimeout(0, 0), null, Duration.ofSeconds(1),
-0.005,
1,
true,
true
)
}
Expand All @@ -57,6 +59,7 @@ class RuleConfigurationTest {
Duration.ofSeconds(1),
0.005,
maxEventBatchContentSize,
true,
true
)
}
Expand All @@ -74,6 +77,7 @@ class RuleConfigurationTest {
Duration.ofSeconds(1),
0.005,
1,
true,
true
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2020-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand Down Expand Up @@ -163,6 +163,7 @@ abstract class AbstractCheckTaskTest {
configuration.timePrecision,
configuration.decimalPrecision,
maxEventBatchContentSize,
true,
true
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2021 Exactpro (Exactpro Systems Limited)
* Copyright 2021-2022 Exactpro (Exactpro Systems Limited)
* Licensed 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
Expand Down
Loading

0 comments on commit 0b8e211

Please sign in to comment.