summaryrefslogtreecommitdiffstats
path: root/tests/sql/sla_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:41 +0000
commit5d920465245906e2250c288c2b1ffea608a37539 (patch)
tree8d52f82e5d4a1717f136c7e5f6c389464c403e79 /tests/sql/sla_test.go
parentReleasing progress-linux version 1.1.1-2~progress7.99u1. (diff)
downloadicingadb-5d920465245906e2250c288c2b1ffea608a37539.tar.xz
icingadb-5d920465245906e2250c288c2b1ffea608a37539.zip
Merging upstream version 1.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/sql/sla_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/sql/sla_test.go b/tests/sql/sla_test.go
index 8a89850..de2bace 100644
--- a/tests/sql/sla_test.go
+++ b/tests/sql/sla_test.go
@@ -48,6 +48,42 @@ func TestSla(t *testing.T) {
End: 2000,
Expected: 60.0,
}, {
+ Name: "MultipleStateChangesDecimalsOddNumbers",
+ // Test flapping again, also that calculations are rounded correctly including decimal places.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -2.3%
+ &State{Time: 1023, State: 0, PreviousState: 2},
+ &State{Time: 1100, State: 2, PreviousState: 0}, // -14.2%
+ &State{Time: 1242, State: 0, PreviousState: 2},
+ &State{Time: 1300, State: 2, PreviousState: 0}, // -0.7%
+ &State{Time: 1307, State: 0, PreviousState: 2},
+ &State{Time: 1400, State: 2, PreviousState: 0}, // -26.6%
+ &State{Time: 1666, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 2000,
+ Expected: 56.2,
+ }, {
+ Name: "MultipleStateChangesDecimalsFractionOneThird",
+ // Test decimal representation of a fraction including precision and scale.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -33.3..%
+ &State{Time: 1100, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 1300,
+ Expected: 66.6667,
+ }, {
+ Name: "MultipleStateChangesDecimalsFractionSeventhPart",
+ // Test decimal representation of a fraction including precision and scale.
+ Events: []SlaHistoryEvent{
+ &State{Time: 1000, State: 2, PreviousState: 99}, // -85.7142..%
+ &State{Time: 1600, State: 0, PreviousState: 2},
+ },
+ Start: 1000,
+ End: 1700,
+ Expected: 14.2857,
+ }, {
Name: "OverlappingDowntimesAndProblems",
// SLA should be 90%:
// 1000..1100: OK, no downtime