Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Add crossdock tests (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachier authored and black-adder committed Nov 20, 2017
1 parent f325ae1 commit a92f637
Show file tree
Hide file tree
Showing 48 changed files with 1,512 additions and 776 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Build directory
# Build files
/build
/crossdock/crossdock
/crossdock/jaeger-docker-compose.yml

# vim swap files
*.swo
Expand Down Expand Up @@ -37,3 +39,6 @@
*.exe
*.out
*.app

# Log files
*.log
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ matrix:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-4.9
env:
- MATRIX_EVAL="CC=gcc-4.8 && CXX=g++-4.8"
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
branches:
only:
- master
Expand Down
64 changes: 45 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/toolchain.cmake")

set(HUNTER_CACHE_SERVERS "https://github.com/isaachier/cpp-client-hunter-cache")

include(CMakeDependentOption)
include(HunterGate)
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.19.141.tar.gz"
SHA1 "8d7162c0665aba01aaf6bf62f1ed015dc66c5e7c"
URL "https://github.com/ruslo/hunter/archive/v0.19.158.tar.gz"
SHA1 "7bd94f374bca4eff51292ca6ba029b5d688744db"
LOCAL
)

Expand Down Expand Up @@ -88,9 +89,16 @@ find_package(OpenTracing CONFIG REQUIRED)
list(APPEND LIBS OpenTracing::opentracing-static)
list(APPEND package_deps opentracing-cpp)

option(JAEGERTRACING_WITH_YAML_CPP "Use yaml-cpp to parse config files" ON)
hunter_add_package(nlohmann_json)
find_package(nlohmann_json CONFIG REQUIRED)
list(APPEND LIBS nlohmann_json)
list(APPEND package_deps nlohmann_json)

option(JAEGERTRACING_COVERAGE "Build with coverage" $ENV{COVERAGE})
option(JAEGERTRACING_BUILD_EXAMPLES "Build examples" ON)
option(JAEGERTRACING_BUILD_CROSSDOCK "Build crossdock" $ENV{CROSSDOCK})
cmake_dependent_option(
JAEGERTRACING_WITH_YAML_CPP "Use yaml-cpp to parse config files" ON
"NOT JAEGERTRACING_BUILD_CROSSDOCK" ON)

if(JAEGERTRACING_WITH_YAML_CPP)
hunter_add_package(yaml-cpp)
Expand Down Expand Up @@ -118,20 +126,36 @@ if(BUILD_TESTING)
endif()
endif()

if(JAEGERTRACING_BUILD_EXAMPLES)
set(EXAMPLES_SRC
examples/hotrod/Delay.cpp
examples/hotrod/HTTPServer.cpp)
add_executable(customer examples/hotrod/CustomerService.cpp ${EXAMPLES_SRC})
# TODO: add_executable(driver examples/hotrod/DriverService.cpp)
# TODO: add_executable(frontend examples/hotrod/FrontendService.cpp)
# TODO: add_executable(route examples/hotrod/RouteService.cpp)
set(services customer) # TODO: driver frontend route)
foreach(service IN LISTS services)
target_include_directories(${service} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/examples/hotrod>)
target_link_libraries(${service} PUBLIC jaegertracing-static)
endforeach()
if(JAEGERTRACING_BUILD_CROSSDOCK)
set(CROSSDOCK_SRC crossdock/Server.cpp)
add_executable(crossdock ${CROSSDOCK_SRC})
target_include_directories(crossdock PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/crossdock>)
target_link_libraries(crossdock PUBLIC jaegertracing-static)

set(JAEGER_CROSSDOCK_URL
"https://raw.githubusercontent.com/jaegertracing/jaeger/master/docker-compose/\
jaeger-docker-compose.yml")
file(DOWNLOAD ${JAEGER_CROSSDOCK_URL}
"${PROJECT_SOURCE_DIR}/crossdock/jaeger-docker-compose.yml")
find_program(DOCKER_COMPOSE_EXE docker-compose REQUIRED)
set(DOCKER_COMPOSE_CMD ${DOCKER_COMPOSE_EXE}
-f ${PROJECT_SOURCE_DIR}/crossdock/docker-compose.yml
-f ${PROJECT_SOURCE_DIR}/crossdock/jaeger-docker-compose.yml)
add_custom_target(crossdock-kill
COMMAND ${DOCKER_COMPOSE_CMD} kill
COMMAND ${DOCKER_COMPOSE_CMD} rm --force)
add_custom_target(crossdock-run
COMMAND ${DOCKER_COMPOSE_CMD} build
COMMAND ${DOCKER_COMPOSE_CMD} run crossdock
DEPENDS crossdock-kill)
add_custom_target(crossdock-fresh
COMMAND ${DOCKER_COMPOSE_CMD} pull
COMMAND ${DOCKER_COMPOSE_CMD} build
COMMAND ${DOCKER_COMPOSE_CMD} run crossdock
DEPENDS crossdock-kill)
add_custom_target(crossdock-logs
COMMAND ${DOCKER_COMPOSE_CMD} logs)
endif()

set(SRC
Expand All @@ -147,10 +171,11 @@ set(SRC
src/jaegertracing/Transport.cpp
src/jaegertracing/UDPTransport.cpp
src/jaegertracing/baggage/BaggageSetter.cpp
src/jaegertracing/baggage/RemoteRestrictionJSON.cpp
src/jaegertracing/baggage/RemoteRestrictionManager.cpp
src/jaegertracing/baggage/Restriction.cpp
src/jaegertracing/baggage/RestrictionManager.cpp
src/jaegertracing/baggage/RestrictionsConfig.cpp
src/jaegertracing/baggage/RemoteRestrictionManager.cpp
src/jaegertracing/metrics/Counter.cpp
src/jaegertracing/metrics/Gauge.cpp
src/jaegertracing/metrics/InMemoryStatsReporter.cpp
Expand Down Expand Up @@ -192,6 +217,7 @@ set(SRC
src/jaegertracing/samplers/GuaranteedThroughputProbabilisticSampler.cpp
src/jaegertracing/samplers/ProbabilisticSampler.cpp
src/jaegertracing/samplers/RateLimitingSampler.cpp
src/jaegertracing/samplers/RemoteSamplingJSON.cpp
src/jaegertracing/samplers/RemotelyControlledSampler.cpp
src/jaegertracing/samplers/Sampler.cpp
src/jaegertracing/samplers/SamplingStatus.cpp
Expand Down
65 changes: 5 additions & 60 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ include(CMakeParseArguments)
find_program( GCOV_PATH gcov )
find_program( LCOV_PATH lcov )
find_program( GENHTML_PATH genhtml )
find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test)
find_program( SIMPLE_PYTHON_EXECUTABLE python )

if(NOT GCOV_PATH)
Expand Down Expand Up @@ -128,13 +127,12 @@ endif()
# NOTE! The executable should always have a ZERO as exit code otherwise
# the coverage generation will not complete.
#
# SETUP_TARGET_FOR_COVERAGE(
# setup_target_for_coverage(
# NAME testrunner_coverage # New target name
# EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
# DEPENDENCIES testrunner # Dependencies to build first
# )
function(SETUP_TARGET_FOR_COVERAGE)

function(setup_target_for_coverage)
set(options NONE)
set(oneValueArgs NAME)
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
Expand Down Expand Up @@ -174,63 +172,10 @@ function(SETUP_TARGET_FOR_COVERAGE)
COMMAND ;
COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report."
)
endfunction() # setup_target_for_coverage

endfunction() # SETUP_TARGET_FOR_COVERAGE

# Defines a target for running and collection code coverage information
# Builds dependencies, runs the given executable and outputs reports.
# NOTE! The executable should always have a ZERO as exit code otherwise
# the coverage generation will not complete.
#
# SETUP_TARGET_FOR_COVERAGE_COBERTURA(
# NAME ctest_coverage # New target name
# EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR
# DEPENDENCIES executable_target # Dependencies to build first
# )
function(SETUP_TARGET_FOR_COVERAGE_COBERTURA)

set(options NONE)
set(oneValueArgs NAME)
set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES)
cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if(NOT SIMPLE_PYTHON_EXECUTABLE)
message(FATAL_ERROR "python not found! Aborting...")
endif() # NOT SIMPLE_PYTHON_EXECUTABLE

if(NOT GCOVR_PATH)
message(FATAL_ERROR "gcovr not found! Aborting...")
endif() # NOT GCOVR_PATH

# Combine excludes to several -e arguments
set(COBERTURA_EXCLUDES "")
foreach(EXCLUDE ${COVERAGE_EXCLUDES})
set(COBERTURA_EXCLUDES "-e ${EXCLUDE} ${COBERTURA_EXCLUDES}")
endforeach()

add_custom_target(${Coverage_NAME}

# Run tests
${Coverage_EXECUTABLE}

# Running gcovr
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} ${COBERTURA_EXCLUDES}
-o ${Coverage_NAME}.xml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${Coverage_DEPENDENCIES}
COMMENT "Running gcovr to produce Cobertura code coverage report."
)

# Show info where to find the report
add_custom_command(TARGET ${Coverage_NAME} POST_BUILD
COMMAND ;
COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml."
)

endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA

function(APPEND_COVERAGE_COMPILER_FLAGS)
function(append_coverage_compiler_flags)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
endfunction() # APPEND_COVERAGE_COMPILER_FLAGS
endfunction() # append_coverage_compiler_flags
2 changes: 1 addition & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -1 +1 @@
hunter_config(thrift VERSION 0.9.2-p1)
hunter_config(thrift VERSION 0.9.2-p2)
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ comment:
ignore:
- "src/jaegertracing/thrift-gen"
- "**/*Test.cpp"
- "crossdock"
19 changes: 19 additions & 0 deletions crossdock/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM gcc:7.2

WORKDIR /
RUN curl -O https://cmake.org/files/v3.10/cmake-3.10.0-rc5-Linux-x86_64.sh && \
bash cmake-3.10.0-rc5-Linux-x86_64.sh --skip-license

COPY . /app/jaegertracing
RUN rm -rf /app/jaegertracing/build && \
mkdir /app/jaegertracing/build && \
cd /app/jaegertracing/build && \
cmake -DCMAKE_BUILD_TYPE=Debug -DJAEGERTRACING_BUILD_CROSSDOCK=ON .. && \
make crossdock -j3

ENV AGENT_HOST_PORT=jaeger-agent:5775
ENV SAMPLING_SERVER_URL=http://test_driver:5778/sampling

EXPOSE 8080-8082

CMD ["/app/jaegertracing/build/crossdock"]
Loading

0 comments on commit a92f637

Please sign in to comment.