Skip to content

Looking up dynamically allocated port numbers to support testing of proxied services #343

Open
@psychemedia

Description

@psychemedia

Is there a simple pattern for creating basic tests of proxied services, eg using a tool such as playwright?

If we know the port number a service is running on, then a simple test of the following form can be used to check that the page loads with the desired title, and then grabs a screenshot of it:

#test_app.py

PORT= 8765

def test_initial_load(page: Page):
    page.goto(f"http://127.0.0.1:{PORT}")
    expect(page).to_have_title("Page Title")
    page.screenshot(path="proxied-service-screenshot.png")


#Usage: 
# pip install pytest-playwright
# playwright install
# playwright install-deps
# pytest

Using the proxy name alias doesn't seem to get resolved, whereas specifying the port number explicitly does seem to work.

But in a general case, how can we find the port number for a proxied service, particularly if it it allocated dynamically?

I note also that we can get some general metadata about proxied services from http://localhost/server-proxy/servers-info, although not the port numbers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions