s3/client: Keep server port on config
Currently the code temporarily assumes that the endpoint port is 9000. This is what tests' local minio is started with. This patch keeps the port number on endpoint config and makes test get the port number from minio starting code via environment. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
1
main.cc
1
main.cc
@@ -159,6 +159,7 @@ template<>
|
||||
struct convert<::object_storage_endpoint_param> {
|
||||
static bool decode(const Node& node, ::object_storage_endpoint_param& ep) {
|
||||
ep.endpoint = node["name"].as<std::string>();
|
||||
ep.config.port = node["port"].as<unsigned>();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
s3::endpoint_config_ptr make_minio_config() {
|
||||
s3::endpoint_config cfg = {
|
||||
.port = std::stoul(tests::getenv_safe("S3_SERVER_PORT_FOR_TEST")),
|
||||
};
|
||||
return make_lw_shared<s3::endpoint_config>(std::move(cfg));
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ std::unordered_map<sstring, s3::endpoint_config_ptr> make_storage_options_config
|
||||
},
|
||||
[&cfg] (const data_dictionary::storage_options::s3& os) mutable -> void {
|
||||
cfg[os.endpoint] = make_lw_shared<s3::endpoint_config>(s3::endpoint_config {
|
||||
.port = std::stoul(tests::getenv_safe("S3_SERVER_PORT_FOR_TEST")),
|
||||
});
|
||||
}
|
||||
}, so.value);
|
||||
@@ -215,7 +216,7 @@ data_dictionary::storage_options make_test_object_storage_options() {
|
||||
data_dictionary::storage_options ret;
|
||||
ret.value = data_dictionary::storage_options::s3 {
|
||||
.bucket = tests::getenv_safe("S3_PUBLIC_BUCKET_FOR_TEST"),
|
||||
.endpoint = format("{}:9000", tests::getenv_safe("S3_SERVER_ADDRESS_FOR_TEST")),
|
||||
.endpoint = tests::getenv_safe("S3_SERVER_ADDRESS_FOR_TEST"),
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ else:
|
||||
test_tempdir = run.pid_to_dir(os.getpid())
|
||||
os.mkdir(test_tempdir)
|
||||
s3_server_address = os.environ['S3_SERVER_ADDRESS_FOR_TEST']
|
||||
s3_server_port = int(os.environ['S3_SERVER_PORT_FOR_TEST'])
|
||||
s3_public_bucket = os.environ['S3_PUBLIC_BUCKET_FOR_TEST']
|
||||
|
||||
def get_tempdir(pid):
|
||||
@@ -33,6 +34,7 @@ with open(test_tempdir + '/object_storage.yaml', 'w') as config_file:
|
||||
yaml.dump({ 'endpoints': [
|
||||
{
|
||||
'name': s3_server_address,
|
||||
'port': s3_server_port,
|
||||
}
|
||||
]
|
||||
}, config_file)
|
||||
@@ -59,7 +61,7 @@ run.wait_for_services(pid, [ lambda: check_cql(ip) ])
|
||||
print(f'Create keyspace (minio listening at {s3_server_address})')
|
||||
cluster = run.get_cql_cluster(ip)
|
||||
conn = cluster.connect()
|
||||
conn.execute("CREATE KEYSPACE test_ks WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': '1' } AND STORAGE = { 'type': 'S3', 'endpoint': '" + f'{s3_server_address}' + ":9000', 'bucket': '" + f'{s3_public_bucket}' + "' };")
|
||||
conn.execute("CREATE KEYSPACE test_ks WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': '1' } AND STORAGE = { 'type': 'S3', 'endpoint': '" + f'{s3_server_address}' + "', 'bucket': '" + f'{s3_public_bucket}' + "' };")
|
||||
conn.execute("CREATE TABLE test_ks.test_cf ( name text primary key, value text );")
|
||||
conn.execute("INSERT INTO test_ks.test_cf ( name, value ) VALUES ('0', 'zero');")
|
||||
conn.execute("INSERT INTO test_ks.test_cf ( name, value ) VALUES ('1', 'one');")
|
||||
|
||||
@@ -53,6 +53,7 @@ class MinioServer:
|
||||
self.address = await self.hosts.lease_host()
|
||||
self.log_file = self.log_filename.open("wb")
|
||||
os.environ['S3_SERVER_ADDRESS_FOR_TEST'] = f'{self.address}'
|
||||
os.environ['S3_SERVER_PORT_FOR_TEST'] = f'{self.port}'
|
||||
os.environ['S3_PUBLIC_BUCKET_FOR_TEST'] = f'{self.bucket_name}'
|
||||
|
||||
self.logger.info(f'Starting minio server at {self.address}:{self.port}')
|
||||
|
||||
@@ -46,7 +46,7 @@ future<> ignore_reply(const http::reply& rep, input_stream<char>&& in_) {
|
||||
client::client(std::string host, endpoint_config_ptr cfg, private_tag)
|
||||
: _host(std::move(host))
|
||||
, _cfg(std::move(cfg))
|
||||
, _http(ipv4_addr(_host, 9000 /* temporary hard-coded */))
|
||||
, _http(ipv4_addr(_host, _cfg->port))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace s3 {
|
||||
|
||||
struct endpoint_config {
|
||||
unsigned port;
|
||||
};
|
||||
|
||||
using endpoint_config_ptr = seastar::lw_shared_ptr<endpoint_config>;
|
||||
|
||||
Reference in New Issue
Block a user