def test_slow_start_warning(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller, v_s_route_setup, v_s_route_app_setup, options): ic_pod_name = get_first_pod_name(kube_apis.v1, ingress_controller_prerequisites.namespace) text_s = f"{v_s_route_setup.route_s.namespace}/{v_s_route_setup.route_s.name}" text_m = f"{v_s_route_setup.route_m.namespace}/{v_s_route_setup.route_m.name}" vsr_s_event_text = f"Configuration for {text_s} was added or updated with warning(s): " \ f"Slow start will be disabled" vsr_m_event_text = f"Configuration for {text_m} was added or updated with warning(s): " \ f"Slow start will be disabled" print(f"Case 2: no key in ConfigMap, option specified in VSR") new_body_m = generate_item_with_upstream_options( f"{TEST_DATA}/virtual-server-route-upstream-options/route-multiple.yaml", options) new_body_s = generate_item_with_upstream_options( f"{TEST_DATA}/virtual-server-route-upstream-options/route-single.yaml", options) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_m.name, v_s_route_setup.route_m.namespace, new_body_m) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_s.name, v_s_route_setup.route_s.namespace, new_body_s) wait_before_test(1) 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) vsr_s_events = get_events(kube_apis.v1, v_s_route_setup.route_s.namespace) vsr_m_events = get_events(kube_apis.v1, v_s_route_setup.route_m.namespace) assert_event(vsr_s_event_text, vsr_s_events) assert_event(vsr_m_event_text, vsr_m_events) assert "slow_start" not in config
def test_v_s_r_overrides_config_map(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller, v_s_route_setup, v_s_route_app_setup, options, expected_strings, unexpected_strings): req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}" text_s = f"{v_s_route_setup.route_s.namespace}/{v_s_route_setup.route_s.name}" text_m = f"{v_s_route_setup.route_m.namespace}/{v_s_route_setup.route_m.name}" vsr_s_event_text = f"Configuration for {text_s} was added or updated" vsr_m_event_text = f"Configuration for {text_m} was added or updated" events_ns_m = get_events(kube_apis.v1, v_s_route_setup.route_m.namespace) events_ns_s = get_events(kube_apis.v1, v_s_route_setup.route_s.namespace) initial_count_vsr_m = get_event_count(vsr_m_event_text, events_ns_m) initial_count_vsr_s = get_event_count(vsr_s_event_text, events_ns_s) print(f"Case 4: key specified in ConfigMap, option specified in VS") new_body_m = generate_item_with_upstream_options( f"{TEST_DATA}/virtual-server-route-upstream-options/route-multiple.yaml", options) new_body_s = generate_item_with_upstream_options( f"{TEST_DATA}/virtual-server-route-upstream-options/route-single.yaml", options) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_m.name, v_s_route_setup.route_m.namespace, new_body_m) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_s.name, v_s_route_setup.route_s.namespace, new_body_s) 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-route-upstream-options/configmap-with-keys.yaml" ) wait_before_test(1) ic_pod_name = get_first_pod_name( kube_apis.v1, ingress_controller_prerequisites.namespace) 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_s.paths[0]}", headers={"host": v_s_route_setup.vs_host}) vsr_s_events = get_events(kube_apis.v1, v_s_route_setup.route_s.namespace) vsr_m_events = get_events(kube_apis.v1, v_s_route_setup.route_m.namespace) assert_event_count_increased(vsr_m_event_text, initial_count_vsr_m, vsr_m_events) assert_event_count_increased(vsr_s_event_text, initial_count_vsr_s, vsr_s_events) for _ in expected_strings: assert _ in config for _ in unexpected_strings: assert _ not in config assert_response_codes(resp_1, resp_2)
def test_when_option_in_v_s_r_only(self, kube_apis, ingress_controller_prerequisites, crd_ingress_controller, v_s_route_setup, v_s_route_app_setup, option, option_value, expected_string): req_url = f"http://{v_s_route_setup.public_endpoint.public_ip}:{v_s_route_setup.public_endpoint.port}" text_s = f"{v_s_route_setup.route_s.namespace}/{v_s_route_setup.route_s.name}" text_m = f"{v_s_route_setup.route_m.namespace}/{v_s_route_setup.route_m.name}" vsr_s_event_text = f"Configuration for {text_s} was added or updated" vsr_m_event_text = f"Configuration for {text_m} was added or updated" events_ns_m = get_events(kube_apis.v1, v_s_route_setup.route_m.namespace) events_ns_s = get_events(kube_apis.v1, v_s_route_setup.route_s.namespace) initial_count_vsr_m = get_event_count(vsr_m_event_text, events_ns_m) initial_count_vsr_s = get_event_count(vsr_s_event_text, events_ns_s) print(f"Case 2: no {option} in ConfigMap, {option} specified in VSR") new_body_m = generate_item_with_upstream_option( f"{TEST_DATA}/virtual-server-route-upstream-options/route-multiple.yaml", option, option_value) new_body_s = generate_item_with_upstream_option( f"{TEST_DATA}/virtual-server-route-upstream-options/route-single.yaml", option, option_value) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_m.name, v_s_route_setup.route_m.namespace, new_body_m) patch_v_s_route(kube_apis.custom_objects, v_s_route_setup.route_s.name, v_s_route_setup.route_s.namespace, new_body_s) wait_before_test(1) ic_pod_name = get_first_pod_name( kube_apis.v1, ingress_controller_prerequisites.namespace) 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_s.paths[0]}", headers={"host": v_s_route_setup.vs_host}) vsr_s_events = get_events(kube_apis.v1, v_s_route_setup.route_s.namespace) vsr_m_events = get_events(kube_apis.v1, v_s_route_setup.route_m.namespace) assert_event_count_increased(vsr_m_event_text, initial_count_vsr_m, vsr_m_events) assert_event_count_increased(vsr_s_event_text, initial_count_vsr_s, vsr_s_events) assert expected_string in config assert_response_codes(resp_1, resp_2)