Skip to content

Commit

Permalink
Fix problems with unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Sep 22, 2023
1 parent 7db3e6f commit f47d40f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 31 deletions.
6 changes: 5 additions & 1 deletion system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class CServerSpan : public CSpan

void setSpanContext(StringArray & httpHeaders, const char kvDelineator = ':')
{
Owned<IProperties> contextProps = createProperties();
Owned<IProperties> contextProps = createProperties(true);
ForEachItemIn(currentHeaderIndex, httpHeaders)
{
const char* httpHeader = httpHeaders.item(currentHeaderIndex);
Expand Down Expand Up @@ -516,11 +516,15 @@ class CServerSpan : public CSpan

if (httpHeaders->hasProp(kGlobalIdHttpHeaderName))
hpccGlobalId.set(httpHeaders->queryProp(kGlobalIdHttpHeaderName));
else if (httpHeaders->hasProp(kLegacyGlobalIdHttpHeaderName))
hpccGlobalId.set(httpHeaders->queryProp(kLegacyGlobalIdHttpHeaderName));
else
DBGLOG("ServerSpan: HPCCGlobalID not found in http headers");

if (httpHeaders->hasProp(kCallerIdHttpHeaderName))
hpccCallerId.set(httpHeaders->queryProp(kCallerIdHttpHeaderName));
else if (httpHeaders->hasProp(kLegacyCallerIdHttpHeaderName))
hpccCallerId.set(httpHeaders->queryProp(kLegacyCallerIdHttpHeaderName));
else
{
DBGLOG("ServerSpan: HPCCCallerID not provied");
Expand Down
2 changes: 2 additions & 0 deletions system/jlib/jtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
static constexpr const char *kGlobalIdHttpHeaderName = "global-id";
static constexpr const char *kCallerIdHttpHeaderName = "caller-id";
static constexpr const char *kLegacyGlobalIdHttpHeaderName = "hpcc-global-id";
static constexpr const char *kLegacyCallerIdHttpHeaderName = "hpcc-caller-id";

class jlib_decl LogTrace
{
Expand Down
60 changes: 30 additions & 30 deletions testing/unittests/jlibtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ class JlibTraceTest : public CppUnit::TestFixture

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess);

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0,
strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0,
strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0,
strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected",
strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected",
strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected",
strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("traceID")));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty SpanID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("spanID")));
Expand Down Expand Up @@ -178,14 +178,14 @@ class JlibTraceTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing localParentSpanID detected", true,
retrievedSpanCtxAttributes->hasProp("localParentSpanID"));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Mismatched localParentSpanID detected", 0,
strcmp(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID")));
CPPUNIT_ASSERT_MESSAGE("Mismatched localParentSpanID detected",
strsame(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID")));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing remoteParentID detected", true,
retrievedSpanCtxAttributes->hasProp("remoteParentID"));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0,
strcmp(serverTraceID, retrievedSpanCtxAttributes->queryProp("remoteParentID")));
CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected",
strsame(serverTraceID, retrievedSpanCtxAttributes->queryProp("remoteParentID")));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", false,
retrievedSpanCtxAttributes->hasProp(kGlobalIdHttpHeaderName));
Expand Down Expand Up @@ -227,8 +227,8 @@ class JlibTraceTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing localParentSpanID detected", true,
retrievedSpanCtxAttributes->hasProp("localParentSpanID"));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Mismatched localParentSpanID detected", 0,
strcmp(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID")));
CPPUNIT_ASSERT_MESSAGE("Mismatched localParentSpanID detected",
strsame(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID")));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected remoteParentSpanID detected", false,
retrievedSpanCtxAttributes->hasProp("remoteParentSpanID"));
Expand Down Expand Up @@ -323,13 +323,13 @@ class JlibTraceTest : public CppUnit::TestFixture

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess);

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0,
strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0,
strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected",
strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected",
strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0,
strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected",
strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
}

void testPropegatedServerSpan()
Expand All @@ -348,13 +348,13 @@ class JlibTraceTest : public CppUnit::TestFixture

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess);

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0,
strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0,
strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected",
strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected",
strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0,
strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected",
strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("traceID")));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty SpanID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("spanID")));
Expand Down Expand Up @@ -394,13 +394,13 @@ class JlibTraceTest : public CppUnit::TestFixture

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess);

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0,
strcmp("someGlobalID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0,
strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", true,
strsame("someGlobalID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", true,
strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName)));

CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0,
strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", true,
strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID")));
}
}
};
Expand Down

0 comments on commit f47d40f

Please sign in to comment.