title: integration/test_sg_connectivity.cpp summary: Integration tests: SGProcessingBridge BuildSchemaJson + SubmitNetwork fallback.
integration/test_sg_connectivity.cpp¶
Integration tests: SGProcessingBridge BuildSchemaJson + SubmitNetwork fallback. More...
Functions¶
| Name | |
|---|---|
| TEST(SGConnectivity , BuildSchemaJsonValidParamsReturnsJson ) | |
| TEST(SGConnectivity , BuildSchemaJsonEmptyModelUriReturnsInvalidArgument ) | |
| TEST(SGConnectivity , BuildSchemaJsonEmptyInputUriReturnsInvalidArgument ) | |
| TEST(SGConnectivity , BuildSchemaJsonFP4UltraFormatEmitsFP4Type ) | |
| TEST(SGConnectivity , SubmitJobNetworkModeNoClientFallsBackAndFails ) | |
| TEST(SGConnectivity , SubmitJobDirectModeDoesNotRequireClient ) | |
| TEST(SGConnectivity , SetClientNullptrDoesNotCrash ) | |
| TEST(SGConnectivity , SubmitJobInvalidSchemaDoesNotAttemptDispatch ) |
Detailed Description¶
Integration tests: SGProcessingBridge BuildSchemaJson + SubmitNetwork fallback.
Date: 2026-08-09
Plan 02-08 task 3. Verifies the SuperGenius dispatch bridge against the post-02-05 API (no SGMessageAuthenticator, PollForResult, m_geniusNodeConfig).
These tests run WITHOUT a live GeniusSDK node — network dispatch fails and the auto-fallback path (SubmitDirect) is exercised. SubmitDirect itself fails in this environment because SGProcessingManager has no valid model, which is expected: the assertions target error propagation and crash-safety, not success.
Functions Documentation¶
function TEST¶
function TEST¶
function TEST¶
function TEST¶
function TEST¶
function TEST¶
function TEST¶
function TEST¶
Source code¶
#include "common/error.hpp"
#include "core/sgprocessing/sg_processing_bridge.hpp"
#include <boost/asio/io_context.hpp>
#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <InputFormat.hpp>
using namespace sgns::neoswarm;
using namespace sgns::neoswarm::core;
namespace
{
constexpr const char* kModelUri = "file:///tmp/model.mnn";
constexpr const char* kInputUri = "file:///tmp/input.bin";
} // namespace
// =======================================================================
// BuildSchemaJson
// =======================================================================
TEST( SGConnectivity, BuildSchemaJsonValidParamsReturnsJson )
{
SGProcessingBridge bridge;
auto result = bridge.BuildSchemaJson( kModelUri, kInputUri, sgns::InputFormat::FLOAT32, { 1, 512 } );
ASSERT_TRUE( result.has_value() );
EXPECT_FALSE( result.value().empty() );
// GNUS schema marker emitted by BuildSchemaJson (doc["gnus_spec_version"]).
EXPECT_NE( result.value().find( "gnus_spec_version" ), std::string::npos );
}
TEST( SGConnectivity, BuildSchemaJsonEmptyModelUriReturnsInvalidArgument )
{
SGProcessingBridge bridge;
auto result = bridge.BuildSchemaJson( "", kInputUri, sgns::InputFormat::FLOAT32, { 1, 512 } );
ASSERT_FALSE( result.has_value() );
EXPECT_EQ( result.error(), Error::InvalidArgument );
}
TEST( SGConnectivity, BuildSchemaJsonEmptyInputUriReturnsInvalidArgument )
{
SGProcessingBridge bridge;
auto result = bridge.BuildSchemaJson( kModelUri, "", sgns::InputFormat::FLOAT32, { 1, 512 } );
ASSERT_FALSE( result.has_value() );
EXPECT_EQ( result.error(), Error::InvalidArgument );
}
TEST( SGConnectivity, BuildSchemaJsonFP4UltraFormatEmitsFP4Type )
{
SGProcessingBridge bridge;
auto result =
bridge.BuildSchemaJson( kModelUri, kInputUri, sgns::InputFormat::FP4_ULTRA, { 1, 256, 256, 3 } );
ASSERT_TRUE( result.has_value() );
// FP4_ULTRA must dispatch to the "tensor" DataType (a valid from_json selector);
// the encoding is carried only in the separate "format" field. The lowercase
// literal "fp4_ultra" is not a recognized DataType and must never appear
// anywhere in the generated schema — mirrors the canonical assertions in
// test_sgprocessing_pipeline.cpp's BuildSchemaJson_Fp4Ultra (Phase 13, SGF-04b).
EXPECT_NE( result.value().find( "\"type\":\"tensor\"" ), std::string::npos );
EXPECT_NE( result.value().find( "\"format\":\"FP4_ULTRA\"" ), std::string::npos );
EXPECT_EQ( result.value().find( "fp4_ultra" ), std::string::npos );
}
// =======================================================================
// SubmitNetwork fallback / SetClient
// =======================================================================
TEST( SGConnectivity, SubmitJobNetworkModeNoClientFallsBackAndFails )
{
SGProcessingBridge::Config cfg;
cfg.m_networkMode = true;
SGProcessingBridge bridge( cfg );
auto ioc = std::make_shared<boost::asio::io_context>();
// No client set → SubmitNetwork returns NetworkError → bridge falls back to
// SubmitDirect, which fails (no SGProcessingManager / no valid model) with
// InferenceFailed. Asserting InferenceFailed (not NetworkError) proves the
// fallback to SubmitDirect actually ran — a regression that returned the
// initial NetworkError without falling back would fail this assertion.
auto result = bridge.SubmitJob( kModelUri, kInputUri, sgns::InputFormat::FLOAT32, { 1, 512 }, ioc );
ASSERT_FALSE( result.has_value() );
EXPECT_EQ( result.error(), Error::InferenceFailed );
}
TEST( SGConnectivity, SubmitJobDirectModeDoesNotRequireClient )
{
SGProcessingBridge::Config cfg;
cfg.m_networkMode = false; // direct mode — never touches SubmitNetwork
SGProcessingBridge bridge( cfg );
auto ioc = std::make_shared<boost::asio::io_context>();
// Direct mode may fail (SGProcessingManager unavailable) but must not crash.
auto result = bridge.SubmitJob( kModelUri, kInputUri, sgns::InputFormat::FLOAT32, { 1, 512 }, ioc );
ASSERT_FALSE( result.has_value() );
}
TEST( SGConnectivity, SetClientNullptrDoesNotCrash )
{
SGProcessingBridge bridge;
bridge.SetClient( nullptr );
SUCCEED();
}
TEST( SGConnectivity, SubmitJobInvalidSchemaDoesNotAttemptDispatch )
{
// Empty model URI fails BuildSchemaJson before any network/direct dispatch.
SGProcessingBridge::Config cfg;
cfg.m_networkMode = true;
SGProcessingBridge bridge( cfg );
auto ioc = std::make_shared<boost::asio::io_context>();
auto result = bridge.SubmitJob( "", kInputUri, sgns::InputFormat::FLOAT32, { 1, 512 }, ioc );
ASSERT_FALSE( result.has_value() );
EXPECT_EQ( result.error(), Error::InvalidArgument );
}
Updated on 2026-10-09 at 03:59:42 +0000