Skip to content

Commit

Permalink
Fixing make -j and gmock problem and switch folly to a sister dir, ad…
Browse files Browse the repository at this point in the history
…ding colorize, cmake quoting, corruption in url

Summary: Fixing make -j and gmock problem and switch folly to a sister dir, adding colorize, cmake quoting, corruption in url
Closes facebook#12, Closes facebook#18, Closes facebook#10, Closes facebook#22, Closes facebook#24

Reviewed By: @nikunjy

Differential Revision: D2285664
  • Loading branch information
ldemailly committed Jul 29, 2015
1 parent dc80f72 commit 4cb26e3
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 28 deletions.
10 changes: 4 additions & 6 deletions BUILD.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sudo apt-get install libgoogle-glog-dev libboost-system-dev \
# If double-conversion isn't available:

git clone https://github.com/floitsch/double-conversion.git
cd double-conversion; cmake . ; make && sudo make install
cd double-conversion; cmake . ; make -j && sudo make install


# Get and install gflags and glog - it's important to build and configure
Expand All @@ -46,11 +46,11 @@ git clone https://github.com/schuhschuh/gflags.git
mkdir gflags/build
cd gflags/build
cmake -D GFLAGS_NAMESPACE=google -D BUILD_SHARED_LIBS=on ..
make && sudo make install
make -j && sudo make install
# Glog
svn checkout http://google-glog.googlecode.com/svn/trunk/ glog
cd glog
./configure && make && sudo make install
./configure && make -j && sudo make install


# And finally Build wdt itself:
Expand Down Expand Up @@ -81,7 +81,7 @@ brew update
brew install glog gflags boost
## Double conversion
git clone https://github.com/floitsch/double-conversion.git
cd double-conversion; cmake . ; make && sudo make install
cd double-conversion; cmake . ; make -j && sudo make install

### Get folly source tree
As above
Expand All @@ -93,8 +93,6 @@ cd wdt_mac
cmake pathtosrccode -G Xcode -DBUILD_TESTING=on
# Using unix makefiles
cmake pathtosrccode -G "Unix Makefiles" -DBUILD_TESTING=on
# Do not use -j the first time as gmock download cause issues
# http://www.cmake.org/Bug/view.php?id=15663
make -j
make test
sudo make install
Expand Down
33 changes: 20 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.2)
# There is no C per se in WDT but if you use CXX only here many checks fail
# Version is Major.Minor.YYMMDDX for up to 10 releases per day
# Minor currently is also the protocol version - has to match with Protocol.cpp
project("WDT" LANGUAGES C CXX VERSION 1.14.1507210)
project("WDT" LANGUAGES C CXX VERSION 1.14.1507270)

# On MacOS this requires the latest (master) CMake (and/or CMake 3.1.1/3.2)
set(CMAKE_CXX_STANDARD 11)
Expand All @@ -47,25 +47,26 @@ set(CMAKE_CXX_FLAGS "-msse4.2")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "_bin/wdt")

# Check that we have the Folly source tree
set(FOLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/folly CACHE path
set(FOLLY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../folly" CACHE path
"Folly source tree (folly/ThreadLocal.h should be reachable from there")
# Check for folly - TODO: this doesn't work well for relative paths
# (because of relative to build dir vs relative to source tree for -I)
if(NOT EXISTS "${FOLLY_SOURCE_DIR}/folly/ThreadLocal.h")
MESSAGE(FATAL_ERROR "${FOLLY_SOURCE_DIR}/folly/ThreadLocal.h not found
Fix using:
mkdir deps; cd deps; git clone https://github.com/facebook/folly.git
(in a sister directory of the wdt source tree - same level:)
git clone https://github.com/facebook/folly.git
or change FOLLY_SOURCE_DIR (use ccmake or -DFOLLY_SOURCE_DIR=...)
")
endif()


# The part of folly that isn't pure .h and we use:
set (FOLLY_CPP_SRC
${FOLLY_SOURCE_DIR}/folly/Conv.cpp
${FOLLY_SOURCE_DIR}/folly/Demangle.cpp
${FOLLY_SOURCE_DIR}/folly/Malloc.cpp
${FOLLY_SOURCE_DIR}/folly/Checksum.cpp
"${FOLLY_SOURCE_DIR}/folly/Conv.cpp"
"${FOLLY_SOURCE_DIR}/folly/Demangle.cpp"
"${FOLLY_SOURCE_DIR}/folly/Malloc.cpp"
"${FOLLY_SOURCE_DIR}/folly/Checksum.cpp"
)

# WDT's library proper - comes from: ls -1 *.cpp | grep -iv test
Expand Down Expand Up @@ -160,12 +161,12 @@ configure_file(WdtConfig.h.in wdt/WdtConfig.h)

# Malloc stuff tied to not supporting weaksympbols
if (NOT FOLLY_HAVE_WEAK_SYMBOLS)
list(APPEND FOLLY_CPP_SRC ${FOLLY_SOURCE_DIR}/folly/detail/MallocImpl.cpp)
list(APPEND FOLLY_CPP_SRC "${FOLLY_SOURCE_DIR}/folly/detail/MallocImpl.cpp")
message(STATUS "no weak symbols, adding MallocImpl to folly src")
endif()
# For missing __throw_logic_error:
if (NOT FOLLY_HAVE_BITS_FUNCTEXCEPT)
list(APPEND FOLLY_CPP_SRC ${FOLLY_SOURCE_DIR}/folly/detail/FunctionalExcept.cpp)
list(APPEND FOLLY_CPP_SRC "${FOLLY_SOURCE_DIR}/folly/detail/FunctionalExcept.cpp")
message(STATUS "no bits/functexcept.h, adding FunctionalExcept to folly src")
endif()

Expand Down Expand Up @@ -201,8 +202,8 @@ if (BUILD_TESTING)

# Extra code that we use in tests
add_library(wdt4tests
${FOLLY_SOURCE_DIR}/folly/FileUtil.cpp # used by Random used by tests
${FOLLY_SOURCE_DIR}/folly/Random.cpp # used indirectly by tests
"${FOLLY_SOURCE_DIR}/folly/FileUtil.cpp" # used by Random used by tests
"${FOLLY_SOURCE_DIR}/folly/Random.cpp" # used indirectly by tests
)

include(ExternalProject)
Expand All @@ -223,7 +224,7 @@ if (BUILD_TESTING)
)
# Specify include dir for both gmock and gtest
externalproject_get_property(gmock SOURCE_DIR)
include_directories(${SOURCE_DIR}/include ${SOURCE_DIR}/gtest/include)
include_directories("${SOURCE_DIR}/include" "${SOURCE_DIR}/gtest/include")

externalproject_get_property(gmock BINARY_DIR)

Expand All @@ -232,6 +233,7 @@ if (BUILD_TESTING)
# ${GMOCK_PREFIX}/src/gmock/gmock-all.cc
# ${GMOCK_PREFIX}/src/gmock/gmock_main.cc)

add_dependencies(wdt4tests gmock)

# ${BINARY_DIR}/libgmock.a works everywhere except xcode...
# so ugly weird hack generating warnings about unknown dir for now:
Expand All @@ -249,5 +251,10 @@ if (BUILD_TESTING)
add_test(NAME ResourceControllerTests COMMAND resource_controller_test)

add_test(NAME WdtRandGenTest COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/wdt_rand_gen_test.sh)
"${CMAKE_CURRENT_SOURCE_DIR}/wdt_rand_gen_test.sh")

add_test(NAME WdtBasicE2E COMMAND
"${CMAKE_CURRENT_SOURCE_DIR}/wdt_e2e_simple_test.sh")


endif(BUILD_TESTING)
2 changes: 1 addition & 1 deletion FileCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ bool FileCreator::createDirRecursively(const std::string dir, bool force) {
std::string fullDirPath;
folly::toAppend(rootDir_, dir, &fullDirPath);
int code = mkdir(fullDirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (code != 0 && errno != EEXIST) {
if (code != 0 && errno != EEXIST && errno != EISDIR) {
PLOG(ERROR) << "failed to make directory " << fullDirPath;
return false;
} else if (code != 0) {
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![](wdt_logo.png)
`WDT` Warp speed Data Transfer
------------------------------

Expand Down Expand Up @@ -253,7 +254,12 @@ a 1 second delay before we send the first payload byte

See CONTRIBUTING.md

Please run the tests (make test) and the manual tests (integration upcoming)
Please run the tests
```
CTEST_OUTPUT_ON_FAILURE=1 make test
```
And ideally also the manual tests (integration/porting upcoming)

wdt_e2e_test.sh
wdt_download_resumption_test.sh
wdt_network_test.sh
Expand Down
5 changes: 3 additions & 2 deletions WdtBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ WdtTransferRequest::WdtTransferRequest(const string& uriString) {
<< wdtUri.getQueryParam(PROTOCOL_VERSION_PARAM);
errorCode = URI_PARSE_ERROR;
}
StringPiece portsList(wdtUri.getQueryParam(PORTS_PARAM));
string portsStr(wdtUri.getQueryParam(PORTS_PARAM));
StringPiece portsList(portsStr); // pointers into portsStr
do {
StringPiece portNum = portsList.split_step(',');
int port = 0;
int port;
if (!portNum.empty()) {
try {
port = folly::to<int32_t>(portNum);
Expand Down
4 changes: 2 additions & 2 deletions WdtConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#define WDT_VERSION_MAJOR 1
#define WDT_VERSION_MINOR 14
#define WDT_VERSION_BUILD 1507210
#define WDT_VERSION_BUILD 1507270
// Add -fbcode to version str
#define WDT_VERSION_STR "1.14.1507210-fbcode"
#define WDT_VERSION_STR "1.14.1507270-fbcode"
// Tie minor and proto version
#define WDT_PROTOCOL_VERSION WDT_VERSION_MINOR

Expand Down
1 change: 1 addition & 0 deletions WdtResourceControllerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void WdtResourceControllerTest::InvalidNamespaceTest() {
ReceiverPtr receiverPtr;
ErrorCode code = createReceiver(wdtNamespace, transferRequest.transferId,
transferRequest, receiverPtr);
ASSERT_EQ(code, NOT_FOUND);
/// Receiver should not be added
ASSERT_TRUE(receiverPtr == nullptr);
EXPECT_EQ(deRegisterWdtNamespace(wdtNamespace), ERROR);
Expand Down
3 changes: 3 additions & 0 deletions colorize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh
# Very inneficient way to colorize log input
awk '/^I/ {system("tput setaf 2"); print $0} /^W/ {system("tput setaf 3"); print $0} /^E/ {system("tput setaf 1"); print $0} /^C/ {system("tput setaf 5"); print $0} /^[^IWEC]/ {system("tput sgr0"); print $0}'
138 changes: 138 additions & 0 deletions wdt_e2e_simple_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#! /bin/bash

#
# Smaller/minimal version of wdt_e2e_simple_test.sh
#

echo "Run from the cmake build dir (or ~/fbcode - or fbmake runtests)"

# Set DO_VERIFY:
# to 1 : slow/expensive but checks correctness
# to 0 : fast for repeated benchmarking not for correctness
DO_VERIFY=1

# Verbose / to debug failure:
#WDTBIN="_bin/wdt/wdt -minloglevel 0 -v 99"
# Normal:
WDTBIN_OPTS="-minloglevel=0 -sleep_millis 1 -max_retries 999 -full_reporting "\
"-avg_mbytes_per_sec=3000 -max_mbytes_per_sec=3500 "\
"-num_ports=4 -throttler_log_time_millis=200 -enable_checksum=true"
WDTBIN="_bin/wdt/wdt $WDTBIN_OPTS"

if [ -z "$HOSTNAME" ] ; then
echo "HOSTNAME not set, will try with 'localhost'"
HOSTNAME=localhost
else
echo "Will self connect to HOSTNAME=$HOSTNAME"
fi

BASEDIR=/tmp/wdtTest
mkdir -p $BASEDIR
DIR=`mktemp -d $BASEDIR/XXXXXX`
echo "Testing in $DIR"

#pkill -x wdt

mkdir $DIR/src
mkdir $DIR/extsrc

#cp -R wdt folly /usr/bin /usr/lib /usr/lib64 /usr/libexec /usr/share $DIR/src
#cp -R wdt folly /usr/bin /usr/lib /usr/lib64 /usr/libexec $DIR/src
#cp -R wdt $DIR/src

#for size in 1k 64K 512K 1M 16M 256M 512M 1G
#for size in 512K 1M 16M 256M 512M 1G
# Mac's dd doesn't understand K,M,G...
for size in 1024 65536 524288 1232896 19726336
do
base=inp$size
echo dd if=/dev/... of=$DIR/src/$base.1 bs=$size count=1
dd if=/dev/urandom of=$DIR/src/$base.1 bs=$size count=1
# dd if=/dev/zero of=$DIR/src/$base.1 bs=$size count=1
for i in {2..8}
do
cp $DIR/src/$base.1 $DIR/src/$base.$i
done
done
echo "done with setup"

# test symlink issues
(cd $DIR/src ; touch a; ln -s doesntexist badlink; dd if=/dev/zero of=c bs=1024 count=1; mkdir d; ln -s ../d d/e; ln -s ../c d/a)
(cd $DIR/extsrc; mkdir TestDir; mkdir TestDir/test; cd TestDir; echo "Text1" >> file1; cd test; echo "Text2" >> file1; ln -s $DIR/extsrc/TestDir; cp -R $DIR/extsrc/TestDir $DIR/src)

# Can't have both client and server send to stdout in parallel or log lines
# get mangled/are missing - so we redirect the server one
echo "$WDTBIN -minloglevel=1 -directory $DIR/dst > $DIR/server.log 2>&1 &"
$WDTBIN -minloglevel=1 -directory $DIR/dst > $DIR/server.log 2>&1 &
# client now retries connects so no need wait for server to be up
pidofreceiver=$!
# To test only 1 socket (single threaded send/receive)
#$WDTBIN -num_sockets=1 -directory $DIR/src -destination ::1
# Normal


echo "$WDTBIN -directory $DIR/src -destination $HOSTNAME 2>&1 | tee $DIR/client.log"
time $WDTBIN -directory $DIR/src -destination $HOSTNAME 2>&1 | tee $DIR/client.log

# 2nd Receiver:
echo "$WDTBIN -directory $DIR/dst_symlinks >> $DIR/server.log 2>&1 &"
$WDTBIN -directory $DIR/dst_symlinks >> $DIR/server.log 2>&1 &


echo "$WDTBIN -follow_symlinks -directory $DIR/src -destination $HOSTNAME 2>&1 | tee -a $DIR/client.log"
time $WDTBIN -follow_symlinks -directory $DIR/src -destination $HOSTNAME 2>&1 | tee -a $DIR/client.log


if [ $DO_VERIFY -eq 1 ] ; then
echo "Verifying for run without follow_symlinks"
echo "Checking for difference `date`"

NUM_FILES=`(cd $DIR/dst ; ( find . -type f | wc -l))`
echo "Transfered `du -ks $DIR/dst` kbytes across $NUM_FILES files"

(cd $DIR/src ; ( find . -type f -print0 | xargs -0 md5sum | sort ) \
> ../src.md5s )
(cd $DIR/dst ; ( find . -type f -print0 | xargs -0 md5sum | sort ) \
> ../dst.md5s )

echo "Should be no diff"
(cd $DIR; diff -u src.md5s dst.md5s)
STATUS=$?


echo "Verifying for run with follow_symlinks"
echo "Checking for difference `date`"

NUM_FILES=`(cd $DIR/dst_symlinks; ( find . -type f | wc -l))`
echo "Transfered `du -ks $DIR/dst_symlinks` kbytes across $NUM_FILES files"

(cd $DIR/src ; ( find -L . -type f -print0 | xargs -0 md5sum | sort ) \
> ../src_symlinks.md5s )
(cd $DIR/dst_symlinks ; ( find . -type f -print0 | xargs -0 md5sum \
| sort ) > ../dst_symlinks.md5s )

echo "Should be no diff"
(cd $DIR; diff -u src_symlinks.md5s dst_symlinks.md5s)
SYMLINK_STATUS=$?
if [ $STATUS -eq 0 ] ; then
STATUS=$SYMLINK_STATUS
fi
#(cd $DIR; ls -lR src/ dst/ )
else
echo "Skipping independant verification"
STATUS=0
fi


echo "Server logs:"
cat $DIR/server.log

if [ $STATUS -eq 0 ] ; then
echo "Good run, deleting logs in $DIR"
find $DIR -type d | xargs chmod 755 # cp -r can make some unreadable dir
rm -rf $DIR
else
echo "Bad run ($STATUS) - keeping full logs and partial transfer in $DIR"
fi

exit $STATUS
Binary file added wdt_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions wdt_rand_gen_test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /bin/bash
#! /bin/sh

transferId1=$(_bin/wdt/resource_controller_test |& grep Generated | head -1 | \
transferId1=$(_bin/wdt/resource_controller_test 2>&1 | grep Generated | head -1 | \
awk '{print $9}')
transferId2=$(_bin/wdt/resource_controller_test |& grep Generated | head -1 | \
transferId2=$(_bin/wdt/resource_controller_test 2>&1 | grep Generated | head -1 | \
awk '{print $9}')

if [ "$transferId1" == "$transferId2" ]; then
Expand Down

0 comments on commit 4cb26e3

Please sign in to comment.