提交 4f40b15c 编写于 作者: W wgs13579 提交者: guangshu.wgs

code format for variable+equal

上级 2d514853
...@@ -81,9 +81,6 @@ bool CNetUtil::isLocalAddr(uint32_t ip, bool loopSkip) ...@@ -81,9 +81,6 @@ bool CNetUtil::isLocalAddr(uint32_t ip, bool loopSkip)
return false; return false;
} }
/**
* 10.0.100.89 => 1499725834
*/
uint32_t CNetUtil::getAddr(const char *ip) uint32_t CNetUtil::getAddr(const char *ip)
{ {
if (ip == NULL) return 0; if (ip == NULL) return 0;
......
...@@ -511,10 +511,7 @@ inline bool ops_is_ip_private(const sockaddr &ip) ...@@ -511,10 +511,7 @@ inline bool ops_is_ip_private(const sockaddr &ip)
bool zret = false; bool zret = false;
if (ops_is_ip4(ip)) { if (ops_is_ip4(ip)) {
in_addr_t a = ops_ip4_addr_cast(ip); in_addr_t a = ops_ip4_addr_cast(ip);
zret = ((a & htonl(0xFF000000)) == htonl(0x0A000000)) // 10.0.0.0/8 zret = ((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)); // 192.168.0.0/16
|| ((a & htonl(0xFFC00000)) == htonl(0x64400000)) // 100.64.0.0/10
|| ((a & htonl(0xFFF00000)) == htonl(0xAC100000)) // 172.16.0.0/12
|| ((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)); // 192.168.0.0/16
} else if (ops_is_ip6(ip)) { } else if (ops_is_ip6(ip)) {
in6_addr a = ops_ip6_addr_cast(ip); in6_addr a = ops_ip6_addr_cast(ip);
zret = ((a.s6_addr[0] & 0xFE) == 0xFC); // fc00::/7 zret = ((a.s6_addr[0] & 0xFE) == 0xFC); // fc00::/7
...@@ -527,26 +524,6 @@ inline bool ops_is_ip_private(const ObIpEndpoint &ip) ...@@ -527,26 +524,6 @@ inline bool ops_is_ip_private(const ObIpEndpoint &ip)
return ops_is_ip_private(ip.sa_); return ops_is_ip_private(ip.sa_);
} }
// Check for Link Local.
// @return @true if ip is link local.
inline bool ops_is_ip_linklocal(const sockaddr &ip)
{
bool zret = false;
if (ops_is_ip4(ip)) {
in_addr_t a = ops_ip4_addr_cast(ip);
zret = ((a & htonl(0xFFFF0000)) == htonl(0xA9FE0000)); // 169.254.0.0/16
} else if (ops_is_ip6(ip)) {
in6_addr a = ops_ip6_addr_cast(ip);
zret = ((a.s6_addr[0] == 0xFE) && ((a.s6_addr[1] & 0xC0) == 0x80)); // fe80::/10
}
return zret;
}
inline bool ops_is_ip_linklocal(const ObIpEndpoint &ip)
{
return ops_is_ip_linklocal(ip.sa_);
}
// Check for being "any" address. // Check for being "any" address.
// @return true if ip is the any / unspecified address. // @return true if ip is the any / unspecified address.
inline bool ops_is_ip_any(const sockaddr &ip) inline bool ops_is_ip_any(const sockaddr &ip)
......
...@@ -146,8 +146,8 @@ void ObProxyMain::print_usage() const ...@@ -146,8 +146,8 @@ void ObProxyMain::print_usage() const
MPRINT(" -t,--regression_test TEST_NAME regression test"); MPRINT(" -t,--regression_test TEST_NAME regression test");
MPRINT("example:"); MPRINT("example:");
MPRINT(" run without config server:"); MPRINT(" run without config server:");
MPRINT(" ./bin/obproxy -p6789 -r'10.125.224.11:26506;10.125.224.22:26577' -n test -o enable_cluster_checkout=false,syslog_level=INFO"); MPRINT(" ./bin/obproxy -p6789 -r'ip:port;ip:port' -n test -o enable_cluster_checkout=false,syslog_level=INFO");
MPRINT(" OR ./bin/obproxy -p6789 -r'10.125.224.11:26506;10.125.224.22:26577' -c 'ob_test' -n test -o syslog_level=INFO \n"); MPRINT(" OR ./bin/obproxy -p6789 -r'ip:port;ip:port' -c 'ob_test' -n test -o syslog_level=INFO \n");
MPRINT(" run with config server:"); MPRINT(" run with config server:");
MPRINT(" ./bin/obproxy -p6789 -e -n test -o obproxy_config_server_url='your config url',syslog_level=INFO\n"); MPRINT(" ./bin/obproxy -p6789 -e -n test -o obproxy_config_server_url='your config url',syslog_level=INFO\n");
MPRINT(" Non-first start with local config file:"); MPRINT(" Non-first start with local config file:");
...@@ -155,7 +155,7 @@ void ObProxyMain::print_usage() const ...@@ -155,7 +155,7 @@ void ObProxyMain::print_usage() const
MPRINT(" dump config update sql:"); MPRINT(" dump config update sql:");
MPRINT(" ./bin/obproxy -d\n"); MPRINT(" ./bin/obproxy -d\n");
MPRINT(" run regression tests:"); MPRINT(" run regression tests:");
MPRINT(" ./bin/obproxy -p6789 -r10.125.224.11:26506 -ntest -o obproxy_config_server_url='' -t ''"); MPRINT(" ./bin/obproxy -p6789 -rip:port -ntest -o obproxy_config_server_url='' -t ''");
MPRINT("----------------------------------------------------------------------------------"); MPRINT("----------------------------------------------------------------------------------");
} }
......
...@@ -8,6 +8,25 @@ ...@@ -8,6 +8,25 @@
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details. * See the Mulan PubL v2 for more details.
*
* *************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/ */
#define USING_LOG_PREFIX PROXY #define USING_LOG_PREFIX PROXY
...@@ -21,63 +40,7 @@ namespace oceanbase ...@@ -21,63 +40,7 @@ namespace oceanbase
{ {
namespace obproxy namespace obproxy
{ {
const char *ObBlowFish::ENC_KEY_BYTES_PROD_STR = "gQzLk5tTcGYlQ47GG29xQxfbHIURCheJ"; const char *ObBlowFish::ENC_KEY_BYTES_PROD_STR = "";
int ObBlowFish::encode(char *in, const int64_t in_len, char *out, const int64_t out_len)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(in) || OB_ISNULL(out)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(in), K(out), K(in_len), K(out_len), K(ret));
} else {
char tmp_out[OB_MAX_PASSWORD_LENGTH];
memset(tmp_out, 0, sizeof(tmp_out));
int64_t in_str_len = strlen(in);
int64_t padding_len = BF_BLOCK - in_str_len % BF_BLOCK;
if (OB_UNLIKELY(in_str_len + padding_len >= in_len)) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("in buffer size is not enough", K(padding_len), K(in), K(in_len), K(ret));
} else {
for (int64_t i = in_str_len; i < in_str_len + padding_len; ++i) {
in[i] = static_cast<char>(padding_len);
}
if (OB_FAIL(do_bf_ecb_encrypt(reinterpret_cast<const unsigned char *>(in), in_str_len + padding_len,
reinterpret_cast<unsigned char *>(tmp_out), OB_MAX_PASSWORD_LENGTH, BF_ENCRYPT))) {
LOG_WARN("fail to do bf ecb encrypt", K(in), K(padding_len), K(ret));
} else if (OB_FAIL(covert_string_to_hex(tmp_out, strlen(tmp_out), out, out_len))) {
LOG_WARN("fail to convert str to hex", K(ret));
}
}
}
return ret;
}
int ObBlowFish::decode(const char *in, const int64_t in_str_len, char *out, const int64_t out_len)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(in) || OB_ISNULL(out)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(in), K(out), K(in_str_len), K(out_len), K(ret));
} else {
char tmp_out[OB_MAX_PASSWORD_LENGTH];
memset(tmp_out, 0, sizeof(tmp_out));
int64_t tmp_out_len = 0;
if (OB_FAIL(convert_large_str_to_hex(in, in_str_len, tmp_out, OB_MAX_PASSWORD_LENGTH, tmp_out_len))) {
} else if (OB_FAIL(do_bf_ecb_encrypt(reinterpret_cast<const unsigned char *>(tmp_out), tmp_out_len,
reinterpret_cast<unsigned char *>(out), out_len, BF_DECRYPT))) {
LOG_WARN("fail to do bf ecn encrypt", K(ret));
} else {
// trim padding number
int64_t result_len = strlen(out);
if (out[result_len - 1] >= 1 && out[result_len - 1] <= 8) {
int64_t padding_len = out[result_len - 1];
result_len = result_len - padding_len;
memset(out + result_len, 0, padding_len);
}
}
}
return ret;
}
int ObBlowFish::do_bf_ecb_encrypt(const unsigned char *in, const int64_t in_str_len, int ObBlowFish::do_bf_ecb_encrypt(const unsigned char *in, const int64_t in_str_len,
unsigned char *out, const int64_t out_len, unsigned char *out, const int64_t out_len,
...@@ -89,13 +52,16 @@ int ObBlowFish::do_bf_ecb_encrypt(const unsigned char *in, const int64_t in_str_ ...@@ -89,13 +52,16 @@ int ObBlowFish::do_bf_ecb_encrypt(const unsigned char *in, const int64_t in_str_
|| OB_UNLIKELY(in_str_len > out_len) || OB_UNLIKELY(in_str_len > out_len)
|| OB_UNLIKELY(BF_ENCRYPT != enc_mode && BF_DECRYPT != enc_mode)) { || OB_UNLIKELY(BF_ENCRYPT != enc_mode && BF_DECRYPT != enc_mode)) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(in), K(out), K(in_str_len), K(out_len), K(enc_mode), K(ret)); LOG_WARN("invalid argument", K(in), K(out), K(in_str_len), K(out_len),
K(enc_mode), K(ret));
} else { } else {
BF_KEY bf_key; BF_KEY bf_key;
BF_set_key(&bf_key, static_cast<int>(strlen(ENC_KEY_BYTES_PROD_STR)), reinterpret_cast<const unsigned char *>(ENC_KEY_BYTES_PROD_STR)); BF_set_key(&bf_key, static_cast<int>(strlen(ObBlowFish::ENC_KEY_BYTES_PROD_STR)),
reinterpret_cast<const unsigned char *>(ObBlowFish::ENC_KEY_BYTES_PROD_STR));
int pos = 0; int pos = 0;
while (pos != in_str_len) { while (pos != in_str_len) {
BF_ecb_encrypt(reinterpret_cast<const unsigned char *>(in + pos), reinterpret_cast<unsigned char *>(out + pos), &bf_key, enc_mode); BF_ecb_encrypt(reinterpret_cast<const unsigned char *>(in + pos),
reinterpret_cast<unsigned char *>(out + pos), &bf_key, enc_mode);
pos += BF_BLOCK; pos += BF_BLOCK;
} }
} }
...@@ -132,6 +98,7 @@ int ObBlowFish::covert_string_to_hex(const char *str, const int64_t str_len, ...@@ -132,6 +98,7 @@ int ObBlowFish::covert_string_to_hex(const char *str, const int64_t str_len,
if (OB_ISNULL(str) || OB_ISNULL(hex_str) if (OB_ISNULL(str) || OB_ISNULL(hex_str)
|| OB_UNLIKELY(hex_len <= str_len * 2)) { || OB_UNLIKELY(hex_len <= str_len * 2)) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(hex_str), K(hex_len), K(str), K(str_len), K(ret));
} else { } else {
for (int64_t i = 0; OB_SUCC(ret) && i < str_len; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < str_len; ++i) {
if (OB_UNLIKELY(-1 == sprintf(hex_str, "%.2x", static_cast<unsigned char>(str[i])))) { if (OB_UNLIKELY(-1 == sprintf(hex_str, "%.2x", static_cast<unsigned char>(str[i])))) {
...@@ -147,7 +114,8 @@ int ObBlowFish::covert_string_to_hex(const char *str, const int64_t str_len, ...@@ -147,7 +114,8 @@ int ObBlowFish::covert_string_to_hex(const char *str, const int64_t str_len,
} }
int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len, int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len,
char *hex_str, const int64_t hex_len, int64_t &hex_str_len) char *hex_str, const int64_t hex_len,
int64_t &hex_str_len)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
UNUSED(hex_len); UNUSED(hex_len);
...@@ -155,7 +123,8 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len, ...@@ -155,7 +123,8 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len,
const char *last_minus_pos = NULL; const char *last_minus_pos = NULL;
bool is_negative = false; bool is_negative = false;
while (cursor != str + str_len) { while (cursor != str + str_len) {
cursor = static_cast<const char *>(memchr(reinterpret_cast<const void *>(cursor), '-', static_cast<int32_t>(str_len - (cursor - str)))); cursor = static_cast<const char *>(memchr(reinterpret_cast<const void *>(cursor), '-',
static_cast<int32_t>(str_len - (cursor - str))));
if (NULL != cursor) { if (NULL != cursor) {
last_minus_pos = cursor; last_minus_pos = cursor;
++cursor; ++cursor;
...@@ -165,6 +134,7 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len, ...@@ -165,6 +134,7 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len,
} }
if (NULL != last_minus_pos && last_minus_pos != str) { if (NULL != last_minus_pos && last_minus_pos != str) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(str), K(last_minus_pos), K(ret));
} else { } else {
if (NULL == last_minus_pos) { if (NULL == last_minus_pos) {
cursor = str; cursor = str;
...@@ -235,7 +205,8 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len, ...@@ -235,7 +205,8 @@ int ObBlowFish::convert_large_str_to_hex(const char *str, const int64_t str_len,
return ret; return ret;
} }
void ObBlowFish::destructive_multi_add(int64_t *x, const int64_t int_num, int64_t y, int64_t z) void ObBlowFish::destructive_multi_add(int64_t *x, const int64_t int_num,
int64_t y, int64_t z)
{ {
int64_t ylong = y & 0xffffffffL; int64_t ylong = y & 0xffffffffL;
int64_t zlong = z & 0xffffffffL; int64_t zlong = z & 0xffffffffL;
...@@ -294,7 +265,8 @@ int ObBlowFish::get_bit_count(int var) ...@@ -294,7 +265,8 @@ int ObBlowFish::get_bit_count(int var)
return var & 255; return var & 255;
} }
int ObBlowFish::get_bit_len(int64_t *mag, int64_t start_idx, int64_t int_num, const bool is_negative) int ObBlowFish::get_bit_len(int64_t *mag, int64_t start_idx,
int64_t int_num, const bool is_negative)
{ {
int ret = -1; int ret = -1;
int mag_len = static_cast<int>(int_num - start_idx); int mag_len = static_cast<int>(int_num - start_idx);
...@@ -314,5 +286,67 @@ int ObBlowFish::get_bit_len(int64_t *mag, int64_t start_idx, int64_t int_num, co ...@@ -314,5 +286,67 @@ int ObBlowFish::get_bit_len(int64_t *mag, int64_t start_idx, int64_t int_num, co
return ret; return ret;
} }
int ObBlowFish::encode(char *in, const int64_t in_len, char *out, const int64_t out_len)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(in) || OB_ISNULL(out)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(in), K(out), K(in_len), K(out_len), K(ret));
} else {
char tmp_out[OB_MAX_PASSWORD_LENGTH];
memset(tmp_out, 0, sizeof(tmp_out));
int64_t in_str_len = strlen(in);
int64_t padding_len = BF_BLOCK - in_str_len % BF_BLOCK;
if (OB_UNLIKELY(in_str_len + padding_len >= in_len)) {
ret = OB_SIZE_OVERFLOW;
LOG_WARN("in buffer size is not enough", K(padding_len), K(in), K(in_len), K(ret));
} else {
for (int64_t i = in_str_len; i < in_str_len + padding_len; ++i) {
in[i] = static_cast<char>(padding_len);
}
if (OB_FAIL(do_bf_ecb_encrypt(reinterpret_cast<const unsigned char *>(in),
in_str_len + padding_len,
reinterpret_cast<unsigned char *>(tmp_out),
OB_MAX_PASSWORD_LENGTH, BF_ENCRYPT))) {
LOG_WARN("fail to do bf ecb encrypt", K(in), K(padding_len), K(ret));
} else if (OB_FAIL(covert_string_to_hex(tmp_out, strlen(tmp_out), out, out_len))) {
LOG_WARN("fail to convert str to hex", K(ret));
}
}
}
return ret;
}
int ObBlowFish::decode(const char *in, const int64_t in_str_len, char *out, const int64_t out_len)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(in) || OB_ISNULL(out)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(in), K(out), K(in_str_len), K(out_len), K(ret));
} else {
char tmp_out[OB_MAX_PASSWORD_LENGTH];
memset(tmp_out, 0, sizeof(tmp_out));
int64_t tmp_out_len = 0;
if (OB_FAIL(convert_large_str_to_hex(in, in_str_len, tmp_out,
OB_MAX_PASSWORD_LENGTH, tmp_out_len))) {
LOG_WARN("failt to convert large str to hex", K(in), K(in_str_len), K(ret));
} else if (OB_FAIL(do_bf_ecb_encrypt(reinterpret_cast<const unsigned char *>(tmp_out),
tmp_out_len,
reinterpret_cast<unsigned char *>(out),
out_len, BF_DECRYPT))) {
LOG_WARN("fail to do bf ecn encrypt", K(ret));
} else {
// trim padding number
int64_t result_len = strlen(out);
if (out[result_len - 1] >= 1 && out[result_len - 1] <= 8) {
int64_t padding_len = out[result_len - 1];
result_len = result_len - padding_len;
memset(out + result_len, 0, padding_len);
}
}
}
return ret;
}
} // end namespace obproxy } // end namespace obproxy
} // end namespace oceanbase } // end namespace oceanbase
...@@ -95,10 +95,9 @@ const char *ObProxyTableInfo::PROXY_VIP_TENANT_TABLE_NAME = "ob_all_proxy_vip_te ...@@ -95,10 +95,9 @@ const char *ObProxyTableInfo::PROXY_VIP_TENANT_TABLE_NAME = "ob_all_proxy_vip_te
const char *ObProxyTableInfo::PROXY_VIP_TENANT_VERSION_NAME = "ob_proxy_vip_tenant_version"; const char *ObProxyTableInfo::PROXY_VIP_TENANT_VERSION_NAME = "ob_proxy_vip_tenant_version";
const char *ObProxyTableInfo::READ_ONLY_USERNAME_USER = "proxyro"; // do not modify const char *ObProxyTableInfo::READ_ONLY_USERNAME_USER = "proxyro";
const char *ObProxyTableInfo::READ_ONLY_USERNAME = "proxyro@sys"; // do not modify const char *ObProxyTableInfo::READ_ONLY_USERNAME = "proxyro@sys";
const char *ObProxyTableInfo::READ_ONLY_DATABASE = "oceanbase"; // do not modify const char *ObProxyTableInfo::READ_ONLY_DATABASE = "oceanbase";
const char *ObProxyTableInfo::READ_ONLY_PASSWD_STAGED1 = "ee0e5138c912aed80b683c05303684be347ce81d"; // do not modify
const char *ObProxyTableInfo::TEST_MODE_USERNAME = "root@sys"; const char *ObProxyTableInfo::TEST_MODE_USERNAME = "root@sys";
const char *ObProxyTableInfo::TEST_MODE_PASSWORD = ""; const char *ObProxyTableInfo::TEST_MODE_PASSWORD = "";
......
...@@ -67,7 +67,6 @@ public: ...@@ -67,7 +67,6 @@ public:
static const char *READ_ONLY_USERNAME_USER; static const char *READ_ONLY_USERNAME_USER;
static const char *READ_ONLY_USERNAME; static const char *READ_ONLY_USERNAME;
static const char *READ_ONLY_DATABASE; static const char *READ_ONLY_DATABASE;
static const char *READ_ONLY_PASSWD_STAGED1;
static const char *TEST_MODE_USERNAME; static const char *TEST_MODE_USERNAME;
static const char *TEST_MODE_PASSWORD; static const char *TEST_MODE_PASSWORD;
......
...@@ -493,22 +493,22 @@ struct PrivilegeRow { ...@@ -493,22 +493,22 @@ struct PrivilegeRow {
const char *comment_; const char *comment_;
}; };
const char* const ALTER_TB_MSG = "To alter the table"; const char* const ALTER_TB_MSG = "To alter the table";
const char* const CREATE_DB_TB_MSG = "To create new databases and tables"; const char* const CREATE_DB_TB_MSG = "To create new databases and tables";
const char* const CREATE_VIEW_MSG = "To create new views"; const char* const CREATE_VIEW_MSG = "To create new views";
const char* const CREATE_USER_MSG = "To create new users"; const char* const CREATE_USER_MSG = "To create new users";
const char* const DELETE_ROWS_MSG = "To delete existing rows"; const char* const DELETE_ROWS_MSG = "To delete existing rows";
const char* const DROP_DB_TB_VIEWS_MSG = "To drop databases, tables, and views"; const char* const DROP_DB_TB_VIEWS_MSG = "To drop databases, tables, and views";
const char* const GRANT_OPTION_MSG = "To give to other users those privileges you possess"; const char* const GRANT_OPTION_MSG = "To give to other users those privileges you possess";
const char* const INDEX_MSG = "To create or drop indexes"; const char* const INDEX_MSG = "To create or drop indexes";
const char* const INSERT_MSG = "To insert data into tables"; const char* const INSERT_MSG = "To insert data into tables";
const char* const PROCESS_MSG = "To view the plain text of currently executing queries"; const char* const PROCESS_MSG = "To view the plain text of currently executing queries";
const char* const SELECT_MSG = "To retrieve rows from table"; const char* const SELECT_MSG = "To retrieve rows from table";
const char* const SHOW_DB_MSG = "To see all databases with SHOW DATABASES"; const char* const SHOW_DB_MSG = "To see all databases with SHOW DATABASES";
const char* const SHOW_VIEW_MSG = "To see views with SHOW CREATE VIEW"; const char* const SHOW_VIEW_MSG = "To see views with SHOW CREATE VIEW";
const char* const SUPER_MSG = "To use KILL thread, SET GLOBAL, CHANGE MASTER, etc."; const char* const SUPER_MSG = "To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.";
const char* const UPDATE_MSG = "To update existing rows"; const char* const UPDATE_MSG = "To update existing rows";
const char* const USAGE_MSG = "No privileges - allow connect only"; const char* const USAGE_MSG = "No privileges - allow connect only";
static const PrivilegeRow all_privileges[] = static const PrivilegeRow all_privileges[] =
{ {
{"Alter", "Tables", ALTER_TB_MSG}, {"Alter", "Tables", ALTER_TB_MSG},
......
...@@ -45,7 +45,7 @@ class MainHandler(): ...@@ -45,7 +45,7 @@ class MainHandler():
if (os.path.isfile(self.opt.base_parser)): if (os.path.isfile(self.opt.base_parser)):
run_cmd("./%s -f %s -r %s" % (self.opt.base_parser, self.opt.test_case, result_file_name)) run_cmd("./%s -f %s -r %s" % (self.opt.base_parser, self.opt.test_case, result_file_name))
else: else:
url = 'http://10.218.248.181:7788/obproxy_build/%s' % self.opt.base_parser url = 'http://ip:port/obproxy_build/%s' % self.opt.base_parser
print 'get base parser from %s' % url print 'get base parser from %s' % url
run_cmd("wget %s -O %s &>/dev/null && chmod a+x %s" % (url, self.opt.base_parser, self.opt.base_parser)) run_cmd("wget %s -O %s &>/dev/null && chmod a+x %s" % (url, self.opt.base_parser, self.opt.base_parser))
if (os.path.isfile(self.opt.base_parser)): if (os.path.isfile(self.opt.base_parser)):
......
...@@ -210,12 +210,11 @@ TEST_F(TestConfigServerProcessor, test_get_json_config_info) ...@@ -210,12 +210,11 @@ TEST_F(TestConfigServerProcessor, test_get_json_config_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
config_processor_.proxy_config_.app_name.set_value("ob1.kyle.sj"); config_processor_.proxy_config_.app_name.set_value("ob1.kyle.sj");
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8080/diamond/cgi/a.py?key=unittest_test_config_server.proxy&method=get");
ret = config_processor_.refresh_json_config_info(); ret = config_processor_.refresh_json_config_info();
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.bin_url_.ptr(), ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.bin_url_.ptr(),
"http://11.166.86.153:8877", config_processor_.json_config_info_->data_info_.bin_url_.length())); "", config_processor_.json_config_info_->data_info_.bin_url_.length()));
ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.meta_table_info_.db_.ptr(), ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.meta_table_info_.db_.ptr(),
"oceanbase", config_processor_.json_config_info_->data_info_.meta_table_info_.db_.length())); "oceanbase", config_processor_.json_config_info_->data_info_.meta_table_info_.db_.length()));
ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.meta_table_info_.username_.ptr(), ASSERT_EQ(0, memcmp(config_processor_.json_config_info_->data_info_.meta_table_info_.username_.ptr(),
...@@ -224,8 +223,7 @@ TEST_F(TestConfigServerProcessor, test_get_json_config_info) ...@@ -224,8 +223,7 @@ TEST_F(TestConfigServerProcessor, test_get_json_config_info)
"admin", config_processor_.json_config_info_->data_info_.meta_table_info_.password_.length())); "admin", config_processor_.json_config_info_->data_info_.meta_table_info_.password_.length()));
ASSERT_EQ(1, config_processor_.json_config_info_->data_info_.cluster_array_.count()); ASSERT_EQ(1, config_processor_.json_config_info_->data_info_.cluster_array_.count());
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8899/xxx");
ret = config_processor_.refresh_json_config_info(); ret = config_processor_.refresh_json_config_info();
ASSERT_EQ(OB_CURL_ERROR, ret); ASSERT_EQ(OB_CURL_ERROR, ret);
} }
...@@ -238,22 +236,19 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_json_config) ...@@ -238,22 +236,19 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_json_config)
ObString content; ObString content;
content.assign_buffer(buf, OB_PROXY_CONFIG_BUFFER_SIZE); content.assign_buffer(buf, OB_PROXY_CONFIG_BUFFER_SIZE);
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8080/diamond/cgi/a.py?key=unittest_test_config_server.proxy&method=get");
const char *config_url = config_processor_.proxy_config_.obproxy_config_server_url; const char *config_url = config_processor_.proxy_config_.obproxy_config_server_url;
ret = config_processor_.fetch_by_curl(config_url, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT, ret = config_processor_.fetch_by_curl(config_url, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT,
static_cast<void *>(&content), ObConfigServerProcessor::write_data); static_cast<void *>(&content), ObConfigServerProcessor::write_data);
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153/xxx");
const char *wrong_config_url = config_processor_.proxy_config_.obproxy_config_server_url; const char *wrong_config_url = config_processor_.proxy_config_.obproxy_config_server_url;
ret = config_processor_.fetch_by_curl(wrong_config_url, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT, ret = config_processor_.fetch_by_curl(wrong_config_url, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT,
static_cast<void *>(&content), ObConfigServerProcessor::write_data); static_cast<void *>(&content), ObConfigServerProcessor::write_data);
ASSERT_EQ(OB_CURL_ERROR, ret); ASSERT_EQ(OB_CURL_ERROR, ret);
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8888/diamond/cgi/a.py?key=ob1.kyle.sj.test&method=get");
const char *wrong_http_port = config_processor_.proxy_config_.obproxy_config_server_url; const char *wrong_http_port = config_processor_.proxy_config_.obproxy_config_server_url;
ret = config_processor_.fetch_by_curl(wrong_http_port, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT, ret = config_processor_.fetch_by_curl(wrong_http_port, ObConfigServerProcessor::CURL_TRANSFER_TIMEOUT,
static_cast<void *>(&content), ObConfigServerProcessor::write_data); static_cast<void *>(&content), ObConfigServerProcessor::write_data);
...@@ -263,9 +258,8 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_json_config) ...@@ -263,9 +258,8 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_json_config)
TEST_F(TestConfigServerProcessor, test_get_newest_cluster_rs_list) TEST_F(TestConfigServerProcessor, test_get_newest_cluster_rs_list)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
config_processor_.proxy_config_.app_name.set_value("ob1.kyle.sj"); config_processor_.proxy_config_.app_name.set_value("");
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8080/diamond/cgi/a.py?key=unittest_test_config_server.proxy&method=get");
ret = config_processor_.refresh_json_config_info(); ret = config_processor_.refresh_json_config_info();
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
...@@ -279,7 +273,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin) ...@@ -279,7 +273,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const char *save_path = "obproxy_new"; const char *save_path = "obproxy_new";
config_processor_.json_config_info_->data_info_.bin_url_.url_ = ObString::make_string("http://10.125.224.4:9191/method=get"); config_processor_.json_config_info_->data_info_.bin_url_.url_ = ObString::make_string("");
ret = config_processor_.do_fetch_proxy_bin(save_path, "obproxy.el6.x86_64.rpm"); ret = config_processor_.do_fetch_proxy_bin(save_path, "obproxy.el6.x86_64.rpm");
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
remove(save_path); remove(save_path);
...@@ -293,7 +287,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin) ...@@ -293,7 +287,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
ASSERT_EQ(OB_ERR_UNEXPECTED, ret); ASSERT_EQ(OB_ERR_UNEXPECTED, ret);
//test short timeout //test short timeout
const char *bin_url = "http://10.125.224.4:9191/method=get&Version=big.obproxy.el6.x86_64.rpm"; const char *bin_url = "";
int fd = 0; int fd = 0;
if ((fd = ::open(save_path, O_WRONLY | O_CREAT, if ((fd = ::open(save_path, O_WRONLY | O_CREAT,
...@@ -307,7 +301,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin) ...@@ -307,7 +301,7 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
remove(save_path); remove(save_path);
//test wrong url //test wrong url
const char *wrong_bin_url = "http://10.125.224.4:9191/method=get&Version=/test_dir/obproxy.el6.x86_64.rpm"; const char *wrong_bin_url = "";
int64_t fetch_timeout = config_processor_.proxy_config_.fetch_proxy_bin_timeout / 1000000;//us --> s int64_t fetch_timeout = config_processor_.proxy_config_.fetch_proxy_bin_timeout / 1000000;//us --> s
if (fetch_timeout <= 0) { if (fetch_timeout <= 0) {
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
...@@ -324,13 +318,13 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin) ...@@ -324,13 +318,13 @@ TEST_F(TestConfigServerProcessor, test_do_fetch_proxy_bin)
TEST_F(TestConfigServerProcessor, test_get_idc_url) TEST_F(TestConfigServerProcessor, test_get_idc_url)
{ {
const char *buf1 = "http://11.166.86.153:8080/oceanbase_obconfig/obtest_jianhua.sjh_10.125.224.4_ob1"; const char *buf1 = "";
const char *buf2 = "http://ocp-api.alipay.com/services?Action=ObRootServiceInfo&User_ID=alibaba&UID=zhitao.rzt&ObRegion=rhz_obtrans60"; const char *buf2 = "";
const char *buf3 = "http://ocp-api.alipay.com/services?action=obrootserviceinfo&user_id=alibaba&uid=zhitao.rzt&obregion=rhz_obtrans60"; const char *buf3 = "";
const char *buf4 = "HTTP://OCP-API.ALIPAY.COM/SERVICES?ACTION=OBROOTSERVICEINFO&USER_ID=ALIBABA&UID=ZHITAO.RZT&OBREGION=RHZ_OBTRANS60"; const char *buf4 = "";
const char *expect_buf1 = "http://11.166.86.153:8080/oceanbase_obconfig/obtest_jianhua.sjh_10.125.224.4_ob1_idc_list"; const char *expect_buf1 = "";
const char *expect_buf2 = "http://ocp-api.alipay.com/services?Action=ObIDCRegionInfo&User_ID=alibaba&UID=zhitao.rzt&ObRegion=rhz_obtrans60"; const char *expect_buf2 = "";
const char *expect_buf3 = "http://ocp-api.alipay.com/services?action=ObIDCRegionInfo&user_id=alibaba&uid=zhitao.rzt&obregion=rhz_obtrans60"; const char *expect_buf3 = "";
const char *expect_buf4 = "HTTP://OCP-API.ALIPAY.COM/SERVICES?ACTION=ObIDCRegionInfo&USER_ID=ALIBABA&UID=ZHITAO.RZT&OBREGION=RHZ_OBTRANS60"; const char *expect_buf4 = "HTTP://OCP-API.ALIPAY.COM/SERVICES?ACTION=ObIDCRegionInfo&USER_ID=ALIBABA&UID=ZHITAO.RZT&OBREGION=RHZ_OBTRANS60";
const int64_t max_size = 256; const int64_t max_size = 256;
char common_buf[256]; char common_buf[256];
...@@ -364,8 +358,7 @@ TEST_F(TestConfigServerProcessor, test_get_idc_list) ...@@ -364,8 +358,7 @@ TEST_F(TestConfigServerProcessor, test_get_idc_list)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
config_processor_.proxy_config_.app_name.set_value("ob1.kyle.sj"); config_processor_.proxy_config_.app_name.set_value("ob1.kyle.sj");
config_processor_.proxy_config_.obproxy_config_server_url.set_value( config_processor_.proxy_config_.obproxy_config_server_url.set_value("");
"http://11.166.86.153:8080/diamond/cgi/a.py?key=unittest_test_config_server.proxy&method=get");
ret = config_processor_.refresh_json_config_info(); ret = config_processor_.refresh_json_config_info();
ASSERT_EQ(OB_SUCCESS, ret); ASSERT_EQ(OB_SUCCESS, ret);
......
...@@ -49,7 +49,7 @@ TEST_F(TestProxySessionInfo, basic_func) ...@@ -49,7 +49,7 @@ TEST_F(TestProxySessionInfo, basic_func)
{ {
ObServerSessionInfo session; ObServerSessionInfo session;
session.reset(); session.reset();
ObAddr server(static_cast<ObAddr::VER>(4), "10.232.4.4", 3300); ObAddr server(static_cast<ObAddr::VER>(4), "", 3300);
session.version_.sys_var_version_ = 100; session.version_.sys_var_version_ = 100;
session.version_.hot_sys_var_version_ = 100; session.version_.hot_sys_var_version_ = 100;
session.version_.user_var_version_ = 1000; session.version_.user_var_version_ = 1000;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册