diff --git a/testsuite/tests/glbc/__init__.py b/testsuite/tests/glbc/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/testsuite/tests/glbc/conftest.py b/testsuite/tests/glbc/conftest.py new file mode 100644 index 00000000..b6a089ee --- /dev/null +++ b/testsuite/tests/glbc/conftest.py @@ -0,0 +1,13 @@ +"""Root conftest for glbc tests""" +import pytest + +from testsuite.openshift.httpbin import Httpbin + + +@pytest.fixture(scope="session") +def backend(request, kcp, blame, label): + """Deploys Httpbin backend""" + httpbin = Httpbin(kcp, blame("httpbin"), label) + request.addfinalizer(httpbin.delete) + httpbin.commit() + return httpbin diff --git a/testsuite/tests/glbc/test_ingress_reconciliation.py b/testsuite/tests/glbc/test_ingress_reconciliation.py new file mode 100644 index 00000000..20de2879 --- /dev/null +++ b/testsuite/tests/glbc/test_ingress_reconciliation.py @@ -0,0 +1,47 @@ +"""Basic tests for ingress reconciliation""" +import time + +import backoff +import httpx +import pytest + +from testsuite.openshift.objects.ingress import Ingress + +pytestmark = [pytest.mark.glbc] + + +@pytest.fixture(scope="module") +def backend_ingress(request, backend, blame): + """Returns created ingress for given backend""" + # with backend.openshift.context: + service = backend.service + service_name = service.name() + port = backend.port + + name = blame("backend-ingress") + + ingress = Ingress.create_service_ingress(backend.openshift, name, service_name, port) + request.addfinalizer(ingress.delete) + ingress.commit() + + return ingress + + +@backoff.on_exception(backoff.fibo, exception=httpx.ConnectError, max_time=600) +def test_ingress_host_add(backend_ingress): + """Creates ingress for a backend and checks for host field filled by glbc, checks host points to backend""" + rules = backend_ingress.rules + assert len(rules) == 1 + + backend_ingress.wait_for_hosts() + host = rules[0].get("host") + + assert host + + # needed because of negative dns caching + # once https://github.com/kcp-dev/kcp-glbc/issues/354 is implemented this can be removed and reimplemented + time.sleep(20) # wait until dns record is propagated + + response = httpx.get(f"http://{host}") + + assert response.status_code == 200