I've started trying to test ETSDB with Common Test and found that it wasn't terribly straightforward to test the Riak Core vnode. The vnode is managed by a Riak Core gen_fsm and isn't a built-in OTP behavior.
I wanted to include the Riak Core gen_fsm to make sure that I integrated it
properly. First you want to spin up the
riak_core_vnode with your vnode
implementation and save the config in the Pid.
Similarly to tear it down you should send a message to stop the FSM. This requires a
tear down call and adding a handler in your vnode to return a
That includes the
send_command which is a variation from the Riak Core
source. It will handle sending the message in a way that can get the response
sent back to the sending process. Riak Core does some mucking around to deal
with running with the full application.
Now you can call
send_command with the Pid of the FSM and with the ref
returned can pull that messages out of the mailbox!