Skip to content

Commit

Permalink
calculate diff only when test fails and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
haywoodsh committed Oct 12, 2022
1 parent c2e3cb7 commit db33331
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
4 changes: 2 additions & 2 deletions internal/configs/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ func TestGenerateNginxCfgWithIPV6Disabled(t *testing.T) {

result, warnings := generateNginxCfg(&cafeIngressEx, nil, nil, false, configParams, isPlus, false, &StaticConfigParams{DisableIPV6: true}, false)

if diff := cmp.Diff(expected, result); diff != "" {
t.Errorf("generateNginxCfg() returned unexpected result (-want +got):\n%s", diff)
if !cmp.Equal(expected, result) {
t.Errorf("generateNginxCfg() returned unexpected result (-want +got):\n%s", cmp.Diff(expected, result))
}
if len(warnings) != 0 {
t.Errorf("generateNginxCfg() returned warnings: %v", warnings)
Expand Down
57 changes: 25 additions & 32 deletions tests/suite/test_disable_ipv6_ingress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pytest

from settings import TEST_DATA
from suite.fixtures import PublicEndpoint
from suite.resources_utils import (
Expand Down Expand Up @@ -33,12 +32,7 @@ class DisableIPV6Setup:
namespace (str):
"""

def __init__(self,
public_endpoint: PublicEndpoint,
ingress_name,
ingress_host,
ingress_pod_name,
namespace):
def __init__(self, public_endpoint: PublicEndpoint, ingress_name, ingress_host, ingress_pod_name, namespace):
self.public_endpoint = public_endpoint
self.ingress_host = ingress_host
self.ingress_name = ingress_name
Expand All @@ -47,22 +41,26 @@ def __init__(self,


@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:
def disable_ipv6_setup(
request,
kube_apis,
ingress_controller_prerequisites,
ingress_controller_endpoint,
ingress_controller,
test_namespace,
) -> DisableIPV6Setup:
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")
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)
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")
f"{TEST_DATA}/disable-ipv6-ingress/{request.param}/disable-ipv6-ingress.yaml"
)
create_example_app(kube_apis, "simple", test_namespace)
wait_until_all_pods_are_ready(kube_apis.v1, test_namespace)

Expand All @@ -76,35 +74,30 @@ def disable_ipv6_setup(request,
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}/disable-ipv6-ingress/{request.param}/disable-ipv6-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 DisableIPV6Setup(ingress_controller_endpoint, ingress_name, ingress_host, 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"),
],
indirect=True,
)
def test_ipv6_listeners_not_in_config(
self,
kube_apis,
disable_ipv6_setup: DisableIPV6Setup,
ingress_controller_prerequisites,
self,
kube_apis,
disable_ipv6_setup: DisableIPV6Setup,
ingress_controller_prerequisites,
):
wait_before_test()
nginx_config = get_nginx_template_conf(kube_apis.v1, ingress_controller_prerequisites.namespace)
Expand Down

0 comments on commit db33331

Please sign in to comment.