Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ut #1980

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix ut #1980

wants to merge 3 commits into from

Conversation

NameHaibinZhang
Copy link
Collaborator

@NameHaibinZhang NameHaibinZhang commented Dec 19, 2024

This pull request includes several changes to the K8sMetadata class and its associated unit tests to improve memory management and testing coverage. The key changes involve adding a cache-clearing method, modifying the singleton pattern, and updating the unit tests to reflect these changes.

Improvements to K8sMetadata class:

  • Added ClearCache method to K8sMetadata class to clear containerCache and ipCache. (core/metadata/K8sMetadata.cpp, core/metadata/K8sMetadata.h) [1] [2]
  • Modified the destructor of K8sMetadata to call ClearCache. (core/metadata/K8sMetadata.h)
  • Changed the singleton pattern to return a pointer instead of a reference. (core/metadata/K8sMetadata.h, core/metadata/LabelingK8sMetadata.cpp) [1] [2] [3] [4]

Updates to unit tests:

  • Re-enabled the metadata_unittest executable and Google Test discovery in CMakeLists.txt. (core/unittest/metadata/CMakeLists.txt)
  • Refactored K8sMetadataUnittest to use the new pointer-based singleton and added cache clearing in TearDown. (core/unittest/metadata/K8sMetadataUnittest.cpp) [1] [2] [3] [4] [5] [6]

processor.AddLabels(*mSpanEvent, container_vec, remote_ip_vec);
APSARA_TEST_EQUAL("kube-proxy-worker", mSpanEvent->GetTag("peerWorkloadName").to_string());
APSARA_TEST_TRUE_FATAL(k8sMetadata.GetInfoByIpFromCache("10.41.0.2") != nullptr);
APSARA_TEST_TRUE_FATAL(k8sMetadata->GetInfoByIpFromCache("10.41.0.2") != nullptr);
delete l;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mSpanEvent析构的时候应该会自动释放的,这里会double free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants