projects
/
m6w6
/
libmemcached
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
9e4ae97
)
Merge up to gearmand.
author
Brian Aker
<brian@tangent.org>
Sat, 14 Jul 2012 19:23:35 +0000
(12:23 -0700)
committer
Brian Aker
<brian@tangent.org>
Sat, 14 Jul 2012 19:23:35 +0000
(12:23 -0700)
12 files changed:
libtest/fatal.hpp
patch
|
blob
|
history
libtest/gearmand.cc
patch
|
blob
|
history
libtest/gearmand.h
patch
|
blob
|
history
libtest/main.cc
patch
|
blob
|
history
libtest/memcached.cc
patch
|
blob
|
history
libtest/memcached.h
patch
|
blob
|
history
libtest/server.cc
patch
|
blob
|
history
libtest/server.h
patch
|
blob
|
history
libtest/server_container.cc
patch
|
blob
|
history
libtest/timer.cc
patch
|
blob
|
history
libtest/timer.hpp
patch
|
blob
|
history
libtest/unittest.cc
patch
|
blob
|
history
diff --git
a/libtest/fatal.hpp
b/libtest/fatal.hpp
index f0ee08131614f3ee3dc8d8b1ff9bce0eeae1b024..7a8ce5161491173670359ed67ca08dad9a807478 100644
(file)
--- a/
libtest/fatal.hpp
+++ b/
libtest/fatal.hpp
@@
-42,6
+42,13
@@
#define __PRETTY_FUNCTION__ __func__
#endif
#define __PRETTY_FUNCTION__ __func__
#endif
+#define YATL_STRINGIFY(x) #x
+#define YATL_TOSTRING(x) YATL_STRINGIFY(x)
+#define YATL_AT __FILE__ ":" YATL_TOSTRING(__LINE__)
+#define YATL_AT_PARAM __func__, AT
+#define YATL_UNIQUE __FILE__ ":" YATL_TOSTRING(__LINE__) "_unique"
+#define YATL_UNIQUE_FUNC_NAME __FILE__ ":" YATL_TOSTRING(__LINE__) "_unique_func"
+
#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__
namespace libtest {
#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__
namespace libtest {
diff --git
a/libtest/gearmand.cc
b/libtest/gearmand.cc
index 82953e993de8c928375f3515fd2c819c08a2bd39..e25cdf7479ac860ff43b916a46b4439342abe3e3 100644
(file)
--- a/
libtest/gearmand.cc
+++ b/
libtest/gearmand.cc
@@
-69,11
+69,7
@@
class Gearmand : public libtest::Server
{
private:
public:
{
private:
public:
- Gearmand(const std::string& host_arg, in_port_t port_arg) :
- libtest::Server(host_arg, port_arg, GEARMAND_BINARY, true)
- {
- set_pid_file();
- }
+ Gearmand(const std::string& host_arg, in_port_t port_arg, const char* binary= GEARMAND_BINARY);
bool ping()
{
bool ping()
{
@@
-94,7
+90,11
@@
public:
gearman_client_free(client);
return true;
}
gearman_client_free(client);
return true;
}
- Error << hostname().c_str() << ":" << port() << " was " << gearman_strerror(rc) << " extended: " << gearman_client_error(client);
+
+ if (out_of_ban_killed() == false)
+ {
+ Error << hostname().c_str() << ":" << port() << " was " << gearman_strerror(rc) << " extended: " << gearman_client_error(client);
+ }
}
else
{
}
else
{
@@
-145,6
+145,12
@@
public:
bool build(size_t argc, const char *argv[]);
};
bool build(size_t argc, const char *argv[]);
};
+Gearmand::Gearmand(const std::string& host_arg, in_port_t port_arg, const char* binary_arg) :
+ libtest::Server(host_arg, port_arg, binary_arg, true)
+{
+ set_pid_file();
+}
+
bool Gearmand::build(size_t argc, const char *argv[])
{
if (getuid() == 0 or geteuid() == 0)
bool Gearmand::build(size_t argc, const char *argv[])
{
if (getuid() == 0 or geteuid() == 0)
@@
-169,4
+175,9
@@
libtest::Server *build_gearmand(const char *hostname, in_port_t try_port)
return new Gearmand(hostname, try_port);
}
return new Gearmand(hostname, try_port);
}
+libtest::Server *build_gearmand(const char *hostname, in_port_t try_port, const char* binary)
+{
+ return new Gearmand(hostname, try_port, binary);
+}
+
}
}
diff --git
a/libtest/gearmand.h
b/libtest/gearmand.h
index 0c09774c1a3ceae93e46dfd3149bf6ef26dee134..49c08c9f6b723e50b01fd3b7586bbe59dc2593cf 100644
(file)
--- a/
libtest/gearmand.h
+++ b/
libtest/gearmand.h
@@
-44,4
+44,6
@@
namespace libtest {
libtest::Server *build_gearmand(const char *hostname, in_port_t try_port);
libtest::Server *build_gearmand(const char *hostname, in_port_t try_port);
+libtest::Server *build_gearmand(const char *hostname, in_port_t try_port, const char* binary);
+
}
}
diff --git
a/libtest/main.cc
b/libtest/main.cc
index 5fa538899b820a92b88ecc0fc374a92a4896ae4c..79f177c3ca60bfe0d513282da35825bceea552ae 100644
(file)
--- a/
libtest/main.cc
+++ b/
libtest/main.cc
@@
-316,6
+316,11
@@
int main(int argc, char *argv[])
std::cerr << "std::exception:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
std::cerr << "std::exception:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
+ catch (char const*)
+ {
+ std::cerr << "Exception:" << std::endl;
+ exit_code= EXIT_FAILURE;
+ }
catch (...)
{
std::cerr << "Unknown exception halted execution." << std::endl;
catch (...)
{
std::cerr << "Unknown exception halted execution." << std::endl;
diff --git
a/libtest/memcached.cc
b/libtest/memcached.cc
index b8838a06a495bd4bbdf8702daf523e1d1953600d..d92944f6bfeb1bd9cec17320229cd880f3edb6f6 100644
(file)
--- a/
libtest/memcached.cc
+++ b/
libtest/memcached.cc
@@
-97,6
+97,7
@@
public:
libtest::Server(host_arg, port_arg,
MEMCACHED_BINARY, is_memcached_libtool(), is_socket_arg)
{
libtest::Server(host_arg, port_arg,
MEMCACHED_BINARY, is_memcached_libtool(), is_socket_arg)
{
+ set_pid_file();
}
virtual const char *sasl() const
}
virtual const char *sasl() const
@@
-114,13
+115,27
@@
public:
return _username;
}
return _username;
}
-
virtual bool has_pid_
file() const
+
bool wait_for_pid
file() const
{
{
- return false;
+ Wait wait(pid(), 4);
+
+ return wait.successful();
}
bool ping()
{
}
bool ping()
{
+#if 0
+ // Memcached is slow to start, so we need to do this
+ if (pid_file().empty() == false)
+ {
+ if (wait_for_pidfile() == false)
+ {
+ Error << "Pidfile was not found:" << pid_file() << " :" << running();
+ return -1;
+ }
+ }
+#endif
+
memcached_return_t rc;
bool ret;
memcached_return_t rc;
bool ret;
diff --git
a/libtest/memcached.h
b/libtest/memcached.h
index 915d3fa8a97cb15828ceb7d534d235e0f5832856..405f275f786ed9b20ed0798e5894f7b9176b398d 100644
(file)
--- a/
libtest/memcached.h
+++ b/
libtest/memcached.h
@@
-49,3
+49,4
@@
libtest::Server *build_memcached_sasl(const std::string& hostname, const in_port
libtest::Server *build_memcached_sasl_socket(const std::string& socket_file, const in_port_t try_port, const std::string& username, const std::string& password);
}
libtest::Server *build_memcached_sasl_socket(const std::string& socket_file, const in_port_t try_port, const std::string& username, const std::string& password);
}
+
diff --git
a/libtest/server.cc
b/libtest/server.cc
index 99991209dc2703297ec5c38838bfcb5351a511ad..61f8e9835cb29f9e48c6e613a8b8609a6c2d97ab 100644
(file)
--- a/
libtest/server.cc
+++ b/
libtest/server.cc
@@
-99,7
+99,8
@@
Server::Server(const std::string& host_arg, const in_port_t port_arg,
_is_socket(is_socket_arg),
_port(port_arg),
_hostname(host_arg),
_is_socket(is_socket_arg),
_port(port_arg),
_hostname(host_arg),
- _app(executable, _is_libtool)
+ _app(executable, _is_libtool),
+ out_of_ban_killed_(false)
{
}
{
}
@@
-111,7
+112,6
@@
bool Server::check()
{
_app.slurp();
_app.check();
{
_app.slurp();
_app.check();
-
return true;
}
return true;
}
@@
-401,6
+401,7
@@
bool Server::set_log_file()
bool Server::args(Application& app)
{
bool Server::args(Application& app)
{
+
// Set a log file if it was requested (and we can)
if (has_log_file_option())
{
// Set a log file if it was requested (and we can)
if (has_log_file_option())
{
diff --git
a/libtest/server.h
b/libtest/server.h
index a41e621bb1f491cccf804d334493b360c53e4409..f27ce08f7455066598b6ac333b7eef079cdcc1a9 100644
(file)
--- a/
libtest/server.h
+++ b/
libtest/server.h
@@
-250,6
+250,16
@@
public:
bool validate();
bool validate();
+ void out_of_ban_killed(bool arg)
+ {
+ out_of_ban_killed_= arg;
+ }
+
+ bool out_of_ban_killed()
+ {
+ return out_of_ban_killed_;
+ }
+
protected:
bool set_pid_file();
Options _options;
protected:
bool set_pid_file();
Options _options;
@@
-262,6
+272,7
@@
private:
bool set_log_file();
bool set_socket_file();
void reset_pid();
bool set_log_file();
bool set_socket_file();
void reset_pid();
+ bool out_of_ban_killed_;
bool args(Application&);
std::string _error;
bool args(Application&);
std::string _error;
diff --git
a/libtest/server_container.cc
b/libtest/server_container.cc
index 6973937bc6f8749de1ef7da815c027336fd1ba0f..d8ef5d495364ad4c51e42722b3a70faeb20a67ac 100644
(file)
--- a/
libtest/server_container.cc
+++ b/
libtest/server_container.cc
@@
-75,7
+75,7
@@
void server_startup_st::push_server(Server *arg)
}
else
{
}
else
{
- char port_str[NI_MAXSERV];
+ char port_str[NI_MAXSERV]
= { 0 }
;
snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
server_config_string+= "--server=";
snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
server_config_string+= "--server=";
@@
-142,7
+142,7
@@
bool server_startup_st::shutdown()
bool success= true;
for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
bool success= true;
for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
- if ((*iter)
and (*iter)
->has_pid() and (*iter)->kill() == false)
+ if ((*iter)->has_pid() and (*iter)->kill() == false)
{
Error << "Unable to kill:" << *(*iter);
success= false;
{
Error << "Unable to kill:" << *(*iter);
success= false;
@@
-206,6
+206,16
@@
bool server_startup_st::start_server(const std::string& server_type, in_port_t t
}
}
}
}
}
}
+ else if (server_type.compare("hostile-gearmand") == 0)
+ {
+ if (GEARMAND_BINARY)
+ {
+ if (HAVE_LIBGEARMAN)
+ {
+ server= build_gearmand("localhost", try_port, "gearmand/hostile_gearmand");
+ }
+ }
+ }
else if (server_type.compare("drizzled") == 0)
{
if (DRIZZLED_BINARY)
else if (server_type.compare("drizzled") == 0)
{
if (DRIZZLED_BINARY)
diff --git
a/libtest/timer.cc
b/libtest/timer.cc
index 0a8d69b548c71caabb4e52fd6d27d0f77147ebb9..ffa8a4b6a3cb89e6cef11ee913697bb756c5d09c 100644
(file)
--- a/
libtest/timer.cc
+++ b/
libtest/timer.cc
@@
-35,8
+35,11
@@
*/
#include <config.h>
*/
#include <config.h>
+
#include <libtest/timer.hpp>
#include <libtest/timer.hpp>
+
#include <ctime>
#include <ctime>
+#include <iomanip>
namespace libtest {
namespace libtest {
@@
-45,9
+48,18
@@
std::ostream& operator<<(std::ostream& output, const libtest::Timer& arg)
struct timespec temp;
arg.difference(temp);
struct timespec temp;
arg.difference(temp);
- output << temp.tv_sec;
+ if (temp.tv_sec > 60)
+ {
+ output << temp.tv_sec / 60;
+ output << "." << temp.tv_sec % 60;
+ }
+ else
+ {
+ output << temp.tv_sec;
+ }
+
output << ":";
output << ":";
- output << temp.tv_nsec;
+ output <<
std::setfill('0') << std::setw(9) <<
temp.tv_nsec;
return output;
}
return output;
}
diff --git
a/libtest/timer.hpp
b/libtest/timer.hpp
index 37da32f1af1e9ad99086da3faae060b54d4673ae..28ec47416766c3eb917447d527a57ef1e0e47e97 100644
(file)
--- a/
libtest/timer.hpp
+++ b/
libtest/timer.hpp
@@
-36,8
+36,9
@@
#pragma once
#pragma once
+#include <cstdlib>
#include <ctime>
#include <ctime>
-#include <ostream>
+#include <
i
ostream>
#ifdef __MACH__
# include <mach/clock.h>
#ifdef __MACH__
# include <mach/clock.h>
@@
-72,11
+73,34
@@
public:
_time(_end);
}
_time(_end);
}
+ void offset(int64_t minutes_arg, int64_t seconds_arg, int64_t nanoseconds)
+ {
+ reset();
+ _end= _begin;
+ _end.tv_sec+= (minutes_arg * 60) +seconds_arg;
+ _end.tv_nsec+= nanoseconds;
+ }
+
+ int64_t minutes()
+ {
+ struct timespec result;
+ difference(result);
+ return int64_t(result.tv_sec / 60);
+ }
+
+ uint64_t elapsed_milliseconds() const
+ {
+ struct timespec temp;
+ difference(temp);
+
+ return temp.tv_sec*1000 +temp.tv_nsec/1000000;
+ }
+
void difference(struct timespec& arg) const
{
if ((_end.tv_nsec -_begin.tv_nsec) < 0)
{
void difference(struct timespec& arg) const
{
if ((_end.tv_nsec -_begin.tv_nsec) < 0)
{
- arg.tv_sec= _end.tv_sec -_begin.tv_sec-1;
+ arg.tv_sec= _end.tv_sec -_begin.tv_sec
-1;
arg.tv_nsec= 1000000000 +_end.tv_nsec -_begin.tv_nsec;
}
arg.tv_nsec= 1000000000 +_end.tv_nsec -_begin.tv_nsec;
}
diff --git
a/libtest/unittest.cc
b/libtest/unittest.cc
index c0381f4d66155f65b39f5b22b5f1b993289e67d1..b68669f51829f56c1c10c0400869f38906d2a39b 100644
(file)
--- a/
libtest/unittest.cc
+++ b/
libtest/unittest.cc
@@
-726,6
+726,21
@@
static test_return_t check_dns_TEST(void *)
return TEST_SUCCESS;
}
return TEST_SUCCESS;
}
+static test_return_t Timer_TEST(void *)
+{
+ int64_t minutes= random() % 50;
+ minutes++;
+
+ Timer check;
+
+ check.reset();
+ check.offset(minutes, 2, 200);
+
+ test_compare(check.minutes(), minutes);
+
+ return TEST_SUCCESS;
+}
+
static test_return_t lookup_true_TEST(void *)
{
test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
static test_return_t lookup_true_TEST(void *)
{
test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
@@
-913,6
+928,11
@@
test_st create_tmpfile_TESTS[] ={
{0, 0, 0}
};
{0, 0, 0}
};
+test_st timer_TESTS[] ={
+ {"libtest::Timer", 0, Timer_TEST },
+ {0, 0, 0}
+};
+
test_st dns_TESTS[] ={
{"libtest::lookup(true)", 0, lookup_true_TEST },
{"libtest::lookup(false)", 0, lookup_false_TEST },
test_st dns_TESTS[] ={
{"libtest::lookup(true)", 0, lookup_true_TEST },
{"libtest::lookup(false)", 0, lookup_false_TEST },
@@
-979,6
+999,7
@@
collection_st collection[] ={
{"number_of_cpus()", 0, 0, number_of_cpus_TESTS },
{"create_tmpfile()", 0, 0, create_tmpfile_TESTS },
{"dns", 0, 0, dns_TESTS },
{"number_of_cpus()", 0, 0, number_of_cpus_TESTS },
{"create_tmpfile()", 0, 0, create_tmpfile_TESTS },
{"dns", 0, 0, dns_TESTS },
+ {"libtest::Timer", 0, 0, timer_TESTS },
{0, 0, 0, 0}
};
{0, 0, 0, 0}
};