Beispiel #1
0
def test_cluster_allocatable_cpu_resource(node_allocatable_cpu, cluster_nodes,
                                          cluster):
    expected = section.AllocatableResource(context="cluster",
                                           value=node_allocatable_cpu *
                                           cluster_nodes)
    actual = cluster.allocatable_cpu_resource()
    assert actual == expected
Beispiel #2
0
def test_cluster_allocatable_memory_resource(node_allocatable_memory: float,
                                             cluster_nodes: int,
                                             cluster: agent.Cluster):
    expected = section.AllocatableResource(context="cluster",
                                           value=node_allocatable_memory *
                                           cluster_nodes)
    actual = cluster.allocatable_memory_resource()
    assert actual == expected
Beispiel #3
0
def test_cluster_allocatable_cpu_resource_cluster(
    api_node_roles_per_node: Sequence[Sequence[str]],
    cluster_nodes: int,
    excluded_node_roles: Sequence[str],
    expected_control_nodes: int,
):
    counted_nodes = (cluster_nodes - expected_control_nodes if "control-plane"
                     in excluded_node_roles else cluster_nodes)
    expected = section.AllocatableResource(context="cluster",
                                           value=6.0 * counted_nodes)
    cluster = api_to_agent_cluster(
        excluded_node_roles=excluded_node_roles,
        nodes=[
            APINodeFactory.build(
                resources={"allocatable": NodeResourcesFactory.build(cpu=6.0)},
                roles=roles,
            ) for roles in api_node_roles_per_node
        ],
    )
    actual = cluster.allocatable_cpu_resource()
    assert actual == expected
Beispiel #4
0
def test_node_allocatable_cpu_resource(node_allocatable_cpu: float,
                                       node: agent.Node):
    expected = section.AllocatableResource(context="node",
                                           value=node_allocatable_cpu)
    actual = node.allocatable_cpu_resource()
    assert actual == expected
Beispiel #5
0
def test_node_allocatable_memory_resource(node_allocatable_memory, node):
    expected = section.AllocatableResource(context="node",
                                           value=node_allocatable_memory)
    actual = node.allocatable_memory_resource()
    assert actual == expected
Beispiel #6
0
def test_cluster_allocatable_memory_resource(node_allocatable_memory, cluster_nodes, cluster):
    expected = section.AllocatableResource(value=node_allocatable_memory * cluster_nodes)
    actual = cluster.allocatable_memory_resource()
    assert actual == expected