Skip to content

Commit

Permalink
refactor(test): refactor bulk load function test (apache#1616)
Browse files Browse the repository at this point in the history
apache#887

There is no functional changes, but only refactor the bulk_load function test.
  • Loading branch information
acelyc111 authored Sep 21, 2023
1 parent 625cebc commit 42136fa
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 166 deletions.
12 changes: 2 additions & 10 deletions src/block_service/local/local_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
// under the License.

#include <errno.h>
#include <nlohmann/json.hpp>
#include <algorithm>
#include <fstream>
#include <initializer_list>
#include <istream>
#include <memory>
#include <set>
#include <type_traits>
#include <utility>

#include "local_service.h"
#include "nlohmann/detail/macro_scope.hpp"
#include "nlohmann/json.hpp"
#include "nlohmann/json_fwd.hpp"
#include "runtime/task/async_calls.h"
#include "utils/autoref_ptr.h"
Expand All @@ -52,13 +51,6 @@ namespace block_service {

DEFINE_TASK_CODE(LPC_LOCAL_SERVICE_CALL, TASK_PRIORITY_COMMON, THREAD_POOL_BLOCK_SERVICE)

struct file_metadata
{
uint64_t size;
std::string md5;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(file_metadata, size, md5)

bool file_metadata_from_json(std::ifstream &fin, file_metadata &fmeta) noexcept
{
std::string data;
Expand Down
10 changes: 10 additions & 0 deletions src/block_service/local/local_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#pragma once

#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/json.hpp> // IWYU pragma: keep
#include <nlohmann/json_fwd.hpp> // IWYU pragma: keep
#include <stdint.h>
#include <string>
#include <vector>
Expand All @@ -32,6 +35,13 @@ class task_tracker;
namespace dist {
namespace block_service {

struct file_metadata
{
int64_t size = 0;
std::string md5;
};
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(file_metadata, size, md5)

class local_service : public block_filesystem
{
public:
Expand Down
1 change: 1 addition & 0 deletions src/block_service/test/local_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <nlohmann/json_fwd.hpp>
#include <fstream>
#include <initializer_list>
#include <stdexcept>
#include <vector>

#include "block_service/local/local_service.h"
Expand Down
4 changes: 4 additions & 0 deletions src/meta/meta_bulk_load_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ struct bulk_load_info
int32_t app_id;
std::string app_name;
int32_t partition_count;
bulk_load_info(int32_t id = 0, const std::string &name = "", int32_t pcount = 0)
: app_id(id), app_name(name), partition_count(pcount)
{
}
DEFINE_JSON_SERIALIZATION(app_id, app_name, partition_count)
};

Expand Down
3 changes: 2 additions & 1 deletion src/test/function_test/bulk_load/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ set(MY_PROJ_LIBS
gssapi_krb5
krb5
function_test_utils
)
rocksdb
test_utils)

set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

Expand Down
Loading

0 comments on commit 42136fa

Please sign in to comment.