8000 Remove unnecessary files and variables · nginx/kubernetes-ingress@66899e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 66899e0

Browse files
committed
Remove unnecessary files and variables
1 parent 4af8235 commit 66899e0

File tree

5 files changed

+37
-140
lines changed

5 files changed

+37
-140
lines changed

tests/data/disable-ipv6-ingress/disable-ipv6-secret.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/data/disable-ipv6-ingress/mergeable/disable-ipv6-ingress.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

tests/data/disable-ipv6-ingress/standard/disable-ipv6-ingress.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/suite/resources_utils.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def scale_deployment(v1: CoreV1Api, apps_v1_api: AppsV1Api, name, namespace, val
239239
now = time.time()
240240
wait_until_all_pods_are_ready(v1, namespace)
241241
later = time.time()
242-
print(f"All pods came up in {int(later-now)} seconds")
242+
print(f"All pods came up in {int(later - now)} seconds")
243243

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

935935

936-
def get_nginx_template_conf(v1: CoreV1Api, ingress_namespace) -> str:
936+
def get_nginx_template_conf(v1: CoreV1Api, ingress_namespace: str, ic_pod_name: str = None) -> str:
937937
"""
938938
Get contents of /etc/nginx/nginx.conf in the pod
939939
:param v1: CoreV1Api
940-
:param ingress_namespace:
940+
:param ingress_namespace: str
941+
:param ic_pod_name: str
941942
:return: str
942943
"""
943-
ic_pod_name = get_first_pod_name(v1, ingress_namespace)
944+
if ic_pod_name is None:
945+
ic_pod_name = get_first_pod_name(v1, ingress_namespace)
944946
file_path = "/etc/nginx/nginx.conf"
945947
return get_file_contents(v1, file_path, ic_pod_name, ingress_namespace)
946948

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

@@ -1160,7 +1162,7 @@ def create_dos_arbitrator(
11601162
before = time.time()
11611163
wait_until_all_pods_are_ready(v1, namespace)
11621164
after = time.time()
1163-
print(f"All pods came up in {int(after-before)} seconds")
1165+
print(f"All pods came up in {int(after - before)} seconds")
11641166
print(f"Dos arbitrator was created with name '{name}'")
11651167

11661168
print("create dos svc")

tests/suite/test_disable_ipv6_ingress.py

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
2+
23
from settings import TEST_DATA
3-
from suite.fixtures import PublicEndpoint
44
from suite.resources_utils import (
55
create_example_app,
66
create_items_from_yaml,
@@ -15,52 +15,38 @@
1515
wait_before_test,
1616
wait_until_all_pods_are_ready,
1717
)
18-
from suite.yaml_utils import get_first_ingress_host_from_yaml, get_name_from_yaml
19-
20-
paths = ["backend1", "backend2"]
18+
from suite.yaml_utils import get_name_from_yaml
2119

2220

23-
class DisableIPV6Setup:
21+
class IngressSetup:
2422
"""
2523
Encapsulate the Disable IPV6 Example details.
2624
2725
Attributes:
28-
public_endpoint (PublicEndpoint):
2926
ingress_name (str):
30-
ingress_host (str):
3127
ingress_pod_name (str):
3228
namespace (str):
3329
"""
3430

35-
def __init__(self, public_endpoint: PublicEndpoint, ingress_name, ingress_host, ingress_pod_name, namespace):
36-
self.public_endpoint = public_endpoint
37-
self.ingress_host = ingress_host
31+
def __init__(self, ingress_name, ingress_pod_name, namespace):
3832
self.ingress_name = ingress_name
3933
self.ingress_pod_name = ingress_pod_name
4034
self.namespace = namespace
4135

4236

43-
@pytest.fixture(scope="class", params=["standard", "mergeable"])
44-
def disable_ipv6_setup(
45-
request,
46-
kube_apis,
47-
ingress_controller_prerequisites,
48-
ingress_controller_endpoint,
49-
ingress_controller,
50-
test_namespace,
51-
) -> DisableIPV6Setup:
37+
@pytest.fixture(scope="class")
38+
def ingress_setup(
39+
request,
40+
kube_apis,
41+
ingress_controller_prerequisites,
42+
ingress_controller_endpoint,
43+
ingress_controller,
44+
test_namespace,
45+
) -> IngressSetup:
5246
print("------------------------- Deploy Disable IPV6 Example -----------------------------------")
53-
secret_name = create_secret_from_yaml(
54-
kube_apis.v1, test_namespace, f"{TEST_DATA}/disable-ipv6-ingress/disable-ipv6-secret.yaml"
55-
)
56-
57-
create_items_from_yaml(
58-
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace
59-
)
60-
ingress_name = get_name_from_yaml(f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml")
61-
ingress_host = get_first_ingress_host_from_yaml(
62-
f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml"
63-
)
47+
secret_name = create_secret_from_yaml(kube_apis.v1, test_namespace, f"{TEST_DATA}/smoke/smoke-secret.yaml")
48+
create_items_from_yaml(kube_apis, f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml", test_namespace)
49+
ingress_name = get_name_from_yaml(f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml")
6450
create_example_app(kube_apis, "simple", test_namespace)
6551
wait_until_all_pods_are_ready(kube_apis.v1, test_namespace)
6652

@@ -74,38 +60,38 @@ def disable_ipv6_setup(
7460
def fin():
7561
print("Clean up the Disable IPV6 Application:")
7662
delete_common_app(kube_apis, "simple", test_namespace)
77-
delete_items_from_yaml(
78-
kube_apis, f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml", test_namespace
79-
)
63+
delete_items_from_yaml(kube_apis, f"{TEST_DATA}/smoke/standard/smoke-ingress.yaml", test_namespace)
8064
delete_secret(kube_apis.v1, secret_name, test_namespace)
8165

8266
request.addfinalizer(fin)
8367

84-
return DisableIPV6Setup(ingress_controller_endpoint, ingress_name, ingress_host, ic_pod_name, test_namespace)
68+
return IngressSetup(ingress_name, ic_pod_name, test_namespace)
8569

8670

8771
@pytest.mark.ingresses
8872
class TestDisableIPV6:
8973
@pytest.mark.parametrize(
9074
"ingress_controller",
9175
[
92-
pytest.param({"extra_args": ["-disable-ipv6"]}, id="one-additional-cli-args"),
76+
pytest.param({"extra_args": ["-disable-ipv6"]}),
9377
],
9478
indirect=True,
9579
)
9680
def test_ipv6_listeners_not_in_config(
97-
self,
98-
kube_apis,
99-
disable_ipv6_setup: DisableIPV6Setup,
100-
ingress_controller_prerequisites,
81+
self,
82+
kube_apis,
83+
ingress_setup: IngressSetup,
84+
ingress_controller_prerequisites,
10185
):
10286
wait_before_test()
103-
nginx_config = get_nginx_template_conf(kube_apis.v1, ingress_controller_prerequisites.namespace)
87+
nginx_config = get_nginx_template_conf(
88+
kube_apis.v1, ingress_controller_prerequisites.namespace, ingress_setup.ingress_pod_name
89+
)
10490
upstream_conf = get_ingress_nginx_template_conf(
10591
kube_apis.v1,
106-
disable_ipv6_setup.namespace,
107-
disable_ipv6_setup.ingress_name,
108-
disable_ipv6_setup.ingress_pod_name,
92+
ingress_setup.namespace,
93+
ingress_setup.ingress_name,
94+
ingress_setup.ingress_pod_name,
10995
ingress_controller_prerequisites.namespace,
11096
)
11197
assert "listen [::]:" not in nginx_config

0 commit comments

Comments
 (0)
0