Skip to content

draft for dhcp server testcase#4485

Merged
wen587 merged 10 commits intosonic-net:masterfrom
wen587:gu_dhcp
Nov 13, 2021
Merged

draft for dhcp server testcase#4485
wen587 merged 10 commits intosonic-net:masterfrom
wen587:gu_dhcp

Conversation

@wen587
Copy link
Contributor

@wen587 wen587 commented Oct 14, 2021

Description of PR

Summary: Testcase of dhcp server for generic updater apply-patch
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911

Approach

What is the motivation for this PR?

End to End test support for Generic Updater apply-patch
This PR is to verify the usage of 'config apply-patch' works on dhcp server under vlan.

How did you do it?

First we setup vlan for test. Then make some config apply change. And check if the dhcp server is changed as expected.
For code reusability, some vlan setup functions are moved to tests/common/fixtures/duthost_utils.py
Implement a utility file gu_utils.py for future other testcase.

How did you verify/test it?

Run test on sonic-mgmt/tests/generic_config_updater/test_dhcp_relay.py

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

Copy link
Contributor

@qiluo-msft qiluo-msft Oct 20, 2021

Choose a reason for hiding this comment

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

Generate 4 dhcp server for each vlan

Thanks for providing illustrative comments! As we discussed, we need to document of sub-test-case design.

For the init configuration

  1. 4 servers as your implementation
  2. 0 servers
  3. too many servers that will reach maximal soon. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Also design for DHCPv6? It is a relative new feature, but we can still design for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor

@qiluo-msft qiluo-msft Oct 20, 2021

Choose a reason for hiding this comment

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

add

"""Test add and del dhcp servers cases


There are some corner cases for "add":

  1. reach maximal servers
  2. add an existing one
    #Pending

Copy link
Contributor

Choose a reason for hiding this comment

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

How about "1. reach maximal servers" ? Is there an maximal number by design or by implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will ask see if there is the design

Copy link
Contributor

Choose a reason for hiding this comment

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

Low priority test case.

@lgtm-com
Copy link

lgtm-com bot commented Oct 28, 2021

This pull request introduces 1 alert when merging afafa900a7a868f79351e46ddfae78e8e3f57012 into 66c554d - view on LGTM.com

new alerts:

  • 1 for Unused import

@wen587 wen587 requested a review from ganglyu October 29, 2021 02:40
@lgtm-com
Copy link

lgtm-com bot commented Oct 29, 2021

This pull request introduces 1 alert when merging d2573c2af20287f83e2c823465d2e00888ba1cd8 into 058a790 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Nov 1, 2021

This pull request introduces 1 alert when merging 4faac70e9f33b576182c395291ee3a4cdb54ad17 into 7f777f4 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Nov 2, 2021

This pull request introduces 1 alert when merging 6c4554c3eef2f8f20f0ccfb406c37a252fbb8c09 into 106b4bb - view on LGTM.com

new alerts:

  • 1 for Unused import

@qiluo-msft qiluo-msft mentioned this pull request Nov 10, 2021
4 tasks
@lgtm-com
Copy link

lgtm-com bot commented Nov 11, 2021

This pull request introduces 1 alert when merging 323eeacd9caef436785a3e27c6a6ed590245a257 into 8d65f7c - view on LGTM.com

new alerts:

  • 1 for Unused import

Copy link
Contributor

@qiluo-msft qiluo-msft Nov 11, 2021

Choose a reason for hiding this comment

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

utils_vlan_intfs_dict_orig

It's not easy to understand the function just from the name. They are implemented to be reused. Could you add some function level comments, explaining the purpose, parameter, and return values. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Also applicable to other new functions in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Contributor

@qiluo-msft qiluo-msft Nov 11, 2021

Choose a reason for hiding this comment

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

output = duthost.shell(cmds)

# output = duthost.shell(cmds)


Remove commented code. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Copy link
Contributor

@qiluo-msft qiluo-msft Nov 11, 2021

Choose a reason for hiding this comment

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

duthost.shell

duthost.shell("sudo systemctl reset-failed {}.service".format(container_name))


Always check return code, in reality, we see systemctl fails. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Contributor

Choose a reason for hiding this comment

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

first_avai_vlan_port

avai -> available?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

@qiluo-msft qiluo-msft Nov 11, 2021

Choose a reason for hiding this comment

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

vlan_intfs_list[1]

Is it possible that the value is too large and the IP is not valid? Check before use it this way? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. It is restricted by utils_vlan_intfs_dict_add which in range(0, 255)

Copy link
Contributor

@qiluo-msft qiluo-msft Nov 11, 2021

Choose a reason for hiding this comment

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

3

also a magic number #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I use magic number due that if the index change, the json will look much different. Here I choose to remove the last element for simplicity but also check the correctness. If I choose to remove other index such as 1. The json_patch will look like this:

[
 {
  "op": "remove",
  "path": "/VLAN/Vlan108/dhcp_servers/3"
 },
 {
  "op": "replace",
  "path": "/VLAN/Vlan108/dhcp_servers/2",
  "value": "192.0.108.4"
 },
 {
  "op": "replace",
  "path": "/VLAN/Vlan108/dhcp_servers/1",
  "value": "192.0.108.3"
 }
]

The vlan dhcp server is not simple key->value pair. It looks like a key->indexed value

@wen587 wen587 marked this pull request as ready for review November 12, 2021 23:54
@wen587 wen587 requested a review from a team as a code owner November 12, 2021 23:54
@wen587 wen587 merged commit 0bcb76e into sonic-net:master Nov 13, 2021
AntonHryshchuk pushed a commit to AntonHryshchuk/sonic-mgmt that referenced this pull request Jan 4, 2022
…config updater(sonic-net#4485)

Summary:
Testcase of dhcp server under vlan for generic updater apply-patch

Approach:
What is the motivation for this PR?
This is a requirement from E2E test support for Generic Updater apply-patch.
This PR is to verify the usage of 'config apply-patch' works on dhcp server under vlan. 

How did you do it?
First we setup vlan for test. Then make some config apply change. And check if the dhcp server is changed as expected.

How did you verify/test it?
Run test on sonic-mgmt/tests/generic_config_updater/test_dhcp_relay.py
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.

3 participants