test: Auto-skip object-storage test cases if run from shell

In case an sstable unit test case is run individually, it would fail
with exception saying that S3_... environment is not set. It's better to
skip the test-case rather than fail. If someone wants to run it from
shell, it will have to prepare S3 server (minio/AWS public bucket) and
provide proper environment for the test-case.

refs: #13569

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>

Closes #13755
This commit is contained in:
Pavel Emelyanov
2023-05-03 11:46:02 +03:00
committed by Botond Dénes
parent e7c9ca560b
commit fe70333c19
6 changed files with 20 additions and 4 deletions

View File

@@ -1909,7 +1909,7 @@ with open(buildfile, 'w') as f:
if binary not in tests_not_using_seastar_test_framework:
local_libs += ' ' + "$seastar_testing_libs_{}".format(mode)
else:
local_libs += ' ' + '-lgnutls'
local_libs += ' ' + '-lgnutls' + ' ' + '-lboost_unit_test_framework'
# Our code's debugging information is huge, and multiplied
# by many tests yields ridiculous amounts of disk space.
# So we strip the tests by default; The user can very

View File

@@ -1032,6 +1032,7 @@ async def run_test(test: Test, options: argparse.Namespace, gentle_kill=False, e
# TMPDIR env variable is used by any seastar/scylla
# test for directory to store test temporary data.
TMPDIR=os.path.join(options.tmpdir, test.mode),
SCYLLA_TEST_ENV='yes',
**env,
),
preexec_fn=os.setsid,

View File

@@ -60,6 +60,7 @@
#include "test/lib/reader_concurrency_semaphore.hh"
#include "test/lib/sstable_utils.hh"
#include "test/lib/random_utils.hh"
#include "test/lib/test_utils.hh"
#include "readers/from_mutations_v2.hh"
#include "readers/from_fragments_v2.hh"
#include "test/lib/random_schema.hh"
@@ -301,7 +302,7 @@ SEASTAR_TEST_CASE(datafile_generation_16) {
return test_datafile_generation_16({});
}
SEASTAR_TEST_CASE(datafile_generation_16_s3) {
SEASTAR_TEST_CASE(datafile_generation_16_s3, *boost::unit_test::precondition(tests::has_scylla_test_env)) {
return test_datafile_generation_16(test_env_config{ .storage = make_test_object_storage_options() });
}

View File

@@ -19,6 +19,7 @@
#include "test/lib/key_utils.hh"
#include "test/lib/sstable_utils.hh"
#include "test/lib/test_services.hh"
#include "test/lib/test_utils.hh"
#include "service/storage_proxy.hh"
#include "db/config.hh"
@@ -143,7 +144,7 @@ SEASTAR_TEST_CASE(sstable_resharding_test) {
});
}
SEASTAR_TEST_CASE(sstable_resharding_over_s3_test) {
SEASTAR_TEST_CASE(sstable_resharding_over_s3_test, *boost::unit_test::precondition(tests::has_scylla_test_env)) {
return sstables::test_env::do_with_async([] (auto& env) {
run_sstable_resharding_test(env);
}, test_env_config{ .storage = make_test_object_storage_options() });

View File

@@ -51,6 +51,17 @@ void fail(std::string_view msg, std::source_location sl) {
throw_with_backtrace<std::runtime_error>(format_msg(__FUNCTION__, false, sl, msg));
}
extern boost::test_tools::assertion_result has_scylla_test_env(boost::unit_test::test_unit_id) {
if (::getenv("SCYLLA_TEST_ENV")) {
return true;
}
testlog.info("Test environment is not configured. "
"Check test/pylib/minio_server.py for an example of how to configure the environment for it to run.");
return false;
}
}
sstring make_random_string(size_t size) {

View File

@@ -11,7 +11,7 @@
#include <source_location>
#include "utils/source_location-compat.hh"
#include <string>
#include <boost/test/unit_test.hpp>
#include <fmt/format.h>
// Thread safe alternatives to BOOST_REQUIRE_*, BOOST_CHECK_* and BOOST_FAIL().
@@ -55,4 +55,6 @@ inline std::string getenv_safe(std::string_view name) {
return std::string(v);
}
extern boost::test_tools::assertion_result has_scylla_test_env(boost::unit_test::test_unit_id);
}