Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.0 -> main] make resource monitor plugin tests deterministic by using fixed fc::temp_directory instead of dynamic /tmp #1828

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions plugins/resource_monitor_plugin/test/test_resmon_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,31 @@ BOOST_AUTO_TEST_SUITE(resmon_plugin_tests)

BOOST_FIXTURE_TEST_CASE(startupNormal, resmon_fixture)
{
BOOST_REQUIRE_NO_THROW( plugin_startup({"/tmp"}));
// do not use native "/tmp", as subdirectories in /tmp on test machine
// can be removed during a test run, causing file_space_handler::add_file_system
// to assert when doing get_stat on a removed directory
fc::temp_directory temp_dir;
BOOST_REQUIRE_NO_THROW(plugin_startup({temp_dir.path()}));
}

BOOST_FIXTURE_TEST_CASE(startupDuplicateDirs, resmon_fixture)
{
BOOST_REQUIRE_NO_THROW( plugin_startup({"/tmp", "/tmp"}));
fc::temp_directory temp_dir;
BOOST_REQUIRE_NO_THROW(plugin_startup({temp_dir.path(), temp_dir.path()}));
}

BOOST_FIXTURE_TEST_CASE(startupMultDirs, resmon_fixture)
{
// Under "/" are multiple file systems
BOOST_REQUIRE_NO_THROW( plugin_startup({"/", "/tmp"}));
fc::temp_directory temp_dir_1;
fc::temp_directory temp_dir_2;
BOOST_REQUIRE_NO_THROW(plugin_startup({temp_dir_1.path(), temp_dir_2.path()}));
}

BOOST_FIXTURE_TEST_CASE(startupNoExistingDirs, resmon_fixture)
{
// "hsdfgd983" a random file and not existing
BOOST_REQUIRE_THROW( plugin_startup({"/tmp", "hsdfgd983"}), chain::plugin_config_exception);
}

BOOST_FIXTURE_TEST_CASE(startupLongRun, resmon_fixture)
{
BOOST_REQUIRE_NO_THROW( plugin_startup({"/tmp"}, 5));
fc::temp_directory temp_dir;
// temp_dir/hsdfgd983 does not exist in a just created temp directory
BOOST_REQUIRE_THROW(plugin_startup({temp_dir.path(), temp_dir.path() / "hsdfgd983"}), chain::plugin_config_exception);
}

BOOST_FIXTURE_TEST_CASE(warningIntervalTooBig, resmon_fixture)
Expand Down