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

test(dp): Retain DB state in orc8r integration tests #12607

Merged
merged 1 commit into from May 2, 2022

Conversation

xbend
Copy link
Contributor

@xbend xbend commented Apr 29, 2022

Summary

  • Do not clear/initialize DB in orc8r integration tests setup/teardown
  • Clear/initialize DB in orc8r integration testcase classes
  • Use randmized CBSD serial numbers per orc8r integration test to meet unique constraint on that field in the (now retained between tests) DB

Additional Information

  • This change is backwards-breaking

@xbend xbend requested review from a team and taaraora April 29, 2022 17:00
@pull-request-size pull-request-size bot added the size/L Denotes a Pull Request that changes 100-499 lines. label Apr 29, 2022
@github-actions
Copy link
Contributor

Thanks for opening a PR! 💯

A couple initial guidelines

Howto

  • Reviews. The "Reviewers" listed for this PR are the Magma maintainers who will shepherd it.
  • Checks. All required CI checks must pass before merge.
  • Merge. Once approved and passing CI checks, use the ready2merge label to indicate the maintainers can merge your PR.

More info

Please take a moment to read through the Magma project's

If this is your first Magma PR, also consider reading

@github-actions
Copy link
Contributor

github-actions bot commented Apr 29, 2022

Oops! Looks like you failed the DCO check. Be sure to sign all your commits.

Howto

♻️ Updated: ✅ The check is passing the DCO check after the last commit.

@@ -389,26 +420,31 @@ def send_request_to_backend(
method: str, url_suffix: str, params: Optional[Dict[str, Any]] = None,
json: Optional[Dict[str, Any]] = None,
) -> requests.Response:
return requests.request(
Copy link
Contributor

Choose a reason for hiding this comment

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

there is no need for this change (I guess it was just used for debugging)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted.

@@ -378,7 +409,7 @@ def wait_for_elastic_to_start() -> None:

def when_elastic_indexes_data():
# TODO use retrying instead
sleep(5)
sleep(15)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is painful, can we create a ticket for using retries for elastic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -19,6 +19,8 @@
from threading import Event, Thread
from time import sleep
from typing import Any, Dict, List, Optional
from unittest import TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

looks unused

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.

@@ -245,6 +260,17 @@ def when_cbsds_are_fetched(
self.assertEqual(len(cbsds), expected_cbsds_num)
return cbsds

def when_cbsd_is_fetched(self, serial_number: str = None) -> Dict[str, Any]:
params = {}
params['serial_number'] = serial_number
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just params = {'serial_number': serial_number}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redone as suggested.

def then_cbsd_is_deleted(self):
r = send_request_to_backend('get', 'cbsds')
def then_cbsd_is_deleted(self, serial_number: str):
params = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a lot of duplication between this method and when_cbsd_is_fetched method, can common part be extracted?

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 private check method.

* Do not clear/initialize DB in orc8r integration tests setup/teardown
* Clear/initialize DB in orc8r integration testcase classes
* Use randmized CBSD serial numbers per orc8r integration test
to meet unique constraint on that field in the (now retained between tests) DB

Signed-off-by: Artur Dębski <artur.debski@freedomfi.com>
@xbend xbend removed the request for review from taaraora May 2, 2022 21:17
@xbend xbend merged commit 45385b1 into magma:master May 2, 2022
@xbend xbend deleted the dp_tests_improvements branch May 2, 2022 21:21
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
* Do not clear/initialize DB in orc8r integration tests setup/teardown
* Clear/initialize DB in orc8r integration testcase classes
* Use randmized CBSD serial numbers per orc8r integration test
to meet unique constraint on that field in the (now retained between tests) DB

Signed-off-by: Artur Dębski <artur.debski@freedomfi.com>

Co-authored-by: Artur Dębski <artur.debski@freedomfi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a Pull Request that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants