42 #include <boost/thread/thread.hpp>
53 #include <sys/types.h>
62 const char *usage[] = {
65 " This program tests the operation of the DFS and DFS broker",
66 " by copying the file /usr/share/dict/words to the DFS via the",
67 " broker, then copying it back and making sure the returned copy",
68 " matches the original. It assumes the DFS broker is listenting",
69 " at localhost:38546",
74 string outfileA = testdir +
"/output.a";
75 string outfileB = testdir +
"/output.b";
79 thread_func.set_dfs_file(outfileA);
80 thread_func.set_output_file(
"output.a");
81 Thread thread1(thread_func);
83 thread_func.set_dfs_file(outfileB);
84 thread_func.set_output_file(
"output.b");
85 Thread thread2(thread_func);
90 if (system(
"cmp words output.a"))
93 if (system(
"cmp output.a output.b"))
98 ofstream filestr (
"fsTest.out");
99 vector<Filesystem::Dirent> listing;
101 client->readdir(testdir, listing);
103 sort(listing.begin(), listing.end());
105 for (
size_t i=0; i<listing.size(); i++) {
107 if (listing[i].is_dir)
108 filestr <<
"0 " << listing[i].name <<
"/";
110 filestr << listing[i].length <<
" " << listing[i].name;
116 if (system(
"diff fsTest.out fsTest.golden"))
121 const char *magic =
"the quick brown fox jumps over a lazy dog";
123 string file_a = testdir +
"/filename.a";
124 string file_b = testdir +
"/filename.b";
126 StaticBuffer sbuf((
char *)magic, strlen(magic) + 1,
false);
127 client->append(fd, sbuf);
129 client->rename(file_a, file_b);
130 fd = client->open(file_b, 0);
131 client->read(fd, buf,
sizeof(buf));
138 int main(
int argc,
char **argv) {
140 struct sockaddr_in addr;
156 conn_mgr = make_shared<ConnectionManager>();
157 client = make_shared<FsBroker::Lib::Client>(conn_mgr, addr, 15000);
159 if (!client->wait_for_connection(15000)) {
160 HT_ERROR(
"Unable to connect to DFS");
163 string testdir =
format(
"/fsTest%d", (
int)getpid());
164 client->mkdirs(testdir);
166 test_copy(client, testdir);
168 string subdir = testdir +
"/mydir";;
169 client->mkdirs(subdir);
170 test_readdir(client, testdir);
172 test_rename(client, testdir);
174 client->rmdir(testdir);
A memory buffer of static size.
Retrieves system information (hardware, installation directory, etc)
PropertiesPtr properties
This singleton map stores all options.
static void initialize(uint16_t reactor_count)
Initializes I/O reactors.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Helper class for printing usage banners on the command line.
void init(int argc, char *argv[], const Desc *desc=NULL)
Initialize with default policy.
static void initialize(const String &install_directory=String())
Initializes the static class members; checks header version vs.
int main(int argc, char **argv)
File system utility functions.
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Logging routines and macros.
Compatibility Macros for C/C++.
Initialization helper for applications.
A memory buffer of static size.
Importing boost::thread and boost::thread_group into the Hypertable namespace.
Declarations for FsTestThreadFunction.
static bool initialize(sockaddr_in *addr, const char *host, uint16_t port)
Initialize a sockaddr_in structure from host:port.
Declarations for ConnectionManager.
Internet address wrapper classes and utility functions.
Declarations for ReactorFactory.
This is a generic exception class for Hypertable.
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
static void dump_and_exit(const char **usage, int rcode=1)
Same as dump, but performs _exit(rcode) afterwards.
Error codes, Exception handling, error logging.