test/src/processing/processing_service_test.cpp
TEST_F(ProcessingServiceTest, ProcessingSlotsAreAvailable)
{
    auto pubs = std::make_shared<sgns::ipfs_pubsub::GossipPubSub>();
    pubs->Start(40001, {});

    auto processingCore = std::make_shared<ProcessingCoreImpl>();
    auto taskQueue = std::make_shared<ProcessingTaskQueueImpl>();
    ProcessingServiceImpl processingService(pubs, 1, 1, taskQueue, processingCore);


    sgns::ipfs_pubsub::GossipPubSubTopic gridChannel(pubs, "GRID_CHANNEL_ID");
    gridChannel.Subscribe([](boost::optional<const sgns::ipfs_pubsub::GossipPubSub::Message&> message) {});
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

    processingService.Listen("GRID_CHANNEL_ID");
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

    SGProcessing::GridChannelMessage gridMessage;
    auto channelResponse = gridMessage.mutable_processing_channel_response();
    channelResponse->set_channel_id("PROCESSING_CHANNEL_ID");
    channelResponse->set_channel_capacity(1);
    channelResponse->set_channel_nodes_joined(0);
    gridChannel.Publish(gridMessage.SerializeAsString());

    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    pubs->Stop();

    EXPECT_EQ(processingService.GetProcessingNodesCount(), 1);
}
/**
 * @given Empty room list
 * @when A room with available slots received
 * @then A processing node is created
 */
@given Empty room list
@when A room with available slots received
@then A processing node is created
@given Empty room list @when A room with available slots received @then A processing node is created
TEST_F(ProcessingServiceTest, ProcessingSlotsAreAvailable)
{
    auto pubs = std::make_shared<sgns::ipfs_pubsub::GossipPubSub>();
    pubs->Start(40001, {});
    auto processingCore = std::make_shared<ProcessingCoreImpl>();
    auto taskQueue = std::make_shared<ProcessingTaskQueueImpl>();
    ProcessingServiceImpl processingService(pubs, 1, 1, taskQueue, processingCore);
    sgns::ipfs_pubsub::GossipPubSubTopic gridChannel(pubs, "GRID_CHANNEL_ID");
    gridChannel.Subscribe([](boost::optional<const sgns::ipfs_pubsub::GossipPubSub::Message&> message) {});
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    processingService.Listen("GRID_CHANNEL_ID");
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    SGProcessing::GridChannelMessage gridMessage;
    auto channelResponse = gridMessage.mutable_processing_channel_response();
    channelResponse->set_channel_id("PROCESSING_CHANNEL_ID");
    channelResponse->set_channel_capacity(1);
    channelResponse->set_channel_nodes_joined(0);
    gridChannel.Publish(gridMessage.SerializeAsString());
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    pubs->Stop();
    EXPECT_EQ(processingService.GetProcessingNodesCount(), 1);
}
TEST_F ( ProcessingServiceTest , ProcessingSlotsAreAvailable ) { auto pubs = std :: make_shared < sgns :: ipfs_pubsub :: GossipPubSub > ( ) ; pubs -> Start ( 40001 , { } ) ; auto processingCore = std :: make_shared < ProcessingCoreImpl > ( ) ; auto taskQueue = std :: make_shared < ProcessingTaskQueueImpl > ( ) ; ProcessingServiceImpl processingService ( pubs , 1 , 1 , taskQueue , processingCore ) ; sgns :: ipfs_pubsub :: GossipPubSubTopic gridChannel ( pubs , " " ) ; gridChannel . Subscribe ( [ ] ( boost :: optional < const sgns :: ipfs_pubsub :: GossipPubSub :: Message & > message ) { } ) ; std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( 1000 ) ) ; processingService . Listen ( " " ) ; std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( 1000 ) ) ; SGProcessing :: GridChannelMessage gridMessage ; auto channelResponse = gridMessage . mutable_processing_channel_response ( ) ; channelResponse -> set_channel_id ( " " ) ; channelResponse -> set_channel_capacity ( 1 ) ; channelResponse -> set_channel_nodes_joined ( 0 ) ; gridChannel . Publish ( gridMessage . SerializeAsString ( ) ) ; std :: this_thread :: sleep_for ( std :: chrono :: milliseconds ( 1000 ) ) ; pubs -> Stop ( ) ; EXPECT_EQ ( processingService . GetProcessingNodesCount ( ) , 1 ) ; }
@given Empty room list
 @when A room with available slots received
 @then A processing node is created
@given Empty room list @when A room with available slots received @then A processing node is created