Commit 2277bef1 authored by Ramon Nou's avatar Ramon Nou
Browse files

Big tests, missing directories yet

parent d342ef6b
Loading
Loading
Loading
Loading
Loading
+119 −0
Original line number Diff line number Diff line
@@ -449,6 +449,125 @@ SCENARIO("Posix writes", "[flex_stager][posix_writes]") {
    }
}

SCENARIO("Big POSIX reads", "[flex_stager][Big_posix_reads]") {

    random_data_generator rng{catch2_seed, 0,
                              std::numeric_limits<std::uint64_t>::max() - 1u};

    GIVEN("Some input datasets from a PFS") {

        REQUIRE(!server_address.empty());

        cargo::server server{server_address};

        const auto sources =
                prepare_datasets(cargo::dataset::type::posix,
                                 "pxbr-source-dataset-{}", NDATASETS);
        const auto targets = prepare_datasets(
                cargo::dataset::type::posix, "pxbr-target-dataset-{}", NDATASETS);

        static std::vector<scoped_file> input_files;
        input_files.reserve(sources.size());

        for(const auto& d : sources) {
            input_files.emplace_back(
                    create_temporary_file(d.path(), 720*1024, rng));
        }

        // ensure there are no dangling output files from another test run
        std::for_each(targets.begin(), targets.end(), [](auto&& dataset) {
            std::filesystem::remove(dataset.path());
        });


        WHEN("Transferring datasets to a POSIX storage system") {
            const auto tx = cargo::transfer_datasets(server, sources, targets);

            // wait for the transfer to complete
            auto s = tx.wait();

            CAPTURE(s.error());
            REQUIRE(s.state() == cargo::transfer_state::completed);
            REQUIRE(s.error() == cargo::error_code::success);

            THEN("Output datasets are identical to input datasets") {

                std::vector<scoped_file> output_files;
                std::transform(targets.cbegin(), targets.cend(),
                               std::back_inserter(output_files),
                               [](auto&& target) {
                                   return scoped_file{target.path()};
                               });

                for(std::size_t i = 0; i < input_files.size(); ++i) {
                    REQUIRE(std::filesystem::exists(output_files[i].path()));
                    REQUIRE(::equal(input_files[i].path(),
                                    output_files[i].path()));
                }
            }
        }
    }
}

SCENARIO("Big Posix writes", "[flex_stager][big_posix_writes]") {

    std::size_t file_size = 712*1024; // GENERATE(1000, 10000);

    [[maybe_unused]] ascii_data_generator ascii_gen{512};
    [[maybe_unused]] random_data_generator rng{
            catch2_seed, 0, std::numeric_limits<std::uint64_t>::max() - 1u};

    GIVEN("Some input datasets from a POSIX storage system") {

        REQUIRE(!server_address.empty());

        cargo::server server{server_address};

        const auto sources = prepare_datasets(
                cargo::dataset::type::posix, "pxbw-source-dataset-{}", NDATASETS);
        const auto targets =
                prepare_datasets(cargo::dataset::type::parallel,
                                 "pxbw-target-dataset-{}", NDATASETS);

        static std::vector<scoped_file> input_files;
        input_files.reserve(sources.size());

        for(const auto& d : sources) {
            input_files.emplace_back(
                    create_temporary_file(d.path(), file_size, rng));
        }

        // ensure there are no danling output files from another test run
        std::for_each(targets.begin(), targets.end(), [](auto&& dataset) {
            std::filesystem::remove(dataset.path());
        });

        WHEN("Transferring datasets to a PFS") {
            const auto tx = cargo::transfer_datasets(server, sources, targets);

            // wait for the transfer to complete
            auto s = tx.wait();

            CAPTURE(s.error());
            REQUIRE(s.state() == cargo::transfer_state::completed);
            REQUIRE(s.error() == cargo::error_code::success);

            THEN("Output datasets are identical to input datasets") {

                std::vector<scoped_file> output_files;
                std::transform(targets.cbegin(), targets.cend(),
                               std::back_inserter(output_files),
                               [](auto&& target) {
                                   return scoped_file{target.path()};
                               });

                for(std::size_t i = 0; i < input_files.size(); ++i) {
                    REQUIRE(::equal(input_files[i].path(), targets[i].path()));
                }
            }
        }
    }
}

int
main(int argc, char* argv[]) {