Пример #1
0
def test_73_31pods_1node():
    k, p = prepare_test_29_many_pods_not_enough_capacity_for_service_without_yaml_loading(
        1, 65, 30, 0, 0, 1)
    assert_conditions = ["MarkServiceOutageEvent",\
                    "Mark_node_outage_event"]
    not_assert_conditions = []
    checks_assert_conditions_in_one_mode(k, p, assert_conditions,
                                         not_assert_conditions, DEBUG_MODE)
Пример #2
0
def test_40():
    k, k2, p, p2 = prepare_test_29_many_pods_not_enough_capacity_for_service(
        2, 25, 5, 5, 5, 5)
    assert_conditions = ["MarkServiceOutageEvent",\
                    "Mark_node_outage_event"]
    not_assert_conditions = []
    checks_assert_conditions_in_one_mode(k, p, assert_conditions,
                                         not_assert_conditions, DEBUG_MODE)
Пример #3
0
def test_55_31pods():
    k, p = prepare_test_29_many_pods_not_enough_capacity_for_service_without_yaml_loading(
        2, 40, 15, 0, 0, 1)
    assert_conditions = ["SchedulerQueueCleanHighCost",\
                    "Mark_node_outage_event"]
    not_assert_conditions = []
    checks_assert_conditions_in_one_mode(k, p, assert_conditions,
                                         not_assert_conditions,
                                         "functional test", DEBUG_MODE)
Пример #4
0
def test_34():
    k, k2, p, p2 = prepare_test_29_many_pods_not_enough_capacity_for_service(
        2, 40, 5, 5, 5, 5)
    assert_conditions = ["SchedulerQueueCleanHighCost",\
                    "Mark_node_outage_event"]
    not_assert_conditions = []
    checks_assert_conditions_in_one_mode(k, p, assert_conditions,
                                         not_assert_conditions,
                                         "functional test", DEBUG_MODE)
def test_1():
    k, k2, p, p2 = prepare_test_29_many_pods_not_enough_capacity_for_service(2,4,0,0,0,1)
    assert_conditions = ["MarkServiceOutageEvent",\
                        "Mark_node_outage_event",
                        "Start"]
    not_assert_conditions = []
    assert_brake = checks_assert_conditions_in_one_mode(k,p,assert_conditions,not_assert_conditions,"functional test", DEBUG_MODE)
Пример #6
0
def test_9_121pods():
    nodes_amount=7
    nodes_capacity=40
    pods_running_on_each_node_with_req_2_mem_2_cpu_s1 = 15
    pods_running_on_each_node_with_req_0_mem_0_cpu_s1 = 0
    pods_running_on_each_node_with_req_2_mem_2_cpu_no_serv = 2
    pods_running_on_node0_with_req_2_mem_2_cpu_s1 = 1

    k, p, test_case = prepare_many_pods_without_yaml(nodes_amount,\
                                        nodes_capacity,pods_running_on_each_node_with_req_2_mem_2_cpu_s1,\
                                        pods_running_on_each_node_with_req_0_mem_0_cpu_s1,\
                                        pods_running_on_each_node_with_req_2_mem_2_cpu_no_serv,\
                                        pods_running_on_node0_with_req_2_mem_2_cpu_s1)
    assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    not_assert_conditions = []

    for node_item in test_case.nodes:
        for service_item in test_case.services:
            print(" -------------->>>> test for " + str(node_item) + "  " + str(service_item) + "  <<<<-------------")
            node_item.isSearched = True
            service_item.isSearched = True
            assert_brake = checks_assert_conditions_in_one_mode(k,p,assert_conditions,not_assert_conditions,"functional test", DEBUG_MODE)
            print_objects(k.state_objects)
            node_item.isSearched = False
            service_item.isSearched = False
Пример #7
0
def test_4_3pods_NONO_Service_outage():
    k, p, test_case = prepare_many_pods_without_yaml(2,20,1,0,0,1)
    assert_conditions = ["StartPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull",\
                "SchedulerCleaned"]
    not_assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    assert_brake = checks_assert_conditions_in_one_mode(k,p,assert_conditions,not_assert_conditions,"functional test", DEBUG_MODE)
Пример #8
0
def test_1_3pods_Service_outage():
    k, p, test_case = prepare_many_pods_without_yaml(2, 4, 1, 0, 0, 1)
    assert_conditions = ["Remove_pod_from_the_cluster_IF_service_isnotnull_IF_is_last_for_service",\
                        "SchedulerCleaned"]
    not_assert_conditions = []
    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)
Пример #9
0
def test_75_75pods_5nodes():
    k, p = prepare_test_29_many_pods_not_enough_capacity_for_service_without_yaml_loading(
        5, 32, 14, 0, 0, 1)
    assert_conditions = ["MarkServiceOutageEvent",\
                "Mark_node_outage_event"]
    not_assert_conditions = []
    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)
Пример #10
0
def test_2_3pods_NO_Service_outage():
    k, p, test_case = prepare_many_pods_without_yaml(2, 6, 1, 0, 0, 1)
    assert_conditions = ["Remove_pod_from_the_cluster_IF_service_isnotnull_IF_is_last_for_service",\
                "SchedulerCleaned"]
    not_assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)
    print_objects(k.state_objects)
Пример #11
0
def test_7_11pods():
    nodes_amount=2
    nodes_capacity=17
    pods_running_on_2_nodes_with_req_2_mem_2_cpu_s1 = 5
    pods_running_on_2_nodes_with_req_0_mem_0_cpu_s1 = 0
    pods_running_on_2_nodes_with_req_2_mem_2_cpu_no_serv = 2
    pods_running_on_node0_with_req_2_mem_2_cpu_s1 = 1

    k, p, test_case = prepare_many_pods_without_yaml(nodes_amount,\
                                        nodes_capacity,pods_running_on_2_nodes_with_req_2_mem_2_cpu_s1,\
                                        pods_running_on_2_nodes_with_req_0_mem_0_cpu_s1,\
                                        pods_running_on_2_nodes_with_req_2_mem_2_cpu_no_serv,\
                                        pods_running_on_node0_with_req_2_mem_2_cpu_s1)
    assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    not_assert_conditions = []

    # ----  model test start ---- 
    # p.Initiate_node_outage_searched(test_case.nodes[0], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[0], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[1], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[2], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[3], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[4], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[5], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[6], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[14], test_case.globalVar)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[0], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[1], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[2], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[3], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[4], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNull_Daemonset_isNull(test_case.pods[5], test_case.nodes[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNull_Daemonset_isNull(test_case.pods[6], test_case.nodes[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[14], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.NodeOutageFinished(test_case.nodes[0], test_case.globalVar)
    # p.SelectNode(test_case.pods[0], test_case.nodes[1], test_case.globalVar)
    # p.SelectNode(test_case.pods[5], test_case.nodes[1], test_case.globalVar)
    # p.StartPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.nodes[1], test_case.pods[0], test_case.scheduler, test_case.services[0], test_case.globalVar)
    # p.StartPod_IF_Deployment_isNUll_Service_isNull_Daemonset_isNull(test_case.nodes[1], test_case.pods[5], test_case.scheduler, test_case.globalVar)


    # ---- model test end ----- 


    for node_item in test_case.nodes:
        for service_item in test_case.services:
            print(" -------------->>>> test for " + str(node_item) + "  " + str(service_item) + "  <<<<-------------")
            node_item.isSearched = True
            service_item.isSearched = True
            assert_brake = checks_assert_conditions_in_one_mode(k,p,assert_conditions,not_assert_conditions,"functional test", DEBUG_MODE)
            print_objects(k.state_objects)
            node_item.isSearched = False
            service_item.isSearched = False
def test_25pods_1node():
    k, p = prepare_test_29_many_pods_not_enough_capacity_for_service_without_yaml_loading(
        1, 17, 10, 0, 4, 1)
    assert_conditions = ["MarkServiceOutageEvent",\
                "Mark_node_outage_event"]
    not_assert_conditions = []
    globalVar_k1 = next(
        filter(lambda x: isinstance(x, GlobalVar), k.state_objects))

    class NewGoal_k1(DebuggingCheckNodeOutage):
        goal = lambda self: globalVar_k1.is_node_disrupted == True

    NewGoal_k1.__name__ = "test_12pods_1node"  #inspect.stack()[1].function
    p = NewGoal_k1(k.state_objects)
    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)
Пример #13
0
def test_6_11pods():
    nodes_amount = 2
    nodes_capacity = 14
    pods_running_on_2_nodes_with_req_2_mem_2_cpu_s1 = 5
    pods_running_on_2_nodes_with_req_0_mem_0_cpu_s1 = 0
    pods_running_on_2_nodes_with_req_2_mem_2_cpu_s2 = 0
    pods_running_on_node0_with_req_2_mem_2_cpu_s2 = 1

    k, p, test_case = prepare_many_pods_without_yaml(nodes_amount,\
                                        nodes_capacity,pods_running_on_2_nodes_with_req_2_mem_2_cpu_s1,\
                                        pods_running_on_2_nodes_with_req_0_mem_0_cpu_s1,\
                                        pods_running_on_2_nodes_with_req_2_mem_2_cpu_s2,\
                                        pods_running_on_node0_with_req_2_mem_2_cpu_s2)
    assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    not_assert_conditions = []

    # ----  model test start ----
    # p.Initiate_node_outage(test_case.nodes[0], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0],test_case.pods[0],test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0],test_case.pods[1],test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0],test_case.pods[2],test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0],test_case.pods[3],test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[4], test_case.globalVar)
    # p.Initiate_killing_of_Pod_because_of_node_outage(test_case.nodes[0], test_case.pods[10], test_case.globalVar)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[0], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[1], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[2], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[3], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[4], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.KillPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.pods[10], test_case.nodes[0], test_case.services[0], test_case.scheduler)
    # p.NodeOutageFinished(test_case.nodes[0], test_case.globalVar)
    # p.SelectNode(test_case.pods[0], test_case.nodes[1], test_case.globalVar)
    # p.SelectNode(test_case.pods[1], test_case.nodes[1], test_case.globalVar)
    # p.StartPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.nodes[1], test_case.pods[0], test_case.scheduler, test_case.services[0])
    # p.StartPod_IF_Deployment_isNUll_Service_isNotNull_Daemonset_isNull(test_case.nodes[1], test_case.pods[1], test_case.scheduler, test_case.services[0])

    # ---- model test end -----

    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)
Пример #14
0
def test_1_3pods_Service_outage():
    k, p, test_case = prepare_many_pods_without_yaml(2,4,1,0,0,1)
    assert_conditions = ["Service_outage_hypothesis",\
                        "Remove_pod_from_the_queue"]
    not_assert_conditions = []
    assert_brake = checks_assert_conditions_in_one_mode(k,p,assert_conditions,not_assert_conditions,"functional test", DEBUG_MODE)
Пример #15
0
def test_1():
    # Initialize scheduler, globalvar
    k = KubernetesCluster()
    scheduler = next(
        filter(lambda x: isinstance(x, Scheduler), k.state_objects))
    # initial node state
    i = 0
    j = 0
    nodes = []
    pods = []

    # Service to detecte eviction
    s1 = Service()
    s1.metadata_name = "test-service"
    s1.amountOfActivePods = 0
    s1.antiaffinity = True
    services = []
    services.append(s1)
    s2 = Service()
    s2.metadata_name = "test-service2"
    s2.amountOfActivePods = 0
    # create Deploymnent that we're going to detect failure of...
    d = Deployment()
    d.spec_replicas = 2
    node_item = Node()
    node_item.metadata_name = "node 1"
    node_item.cpuCapacity = 10
    node_item.memCapacity = 10
    node_item.isNull = False
    node_item.status = STATUS_NODE["Active"]
    nodes.append(node_item)

    pod = build_running_pod_with_d(1, 2, 2, node_item, None, None, s1, pods)
    pod = build_running_pod_with_d(2, 2, 2, node_item, None, None, s1, pods)
    pod = build_running_pod_with_d(3, 2, 2, node_item, None, None, None, pods)
    pod = build_running_pod_with_d(4, 2, 2, node_item, None, None, None, pods)

    node_item = Node()
    node_item.metadata_name = "node 2"
    node_item.cpuCapacity = 10
    node_item.memCapacity = 10
    node_item.isNull = False
    node_item.status = STATUS_NODE["Active"]
    nodes.append(node_item)

    pod = build_running_pod_with_d(5, 2, 2, node_item, None, None, s1, pods)
    pod = build_running_pod_with_d(7, 2, 2, node_item, None, None, s2, pods)
    pod = build_running_pod_with_d(8, 2, 2, node_item, None, None, s2, pods)

    node_item = Node()
    node_item.metadata_name = "node 3"
    node_item.cpuCapacity = 4
    node_item.memCapacity = 4
    node_item.isNull = False
    node_item.status = STATUS_NODE["Active"]
    nodes.append(node_item)

    pod = build_running_pod_with_d(9, 2, 2, node_item, None, None, None, pods)
    pod = build_running_pod_with_d(6, 2, 2, node_item, None, None, None, pods)

    node_item = Node()
    node_item.metadata_name = "node 4"
    node_item.cpuCapacity = 8
    node_item.memCapacity = 8
    node_item.isNull = False
    node_item.status = STATUS_NODE["New"]
    nodes.append(node_item)

    node_item = Node()
    node_item.metadata_name = "node 5"
    node_item.cpuCapacity = 8
    node_item.memCapacity = 8
    node_item.isNull = False
    node_item.status = STATUS_NODE["New"]
    nodes.append(node_item)
    for node in nodes:
        for pod in pods:
            if not pod.nodeSelectorSet: pod.nodeSelectorList.add(node)
        for node2 in nodes:
            if node != node2:
                node2.different_than.add(node)
    # priority for pod-to-evict
    pc = PriorityClass()
    pc.priority = 10
    pc.metadata_name = "high-prio-test"

    k.state_objects.extend(nodes)
    k.state_objects.extend(pods)
    k.state_objects.extend([pc, s1, s2])
    create_objects = []
    k._build_state()
    globalVar = next(
        filter(lambda x: isinstance(x, GlobalVar), k.state_objects))
    scheduler = next(
        filter(lambda x: isinstance(x, Scheduler), k.state_objects))

    class Antiaffinity_implement_k1(Antiaffinity_implement):
        def goal(self):
            assert services[0].antiaffinity_prefered_policy_met == True

    p = Antiaffinity_implement_k1(k.state_objects)
    Antiaffinity_implement_k1.__name__ = inspect.stack()[0].function
    assert_conditions = ["manually_initiate_killing_of_podt",\
                        "Not_at_same_node"]
    not_assert_conditions = []
    print_objects(k.state_objects)
    test_case = StateSet()
    test_case.scheduler = scheduler
    test_case.globalVar = globalVar
    test_case.pods = pods
    test_case.nodes = nodes
    services = [s1, s2]
    test_case.services = services
    assert_brake = checks_assert_conditions_in_one_mode(
        k, p, assert_conditions, not_assert_conditions, "functional test",
        DEBUG_MODE)