Files
SpacetimeDB/smoketests/tests/servers.py
Zeke Foppa 86089e338f Smoketests can run against remote servers (#3012)
# Description of Changes

This enables smoketests to run against remote servers, such as maincloud
/ maincloud staging.

I also added a `--spacetime-login` param, for servers that require a
"proper" spacetime login (such as both servers above).

Usage:
```bash
python3 -m smoketests \
  --remote-server https://maincloud.staging.spacetimedb.com \
  --spacetime-login \
  -x replication # for some reason this is required, even though I swear it should be disabled by not passing `--docker`
```

# API and ABI breaking changes

None. CI only.

# Expected complexity level and risk

1

# Testing
- [x] Smoketests pass on this PR
- [x] Smoketests pass when run against maincloud staging (using the
instructions above)
- [x] Manual review to check whether I've accidentally de-fanged any
"test for negative case" tests

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-22 17:13:42 +00:00

37 lines
1.8 KiB
Python

from .. import Smoketest, extract_field, requires_local_server
import re
# We require a local server because these tests have hardcoded server addresses.
@requires_local_server
class Servers(Smoketest):
AUTOPUBLISH = False
def test_servers(self):
"""Verify that we can add and list server configurations"""
out = self.spacetime("server", "add", "--url", "https://testnet.spacetimedb.com", "testnet", "--no-fingerprint")
self.assertEqual(extract_field(out, "Host:"), "testnet.spacetimedb.com")
self.assertEqual(extract_field(out, "Protocol:"), "https")
servers = self.spacetime("server", "list")
self.assertRegex(servers, re.compile(r"^\s*testnet\.spacetimedb\.com\s+https\s+testnet\s*$", re.M))
self.assertRegex(servers, re.compile(r"^\s*\*\*\*\s+127\.0\.0\.1:3000\s+http\s+localhost\s*$", re.M))
out = self.spacetime("server", "fingerprint", "http://127.0.0.1:3000", "-y")
self.assertIn("No saved fingerprint for server 127.0.0.1:3000.", out)
out = self.spacetime("server", "fingerprint", "http://127.0.0.1:3000")
self.assertIn("Fingerprint is unchanged for server 127.0.0.1:3000", out)
out = self.spacetime("server", "fingerprint", "localhost")
self.assertIn("Fingerprint is unchanged for server localhost", out)
def test_edit_server(self):
"""Verify that we can edit server configurations"""
out = self.spacetime("server", "add", "--url", "https://foo.com", "foo", "--no-fingerprint")
out = self.spacetime("server", "edit", "foo", "--url", "https://edited-testnet.spacetimedb.com", "--new-name", "edited-testnet", "--no-fingerprint", "--yes")
servers = self.spacetime("server", "list")
self.assertRegex(servers, re.compile(r"^\s*edited-testnet\.spacetimedb\.com\s+https\s+edited-testnet\s*$", re.M))