(t *testing.T)
| 1465 | } |
| 1466 | |
| 1467 | func TestRulerHAEvaluation(t *testing.T) { |
| 1468 | const numRulesGroups = 20 |
| 1469 | |
| 1470 | random := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 1471 | s, err := e2e.NewScenario(networkName) |
| 1472 | require.NoError(t, err) |
| 1473 | defer s.Close() |
| 1474 | |
| 1475 | // Generate multiple rule groups, with 1 rule each. |
| 1476 | ruleGroups := make([]rulefmt.RuleGroup, numRulesGroups) |
| 1477 | expectedNames := make([]string, numRulesGroups) |
| 1478 | evalInterval, _ := model.ParseDuration("2s") |
| 1479 | for i := 0; i < numRulesGroups; i++ { |
| 1480 | num := random.Intn(10) |
| 1481 | ruleName := fmt.Sprintf("test_%d", i) |
| 1482 | |
| 1483 | expectedNames[i] = ruleName |
| 1484 | |
| 1485 | if num%2 == 0 { |
| 1486 | ruleGroups[i] = rulefmt.RuleGroup{ |
| 1487 | Name: ruleName, |
| 1488 | Interval: evalInterval, |
| 1489 | Rules: []rulefmt.Rule{{ |
| 1490 | Alert: fmt.Sprintf("rule_%d", i), |
| 1491 | Expr: strconv.Itoa(i), |
| 1492 | }}, |
| 1493 | } |
| 1494 | } else { |
| 1495 | ruleGroups[i] = rulefmt.RuleGroup{ |
| 1496 | Name: ruleName, |
| 1497 | Interval: evalInterval, |
| 1498 | Rules: []rulefmt.Rule{{ |
| 1499 | Record: fmt.Sprintf("rule_%d", i), |
| 1500 | Expr: strconv.Itoa(i), |
| 1501 | }}, |
| 1502 | } |
| 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | // Start dependencies. |
| 1507 | consul := e2edb.NewConsul() |
| 1508 | minio := e2edb.NewMinio(9000, rulestoreBucketName) |
| 1509 | require.NoError(t, s.StartAndWaitReady(consul, minio)) |
| 1510 | |
| 1511 | // Configure the ruler. |
| 1512 | overrides := map[string]string{ |
| 1513 | // Since we're not going to run any rule, we don't need the |
| 1514 | // store-gateway to be configured to a valid address. |
| 1515 | "-querier.store-gateway-addresses": "localhost:12345", |
| 1516 | // Enable the bucket index so we can skip the initial bucket scan. |
| 1517 | "-blocks-storage.bucket-store.bucket-index.enabled": "true", |
| 1518 | "-ruler.ring.replication-factor": "2", |
| 1519 | "-ruler.enable-ha-evaluation": "true", |
| 1520 | "-ruler.poll-interval": "5s", |
| 1521 | "-ruler.client.remote-timeout": "10ms", |
| 1522 | } |
| 1523 | |
| 1524 | rulerFlags := mergeFlags( |
nothing calls this directly
no test coverage detected