Skip to content

Commit

Permalink
Remove unnecessary files and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
haywoodsh committed Oct 13, 2022
1 parent 4af8235 commit 66899e0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 140 deletions.
8 changes: 0 additions & 8 deletions tests/data/disable-ipv6-ingress/disable-ipv6-secret.yaml

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions tests/data/disable-ipv6-ingress/standard/disable-ipv6-ingress.yaml

This file was deleted.

14 changes: 8 additions & 6 deletions tests/suite/resources_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def scale_deployment(v1: CoreV1Api, apps_v1_api: AppsV1Api, name, namespace, val
now = time.time()
wait_until_all_pods_are_ready(v1, namespace)
later = time.time()
print(f"All pods came up in {int(later-now)} seconds")
print(f"All pods came up in {int(later - now)} seconds")

elif value == 0:
replica_num = (apps_v1_api.read_namespaced_deployment_scale(name, namespace)).spec.replicas
Expand Down Expand Up @@ -933,14 +933,16 @@ def clear_file_contents(v1: CoreV1Api, file_path, pod_name, pod_namespace):
)


def get_nginx_template_conf(v1: CoreV1Api, ingress_namespace) -> str:
def get_nginx_template_conf(v1: CoreV1Api, ingress_namespace: str, ic_pod_name: str = None) -> str:
"""
Get contents of /etc/nginx/nginx.conf in the pod
:param v1: CoreV1Api
:param ingress_namespace:
:param ingress_namespace: str
:param ic_pod_name: str
:return: str
"""
ic_pod_name = get_first_pod_name(v1, ingress_namespace)
if ic_pod_name is None:
ic_pod_name = get_first_pod_name(v1, ingress_namespace)
file_path = "/etc/nginx/nginx.conf"
return get_file_contents(v1, file_path, ic_pod_name, ingress_namespace)

Expand Down Expand Up @@ -1117,7 +1119,7 @@ def create_ingress_controller(v1: CoreV1Api, apps_v1_api: AppsV1Api, cli_argumen
before = time.time()
wait_until_all_pods_are_ready(v1, namespace)
after = time.time()
print(f"All pods came up in {int(after-before)} seconds")
print(f"All pods came up in {int(after - before)} seconds")
print(f"Ingress Controller was created with name '{name}'")
return name

Expand Down Expand Up @@ -1160,7 +1162,7 @@ def create_dos_arbitrator(
before = time.time()
wait_until_all_pods_are_ready(v1, namespace)
after = time.time()
print(f"All pods came up in {int(after-before)} seconds")
print(f"All pods came up in {int(after - before)} seconds")
print(f"Dos arbitrator was created with name '{name}'")

print("create dos svc")
Expand Down
72 changes: 29 additions & 43 deletions tests/suite/test_disable_ipv6_ingress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from settings import TEST_DATA
from suite.fixtures import PublicEndpoint
from suite.resources_utils import (
create_example_app,
create_items_from_yaml,
Expand All @@ -15,52 +15,38 @@
wait_before_test,
wait_until_all_pods_are_ready,
)
from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml

paths = ["backend1", "backend2"]
from suite.yaml_utils import get_name_from_yaml


class DisableIPV6Setup:
class IngressSetup:
"""
Encapsulate the Disable IPV6 Example details.
Attributes:
public_endpoint (PublicEndpoint):
ingress_name (str):
ingress_host (str):
ingress_pod_name (str):
namespace (str):
"""

def __init__(self, public_endpoint: PublicEndpoint, ingress_name, ingress_host, ingress_pod_name, namespace):
self.public_endpoint = public_endpoint
self.ingress_host = ingress_host
def __init__(self, ingress_name, ingress_pod_name, namespace):
self.ingress_name = ingress_name
self.ingress_pod_name = ingress_pod_name
self.namespace = namespace


@pytest.fixture(scope="class", params=["standard", "mergeable"])
def disable_ipv6_setup(
request,
kube_apis,
ingress_controller_prerequisites,
ingress_controller_endpoint,
ingress_controller,
test_namespace,
) -> DisableIPV6Setup:
@pytest.fixture(scope="class")
def ingress_setup(
request,
kube_apis,
ingress_controller_prerequisites,
ingress_controller_endpoint,
ingress_controller,
test_namespace,
) -> IngressSetup:
print("------------------------- Deploy Disable IPV6 Example -----------------------------------")
secret_name = create_secret_from_yaml(
kube_apis.v1, test_namespace, f"{TEST_DATA}/disable-ipv6-ingress/disable-ipv6-secret.yaml"
)

create_items_from_yaml(
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace
)
ingress_name = get_name_from_yaml(f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml")
ingress_host = get_first_ingress_host_from_yaml(
f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml"
)
secret_name = create_secret_from_yaml(kube_apis.v1, test_namespace, f"{TEST_DATA}/smoke/smoke-secret.yaml")
create_items_from_yaml(kube_apis, f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml", test_namespace)
ingress_name = get_name_from_yaml(f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml")
create_example_app(kube_apis, "simple", test_namespace)
wait_until_all_pods_are_ready(kube_apis.v1, test_namespace)

Expand All @@ -74,38 +60,38 @@ def disable_ipv6_setup(
def fin():
print("Clean up the Disable IPV6 Application:")
delete_common_app(kube_apis, "simple", test_namespace)
delete_items_from_yaml(
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace
)
delete_items_from_yaml(kube_apis, f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml", test_namespace)
delete_secret(kube_apis.v1, secret_name, test_namespace)

request.addfinalizer(fin)

return DisableIPV6Setup(ingress_controller_endpoint, ingress_name, ingress_host, ic_pod_name, test_namespace)
return IngressSetup(ingress_name, ic_pod_name, test_namespace)


@pytest.mark.ingresses
class TestDisableIPV6:
@pytest.mark.parametrize(
"ingress_controller",
[
pytest.param({"extra_args": ["-disable-ipv6"]}, id="one-additional-cli-args"),
pytest.param({"extra_args": ["-disable-ipv6"]}),
],
indirect=True,
)
def test_ipv6_listeners_not_in_config(
self,
kube_apis,
disable_ipv6_setup: DisableIPV6Setup,
ingress_controller_prerequisites,
self,
kube_apis,
ingress_setup: IngressSetup,
ingress_controller_prerequisites,
):
wait_before_test()
nginx_config = get_nginx_template_conf(kube_apis.v1, ingress_controller_prerequisites.namespace)
nginx_config = get_nginx_template_conf(
kube_apis.v1, ingress_controller_prerequisites.namespace, ingress_setup.ingress_pod_name
)
upstream_conf = get_ingress_nginx_template_conf(
kube_apis.v1,
disable_ipv6_setup.namespace,
disable_ipv6_setup.ingress_name,
disable_ipv6_setup.ingress_pod_name,
ingress_setup.namespace,
ingress_setup.ingress_name,
ingress_setup.ingress_pod_name,
ingress_controller_prerequisites.namespace,
)
assert "listen [::]:" not in nginx_config
Expand Down

0 comments on commit 66899e0

Please sign in to comment.