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

feat(dp): Enodebd triggered update #12804

Merged
merged 6 commits into from May 31, 2022

Conversation

WojSad
Copy link
Contributor

@WojSad WojSad commented May 20, 2022

feat(dp): Enodebd triggered update

Summary

DP now has two grpc methods to update a cbsd (UserUpdateCbsd and EnodebdUpdateCbsd)
The separation was needed for the purpose of single-step registration (under development). Enodebd needs to be able to update a cbsd separately with installation param, radio category and single_step_enabled flag.
EnodebdUpdateCbsd receives single-step related information from enodebd and updates the cbsd in the db by calling the storage side Update method.

Introduced data builders for tests to make writing mocked entities and models easier
Refactored tests
Updated protos and swaggers

Introduced select for update in the sqorc library

Test Plan

All tests related to Cbsd CRUD have been refactored, new tests were added.

@WojSad WojSad requested review from a team, xbend and maxhbr May 20, 2022 13:30
@netlify
Copy link

netlify bot commented May 20, 2022

👷 Deploy request for competent-euler-513227 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ecf40e4

@pull-request-size pull-request-size bot added the size/XXL Denotes a Pull Request that changes 1000+ lines. label May 20, 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 github-actions bot added component: dp All updates to Domain Proxy dp module component: nms NMS-related issue component: orc8r Orchestrator-related issue labels May 20, 2022
description: AGL - relative to the ground level. AMSL - relative to the mean
sea level
enum:
- agl
Copy link
Contributor

Choose a reason for hiding this comment

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

[yamllint] reported by reviewdog 🐶
[error] wrong indentation: expected 10 but found 8 (indentation)

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

Oops! Looks like you failed the Python Format Check.

Howto

♻️ Updated: ✅ The check is passing the Python Format Check after the last commit.

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

feg-workflow

    2 files  202 suites   38s ⏱️
371 tests 371 ✔️ 0 💤 0
385 runs  385 ✔️ 0 💤 0

Results for commit a821237.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

nms-workflow

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0

Results for commit a821237.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

cloud-workflow

    7 files  355 suites   2m 15s ⏱️
979 tests 979 ✔️ 0 💤 0

Results for commit a821237.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

agw-workflow

     77 files     122 suites   6m 36s ⏱️
1 151 tests 1 147 ✔️ 4 💤 0
1 152 runs  1 148 ✔️ 4 💤 0

Results for commit a821237.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented May 20, 2022

dp-workflow

  2 files    2 suites   3m 10s ⏱️
15 tests 15 ✔️ 0 💤 0

Results for commit a821237.

♻️ This comment has been updated with latest results.

@@ -16,8 +16,8 @@ spec:
- image: test_runner_image
name: test-runner-orc8
imagePullPolicy: IfNotPresent
command: ["python"]
args: ["-m", "pytest", "-vvv", "-s", "-m", "orc8r", "--junit-xml=/backend/test_runner/test-results/test_report.xml", "tests"]
command: ["sleep"]
Copy link
Contributor

Choose a reason for hiding this comment

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

@sklgromek I think we should add some target to makefile to do that, since this is not the first time such debugging version was committed by accident

Copy link
Contributor

Choose a reason for hiding this comment

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

@jkmar I agree. I will prepare something for that

@@ -0,0 +1,517 @@
package builders_test
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is separate package already, I would go with just builders as package name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"magma/dp/cloud/go/services/dp/storage/db"
)

func dbFloat64OrNil(field *sql.NullFloat64, val *wrappers.DoubleValue) {
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 this:

if val == nil {
    return sql.NullFloat64{}
}
return db.MakeFloat(val.Value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -275,8 +304,7 @@ func (s *HandlersTestSuite) TestCreateCbsdWithoutAllRequiredParams() {
e := echo.New()
obsidianHandlers := cbsd.GetHandlers()
payload := &models.MutableCbsd{
Capabilities: models.Capabilities{
AntennaGain: to_pointer.Float(1),
Capabilities: &models.Capabilities{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why builder is not used here? (while it is used for same type just a few lines above) It's a bit inconsistent

"magma/dp/cloud/go/services/dp/obsidian/models"
"magma/dp/cloud/go/services/dp/obsidian/to_pointer"

"github.com/stretchr/testify/assert"
Copy link
Contributor

Choose a reason for hiding this comment

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

go imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

func TestCbsdFromBackendWithEmptyFrequencies(t *testing.T) {
details := b.NewDetailedProtoCbsdBuilder(
b.NewCbsdProtoPayloadBuilder()).Details
details.Data.Preferences.FrequenciesMhz = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it not done with builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}, {
name: "Should validate antenna gain",
data: newMutableCbsd(withAntennaGain(nil)),
expectedError: "antenna_gain in body is required",
}, {
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 adding some tests to validate installation params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, validated height type since this is the only enum

@@ -46,6 +47,16 @@ type MutableCbsd struct {
DesiredState *DBCbsdState
}

type EnodebdPayload struct {
Copy link
Contributor

@jkmar jkmar May 23, 2022

Choose a reason for hiding this comment

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

Why is this exported? (It is 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.

deleted

func (c *cbsdManagerInTransaction) checkIfCbsdExists(networkId string, id int64) error {
_, err := db.NewQuery().
func (c *cbsdManagerInTransaction) enodebdUpdateCbsd(data *DBCbsd) error {
mask := db.NewIncludeMask("id")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a broader mask, so that comparison of installation params is possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as agreed, will do in a later pr

@WojSad WojSad force-pushed the enodebd-triggered-update branch 3 times, most recently from e8e3fbd to 291b8ec Compare May 24, 2022 11:31
@WojSad
Copy link
Contributor Author

WojSad commented May 24, 2022

@magma/approvers-orc8r please have a look at this PR. The orc8r part affected is the SQL LOCKER bit in sqorc library

@xbend xbend added the ready2merge This PR is ready to be merged (is approved and passes all required checks) label May 25, 2022
@xbend
Copy link
Contributor

xbend commented May 25, 2022

@maxhbr
FYI, this PR includes the changes that were already contained in a PR you have reviewed, but it was suggested to have those changes be pushed together with a code that uses it, so those changes are included here

@jpad-freedomfi
Copy link
Contributor

@maxhbr Can you provide review for this so we can merge?

@xbend
Copy link
Contributor

xbend commented May 30, 2022

@magma/approvers-orc8r
Bump, can anybody from orc8r approves take a look at the sqorc changes?

Copy link
Member

@maxhbr maxhbr left a comment

Choose a reason for hiding this comment

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

The orc8r part loos good

Wojciech Sadowy and others added 6 commits May 31, 2022 10:31
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>
Not all sql dialects support locking feature (SELECT FOR UPDATE),
so in order to use locking for different dialects,
a locker interface was introduced.

Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
@WojSad WojSad enabled auto-merge (squash) May 31, 2022 09:14
@WojSad WojSad merged commit 72e819c into magma:master May 31, 2022
mpfirrmann pushed a commit to mpfirrmann/magma that referenced this pull request May 31, 2022
* feat(dp): CBSD update modification

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* chore(dp): Add lock to db framework

Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>

* chore(orc8r): Add sql locker to sqorc lib

Not all sql dialects support locking feature (SELECT FOR UPDATE),
so in order to use locking for different dialects,
a locker interface was introduced.

Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>

* fixed tests

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* moved pointer converters

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* fixes

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

Co-authored-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Co-authored-by: Kuba Marciniszyn <kuba@freedomfi.com>
@WojSad WojSad deleted the enodebd-triggered-update branch June 28, 2022 13:05
emakeev pushed a commit to emakeev/magma that referenced this pull request Aug 5, 2022
* feat(dp): CBSD update modification

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* chore(dp): Add lock to db framework

Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>

* chore(orc8r): Add sql locker to sqorc lib

Not all sql dialects support locking feature (SELECT FOR UPDATE),
so in order to use locking for different dialects,
a locker interface was introduced.

Signed-off-by: Kuba Marciniszyn <kuba@freedomfi.com>

* fixed tests

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* moved pointer converters

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

* fixes

Signed-off-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>

Co-authored-by: Wojciech Sadowy <wojciech.sadowy@freedomfi.com>
Co-authored-by: Kuba Marciniszyn <kuba@freedomfi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dp All updates to Domain Proxy dp module component: nms NMS-related issue component: orc8r Orchestrator-related issue ready2merge This PR is ready to be merged (is approved and passes all required checks) size/XXL Denotes a Pull Request that changes 1000+ lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants