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

Commit d123936

Browse files
GitHub Actions should execute tests (#260)
* 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]>
1 parent d64d606 commit d123936

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

.github/workflows/macos.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434

3535
- name: Build
3636
run: cmake --build build -j4
37+
38+
- name: Test
39+
run: |
40+
cd build
41+
ctest -V --timeout 600

.github/workflows/ubuntu.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434

3535
- name: Build
3636
run: cmake --build build -j4
37+
38+
- name: Test
39+
run: |
40+
cd build
41+
ctest -V --timeout 600

.github/workflows/windows.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ jobs:
3434

3535
- name: Build
3636
run: cmake --build build -j4
37+
38+
- name: Test
39+
run: |
40+
cd build
41+
ctest -V -C Debug --timeout 600

src/jaegertracing/ThriftSenderTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ TEST(ThriftSender, testManyMessages)
7373
std::static_pointer_cast<const Tracer>(opentracing::Tracer::Global());
7474

7575
std::unique_ptr<utils::Transport> transporter(
76-
new utils::UDPTransporter(handle->_mockAgent->spanServerAddress(), 0));
76+
new utils::UDPTransporter(handle->_mockAgent->spanServerAddress(), 9216));
7777
ThriftSender sender(
7878
std::forward<std::unique_ptr<utils::Transport>>(transporter));
7979
constexpr auto kNumMessages = 2000;
@@ -100,7 +100,7 @@ TEST(ThriftSender, testExceptions)
100100
MockUDPSender::ExceptionType::kString
101101
};
102102
for (auto type : exceptionTypes) {
103-
MockThriftSender mockSender(net::IPAddress::v4("localhost", 0), 0, type);
103+
MockThriftSender mockSender(net::IPAddress::v4("localhost", 1234), 0, type);
104104
mockSender.append(span);
105105
ASSERT_THROW(mockSender.flush(), Sender::Exception);
106106
}

src/jaegertracing/TracerTest.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,26 +556,16 @@ TEST(Tracer, testTracerSpanSelfRefWithOtherRefs)
556556

557557
TEST(Tracer, testTracerWithTraceId128Bit)
558558
{
559-
Config config(
560-
false,
561-
true,
562-
samplers::Config(
563-
"const", 1, "", 0, samplers::Config::Clock::duration()),
564-
reporters::Config(0, std::chrono::milliseconds(100), false, "", ""),
565-
propagation::HeadersConfig(),
566-
baggage::RestrictionsConfig(),
567-
"test-service",
568-
std::vector<Tag>());
569-
570-
auto tracer = Tracer::make(config);
571-
572-
opentracing::StartSpanOptions options;
573-
std::unique_ptr<Span> span(static_cast<Span*>(
574-
tracer->StartSpanWithOptions("test-operation", options).release()));
575-
576-
auto traceID = span->context().traceID();
577-
578-
ASSERT_GT(traceID.high(), 0);
559+
const auto handle = testutils::TracerUtil::installGlobalTracer128Bit();
560+
const auto tracer = std::static_pointer_cast<Tracer>(opentracing::Tracer::Global());
561+
{
562+
auto span = tracer->StartSpan("test-operation");
563+
ASSERT_TRUE(span);
564+
auto jaegerSpan = dynamic_cast<jaegertracing::Span&>(*span.get());
565+
auto traceID = jaegerSpan.context().traceID();
566+
ASSERT_GT(traceID.high(), 0);
567+
}
568+
tracer->close();
579569
}
580570

581571
} // namespace jaegertracing

src/jaegertracing/testutils/TracerUtil.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace jaegertracing {
3131
namespace testutils {
3232
namespace TracerUtil {
3333

34-
std::shared_ptr<ResourceHandle> installGlobalTracer()
34+
std::shared_ptr<ResourceHandle> installGlobalTracer(bool traceId128Bit)
3535
{
3636
std::unique_ptr<ResourceHandle> handle(new ResourceHandle());
3737
handle->_mockAgent->start();
@@ -40,7 +40,7 @@ std::shared_ptr<ResourceHandle> installGlobalTracer()
4040
<< "http://" << handle->_mockAgent->samplingServerAddress().authority();
4141
Config config(
4242
false,
43-
false,
43+
traceId128Bit,
4444
samplers::Config("const",
4545
1,
4646
samplingServerURLStream.str(),
@@ -58,6 +58,16 @@ std::shared_ptr<ResourceHandle> installGlobalTracer()
5858
return std::move(handle);
5959
}
6060

61+
std::shared_ptr<ResourceHandle> installGlobalTracer()
62+
{
63+
return installGlobalTracer(false);
64+
}
65+
66+
std::shared_ptr<ResourceHandle> installGlobalTracer128Bit()
67+
{
68+
return installGlobalTracer(true);
69+
}
70+
6171
std::shared_ptr<opentracing::Tracer> buildTracer(const std::string& endpoint)
6272
{
6373
std::ostringstream samplingServerURLStream;

src/jaegertracing/testutils/TracerUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct ResourceHandle {
4141
};
4242

4343
std::shared_ptr<ResourceHandle> installGlobalTracer();
44+
std::shared_ptr<ResourceHandle> installGlobalTracer128Bit();
4445
std::shared_ptr<opentracing::Tracer> buildTracer(const std::string& endpoint);
4546

4647
} // namespace TracerUtil

0 commit comments

Comments
 (0)