Upgrade brpc to 0.9.5 (#1243)

Change some ut
This commit is contained in:
ZHAO Chun
2019-06-04 11:13:23 +08:00
committed by Mingyu Chen
parent ae75e44e05
commit bedd94dca2
8 changed files with 57 additions and 43 deletions

View File

@ -35,7 +35,8 @@ public:
}
void SetUp() {
system("rm tmp_file");
system("mkdir -p ./ut_dir/");
system("rm ./ut_dir/tmp_file");
_out_stream = new (std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
ASSERT_TRUE(_out_stream != NULL);
_writer = new (std::nothrow) BitFieldWriter(_out_stream);
@ -52,13 +53,13 @@ public:
}
void CreateReader() {
ASSERT_EQ(OLAP_SUCCESS, _helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, _helper.open_with_mode(_file_path.c_str(),
O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IWUSR));
_out_stream->write_to_file(&_helper, 0);
_helper.close();
ASSERT_EQ(OLAP_SUCCESS, _helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, _helper.open_with_mode(_file_path.c_str(),
O_RDONLY, S_IRUSR | S_IWUSR));
_shared_buffer = StorageByteBuffer::create(
@ -87,6 +88,8 @@ public:
StorageByteBuffer* _shared_buffer;
ReadOnlyFileStream* _stream;
OlapReaderStatistics _stats;
std::string _file_path = "./ut_dir/tmp_file";
};
TEST_F(TestBitField, ReadWriteOneBit) {

View File

@ -130,10 +130,11 @@ public:
ASSERT_TRUE(_column_reader != NULL);
system("rm ./tmp_file");
system("mkdir -p ./ut_dir");
system("rm ./ut_dir/tmp_file");
ASSERT_EQ(OLAP_SUCCESS,
helper.open_with_mode("tmp_file",
helper.open_with_mode("./ut_dir/tmp_file",
O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IWUSR));
std::vector<int> off;
@ -177,7 +178,7 @@ public:
}
helper.close();
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("./ut_dir/tmp_file",
O_RDONLY, S_IRUSR | S_IWUSR));
_shared_buffer = StorageByteBuffer::create(

View File

@ -19,21 +19,19 @@
#include <sstream>
#include <fstream>
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <gtest/gtest.h>
#include <boost/filesystem.hpp>
#include <json2pb/json_to_pb.h>
#include "olap/store.h"
#include "olap/olap_header_manager.h"
#include "olap/olap_define.h"
#include "boost/filesystem.hpp"
#include "json2pb/json_to_pb.h"
#include "util/file_utils.h"
#ifndef BE_TEST
#define BE_TEST
#endif
using ::testing::_;
using ::testing::Return;
using ::testing::SetArgPointee;
using std::string;
namespace doris {
@ -43,13 +41,14 @@ const std::string header_path = "./be/test/olap/test_data/header.txt";
class OlapHeaderManagerTest : public testing::Test {
public:
virtual void SetUp() {
std::string root_path = "./store";
ASSERT_TRUE(boost::filesystem::create_directory(root_path));
_store = new(std::nothrow) OlapStore(root_path);
_root_path = "./ut_dir/olap_header_mgr_test";
FileUtils::remove_all(_root_path);
FileUtils::create_dir(_root_path);
_store = new(std::nothrow) OlapStore(_root_path);
ASSERT_NE(nullptr, _store);
Status st = _store->load();
ASSERT_TRUE(st.ok());
ASSERT_TRUE(boost::filesystem::exists("./store/meta"));
ASSERT_TRUE(boost::filesystem::exists(_root_path + "/meta"));
std::ifstream infile(header_path);
char buffer[1024];
@ -64,10 +63,11 @@ public:
virtual void TearDown() {
delete _store;
ASSERT_TRUE(boost::filesystem::remove_all("./store"));
ASSERT_TRUE(boost::filesystem::remove_all(_root_path));
}
private:
std::string _root_path;
OlapStore* _store;
std::string _json_header;
};

View File

@ -18,19 +18,17 @@
#include <string>
#include <sstream>
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include <gtest/gtest.h>
#include <boost/filesystem.hpp>
#include "olap/olap_meta.h"
#include "olap/olap_define.h"
#include "boost/filesystem.hpp"
#include "util/file_utils.h"
#ifndef BE_TEST
#define BE_TEST
#endif
using ::testing::_;
using ::testing::Return;
using ::testing::SetArgPointee;
using std::string;
namespace doris {
@ -38,25 +36,29 @@ namespace doris {
class OlapMetaTest : public testing::Test {
public:
virtual void SetUp() {
std::string root_path = "./";
_meta = new OlapMeta(root_path);
_root_path = "./ut_dir/olap_meta_test";
FileUtils::remove_all(_root_path);
FileUtils::create_dir(_root_path);
_meta = new OlapMeta(_root_path);
OLAPStatus s = _meta->init();
ASSERT_EQ(OLAP_SUCCESS, s);
ASSERT_TRUE(boost::filesystem::exists("./meta"));
ASSERT_TRUE(boost::filesystem::exists(_root_path + "/meta"));
}
virtual void TearDown() {
delete _meta;
ASSERT_TRUE(boost::filesystem::remove_all("./meta"));
FileUtils::remove_all(_root_path);
}
private:
std::string _root_path;
OlapMeta* _meta;
};
TEST_F(OlapMetaTest, TestGetRootPath) {
std::string root_path = _meta->get_root_path();
ASSERT_EQ("./", root_path);
ASSERT_EQ("./ut_dir/olap_meta_test", root_path);
}
TEST_F(OlapMetaTest, TestPutAndGet) {

View File

@ -664,7 +664,8 @@ public:
}
virtual void SetUp() {
system("rm tmp_file");
system("mkdir -p ./ut_dir");
system("rm -rf ./ut_dir/tmp_file");
_out_stream = new (std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
ASSERT_TRUE(_out_stream != NULL);
_writer = new (std::nothrow) RunLengthByteWriter(_out_stream);
@ -680,12 +681,12 @@ public:
}
void CreateReader() {
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR));
_out_stream->write_to_file(&helper, 0);
helper.close();
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_RDONLY, S_IRUSR | S_IWUSR));
_shared_buffer = StorageByteBuffer::create(
@ -713,6 +714,8 @@ public:
StorageByteBuffer* _shared_buffer;
ReadOnlyFileStream* _stream;
OlapReaderStatistics _stats;
std::string _file_path = "./ut_dir/tmp_file";
};

View File

@ -37,7 +37,8 @@ public:
}
virtual void SetUp() {
system("rm tmp_file");
system("mkdir -p ./ut_dir");
system("rm -rf ./ut_dir/tmp_file");
_out_stream = new (std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
ASSERT_TRUE(_out_stream != NULL);
_writer = new (std::nothrow) RunLengthIntegerWriter(_out_stream, false);
@ -54,12 +55,12 @@ public:
}
void CreateReader() {
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR));
_out_stream->write_to_file(&helper, 0);
helper.close();
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_RDONLY, S_IRUSR | S_IWUSR));
_shared_buffer = StorageByteBuffer::create(
@ -87,6 +88,8 @@ public:
StorageByteBuffer* _shared_buffer;
ReadOnlyFileStream* _stream;
OlapReaderStatistics _stats;
std::string _file_path = "./ut_dir/tmp_file";
};
@ -350,7 +353,8 @@ public:
}
virtual void SetUp() {
system("rm tmp_file");
system("mkdir -p ./ut_dir");
system("rm ./ut_dir/tmp_file");
_out_stream = new (std::nothrow) OutStream(OLAP_DEFAULT_COLUMN_STREAM_BUFFER_SIZE, NULL);
ASSERT_TRUE(_out_stream != NULL);
_writer = new (std::nothrow) RunLengthIntegerWriter(_out_stream, false);
@ -366,12 +370,12 @@ virtual void SetUp() {
}
void CreateReader() {
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR));
_out_stream->write_to_file(&helper, 0);
helper.close();
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode("tmp_file",
ASSERT_EQ(OLAP_SUCCESS, helper.open_with_mode(_file_path.c_str(),
O_RDONLY, S_IRUSR | S_IWUSR));
_shared_buffer = StorageByteBuffer::create(
@ -399,6 +403,7 @@ virtual void SetUp() {
StorageByteBuffer* _shared_buffer;
ReadOnlyFileStream* _stream;
OlapReaderStatistics _stats;
std::string _file_path = "./ut_dir/tmp_file";
};

View File

@ -489,7 +489,7 @@ build_brpc() {
rm -rf CMakeCache.txt CMakeFiles/
LDFLAGS="-L${TP_LIB_DIR} -static-libstdc++ -static-libgcc" \
$CMAKE_CMD -v -DBUILD_SHARED_LIBS=0 -DCMAKE_INSTALL_PREFIX=$TP_INSTALL_DIR \
-DBRPC_WITH_GLOG=ON -DCMAKE_INCLUDE_PATH="$TP_INSTALL_DIR/include" \
-DBRPC_WITH_GLOG=ON -DWITH_GLOG=ON -DCMAKE_INCLUDE_PATH="$TP_INSTALL_DIR/include" \
-DCMAKE_LIBRARY_PATH="$TP_INSTALL_DIR/lib;$TP_INSTALL_DIR/lib64" \
-DPROTOBUF_PROTOC_EXECUTABLE=$TP_INSTALL_DIR/bin/protoc \
-DProtobuf_PROTOC_EXECUTABLE=$TP_INSTALL_DIR/bin/protoc ..

8
thirdparty/vars.sh vendored
View File

@ -194,10 +194,10 @@ LEVELDB_SOURCE=leveldb-1.20
LEVELDB_MD5SUM="298b5bddf12c675d6345784261302252"
# brpc
BRPC_DOWNLOAD="https://github.com/apache/incubator-brpc/archive/v0.9.0.tar.gz"
BRPC_NAME=incubator-brpc-0.9.0.tar.gz
BRPC_SOURCE=incubator-brpc-0.9.0
BRPC_MD5SUM="79dfdc8b6e2d7a08dc68f14c5fabe6b7"
BRPC_DOWNLOAD="https://github.com/apache/incubator-brpc/archive/0.9.5.tar.gz"
BRPC_NAME=incubator-brpc-0.9.5.tar.gz
BRPC_SOURCE=incubator-brpc-0.9.5
BRPC_MD5SUM="c9f46e4c97a9cd5f836ba2c6c56978dd"
# rocksdb
ROCKSDB_DOWNLOAD="https://github.com/facebook/rocksdb/archive/v5.14.2.tar.gz"