[v9.3.x] Expressions: Fixes the issue showing expressions editor (#62627)

Expressions: Fixes the issue showing expressions editor (#62510)

* Use suggested value for uid

* update the snapshot

* use __expr__

* replace all -100 with __expr__

* update snapshot

* more changes

* revert redundant change

* Use expr.DatasourceUID where it's possible

* generate files

(cherry picked from commit 91221bc436)
This commit is contained in:
ismail simsek
2023-01-31 20:31:33 +01:00
committed by GitHub
parent 4d450ab910
commit ead3a002df
52 changed files with 235 additions and 224 deletions
+29 -28
View File
@@ -12,6 +12,7 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/expr"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -505,7 +506,7 @@ func TestIntegrationAlertAndGroupsQuery(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -646,7 +647,7 @@ func TestIntegrationRulerAccess(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -749,7 +750,7 @@ func TestIntegrationDeleteFolderWithRules(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"expression": "2 + 3 > 1",
"intervalMs": 1000,
@@ -904,7 +905,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -934,7 +935,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -964,7 +965,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -995,7 +996,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1055,7 +1056,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1114,7 +1115,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1134,7 +1135,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1205,7 +1206,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003e 1",
"intervalMs":1000,
@@ -1241,7 +1242,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003e 1",
"intervalMs":1000,
@@ -1299,7 +1300,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 < 1"
@@ -1372,7 +1373,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 < 1"
@@ -1406,7 +1407,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1480,7 +1481,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 < 1"
@@ -1548,7 +1549,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003C 1",
"intervalMs":1000,
@@ -1597,7 +1598,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 < 1"
@@ -1657,7 +1658,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003C 1",
"intervalMs":1000,
@@ -1742,7 +1743,7 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 3 \u003C 1",
"intervalMs":1000,
@@ -1954,7 +1955,7 @@ func TestIntegrationQuota(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 3 > 1"
@@ -1989,7 +1990,7 @@ func TestIntegrationQuota(t *testing.T) {
From: ngmodels.Duration(time.Duration(5) * time.Hour),
To: ngmodels.Duration(time.Duration(3) * time.Hour),
},
DatasourceUID: "-100",
DatasourceUID: expr.DatasourceUID,
Model: json.RawMessage(`{
"type": "math",
"expression": "2 + 4 > 1"
@@ -2048,7 +2049,7 @@ func TestIntegrationQuota(t *testing.T) {
"from":18000,
"to":10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model":{
"expression":"2 + 4 \u003E 1",
"intervalMs":1000,
@@ -2119,7 +2120,7 @@ func TestIntegrationEval(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid":"-100",
"datasourceUid":"__expr__",
"model": {
"type":"math",
"expression":"1 < 2"
@@ -2183,7 +2184,7 @@ func TestIntegrationEval(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"type":"math",
"expression":"1 > 2"
@@ -2247,7 +2248,7 @@ func TestIntegrationEval(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"type":"math",
"expression":"1 > 2"
@@ -2348,7 +2349,7 @@ func TestIntegrationEval(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"type":"math",
"expression":"1 < 2"
@@ -2405,7 +2406,7 @@ func TestIntegrationEval(t *testing.T) {
"from": 18000,
"to": 10800
},
"datasourceUid": "-100",
"datasourceUid": "__expr__",
"model": {
"type":"math",
"expression":"1 > 2"