Skip to content

[snmp_memory] add SNMP memory test#373

Merged
lguohan merged 6 commits intosonic-net:masterfrom
okanchou9:snmp_memory
Mar 20, 2020
Merged

[snmp_memory] add SNMP memory test#373
lguohan merged 6 commits intosonic-net:masterfrom
okanchou9:snmp_memory

Conversation

@okanchou9
Copy link
Contributor

Signed-off-by: okanchou9 [email protected]

  • What I did
  1. Add test to check the difference percentage of Total Memory between SNMP and shell is 0
  2. Add test to check the difference percentage of Total Free Memory between SNMP and shell small than 3% when:
    • Check free memory before stress test
    • Check free memory in stress test
    • Check free memory after stress test
  3. Add test to check memory leak issue, the difference percentage between Total Free Memory before stress test and after should small than 3%
  • How I did it
    Please refer the diff for the details.

  • How to verify it
    Run test with on my box and passed without any issue. Log


- name: Validating SNMP total free memory matches shell result before stress test
assert:
that: "{{ '%.6f'|format((ansible_sysTotalFreeMemery|int - shell_total_free_memory.stdout|int)|abs / ansible_sysTotalFreeMemery|int) }} <= 0.03"
Copy link
Contributor

Choose a reason for hiding this comment

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

is 3% tolerance too small? can we allow like 10% tolerance to make the test more robust.

Copy link
Contributor Author

@okanchou9 okanchou9 Dec 5, 2017

Choose a reason for hiding this comment

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

Since I have 8G RAM in my box, the 3% tolerance of 8G is about 246M already.
I'm not sure the quality of this test if we allow 10% tolerance in this test.
Any good idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

make this as an test parameter, let's the default to 5%?

- name: Stop memory stress generation
shell: killall python /tmp/memory.py
become: yes
ignore_errors: true
Copy link
Contributor

Choose a reason for hiding this comment

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

if previous assert fails, your code will not kill the process and the box will have high memory consumption.

Copy link
Contributor Author

@okanchou9 okanchou9 Dec 5, 2017

Choose a reason for hiding this comment

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

Don't worry about it, I wrote the "always" section which will kill again this python process at line 99 if previous assert failed.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, my question is that if the above assert, will ansible stop there? If ansible stops, then you will not be able to execute subsequent commands.

check here. http://docs.ansible.com/ansible/latest/playbooks_error_handling.html

"Generally playbooks will stop executing any more steps on a host that has a task fail."

Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you mean. I think it is ok.


- name: Validating memory leak issue on DUT
assert:
that: "{{ '%.6f'|format((free_memery_before_test|int - ansible_sysTotalFreeMemery|int)|abs / free_memery_before_test|int) }} <= 0.03"
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this memory leak comes from? the python program?

Copy link
Contributor Author

@okanchou9 okanchou9 Dec 5, 2017

Choose a reason for hiding this comment

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

Yes, those memories which hold by this python process should be released after terminated it.
If the difference between the size of free memory before and after this stress test is more than 3%, I can only consider there is a memory leak happened when terminated the python process.

Copy link
Contributor

Choose a reason for hiding this comment

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

it is hard to say, the other process might increase the usage of memory.

Copy link
Contributor

Choose a reason for hiding this comment

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

checking memory leak is a hard problem, I am mainly worry about the false positive.

Copy link
Contributor Author

@okanchou9 okanchou9 Dec 12, 2017

Choose a reason for hiding this comment

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

hmmm, just removed this test case from this PR and I'll find better way to test the memory leak. Thanks for your info.


- set_fact: free_memery_before_test="{{ ansible_sysTotalFreeMemery }}"

- set_fact: test_momory="{{ ((ansible_sysTotalFreeMemery - 512000) / 1024)|int }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

why minus 512M memory? what is the purpose of memory stress test? is it just to verify the snmp can pick the memory consumption changes or there is some other goal? if only the first goal, then we just need to fill a few hundreds MB and check. We do not need to fill all the available memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test will also check the SNMP process is still functional or not in suck low free memory condition.
It's enough for my box that only left 512M for system free memory.
Please let me know if any.

Copy link
Contributor

Choose a reason for hiding this comment

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

my request here is that can we skip this, if the sysTotalFreeMemory is already less then 512000? As above, can we make this as a tunable parameter, you can make 512M as the default value.

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

as comments.

@lguohan lguohan requested a review from maggiemsft December 5, 2017 11:10
@lguohan
Copy link
Contributor

lguohan commented Dec 5, 2017

@lguohan lguohan merged commit 63af908 into sonic-net:master Mar 20, 2020
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…D automatically (sonic-net#15749)

src/sonic-platform-daemons

* 112656c - (HEAD -> 202205, origin/202205) [ycabled][active-active] no initialize Async Client, when no active-active cable type; fix names for all ycabled threads (sonic-net#373) (4 minutes ago) [vdahiya12]
* e325d5a - Revert "Revert "[ycabled] correct the wrong function call for 'config hwmode state' (sonic-net#372)"" (4 minutes ago) [Ying Xie]
* ddabca1 - Revert "Revert "[dualtor] Fix command `show mux status` (sonic-net#371)"" (4 minutes ago) [Ying Xie]
* 28918da - Revert "Revert "[ycabled] fix bug for `show mux status` delayed response (sonic-net#364)"" (4 minutes ago) [Ying Xie]
* a849de9 - Revert "Revert "add async notification support in active-active topo; refactor code for ycable tasks for change events  (sonic-net#327)"" (4 minutes ago) [Ying Xie]
* cf1e73a - Revert "Revert "[ycabled] refactor code for onboarding async client changes;refactor (sonic-net#355)"" (4 minutes ago) [Ying Xie]
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