Skip to content

Commit

Permalink
cloud_storage_clients: add url_style option to s3_test_client
Browse files Browse the repository at this point in the history
Added the option for `url_style` to `s3_test_client_main.cc`,
allowing for testing of both virtual-style and path-style requests.

Also make sure the `url_style` is initialized correctly everywhere
the `s3_configuration` object is created.
  • Loading branch information
WillemKauf committed Apr 18, 2024
1 parent 7ad5b02 commit 080ae70
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/v/archival/tests/archival_metadata_stm_gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ cloud_storage_clients::s3_configuration get_configuration() {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf.disable_metrics = net::metrics_disabled::yes;
conf.disable_public_metrics = net::public_metrics_disabled::yes;
Expand Down
1 change: 1 addition & 0 deletions src/v/archival/tests/archival_metadata_stm_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct archival_metadata_stm_base_fixture
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
2 changes: 2 additions & 0 deletions src/v/archival/tests/archival_service_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "archival/archiver_manager.h"
#include "archival/tests/service_fixture.h"
#include "archival/types.h"
#include "cloud_storage_clients/types.h"
#include "cluster/controller_api.h"
#include "cluster/errc.h"
#include "cluster/fwd.h"
Expand Down Expand Up @@ -59,6 +60,7 @@ class archiver_cluster_fixture
s3_conf.access_key = cloud_roles::public_key_str("access-key");
s3_conf.secret_key = cloud_roles::private_key_str("secret-key");
s3_conf.region = cloud_roles::aws_region_name("us-east-1");
s3_conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
s3_conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
net::public_metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/archival/tests/service_fixture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ archiver_fixture::get_configurations() {
s3conf.access_key = cloud_roles::public_key_str("acess-key");
s3conf.secret_key = cloud_roles::private_key_str("secret-key");
s3conf.region = cloud_roles::aws_region_name("us-east-1");
s3conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
s3conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
net::public_metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage/tests/anomalies_detector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ class bucket_view_fixture : http_imposter_fixture {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage/tests/s3_imposter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ s3_imposter_fixture::get_configuration() {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
20 changes: 17 additions & 3 deletions src/v/cloud_storage_clients/test_client/s3_test_client_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "bytes/iobuf.h"
#include "cloud_storage_clients/s3_client.h"
#include "cloud_storage_clients/s3_error.h"
#include "cloud_storage_clients/types.h"
#include "http/client.h"
#include "syschecks/syschecks.h"

Expand Down Expand Up @@ -76,6 +77,11 @@ void cli_opts(boost::program_options::options_description_easy_init opt) {
po::value<std::string>()->default_value("us-east-1"),
"aws region");

opt(
"url_style",
po::value<std::string>()->default_value("virtual_host"),
"aws addressing style");

opt(
"in",
po::value<std::string>()->default_value(""),
Expand Down Expand Up @@ -120,9 +126,10 @@ struct fmt::formatter<test_conf> : public fmt::formatter<std::string_view> {
// make the output json-able so we can consume it in python for analysis
return formatter<std::string_view>::format(
fmt::format(
"[ 'bucket': '{}', 'objects': ['{}'] ]",
"[ 'bucket': '{}', 'objects': ['{}'], 'path style': {} ]",
cfg.bucket,
fmt::join(cfg.objects, "', '")),
fmt::join(cfg.objects, "', '"),
cfg.client_cfg.url_style),
ctx);
}
};
Expand Down Expand Up @@ -163,6 +170,13 @@ test_conf cfg_from(boost::program_options::variables_map& m) {
}
return std::nullopt;
}(),
.url_style = [&]() -> cloud_storage_clients::s3_url_style {
if (m["url_style"].as<std::string>() == "virtual_host") {
return cloud_storage_clients::s3_url_style::virtual_host;
} else {
return cloud_storage_clients::s3_url_style::path;
}
}(),
.disable_tls = m.contains("disable-tls") > 0,
})
.get0();
Expand Down Expand Up @@ -358,7 +372,7 @@ int main(int args, char** argv, char** env) {
} else {
vlog(
test_log.error,
"DeleteObject request failes: {}",
"DeleteObject request failed: {}",
undeleted.error());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage_clients/tests/client_pool_mt_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static cloud_storage_clients::s3_configuration transport_configuration() {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage_clients/tests/client_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static cloud_storage_clients::s3_configuration transport_configuration() {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage_clients/tests/s3_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static cloud_storage_clients::s3_configuration transport_configuration() {
conf.access_key = cloud_roles::public_key_str("acess-key");
conf.secret_key = cloud_roles::private_key_str("secret-key");
conf.region = cloud_roles::aws_region_name("us-east-1");
conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
conf.server_addr = server_addr;
conf._probe = ss::make_shared<cloud_storage_clients::client_probe>(
net::metrics_disabled::yes,
Expand Down
1 change: 1 addition & 0 deletions src/v/redpanda/tests/fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class redpanda_thread_fixture {
s3conf.access_key = cloud_roles::public_key_str("acess-key");
s3conf.secret_key = cloud_roles::private_key_str("secret-key");
s3conf.region = cloud_roles::aws_region_name("us-east-1");
s3conf.url_style = cloud_storage_clients::s3_url_style::virtual_host;
s3conf.server_addr = server_addr;
return s3conf;
}
Expand Down

0 comments on commit 080ae70

Please sign in to comment.