how are you running your schema creation
# spicedb
y
how are you running your schema creation, and what preshared-key are you using?
u
I am using
Copy code
SPICEDB_TOKEN="random_key"
running the schema creation as part of the globalSetup function of JEST, via
client.writeSchema(schemaRequest)
🤔
y
but is the
random_key
static, or is it generated by some function on each invocation?
u
static, via env var
y
in
serve-testing
mode, each different preshared key is functionally its own sandbox, so if it's different between the setup function and the calls that would explain what you're seeing
u
the tests only fail on first run after spining up a new spicedb serve-testing container
y
the other thing would be that the memory DB still uses the same consistency semantics as a "real" instance
so if you're not making your subsequent requests with
at_least_as_fresh
or
fully_consistent
, they may not see the revision that includes your schema
u
all requests are using
fully_consistent
, if not some tests become flaky. My concern here is with the first run only where few tests! a theory: it seems that the
client.writeSchema(schemaRequest)
actually triggers the schema creation in async fashin, the response do not mean that it was fully created, no? 🤔 thus when the jest runner carry on, it starts throwing queries against SpiceDB, too fast, before SpiceDB manages to create parts of the schema 🤔
y
that would make some sense. does the test setup await that call, or is it firing it off and then continuing with test running?
j
schemas are revisioned like everything else in SpiceDB
if you call WriteSchema and immediately make a fully consistent call, it should apply
but otherwise, it might use the cache
> the tests only fail on first run after spining up a new spicedb serve-testing container if each test is calling write schema with the same static key
they could be interfering with one another
u
it was a concurrency issue with some paralell tests in Jest. I did refactor it ensuring not to run until writeSchema() finishes. and it works now. ✅ thanks for the swift support 🙌
30 Views