-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glbc: add simple ingress host field reconciliation test
- Loading branch information
Filip Čáp
committed
Oct 26, 2022
1 parent
1165596
commit dba9b28
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |