Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/nidcpower/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31760,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, you can configure it to use a dynamic port and read the port number from stdout. That's what InstrumentStudio's GrpcDeviceServerActivationService does.

Copy link
Collaborator

@ni-jfitzger ni-jfitzger Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We considered it, but we felt this was safer, particularly with multiple instances of gRPC Device Server being kicked off at the same time. Our internal VM Build process launches up to 4 instances at once, repeatedly while testing up to 4 APIs in parallel, so they could, theoretically pick the same port.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't happen. The server specifies a listening port of 0 when calling bind(), which tells the OS to allocate a port from the ephemeral port range. Then the server asks the OS which port it's using and prints that port number to stdout. This should only fail when all of the ports in the ephemeral port range are in use (and there are thousands of these).

"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/nidcpower/system_tests/test_system_nidcpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,9 @@ def test_lcr_compensation_data(self, session):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
9 changes: 9 additions & 0 deletions src/nidigital/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31761,
"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/nidigital/system_tests/test_system_nidigital.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,9 @@ def test_enable_match_fail_combination(self, multi_instrument_session):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
9 changes: 9 additions & 0 deletions src/nidmm/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31762,
"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/nidmm/system_tests/test_system_nidmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ def test_fetch_waveform_into(self, session):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
9 changes: 9 additions & 0 deletions src/nifgen/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31763,
"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/nifgen/system_tests/test_system_nifgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ def test_write_named_waveform_numpy_array_int16(self, session):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
9 changes: 9 additions & 0 deletions src/niscope/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31764,
"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/niscope/system_tests/test_system_niscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ def test_reset_with_defaults(self, single_instrument_session):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
9 changes: 9 additions & 0 deletions src/niswitch/system_tests/grpc_server_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"address": "[::1]",
"port": 31765,
"security" : {
"server_cert": "",
"server_key": "",
"root_cert": ""
}
}
4 changes: 3 additions & 1 deletion src/niswitch/system_tests/test_system_niswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def session_creation_kwargs(self):
class TestGrpc(SystemTests):
@pytest.fixture(scope='class')
def grpc_channel(self):
with system_test_utilities.GrpcServerProcess() as proc:
current_directory = os.path.dirname(os.path.abspath(__file__))
config_file_path = os.path.join(current_directory, 'grpc_server_config.json')
with system_test_utilities.GrpcServerProcess(config_file_path) as proc:
channel = grpc.insecure_channel(f"localhost:{proc.server_port}")
yield channel

Expand Down
4 changes: 2 additions & 2 deletions src/shared/system_test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


class GrpcServerProcess:
def __init__(self):
def __init__(self, config_file_path):
server_exe = self._get_grpc_server_exe()
self._proc = subprocess.Popen([str(server_exe)], stdout=subprocess.PIPE)
self._proc = subprocess.Popen([str(server_exe), config_file_path], stdout=subprocess.PIPE)

# Read/parse output until we find the port number or the process exits; discard the rest.
try:
Expand Down