Skip to content

Commit 093d66e

Browse files
author
Pete Stevenson
authored
Update perf_profiler_bpf_test to use UnitConnector. (#1283)
Summary: we convert `perf_profiler_bpf_test` to use `UnitConnector` to share code across different tests and binaries. We also refactor the Java test case to separately test the expectation that Java symbolization artifacts are removed after processes stop. The main Java test case then conforms to the pattern established for Go and cpp. We also update some of the helper functions in the test to tidy up the common test cases. Type of change: /kind cleanup Test Plan: existing tests & runs per test. - [x] `bazel test //src/stirling/source_connectors/perf_profiler/... --config bpf --runs_per_test 16` ([all tests passed](https://phab.corp.pixielabs.ai/P372)). --------- Signed-off-by: Pete Stevenson <jps@pixielabs.ai>
1 parent dbc37d4 commit 093d66e

3 files changed

Lines changed: 204 additions & 148 deletions

File tree

src/stirling/core/unit_connector.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ class UnitConnector {
111111
return Status::OK();
112112
}
113113

114+
Status ResetConnectorContext(absl::flat_hash_set<md::UPID> upids) {
115+
// Stop transferring data.
116+
PX_RETURN_IF_ERROR(StopTransferDataThread());
117+
if (upids.size() == 0) {
118+
// The upids set is empty: trace all processes and use automatic context refresh.
119+
ctx_ = std::make_unique<EverythingLocalContext>();
120+
} else {
121+
// The upids set is non-empty: we will trace only processes identified by that set.
122+
ctx_ = std::make_unique<StandaloneContext>(upids);
123+
}
124+
// Restart.
125+
PX_RETURN_IF_ERROR(StartTransferDataThread());
126+
127+
return Status::OK();
128+
}
129+
114130
Status Init(absl::flat_hash_set<md::UPID> upids = {}) {
115131
if (upids.size() == 0) {
116132
// Enter this branch if Init() is called with no arguments (i.e. with a default empty set).

src/stirling/source_connectors/perf_profiler/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pl_cc_bpf_test(
5151
"//src/stirling/source_connectors/perf_profiler/testing/cc:profiler_test_app_fib",
5252
"//src/stirling/source_connectors/perf_profiler/testing/go:profiler_test_app_sqrt_go",
5353
"//src/stirling/source_connectors/perf_profiler/testing/java:graal-vm-aot-test",
54+
"//src/stirling/source_connectors/perf_profiler/testing/java:profiler_test",
5455
],
5556
defines = ['JDK_IMAGE_NAMES=\\"%s\\"' % ",".join(jdk_image_names)],
5657
env = {"QEMU_CPU_COUNT": "4"},

0 commit comments

Comments
 (0)