Commit f839774d authored by jan.koester's avatar jan.koester
Browse files

test

parent 6d1ed8f7
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -3224,11 +3224,9 @@ void ClusterMediaBackend::replicate_index(bool force) {
    if (buf.empty()) return;

    if (!force) {
        // Safety: don't push an empty index, and don't push if this node
        // hasn't completed initial sync yet (could overwrite a good index).
        // Safety: never push an empty index (would erase data on other nodes).
        auto local_count = local_.store_ids().size();
        if (local_count == 0) return;
        if (!initial_sync_ok_.load()) return;
    }

    cluster_.replicate("index", buf.data(), buf.size());
+30 −1
Original line number Diff line number Diff line
@@ -876,8 +876,37 @@ TEST(preview_generate_and_cache) {
// ═══════════════════════════════════════════════════════════

TEST(cluster_import_roundtrip) {
    auto tc = makeCluster();
    // Use different ports to avoid conflicts with other tests
    static constexpr int IMPORT_BASE_PORT = 14533;
    auto tc = std::make_unique<TestCluster>();
    tc->certs = generateTestCerts(tc->tmp.path());

    std::vector<ClusterNode> peers;
    for (size_t i = 0; i < NUM_NODES; i++) {
        peers.push_back({"127.0.0.1", IMPORT_BASE_PORT + static_cast<int>(i)});
    }
    for (size_t i = 0; i < NUM_NODES; i++) {
        auto n = std::make_unique<Cluster>();
        ClusterConfig cfg;
        cfg.enabled = true;
        cfg.peers = peers;
        cfg.bind_address = "0.0.0.0";
        cfg.port = IMPORT_BASE_PORT + static_cast<int>(i);
        cfg.cert_file = tc->certs.cert_path;
        cfg.key_file = tc->certs.key_path;
        cfg.store_path = (tc->tmp.path() / ("import_node_" + std::to_string(i))).string();
        cfg.data_blocks = DATA_BLOCKS;
        cfg.parity_blocks = PARITY_BLOCKS;
        fs::create_directories(cfg.store_path);
        n->init(cfg);
        n->start();
        tc->nodes.push_back(std::move(n));
    }
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));

    // Wait until all nodes are online
    auto& node = *tc->nodes[0];
    node.waitForPeers(10);

    BlobCache cache1(64 * 1024 * 1024, blob_value_size);
    ClusterMediaBackend src(node, cache1);