mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Return RuleResponse for api/prometheus/grafana/api/v1/rules (#32919)
* Return RuleResponse for api/prometheus/grafana/api/v1/rules * change TODO to note Co-authored-by: gotjosh <josue@grafana.com> * pr feedback * test fixup Co-authored-by: gotjosh <josue@grafana.com>
This commit is contained in:
@@ -57,7 +57,7 @@ func (st *StateTracker) getOrCreate(uid string, orgId int64, result eval.Result)
|
||||
st.stateCache.mu.Lock()
|
||||
defer st.stateCache.mu.Unlock()
|
||||
|
||||
idString := fmt.Sprintf("%s %s", uid, result.Instance.String())
|
||||
idString := fmt.Sprintf("%s %s", uid, map[string]string(result.Instance))
|
||||
if state, ok := st.stateCache.cacheMap[idString]; ok {
|
||||
return state
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("error parsing date format: %s", err.Error())
|
||||
}
|
||||
cacheId := "test_uid map[label1:value1 label2:value2]"
|
||||
testCases := []struct {
|
||||
desc string
|
||||
uid string
|
||||
@@ -49,7 +50,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
{
|
||||
UID: "test_uid",
|
||||
OrgID: 123,
|
||||
CacheId: "test_uid label1=value1, label2=value2",
|
||||
CacheId: cacheId,
|
||||
Labels: data.Labels{"label1": "value1", "label2": "value2"},
|
||||
State: eval.Normal,
|
||||
Results: []StateEvaluation{
|
||||
@@ -87,7 +88,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
{
|
||||
UID: "test_uid",
|
||||
OrgID: 123,
|
||||
CacheId: "test_uid label1=value1, label2=value2",
|
||||
CacheId: cacheId,
|
||||
Labels: data.Labels{"label1": "value1", "label2": "value2"},
|
||||
State: eval.Alerting,
|
||||
Results: []StateEvaluation{
|
||||
@@ -126,7 +127,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
{
|
||||
UID: "test_uid",
|
||||
OrgID: 123,
|
||||
CacheId: "test_uid label1=value1, label2=value2",
|
||||
CacheId: cacheId,
|
||||
Labels: data.Labels{"label1": "value1", "label2": "value2"},
|
||||
State: eval.Normal,
|
||||
Results: []StateEvaluation{
|
||||
@@ -165,7 +166,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
{
|
||||
UID: "test_uid",
|
||||
OrgID: 123,
|
||||
CacheId: "test_uid label1=value1, label2=value2",
|
||||
CacheId: cacheId,
|
||||
Labels: data.Labels{"label1": "value1", "label2": "value2"},
|
||||
State: eval.Alerting,
|
||||
Results: []StateEvaluation{
|
||||
@@ -204,7 +205,7 @@ func TestProcessEvalResults(t *testing.T) {
|
||||
{
|
||||
UID: "test_uid",
|
||||
OrgID: 123,
|
||||
CacheId: "test_uid label1=value1, label2=value2",
|
||||
CacheId: cacheId,
|
||||
Labels: data.Labels{"label1": "value1", "label2": "value2"},
|
||||
State: eval.Normal,
|
||||
Results: []StateEvaluation{
|
||||
|
||||
Reference in New Issue
Block a user