SSE: Add utility methods for HysteresisCommand (#79157)

* add GetCommandsFromPipeline
* refactor method GetCommandType to func GetExpressionCommandType
* add function to create fingerprint frames
* add function to determine whether raw query represents a hysteresis command and a function to patch it with loaded metrics
This commit is contained in:
Yuri Tseretyan
2023-12-11 22:40:31 +02:00
committed by GitHub
parent f69516bf47
commit bf8be46e6f
7 changed files with 284 additions and 6 deletions
+33
View File
@@ -186,3 +186,36 @@ func TestLoadedDimensionsFromFrame(t *testing.T) {
})
}
}
func TestFingerprintsToFrame(t *testing.T) {
testCases := []struct {
name string
input Fingerprints
expected Fingerprints
expectedError bool
}{
{
name: "when empty map",
input: Fingerprints{},
expected: Fingerprints{},
},
{
name: "when nil",
input: nil,
expected: Fingerprints{},
},
{
name: "when has values",
input: Fingerprints{1: {}, 2: {}, 3: {}, 4: {}, 5: {}},
expected: Fingerprints{1: {}, 2: {}, 3: {}, 4: {}, 5: {}},
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
frame := FingerprintsToFrame(testCase.input)
actual, err := FingerprintsFromFrame(frame)
require.NoError(t, err)
require.EqualValues(t, testCase.expected, actual)
})
}
}