Fork me on GitHub
#xtdb
<
2019-11-11
>
JanisOlex09:11:41

Hello, Cruxians... I have a question for ya Situation : Testing - during test run I don't have direct access to Crux node, but given the tests are run on the same VM and same file system where Crux node runs, is there any good nice way how to access and "listen" to evens on Crux during testing. The big problem I have is that currently I am forced to put Thread.sleep(...) in my tests between writes and reads from crux, but I would like to have consistent and deterministic test and have test continuation after I am sure crux has written stuff in the DB. So my idea was - something to listen on crux log or wherever Crux writes in FS for events. Any good idea?

Ivan Fedorov20:11:37

Hi Janis, sorry for long response. Sure, you can just use sync, it was made for that.

refset11:11:26

@olekss.janis Hi - just to add to @U0A5V8ZR6’s answer, I think you could use the http-server-server and remote API to do the sync conveniently. Or you could expose the sync functionality from the node using your own API

JanisOlex12:11:35

okay, sorry, for so long... will it be very dumb if I ask what is sync?

refset13:11:08

@olekss.janis it's no problem, though Slack logs disappear so quickly these days! sync blocks until the node has ingested the tx-time you give it (which you want to pull out from the sumbit-tx response), otherwise the node may not have processed transaction yet

Ivan Fedorov14:11:42

@olekss.janis sorry, I could’ve been more helpful sync docs part https://juxt.pro/crux/docs/api.html#_sync If you share your test setup we can be more helpful

👍 4
markbastian23:11:56

Does crux have any aggregates? I'm looking for count.

refset11:11:38

Hi! We have an aggregation "decorator" which allows you to add all sorts of interesting reducers (including counting) to the output of the core datalog responses. For an example of usage, see https://github.com/juxt/crux/blob/master/docs/example/repl-walkthrough/graph-traversal.clj#L110-L118

👍 4
markbastian14:11:45

Thanks. I'll give that a shot.

👍 4