mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #59709 from ClickHouse/autoscale-tests
Add test for increase-always autoscaling lambda
This commit is contained in:
commit
6c09f000ec
@ -8,11 +8,10 @@ from pprint import pformat
|
||||
from typing import Any, List, Literal, Optional, Tuple
|
||||
|
||||
import boto3 # type: ignore
|
||||
|
||||
from lambda_shared import (
|
||||
RUNNER_TYPE_LABELS,
|
||||
CHException,
|
||||
ClickHouseHelper,
|
||||
RUNNER_TYPE_LABELS,
|
||||
get_parameter_from_ssm,
|
||||
)
|
||||
|
||||
@ -115,6 +114,8 @@ def set_capacity(
|
||||
# Are we already at the capacity limits
|
||||
stop = stop or asg["MaxSize"] <= asg["DesiredCapacity"]
|
||||
# Let's calculate a new desired capacity
|
||||
# (capacity_deficit + scale_up - 1) // scale_up : will increase min by 1
|
||||
# if there is any capacity_deficit
|
||||
desired_capacity = (
|
||||
asg["DesiredCapacity"] + (capacity_deficit + scale_up - 1) // scale_up
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import unittest
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, List
|
||||
|
||||
from app import set_capacity, Queue
|
||||
from app import Queue, set_capacity
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -68,10 +68,16 @@ class TestSetCapacity(unittest.TestCase):
|
||||
test_cases = (
|
||||
# Do not change capacity
|
||||
TestCase("noqueue", 1, 13, 20, [Queue("in_progress", 155, "noqueue")], -1),
|
||||
TestCase(
|
||||
"w/reserve-1", 1, 13, 20, [Queue("queued", 15, "w/reserve-1")], 14
|
||||
),
|
||||
TestCase("reserve", 1, 13, 20, [Queue("queued", 13, "reserve")], -1),
|
||||
# Increase capacity
|
||||
TestCase(
|
||||
"increase-always",
|
||||
1,
|
||||
13,
|
||||
20,
|
||||
[Queue("queued", 14, "increase-always")],
|
||||
14,
|
||||
),
|
||||
TestCase("increase-1", 1, 13, 20, [Queue("queued", 23, "increase-1")], 17),
|
||||
TestCase(
|
||||
"style-checker", 1, 13, 20, [Queue("queued", 33, "style-checker")], 20
|
||||
|
Loading…
Reference in New Issue
Block a user