Jump to content

How to do automated testing on servers?


photo

Recommended Posts

Posted

Hi all,
we are trying to setup automated testing for our UnigineBased application with the goal. The tests need to executed in a server/Docker environment.
Do you have any recommendation how to do that? I have the following code that runs fine locally, but runs into a time out on the server:
 

#define PREPARE_UNGIGINE(name)                                                                     \
    auto working_directory = std::filesystem::current_path();                                      \
    std::vector<std::string> commandline;                                                          \
    commandline.emplace_back("-sound_app");                                                        \
    commandline.emplace_back("null");                                                              \
    commandline.emplace_back("-log_stdout");                                                       \
    commandline.emplace_back("0");                                                                 \
    commandline.emplace_back("-log_file");                                                         \
    commandline.emplace_back("0");                                                                 \
    commandline.emplace_back("-data_path");                                                        \
    commandline.emplace_back(GetPathToTestFile("data"));                                           \
    commandline.emplace_back("-console_command");                                                  \
    commandline.emplace_back("world_load " + GetPathToTestFile("data/unit_tests.world"));          \
    std::vector<char*> charVec;                                                                    \
    charVec.reserve(commandline.size());                                                           \
    for (const std::string& str : commandline)                                                     \
    {                                                                                              \
        charVec.push_back(const_cast<char*>(str.c_str()));                                         \
    }                                                                                              \
    Unigine::Engine::InitParameters initparams;                                                    \
    initparams.window_title = name;                                                                \
    auto engine             = Unigine::EnginePtr(initparams, (int)charVec.size(), charVec.data()); \
    std::filesystem::current_path(working_directory);                                              \
    REQUIRE(std::filesystem::current_path() == working_directory);                                 \
    REQUIRE(Unigine::Materials::findManualMaterial("Unigine::mesh_base") != nullptr);              \
    auto world = std::make_shared<Helper::AppWorldLogic>();                                        \
    engine->addWorldLogic(world.get());                                                            \
    engine->iterate(); // first iteration required before adding new meshes to prevent crashes


TEST_CASE("Unigine")
{
    const std::string title = "Test";
    PREPARE_UNGIGINE(title.c_str());

    int num = Unigine::Displays::getNum();
    REQUIRE(num >= 0);

    engine.shutdown();
}

Note: we are use Catch2 as testing environment.

Any recommendation is appreciated.
Best regards
Michael

Posted

Hi Michael,

If your tests are capable of running without a GPU, you’ll also need to specify the -video_app null parameter when starting the engine. This way, even if no GPU is available in the Docker container, you should still be able to launch the engine.

Please note that Unigine::Displays::getNum() likely won’t return any meaningful data in a default Docker environment.

If your tests do require a GPU, you can refer to our recommendations for setting up a Docker image with GPU support:

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...