Skip to content

Conversation

@ShahanaFarooqui
Copy link
Collaborator

Step 1: Run gltestserver with test directory

uv run gltestserver run --directory=/tmp/gltests

Step 2: Run pytest in another terminal

uv run python3 -m pytest -vvv ./libs/gl-testing/tests/test_node.py::test_code_snippets

Result: It will print node information successfully.

Step 3: Run the same flow in standalone python program

uv run python examples/python/snippets/getting_started.py

Result: Error from glclient

Creating seed...
Registering node...
Traceback (most recent call last):
  File "/greenlight/examples/python/snippets/getting_started.py", line 173, in <module>
    main()
  File "/greenlight/examples/python/snippets/getting_started.py", line 157, in main
    my_scheduler, device_creds, signer = register_node(seed, developer_cert_path, developer_key_path)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/greenlight/examples/python/snippets/getting_started.py", line 63, in register_node
    registration_response = scheduler.register(signer, invite_code=None)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/greenlight/libs/gl-client-py/glclient/__init__.py", line 87, in register
    res = self.inner.register(signer.inner, invite_code)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: error calling remote method: status: Unknown, message: "transport error", details: [], metadata: MetadataMap { headers: {} }

@cdecker
Copy link
Collaborator

cdecker commented Oct 14, 2025

Thanks for the repro for this. I think this is a bit of a misunderstanding:

  1. Step 1 will spin up a new server, that will listen on a random port on localhost
  2. Step 2 will start tests in isolation, starting and stopping its own mock Greenlight service, the one from Step 1 is not being talked to, the test overrides the scheduler location with the one from the fixtures
  3. Step 3 will load the certificates from the test server, but since the scheduler location is not being overridden, it'll attempt to talk to the production system, not the test server from Step 1.

So nobody is talking to the testserver, just step 3 is using its test certificates causing the mismatch in the mTLS verification. You need to set the envvars as displayed at the bottom of the testserver start, otherwise the default pointing to the prod environment will be used. As for things using gl-testing and pytest, these manage their own testserver, including the setting of envvars so the tests can find it, so no extra testserver is required in the first place (as a matter of fact the gl-testserver is just a standalone version of the gl-testing fixtures wired up to act as a local mock greenlight.

@ShahanaFarooqui
Copy link
Collaborator Author

I was able to successfully run the tests after setting up environment variables properly, like:

GL_CA_CRT=/path/to/certs/ca.crt \
GL_NOBODY_CRT=/path/to/certs/users/nobody.crt \
GL_NOBODY_KEY=/path/to/certs/users/nobody-key.pem \
GL_SCHEDULER_GRPC_URI=https://localhost:<sheduler-port> \
uv run python examples/python/snippets/getting_started.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants