Exemple #1
0
def test_get_boost_values():
    fake_region = "westeros-1"
    fake_pool = "default"
    base_path = load_boost.get_zk_cluster_boost_path(fake_region, fake_pool)

    fake_end_time = 12345.0
    fake_boost_factor = 1.5
    fake_expected_load = 80

    with patch_zk_client({
            base_path + "/end_time":
            str(fake_end_time).encode("utf-8"),
            base_path + "/factor":
            str(fake_boost_factor).encode("utf-8"),
            base_path + "/expected_load":
            str(fake_expected_load).encode("utf-8"),
    }) as mock_zk_client:

        assert load_boost.get_boost_values(
            zk_boost_path=
            f"/paasta_cluster_autoscaler/{fake_region}/{fake_pool}/boost",
            zk=mock_zk_client,
        ) == load_boost.BoostValues(
            end_time=fake_end_time,
            boost_factor=fake_boost_factor,
            expected_load=fake_expected_load,
        )
Exemple #2
0
def test_get_boost_values_when_no_values_exist():
    fake_region = "westeros-1"
    fake_pool = "default"
    with patch_zk_client() as mock_zk_client:

        assert load_boost.get_boost_values(
            zk_boost_path=
            f"/paasta_cluster_autoscaler/{fake_region}/{fake_pool}/boost",
            zk=mock_zk_client,
        ) == load_boost.BoostValues(end_time=0,
                                    boost_factor=1.0,
                                    expected_load=0)
Exemple #3
0
def test_get_boost_values():
    fake_region = 'westeros-1'
    fake_pool = 'default'
    base_path = load_boost.get_zk_cluster_boost_path(fake_region, fake_pool)

    fake_end_time = 12345.0
    fake_boost_factor = 1.5
    fake_expected_load = 80

    with patch_zk_client({
        base_path + '/end_time': str(fake_end_time).encode('utf-8'),
        base_path + '/factor': str(fake_boost_factor).encode('utf-8'),
        base_path + '/expected_load': str(fake_expected_load).encode('utf-8'),
    }) as mock_zk_client:

        assert load_boost.get_boost_values(
            zk_boost_path=f'/paasta_cluster_autoscaler/{fake_region}/{fake_pool}/boost',
            zk=mock_zk_client,
        ) == load_boost.BoostValues(
            end_time=fake_end_time,
            boost_factor=fake_boost_factor,
            expected_load=fake_expected_load,
        )