1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

add verbose optio in testS3Connection

This commit is contained in:
mariadb-KristinaPavlova
2025-06-12 15:08:56 +03:00
committed by Leonid Fedorov
parent 780e34680f
commit dcdfb9d018
5 changed files with 34 additions and 17 deletions

View File

@ -93,7 +93,7 @@ columnstore_link(unit_tests storagemanager)
columnstore_executable(testS3Connection src/testS3Connection.cpp) columnstore_executable(testS3Connection src/testS3Connection.cpp)
target_compile_definitions(testS3Connection PUBLIC BOOST_NO_CXX11_SCOPED_ENUMS) target_compile_definitions(testS3Connection PUBLIC BOOST_NO_CXX11_SCOPED_ENUMS)
columnstore_link(testS3Connection storagemanager) columnstore_link(testS3Connection storagemanager boost_program_options)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TMPDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TMPDIR})

View File

@ -112,7 +112,7 @@ S3Storage::ScopedConnection::~ScopedConnection()
s3->returnConnection(conn); s3->returnConnection(conn);
} }
S3Storage::S3Storage(bool skipRetry) : skipRetryableErrors(skipRetry) S3Storage::S3Storage(bool skipRetry, bool verbose) : skipRetryableErrors(skipRetry), verbose_enabled(verbose)
{ {
/* Check creds from envvars /* Check creds from envvars
Get necessary vars from config Get necessary vars from config
@ -225,7 +225,7 @@ S3Storage::S3Storage(bool skipRetry) : skipRetryableErrors(skipRetry)
} }
ms3_library_init(); ms3_library_init();
if (libs3_debug == "enabled") if (verbose_enabled || libs3_debug == "enabled")
{ {
ms3_debug(1); ms3_debug(1);
} }

View File

@ -32,7 +32,7 @@ namespace storagemanager
class S3Storage : public CloudStorage class S3Storage : public CloudStorage
{ {
public: public:
explicit S3Storage(bool skipRetry = false); explicit S3Storage(bool skipRetry = false, bool verbose = false);
~S3Storage() override; ~S3Storage() override;
@ -57,6 +57,7 @@ class S3Storage : public CloudStorage
void returnConnection(std::shared_ptr<Connection> conn); void returnConnection(std::shared_ptr<Connection> conn);
bool skipRetryableErrors; bool skipRetryableErrors;
bool verbose_enabled;
std::string bucket; // might store this as a char *, since it's only used that way std::string bucket; // might store this as a char *, since it's only used that way
std::string prefix; std::string prefix;

View File

@ -20,23 +20,26 @@
#include <iostream> #include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <boost/program_options.hpp>
using namespace storagemanager; using namespace storagemanager;
using namespace std; using namespace std;
namespace po = boost::program_options;
void printUsage() void printUsage(const po::options_description& desc)
{ {
cout << "MariaDB Columnstore Storage Manager Test Configuration Connectivity.\n" << endl; cout << "MariaDB Columnstore Storage Manager Test Configuration Connectivity.\n" << endl;
cout << "Usage: testS3Connection \n" << endl; cout << "Usage: testS3Connection \n" << endl;
cout<< desc <<endl;
cout << "Returns Success=0 Failure=1\n" << endl; cout << "Returns Success=0 Failure=1\n" << endl;
} }
int s3TestConnection() int s3TestConnection(bool verbose)
{ {
S3Storage* s3 = NULL; S3Storage* s3 = NULL;
int ret = 0; int ret = 0;
try try
{ {
S3Storage* s3 = new S3Storage(true); S3Storage* s3 = new S3Storage(true, verbose);
cout << "S3 Storage Manager Configuration OK" << endl; cout << "S3 Storage Manager Configuration OK" << endl;
delete s3; delete s3;
} }
@ -53,17 +56,30 @@ int s3TestConnection()
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int option; try
while ((option = getopt(argc, argv, "h")) != EOF)
{ {
switch (option) //define options
po::options_description desc("Options");
desc.add_options ()
("help,h", "Print help message")
("verbose,v", po::value<bool>()->default_value(false), "Enable verbose output");
// Parse command line
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if(vm.count("help"))
{ {
case 'h': printUsage (desc);
default: return 0;
printUsage();
return 0;
break;
} }
// Run the test with verbose flag
return s3TestConnection(vm["verbose"].as<bool>());
} }
return s3TestConnection(); catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
} }