GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tests: start every server test on a free port (#466) · humemai/arcadedb-embedded-python@fe4aa86

This repository was archived by the owner on Nov 21, 2026. It is now read-only.

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bindings/python/tests
    • conftest.py
    • test_server.py
    • test_server_http_endpoints.py
    • test_server_packaging.py
    • test_server_patterns.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bindings/python/tests/conftest.py‎

Copy file name to clipboardExpand all lines: bindings/python/tests/conftest.py
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ def pytest_runtest_call(item):
110110
TEST_PASSWORD = "test12345" # nosec B105
111111

112112

113+
def free_port():
114+
"""A free local TCP port, for a server's ``http_port``.
115+
116+
The server's default is the fixed port 2480, so a test that starts a server
117+
without choosing a port fails with "Unable to listen to a HTTP port in the
118+
configured port range 2480 - 2480" whenever anything else on the machine
119+
holds 2480 (the laptop, 2026-10-22). Every test that starts a server passes
120+
``config={"http_port": free_port()}``. For several distinct ports at once,
121+
see ``_free_ports`` in test_server_wire_protocols.py.
122+
"""
123+
import socket
124+
125+
with socket.socket() as s:
126+
s.bind(("127.0.0.1", 0))
127+
return s.getsockname()[1]
128+
129+
113130
@pytest.fixture
114131
def temp_server_root():
115132
"""Create a temporary server root directory."""
Collapse file

‎bindings/python/tests/test_server.py‎

Copy file name to clipboardExpand all lines: bindings/python/tests/test_server.py
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616

1717
import pytest
1818
from arcadedb_embedded import ArcadeDBServer
19-
from tests.conftest import TEST_PASSWORD
19+
from tests.conftest import TEST_PASSWORD, free_port
2020

2121

2222
@pytest.mark.server
2323
def test_server_creation(temp_server_root):
2424
"""Test creating and starting a server."""
25+
port = free_port()
2526
server = ArcadeDBServer(
2627
root_path=temp_server_root,
2728
root_password=TEST_PASSWORD,
28-
config={"http_port": 2480},
29+
config={"http_port": port},
2930
)
3031

3132
assert not server.is_started()
@@ -35,10 +36,10 @@ def test_server_creation(temp_server_root):
3536
# Give server a moment to start
3637
time.sleep(1)
3738

38-
assert server.get_http_port() == 2480
39+
assert server.get_http_port() == port
3940
studio_url = server.get_studio_url()
4041
assert "http://" in studio_url
41-
assert "2480" in studio_url
42+
assert str(port) in studio_url
4243

4344
server.stop()
4445
assert not server.is_started()
@@ -55,7 +56,9 @@ def test_server_database_operations(temp_server_root):
5556
- Operations within same Python process (embedded access)
5657
"""
5758
with ArcadeDBServer(
58-
root_path=temp_server_root, root_password=TEST_PASSWORD
59+
root_path=temp_server_root,
60+
root_password=TEST_PASSWORD,
61+
config={"http_port": free_port()},
5962
) as server:
6063
# Server auto-starts in context manager
6164
time.sleep(1)
@@ -84,15 +87,16 @@ def test_server_database_operations(temp_server_root):
8487
@pytest.mark.server
8588
def test_server_custom_config(temp_server_root):
8689
"""Test server with custom configuration."""
87-
config = {"http_port": 8080, "host": "127.0.0.1", "mode": "production"}
90+
port = free_port()
91+
config = {"http_port": port, "host": "127.0.0.1", "mode": "production"}
8892

8993
server = ArcadeDBServer(
9094
root_path=temp_server_root, root_password=TEST_PASSWORD, config=config
9195
)
9296
server.start()
9397
time.sleep(1)
9498

95-
assert server.get_http_port() == 8080
99+
assert server.get_http_port() == port
96100

97101
server.stop()
98102

Collapse file

‎bindings/python/tests/test_server_http_endpoints.py‎

Copy file name to clipboardExpand all lines: bindings/python/tests/test_server_http_endpoints.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111

1212
import arcadedb_embedded as arcadedb
1313
import pytest
14-
from tests.conftest import TEST_PASSWORD
14+
from tests.conftest import TEST_PASSWORD, free_port
1515

1616

1717
@pytest.fixture
1818
def http_server(tmp_path):
1919
requests = pytest.importorskip("requests")
2020
server = arcadedb.create_server(
21-
root_path=str(tmp_path / "srv"), root_password=TEST_PASSWORD
21+
root_path=str(tmp_path / "srv"),
22+
root_password=TEST_PASSWORD,
23+
config={"http_port": free_port()},
2224
)
2325
server.start()
2426
time.sleep(1)
Collapse file

‎bindings/python/tests/test_server_packaging.py‎

Copy file name to clipboardExpand all lines: bindings/python/tests/test_server_packaging.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ def test_server_starts_and_serves_http(temp_server_root):
109109
"""
110110
requests = pytest.importorskip("requests")
111111
from arcadedb_embedded import create_server
112-
from tests.conftest import TEST_PASSWORD
112+
from tests.conftest import TEST_PASSWORD, free_port
113113

114114
with create_server(
115-
root_path=temp_server_root, root_password=TEST_PASSWORD
115+
root_path=temp_server_root,
116+
root_password=TEST_PASSWORD,
117+
config={"http_port": free_port()},
116118
) as server:
117119
assert server.is_started()
118120
port = server.get_http_port()
@@ -156,10 +158,12 @@ def served(temp_server_root):
156158
"""A started server, a database named ``packaging``, and an authenticated session."""
157159
import requests
158160
from arcadedb_embedded import create_server
159-
from tests.conftest import TEST_PASSWORD
161+
from tests.conftest import TEST_PASSWORD, free_port
160162

161163
with create_server(
162-
root_path=temp_server_root, root_password=TEST_PASSWORD
164+
root_path=temp_server_root,
165+
root_password=TEST_PASSWORD,
166+
config={"http_port": free_port()},
163167
) as server:
164168
server.create_database("packaging").close()
165169
session = requests.Session()
Collapse file

‎bindings/python/tests/test_server_patterns.py‎

Copy file name to clipboardExpand all lines: bindings/python/tests/test_server_patterns.py
+29-7Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import arcadedb_embedded as arcadedb
2222
import pytest
23-
from tests.conftest import TEST_PASSWORD
23+
from tests.conftest import TEST_PASSWORD, free_port
2424

2525

2626
def _http_query(server, db_name, sql):
@@ -94,7 +94,11 @@ def test_server_pattern_recommended(cleanup_test_dirs):
9494

9595
# Step 1: Start server first
9696
print("\n1. Starting ArcadeDB server...")
97-
server = arcadedb.create_server(root_path=root_path, root_password=TEST_PASSWORD)
97+
server = arcadedb.create_server(
98+
root_path=root_path,
99+
root_password=TEST_PASSWORD,
100+
config={"http_port": free_port()},
101+
)
98102
register_server(server)
99103
server.start()
100104
assert server.is_started()
@@ -153,7 +157,11 @@ def test_server_thread_safety(cleanup_test_dirs):
153157

154158
# Start server and create database
155159
print("\n1. Setting up server and database...")
156-
server = arcadedb.create_server(root_path=root_path, root_password=TEST_PASSWORD)
160+
server = arcadedb.create_server(
161+
root_path=root_path,
162+
root_password=TEST_PASSWORD,
163+
config={"http_port": free_port()},
164+
)
157165
register_server(server)
158166
server.start()
159167

@@ -229,7 +237,9 @@ def test_server_context_manager(cleanup_test_dirs):
229237

230238
# Server automatically starts and stops
231239
with arcadedb.create_server(
232-
root_path=root_path, root_password=TEST_PASSWORD
240+
root_path=root_path,
241+
root_password=TEST_PASSWORD,
242+
config={"http_port": free_port()},
233243
) as server:
234244
print(" ✅ Server started (automatic)")
235245

@@ -306,7 +316,11 @@ def test_pattern1_embedded_first_requires_close(cleanup_test_dirs):
306316

307317
# Step 4: Start server
308318
print("\n4. Starting ArcadeDB server...")
309-
server = arcadedb.create_server(root_path=root_path, root_password=TEST_PASSWORD)
319+
server = arcadedb.create_server(
320+
root_path=root_path,
321+
root_password=TEST_PASSWORD,
322+
config={"http_port": free_port()},
323+
)
310324
register_server(server)
311325
server.start()
312326
print(f" ✅ Server started on port {server.get_http_port()}")
@@ -442,7 +456,11 @@ def test_embedded_performance_comparison(cleanup_test_dirs):
442456
print("\n2. Server-Managed Embedded Mode (same process)...")
443457
server_path = create_temp_dir("server_perf_")
444458

445-
server = arcadedb.create_server(root_path=server_path, root_password=TEST_PASSWORD)
459+
server = arcadedb.create_server(
460+
root_path=server_path,
461+
root_password=TEST_PASSWORD,
462+
config={"http_port": free_port()},
463+
)
446464
register_server(server)
447465
server.start()
448466

@@ -538,7 +556,11 @@ def test_http_api_access_pattern(cleanup_test_dirs):
538556

539557
# Step 1: Start server (required for HTTP API)
540558
print("\n1. Starting ArcadeDB server...")
541-
server = arcadedb.create_server(root_path=root_path, root_password=TEST_PASSWORD)
559+
server = arcadedb.create_server(
560+
root_path=root_path,
561+
root_password=TEST_PASSWORD,
562+
config={"http_port": free_port()},
563+
)
542564
register_server(server)
543565
server.start()
544566
time.sleep(1) # Give server time to fully start

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.