The last two tests highlight two ways of interacting with the code running within the cluster.
The first example expects something to be set up and running that provides access to the cluster outside of the test, and simply uses the Python requests library to make an HTTP request directly:
@pytest.mark.dependency(depends=["test_deployment_ready"])def test_service_response(kubectl_proxy): NAMESPACE="default" SERVICE_NAME="flask-service" URI = "http://localhost:8001/api/v1/namespaces/%s/services/%s/proxy/" % (NAMESPACE, SERVICE_NAME) print("requesting %s" % (URI)) r = requests.get(URI) assert r.status_code == 200
It's an incredibly basic test and is fairly fragile. It uses a PyTest fixture defined earlier in the code ...