Skip to content

Commit

Permalink
glbc: add simple ingress host field reconciliation test
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Čáp committed Oct 26, 2022
1 parent 1165596 commit dba9b28
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Empty file.
13 changes: 13 additions & 0 deletions testsuite/tests/glbc/conftest.py
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions testsuite/tests/glbc/test_ingress_reconciliation.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dba9b28

Please sign in to comment.