// // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // we're going to store the received message in here $checkpoint = getCheckpoint(); foreach (firstHostWithRole("zmq_target") as $hostId) { $context = usingZmqContext()->getZmqContext(); $inPort = fromHost($hostId)->getStorySetting("zmq.multi.inPort"); $outPort = fromHost($hostId)->getStorySetting("zmq.multi.outPort"); $inSocket = usingZmqContext($context)->connectToHost($hostId, $inPort, 'PUSH'); $outSocket = usingZmqContext($context)->connectToHost($hostId, $outPort, 'PULL'); expectsZmqSocket($inSocket)->canSendmultiNonBlocking($checkpoint->expectedMessage); $checkpoint->actualMessage = fromZmqSocket($outSocket)->recvMulti(); } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { $checkpoint = getCheckpoint(); assertsObject($checkpoint)->hasAttribute("expectedMessage"); assertsObject($checkpoint)->hasAttribute("actualMessage"); assertsArray($checkpoint->actualMessage)->equals($checkpoint->expectedMessage); });
// ------------------------------------------------------------------------ // ======================================================================== // // PRE-TEST INSPECTION // // ------------------------------------------------------------------------ // ======================================================================== // // POSSIBLE ACTION(S) // // ------------------------------------------------------------------------ $story->addAction(function () { // we're going to store the received message in here $checkpoint = getCheckpoint(); foreach (firstHostWithRole("zmq_target") as $hostId) { // we need to connect $context = usingZmqContext()->getZmqContext(); $inPort = fromHost($hostId)->getStorySetting("zmq.multi.inPort"); $inSocket = usingZmqContext($context)->connectToHost($hostId, $inPort, 'PUSH'); // now let's make sure we are connected expectsZmqSocket($inSocket)->isConnectedToHost($hostId, $inPort); } }); // ======================================================================== // // POST-TEST INSPECTION // // ------------------------------------------------------------------------ $story->addPostTestInspection(function () { // nothing to do });