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

Commit

Permalink
GitHub Actions should execute tests (#260)
Browse files Browse the repository at this point in the history
* Enabled tests for GitHub Actions

Signed-off-by: Tobias Stadler <[email protected]>

* The UDP buffer size on macOS is less then kUDPPacketMaxLength (see sysctl net.inet.udp.maxdgram)

Signed-off-by: Tobias Stadler <[email protected]>

* Test throws a "Cannot connect socket to remote address { family=2,addr=127.0.0.1, port=0 }" exception on macOS

Signed-off-by: Tobias Stadler <[email protected]>

* Fix test on windows

Signed-off-by: Tobias Stadler <[email protected]>

* Improve readability

Signed-off-by: Tobias Stadler <[email protected]>
  • Loading branch information
tobiasstadler authored Feb 9, 2021
1 parent d64d606 commit d123936
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:

- name: Build
run: cmake --build build -j4

- name: Test
run: |
cd build
ctest -V --timeout 600
5 changes: 5 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:

- name: Build
run: cmake --build build -j4

- name: Test
run: |
cd build
ctest -V --timeout 600
5 changes: 5 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ jobs:

- name: Build
run: cmake --build build -j4

- name: Test
run: |
cd build
ctest -V -C Debug --timeout 600
4 changes: 2 additions & 2 deletions src/jaegertracing/ThriftSenderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TEST(ThriftSender, testManyMessages)
std::static_pointer_cast<const Tracer>(opentracing::Tracer::Global());

std::unique_ptr<utils::Transport> transporter(
new utils::UDPTransporter(handle->_mockAgent->spanServerAddress(), 0));
new utils::UDPTransporter(handle->_mockAgent->spanServerAddress(), 9216));
ThriftSender sender(
std::forward<std::unique_ptr<utils::Transport>>(transporter));
constexpr auto kNumMessages = 2000;
Expand All @@ -100,7 +100,7 @@ TEST(ThriftSender, testExceptions)
MockUDPSender::ExceptionType::kString
};
for (auto type : exceptionTypes) {
MockThriftSender mockSender(net::IPAddress::v4("localhost", 0), 0, type);
MockThriftSender mockSender(net::IPAddress::v4("localhost", 1234), 0, type);
mockSender.append(span);
ASSERT_THROW(mockSender.flush(), Sender::Exception);
}
Expand Down
30 changes: 10 additions & 20 deletions src/jaegertracing/TracerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,26 +556,16 @@ TEST(Tracer, testTracerSpanSelfRefWithOtherRefs)

TEST(Tracer, testTracerWithTraceId128Bit)
{
Config config(
false,
true,
samplers::Config(
"const", 1, "", 0, samplers::Config::Clock::duration()),
reporters::Config(0, std::chrono::milliseconds(100), false, "", ""),
propagation::HeadersConfig(),
baggage::RestrictionsConfig(),
"test-service",
std::vector<Tag>());

auto tracer = Tracer::make(config);

opentracing::StartSpanOptions options;
std::unique_ptr<Span> span(static_cast<Span*>(
tracer->StartSpanWithOptions("test-operation", options).release()));

auto traceID = span->context().traceID();

ASSERT_GT(traceID.high(), 0);
const auto handle = testutils::TracerUtil::installGlobalTracer128Bit();
const auto tracer = std::static_pointer_cast<Tracer>(opentracing::Tracer::Global());
{
auto span = tracer->StartSpan("test-operation");
ASSERT_TRUE(span);
auto jaegerSpan = dynamic_cast<jaegertracing::Span&>(*span.get());
auto traceID = jaegerSpan.context().traceID();
ASSERT_GT(traceID.high(), 0);
}
tracer->close();
}

} // namespace jaegertracing
14 changes: 12 additions & 2 deletions src/jaegertracing/testutils/TracerUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace jaegertracing {
namespace testutils {
namespace TracerUtil {

std::shared_ptr<ResourceHandle> installGlobalTracer()
std::shared_ptr<ResourceHandle> installGlobalTracer(bool traceId128Bit)
{
std::unique_ptr<ResourceHandle> handle(new ResourceHandle());
handle->_mockAgent->start();
Expand All @@ -40,7 +40,7 @@ std::shared_ptr<ResourceHandle> installGlobalTracer()
<< "http://" << handle->_mockAgent->samplingServerAddress().authority();
Config config(
false,
false,
traceId128Bit,
samplers::Config("const",
1,
samplingServerURLStream.str(),
Expand All @@ -58,6 +58,16 @@ std::shared_ptr<ResourceHandle> installGlobalTracer()
return std::move(handle);
}

std::shared_ptr<ResourceHandle> installGlobalTracer()
{
return installGlobalTracer(false);
}

std::shared_ptr<ResourceHandle> installGlobalTracer128Bit()
{
return installGlobalTracer(true);
}

std::shared_ptr<opentracing::Tracer> buildTracer(const std::string& endpoint)
{
std::ostringstream samplingServerURLStream;
Expand Down
1 change: 1 addition & 0 deletions src/jaegertracing/testutils/TracerUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct ResourceHandle {
};

std::shared_ptr<ResourceHandle> installGlobalTracer();
std::shared_ptr<ResourceHandle> installGlobalTracer128Bit();
std::shared_ptr<opentracing::Tracer> buildTracer(const std::string& endpoint);

} // namespace TracerUtil
Expand Down

0 comments on commit d123936

Please sign in to comment.