Ejemplo n.º 1
0
def example_app_setup(request, kube_apis, v_s_route_setup) -> None:
    """
    Prepare an example app.

    1st namespace with backend1-svc and backend3-svc and deployment and 2nd namespace with backend2-svc and deployment.

    :param request: internal pytest fixture
    :param kube_apis: client apis
    :param v_s_route_setup:
    :return:
    """
    print(
        "---------------------- Deploy a VS Route Example Application ----------------------------"
    )
    svc_one = create_service_with_name(kube_apis.v1,
                                       v_s_route_setup.route_m.namespace,
                                       "backend1-svc")
    svc_three = create_service_with_name(kube_apis.v1,
                                         v_s_route_setup.route_m.namespace,
                                         "backend3-svc")
    deployment_one = create_deployment_with_name(
        kube_apis.extensions_v1_beta1, v_s_route_setup.route_m.namespace,
        "backend1")
    deployment_three = create_deployment_with_name(
        kube_apis.extensions_v1_beta1, v_s_route_setup.route_m.namespace,
        "backend3")

    svc_two = create_service_with_name(kube_apis.v1,
                                       v_s_route_setup.route_s.namespace,
                                       "backend2-svc")
    deployment_two = create_deployment_with_name(
        kube_apis.extensions_v1_beta1, v_s_route_setup.route_s.namespace,
        "backend2")

    wait_until_all_pods_are_ready(kube_apis.v1,
                                  v_s_route_setup.route_m.namespace)
    wait_until_all_pods_are_ready(kube_apis.v1,
                                  v_s_route_setup.route_s.namespace)

    # wait_before_test(2)

    def fin():
        print("Clean up the Application:")
        delete_deployment(kube_apis.extensions_v1_beta1, deployment_one,
                          v_s_route_setup.route_m.namespace)
        delete_service(kube_apis.v1, svc_one,
                       v_s_route_setup.route_m.namespace)
        delete_deployment(kube_apis.extensions_v1_beta1, deployment_three,
                          v_s_route_setup.route_m.namespace)
        delete_service(kube_apis.v1, svc_three,
                       v_s_route_setup.route_m.namespace)
        delete_deployment(kube_apis.extensions_v1_beta1, deployment_two,
                          v_s_route_setup.route_s.namespace)
        delete_service(kube_apis.v1, svc_two,
                       v_s_route_setup.route_s.namespace)

    request.addfinalizer(fin)
def vs_externalname_setup(request,
                          kube_apis,
                          ingress_controller_prerequisites,
                          virtual_server_setup) -> ExternalNameSetup:
    print("------------------------- Deploy External-Backend -----------------------------------")
    external_ns = create_namespace_with_name_from_yaml(kube_apis.v1, "external-ns", f"{TEST_DATA}/common/ns.yaml")
    external_svc_name = create_service_with_name(kube_apis.v1, external_ns, "external-backend-svc")
    create_deployment_with_name(kube_apis.apps_v1_api, external_ns, "external-backend")
    print("------------------------- Prepare ExternalName Setup -----------------------------------")
    external_svc_src = f"{TEST_DATA}/virtual-server-externalname/externalname-svc.yaml"
    external_svc_host = f"{external_svc_name}.{external_ns}.svc.cluster.local"
    config_map_name = ingress_controller_prerequisites.config_map["metadata"]["name"]
    replace_configmap_from_yaml(kube_apis.v1, config_map_name,
                                ingress_controller_prerequisites.namespace,
                                f"{TEST_DATA}/virtual-server-externalname/nginx-config.yaml")
    external_svc = create_service_from_yaml(kube_apis.v1, virtual_server_setup.namespace, external_svc_src)
    wait_before_test(2)
    ensure_connection_to_public_endpoint(virtual_server_setup.public_endpoint.public_ip,
                                         virtual_server_setup.public_endpoint.port,
                                         virtual_server_setup.public_endpoint.port_ssl)
    ic_pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace)
    ensure_response_from_backend(virtual_server_setup.backend_1_url, virtual_server_setup.vs_host)

    def fin():
        print("Clean up ExternalName Setup:")
        delete_namespace(kube_apis.v1, external_ns)
        replace_configmap(kube_apis.v1, config_map_name,
                          ingress_controller_prerequisites.namespace,
                          ingress_controller_prerequisites.config_map)

    request.addfinalizer(fin)

    return ExternalNameSetup(ic_pod_name, external_svc, external_svc_host)
Ejemplo n.º 3
0
def vsr_externalname_setup(request, kube_apis,
                           ingress_controller_prerequisites,
                           ingress_controller_endpoint) -> ReducedVirtualServerRouteSetup:
    """
    Prepare an example app for Virtual Server Route.

    1st namespace with externalName svc and VS+VSR.

    :param request: internal pytest fixture
    :param kube_apis: client apis
    :param ingress_controller_endpoint:
    :param ingress_controller_prerequisites:
    :return:
    """
    vs_routes_ns = get_route_namespace_from_vs_yaml(
        f"{TEST_DATA}/{request.param['example']}/standard/virtual-server.yaml")
    ns_1 = create_namespace_with_name_from_yaml(kube_apis.v1,
                                                vs_routes_ns[0],
                                                f"{TEST_DATA}/common/ns.yaml")
    print("------------------------- Deploy External-Backend -----------------------------------")
    external_ns = create_namespace_with_name_from_yaml(kube_apis.v1, "external-ns", f"{TEST_DATA}/common/ns.yaml")
    external_svc_name = create_service_with_name(kube_apis.v1, external_ns, "external-backend-svc")
    create_deployment_with_name(kube_apis.apps_v1_api, external_ns, "external-backend")

    print("------------------------- Deploy Virtual Server -----------------------------------")
    vs_name = create_virtual_server_from_yaml(kube_apis.custom_objects,
                                              f"{TEST_DATA}/{request.param['example']}/standard/virtual-server.yaml",
                                              ns_1)
    vs_host = get_first_vs_host_from_yaml(f"{TEST_DATA}/{request.param['example']}/standard/virtual-server.yaml")

    print("------------------------- Deploy Virtual Server Route -----------------------------------")
    vsr_name = create_v_s_route_from_yaml(kube_apis.custom_objects,
                                          f"{TEST_DATA}/{request.param['example']}/route-single.yaml",
                                          ns_1)
    vsr_paths = get_paths_from_vsr_yaml(f"{TEST_DATA}/{request.param['example']}/route-single.yaml")
    route = VirtualServerRoute(ns_1, vsr_name, vsr_paths)

    print("---------------------- Deploy ExternalName service and update ConfigMap ----------------------------")
    config_map_name = ingress_controller_prerequisites.config_map["metadata"]["name"]
    replace_configmap_from_yaml(kube_apis.v1, config_map_name,
                                ingress_controller_prerequisites.namespace,
                                f"{TEST_DATA}/{request.param['example']}/nginx-config.yaml")
    external_svc_host = f"{external_svc_name}.{external_ns}.svc.cluster.local"
    svc_name = create_service_from_yaml(kube_apis.v1,
                                        ns_1, f"{TEST_DATA}/{request.param['example']}/externalname-svc.yaml")
    wait_before_test(2)
    req_url = f"http://{ingress_controller_endpoint.public_ip}:{ingress_controller_endpoint.port}"
    ensure_response_from_backend(f"{req_url}{route.paths[0]}", vs_host)

    def fin():
        print("Delete test namespaces")
        delete_namespace(kube_apis.v1, external_ns)
        delete_namespace(kube_apis.v1, ns_1)

    request.addfinalizer(fin)

    return ReducedVirtualServerRouteSetup(ingress_controller_endpoint,
                                          ns_1, vs_host, vs_name, route, svc_name, external_svc_host)
def external_name_setup(request, kube_apis, ingress_controller_prerequisites,
                        ingress_controller_endpoint, ingress_controller,
                        test_namespace) -> ExternalNameSetup:
    print(
        "------------------------- Deploy External-Backend -----------------------------------"
    )
    external_ns = create_namespace_with_name_from_yaml(
        kube_apis.v1, "external-ns", f"{TEST_DATA}/common/ns.yaml")
    external_svc_name = create_service_with_name(kube_apis.v1, external_ns,
                                                 "external-backend-svc")
    create_deployment_with_name(kube_apis.apps_v1_api, external_ns,
                                "external-backend")
    print(
        "------------------------- Deploy External-Name-Example -----------------------------------"
    )
    ingress_name = create_ingress_from_yaml(
        kube_apis.extensions_v1_beta1, test_namespace,
        f"{TEST_DATA}/externalname-services/externalname-ingress.yaml")
    ingress_host = get_first_ingress_host_from_yaml(
        f"{TEST_DATA}/externalname-services/externalname-ingress.yaml")
    external_host = f"{external_svc_name}.{external_ns}.svc.cluster.local"
    config_map_name = ingress_controller_prerequisites.config_map["metadata"][
        "name"]
    replace_configmap_from_yaml(
        kube_apis.v1, config_map_name,
        ingress_controller_prerequisites.namespace,
        f"{TEST_DATA}/externalname-services/nginx-config.yaml")
    svc_name = create_service_from_yaml(
        kube_apis.v1, test_namespace,
        f"{TEST_DATA}/externalname-services/externalname-svc.yaml")
    ensure_connection_to_public_endpoint(ingress_controller_endpoint.public_ip,
                                         ingress_controller_endpoint.port,
                                         ingress_controller_endpoint.port_ssl)
    ic_pod_name = get_first_pod_name(
        kube_apis.v1, ingress_controller_prerequisites.namespace)

    def fin():
        print("Clean up External-Name-Example:")
        delete_namespace(kube_apis.v1, external_ns)
        replace_configmap(kube_apis.v1, config_map_name,
                          ingress_controller_prerequisites.namespace,
                          ingress_controller_prerequisites.config_map)
        delete_ingress(kube_apis.extensions_v1_beta1, ingress_name,
                       test_namespace)
        delete_service(kube_apis.v1, svc_name, test_namespace)

    request.addfinalizer(fin)

    return ExternalNameSetup(ingress_controller_endpoint, ingress_name,
                             ingress_host, ic_pod_name, svc_name,
                             external_host, test_namespace)
Ejemplo n.º 5
0
    def test_responses_and_events_in_flow(self, kube_apis,
                                          ingress_controller_prerequisites,
                                          crd_ingress_controller,
                                          v_s_route_setup,
                                          v_s_route_app_setup):
        req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}"
        ic_pod_name = get_first_pod_name(
            kube_apis.v1, ingress_controller_prerequisites.namespace)
        vs_name = f"{v_s_route_setup.namespace}/{v_s_route_setup.vs_name}"
        vsr_1_name = f"{v_s_route_setup.namespace}/{v_s_route_setup.route_m.name}"
        vsr_2_name = f"{v_s_route_setup.route_s.namespace}/{v_s_route_setup.route_s.name}"
        vsr_1_event_text = f"Configuration for {vsr_1_name} was added or updated"
        vs_event_text = f"Configuration for {vs_name} was added or updated"
        vsr_2_event_text = f"Configuration for {vsr_2_name} was added or updated"
        initial_config = get_vs_nginx_template_conf(
            kube_apis.v1, v_s_route_setup.namespace, v_s_route_setup.vs_name,
            ic_pod_name, ingress_controller_prerequisites.namespace)

        print("\nStep 1: initial check")
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        assert_locations_in_config(initial_config,
                                   v_s_route_setup.route_m.paths)
        assert_locations_in_config(initial_config,
                                   v_s_route_setup.route_s.paths)
        initial_count_vsr_1 = assert_event_and_get_count(
            vsr_1_event_text, events_ns_1)
        initial_count_vs = assert_event_and_get_count(vs_event_text,
                                                      events_ns_1)
        initial_count_vsr_2 = assert_event_and_get_count(
            vsr_2_event_text, events_ns_2)

        print("\nStep 2: update multiple VSRoute and check")
        patch_v_s_route_from_yaml(
            kube_apis.custom_objects, v_s_route_setup.route_m.name,
            f"{TEST_DATA}/virtual-server-route/route-multiple-updated.yaml",
            v_s_route_setup.route_m.namespace)
        new_vsr_paths = get_paths_from_vsr_yaml(
            f"{TEST_DATA}/virtual-server-route/route-multiple-updated.yaml")
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{new_vsr_paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{new_vsr_paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, initial_count_vsr_1 + 1,
                               events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 1,
                               events_ns_1)
        # 2nd VSRoute gets an event about update too
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 1,
                               events_ns_2)

        print("\nStep 3: restore VSRoute and check")
        patch_v_s_route_from_yaml(
            kube_apis.custom_objects, v_s_route_setup.route_m.name,
            f"{TEST_DATA}/virtual-server-route/route-multiple.yaml",
            v_s_route_setup.route_m.namespace)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, initial_count_vsr_1 + 2,
                               events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 2,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 2,
                               events_ns_2)

        print("\nStep 4: update one backend service port and check")
        svc_1 = read_service(kube_apis.v1, "backend1-svc",
                             v_s_route_setup.route_m.namespace)
        svc_1.spec.ports[0].port = 8080
        replace_service(kube_apis.v1, "backend1-svc",
                        v_s_route_setup.route_m.namespace, svc_1)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert resp_1.status_code == 502
        assert resp_2.status_code == 200
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, initial_count_vsr_1 + 3,
                               events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 3,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 3,
                               events_ns_2)

        print("\nStep 5: restore backend service and check")
        svc_1 = read_service(kube_apis.v1, "backend1-svc",
                             v_s_route_setup.route_m.namespace)
        svc_1.spec.ports[0].port = 80
        replace_service(kube_apis.v1, "backend1-svc",
                        v_s_route_setup.route_m.namespace, svc_1)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert resp_1.status_code == 200
        assert resp_2.status_code == 200
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, initial_count_vsr_1 + 4,
                               events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 4,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 4,
                               events_ns_2)

        print("\nStep 6: remove VSRoute and check")
        delete_v_s_route(kube_apis.custom_objects,
                         v_s_route_setup.route_m.name,
                         v_s_route_setup.namespace)
        wait_before_test(1)
        new_config = get_vs_nginx_template_conf(
            kube_apis.v1, v_s_route_setup.namespace, v_s_route_setup.vs_name,
            ic_pod_name, ingress_controller_prerequisites.namespace)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert resp_1.status_code == 404
        assert resp_2.status_code == 404
        assert resp_3.status_code == 200
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_locations_not_in_config(new_config,
                                       v_s_route_setup.route_m.paths)
        assert_event_and_count(vsr_1_event_text, initial_count_vsr_1 + 4,
                               events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 5,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 5,
                               events_ns_2)

        print("\nStep 7: restore VSRoute and check")
        create_v_s_route_from_yaml(
            kube_apis.custom_objects,
            f"{TEST_DATA}/virtual-server-route/route-multiple.yaml",
            v_s_route_setup.namespace)
        wait_before_test(1)
        new_config = get_vs_nginx_template_conf(
            kube_apis.v1, v_s_route_setup.namespace, v_s_route_setup.vs_name,
            ic_pod_name, ingress_controller_prerequisites.namespace)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_locations_in_config(new_config, v_s_route_setup.route_m.paths)
        assert_event_and_count(vsr_1_event_text, 1, events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 6,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 6,
                               events_ns_2)

        print("\nStep 8: remove one backend service and check")
        delete_service(kube_apis.v1, "backend1-svc",
                       v_s_route_setup.route_m.namespace)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert resp_1.status_code == 502
        assert resp_2.status_code == 200
        assert resp_3.status_code == 200
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, 2, events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 7,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 7,
                               events_ns_2)

        print("\nStep 9: restore backend service and check")
        create_service_with_name(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace,
                                 "backend1-svc")
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        events_ns_1 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_m.namespace)
        events_ns_2 = get_events(kube_apis.v1,
                                 v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, 3, events_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 8,
                               events_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 8,
                               events_ns_2)

        print("\nStep 10: remove VS and check")
        delete_virtual_server(kube_apis.custom_objects,
                              v_s_route_setup.vs_name,
                              v_s_route_setup.namespace)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert resp_1.status_code == 404
        assert resp_2.status_code == 404
        assert resp_3.status_code == 404
        list0_list_ns_1 = get_events(kube_apis.v1,
                                     v_s_route_setup.route_m.namespace)
        list0_list_ns_2 = get_events(kube_apis.v1,
                                     v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, 3, list0_list_ns_1)
        assert_event_and_count(vs_event_text, initial_count_vs + 8,
                               list0_list_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 8,
                               list0_list_ns_2)

        print("\nStep 11: restore VS and check")
        create_virtual_server_from_yaml(
            kube_apis.custom_objects,
            f"{TEST_DATA}/virtual-server-route/standard/virtual-server.yaml",
            v_s_route_setup.namespace)
        wait_before_test(1)
        resp_1 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_2 = requests.get(f"{req_url}{v_s_route_setup.route_m.paths[1]}",
                              headers={"host": v_s_route_setup.vs_host})
        resp_3 = requests.get(f"{req_url}{v_s_route_setup.route_s.paths[0]}",
                              headers={"host": v_s_route_setup.vs_host})
        assert_responses_and_server_name(resp_1, resp_2, resp_3)
        list1_list_ns_1 = get_events(kube_apis.v1,
                                     v_s_route_setup.route_m.namespace)
        list1_list_ns_2 = get_events(kube_apis.v1,
                                     v_s_route_setup.route_s.namespace)
        assert_event_and_count(vsr_1_event_text, 4, list1_list_ns_1)
        assert_event_and_count(vs_event_text, 1, list1_list_ns_1)
        assert_event_and_count(vsr_2_event_text, initial_count_vsr_2 + 9,
                               list1_list_ns_2)