Skip to content

Commit

Permalink
HPCC-30687 Expand JTrace unittest coverage
Browse files Browse the repository at this point in the history
- Defines clientSpan test
- Adds clientSpan test to jtrace suite
- Ensures propagate GlobalID is persisted

Signed-off-by: Rodrigo Pastrana <rodrigo.pastrana@lexisnexisrisk.com>
  • Loading branch information
rpastrana committed Nov 8, 2023
1 parent f7bd330 commit cd3a73e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions testing/unittests/jlibtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class JlibTraceTest : public CppUnit::TestFixture
CPPUNIT_TEST(testInternalSpan);
CPPUNIT_TEST(testMultiNestedSpanTraceOutput);
CPPUNIT_TEST(testNullSpan);
CPPUNIT_TEST(testClientSpanGlobalID);
CPPUNIT_TEST_SUITE_END();

const char * simulatedGlobalYaml = R"!!(global:
Expand Down Expand Up @@ -416,6 +417,31 @@ class JlibTraceTest : public CppUnit::TestFixture
}
}

void testClientSpanGlobalID()
{
Owned<IProperties> mockHTTPHeaders = createProperties();
createMockHTTPHeaders(mockHTTPHeaders, true); //includes global ID

Owned<ISpan> serverSpan = queryTraceManager().createServerSpan("propegatedServerSpan", mockHTTPHeaders);
Owned<ISpan> clientSpan = serverSpan->createClientSpan("clientSpanWithGlobalID");

//retrieve serverSpan context with the intent to interrogate attributes
{
Owned<IProperties> retrievedClientSpanCtxAttributes = createProperties();
bool getClientSpanCtxSuccess = clientSpan->getSpanContext(retrievedClientSpanCtxAttributes.get(), false);

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected on client span", true, getClientSpanCtxSuccess);

CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected",
strsame("IncomingUGID", retrievedClientSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected",
strsame("IncomingCID", retrievedClientSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedClientSpanCtxAttributes->queryProp("traceID")));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty SpanID detected", false, isEmptyString(retrievedClientSpanCtxAttributes->queryProp("spanID")));
}
}

void testPropegatedServerSpan()
{
Owned<IProperties> mockHTTPHeaders = createProperties();
Expand Down

0 comments on commit cd3a73e

Please sign in to comment.