[v9.2.x] Alerting: Mark all tests that interact with the database as integration tests (#56603)

Previously, two tests were not explicitly marked as integration tests
and so were not run against all 3 supported databases in the CI
environment.

(cherry picked from commit 7312a2dab0)


Co-authored-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-10-11 20:43:51 +08:00
committed by GitHub
co-authored by Joe Blubaugh
parent 7d182b4890
commit 4468aac4ee
4 changed files with 11 additions and 12 deletions
+7 -7
View File
@@ -54,25 +54,25 @@ func AlertRuleGen(mutators ...AlertRuleMutator) func() *AlertRule {
if rand.Int63()%2 == 0 {
d := util.GenerateShortUID()
dashUID = &d
p := rand.Int63()
p := rand.Int63n(1 << 30)
panelID = &p
}
rule := &AlertRule{
ID: rand.Int63(),
OrgID: rand.Int63(),
ID: rand.Int63n(1 << 30),
OrgID: rand.Int63n(1 << 30),
Title: "TEST-ALERT-" + util.GenerateShortUID(),
Condition: "A",
Data: []AlertQuery{GenerateAlertQuery()},
Updated: time.Now().Add(-time.Duration(rand.Intn(100) + 1)),
IntervalSeconds: rand.Int63n(60) + 1,
Version: rand.Int63(),
Version: rand.Int63n(1 << 30),
UID: util.GenerateShortUID(),
NamespaceUID: util.GenerateShortUID(),
DashboardUID: dashUID,
PanelID: panelID,
RuleGroup: "TEST-GROUP-" + util.GenerateShortUID(),
RuleGroupIndex: rand.Int(),
RuleGroupIndex: rand.Intn(1 << 30),
NoDataState: randNoDataState(),
ExecErrState: randErrState(),
For: forInterval,
@@ -96,7 +96,7 @@ func WithUniqueID() AlertRuleMutator {
usedID := make(map[int64]struct{})
return func(rule *AlertRule) {
for {
id := rand.Int63()
id := rand.Int63n(1 << 30)
if _, ok := usedID[id]; !ok {
usedID[id] = struct{}{}
rule.ID = id
@@ -116,7 +116,7 @@ func WithUniqueGroupIndex() AlertRuleMutator {
usedIdx := make(map[int]struct{})
return func(rule *AlertRule) {
for {
idx := rand.Int()
idx := rand.Intn(1 << 30)
if _, ok := usedIdx[idx]; !ok {
usedIdx[idx] = struct{}{}
rule.RuleGroupIndex = idx
+1 -1
View File
@@ -20,7 +20,7 @@ import (
)
func Test_subscribeToFolderChanges(t *testing.T) {
orgID := rand.Int63()
orgID := rand.Int63n(30)
folder := &models2.Folder{
Id: 0,
Uid: util.GenerateShortUID(),
@@ -17,7 +17,7 @@ import (
"github.com/grafana/grafana/pkg/util"
)
func TestUpdateAlertRules(t *testing.T) {
func TestIntegrationUpdateAlertRules(t *testing.T) {
sqlStore := sqlstore.InitTestDB(t)
store := DBstore{
SQLStore: sqlStore,
@@ -26,7 +26,6 @@ func TestUpdateAlertRules(t *testing.T) {
},
}
createRule := func(t *testing.T) *models.AlertRule {
t.Helper()
rule := models.AlertRuleGen(withIntervalMatching(store.Cfg.BaseInterval))()
err := sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
_, err := sess.Table(models.AlertRule{}).InsertOne(rule)
@@ -94,7 +93,7 @@ func withIntervalMatching(baseInterval time.Duration) func(*models.AlertRule) {
}
}
func Test_getFilterByOrgsString(t *testing.T) {
func TestIntegration_getFilterByOrgsString(t *testing.T) {
testCases := []struct {
testName string
orgs map[int64]struct{}
@@ -14,7 +14,7 @@ import (
const testAlertingIntervalSeconds = 10
func TestProvisioningStore(t *testing.T) {
func TestIntegrationProvisioningStore(t *testing.T) {
store := createProvisioningStoreSut(tests.SetupTestEnv(t, testAlertingIntervalSeconds))
t.Run("Default provenance of a known type is None", func(t *testing.T) {