test(sdk): address fixture server move from port 9003 to 9010 in local-testcontainer
@@ -78,6 +78,12 @@ if TYPE_CHECKING:
resolver: Callable[[Any], Optional[Dict[str, Any]]]
+# `local-testcontainer` ports
+LOCAL_BASE_PORT = "8080"
+SERVICES_API_PORT = "8083"
+FIXTURE_SERVICE_PORT = "9010"
+
+
class ConsoleFormatter:
BOLD = "\033[1m"
CODE = "\033[2m"
@@ -704,7 +710,7 @@ def pytest_addoption(parser):
)
parser.addoption(
"--base-url",
- default="http://localhost:8080",
+ default=f"http://localhost:{LOCAL_BASE_PORT}",
help='cli to set "base-url"',
)
parser.addoption(
@@ -822,14 +828,14 @@ def check_server_up(
:return:
"""
app_health_endpoint = "healthz"
- fixture_url = base_url.replace("8080", "9003")
+ fixture_url = base_url.replace(LOCAL_BASE_PORT, FIXTURE_SERVICE_PORT)
fixture_health_endpoint = "health"
if os.environ.get("CI") == "true":
return check_server_health(base_url=base_url, endpoint=app_health_endpoint)
if not check_server_health(base_url=base_url, endpoint=app_health_endpoint):
- # start wandb server locally and expose ports 8080, 8083, and 9003
+ # start wandb server locally and expose ports 8080, 8083, and 9010
command = [
"docker",
"run",
@@ -839,11 +845,11 @@ def check_server_up(
"-v",
"wandb:/vol",
"-p",
- "8080:8080",
+ f"{LOCAL_BASE_PORT}:{LOCAL_BASE_PORT}",
"-p",
- "8083:8083",
+ f"{SERVICES_API_PORT}:{SERVICES_API_PORT}",
"-p",
- "9003:9003",
+ f"{FIXTURE_SERVICE_PORT}:{FIXTURE_SERVICE_PORT}",
"-e",
"WANDB_ENABLE_TEST_CONTAINER=true",
"--name",
@@ -873,7 +879,7 @@ class UserFixtureCommand:
username: Optional[str] = None
admin: bool = False
endpoint: str = "db/user"
- port: int = 9003
+ port: str = FIXTURE_SERVICE_PORT
method: Literal["post"] = "post"
@@ -882,7 +888,7 @@ class AddAdminAndEnsureNoDefaultUser:
email: str
password: str
endpoint: str = "api/users-admin"
- port: int = 8083
+ port: str = SERVICES_API_PORT
method: Literal["put"] = "put"
@@ -892,7 +898,7 @@ def fixture_fn(base_url, wandb_server_tag, wandb_server_pull):
cmd: Union[UserFixtureCommand, AddAdminAndEnsureNoDefaultUser]
) -> bool:
endpoint = urllib.parse.urljoin(
- base_url.replace("8080", str(cmd.port)),
+ base_url.replace(LOCAL_BASE_PORT, cmd.port),
cmd.endpoint,
)
