Skip to content

Commit

Permalink
[stirling] Fix netty_tls_trace_bpf_test.cc mux protocol tracing opt…
Browse files Browse the repository at this point in the history
…ion. (#1690)

Summary: To prevent older kernels from complaining about eBPF
instruction count, mux protocol tracing is only enabled for "newer"
kernels. In our test case, we want to enable mux tracing. We fix test
`netty_tls_trace_bpf_test.cc` by enabling mux protocol tracing using the
test `SetUp` method (and we simultaneously disable a few other protocols
to save on eBPF instruction count). Previously, we used an init
function, but that was rendered ineffective after we switched our flags
from command line args. to env. args.

Type of change: /kind bug fix

Test Plan: Existing tests.

Signed-off-by: Pete Stevenson <[email protected]>
  • Loading branch information
Pete Stevenson authored Aug 29, 2023
1 parent 9a4ad3c commit bbcd2d0
Showing 1 changed file with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,27 @@ using ::testing::UnorderedElementsAre;

class ThriftMuxServerContainerWrapper : public ::px::stirling::testing::ThriftMuxServerContainer {};

// The Init() function is used to set flags for the entire test.
// We can't do this in the MuxTraceTest constructor, because it will be too late
// (SocketTraceBPFTestFixture will already have been constructed).
bool Init() {
// Make sure Mux tracing is enabled.
FLAGS_stirling_enable_mux_tracing = true;

// We turn off CQL and NATS tracing to give some BPF instructions back for Mux.
// This is required for older kernels with only 4096 BPF instructions.
FLAGS_stirling_enable_cass_tracing = false;
FLAGS_stirling_enable_nats_tracing = false;

// Enable the raw fptr fallback for determining ssl lib version.
FLAGS_openssl_raw_fptrs_enabled = true;
return true;
namespace {
constexpr bool kClientSideTracing = false;
}

bool kInit = Init();

template <typename TServerContainer>
class BaseOpenSSLTraceTest : public SocketTraceBPFTestFixture</* TClientSideTracing */ false> {
class BaseOpenSSLTraceTest : public SocketTraceBPFTestFixture<kClientSideTracing> {
protected:
void SetUp() override {
PX_SET_FOR_SCOPE(FLAGS_stirling_enable_mux_tracing, true);

// We turn off CQL and NATS tracing to give some BPF instructions back for Mux.
// This is required for older kernels with only 4096 BPF instructions.
PX_SET_FOR_SCOPE(FLAGS_stirling_enable_cass_tracing, false);
PX_SET_FOR_SCOPE(FLAGS_stirling_enable_nats_tracing, false);

// Enable the raw fptr fallback for determining ssl lib version.
PX_SET_FOR_SCOPE(FLAGS_openssl_raw_fptrs_enabled, true);

SocketTraceBPFTestFixture<kClientSideTracing>::SetUp();
}

BaseOpenSSLTraceTest() {
// Run the nginx HTTPS server.
// The container runner will make sure it is in the ready state before unblocking.
Expand Down

0 comments on commit bbcd2d0

Please sign in to comment.