Skip to content

Remove default in orc8r database storage#7484

Merged
hcgatewood merged 4 commits intomagma:masterfrom
mstre123:task2
Jun 23, 2021
Merged

Remove default in orc8r database storage#7484
hcgatewood merged 4 commits intomagma:masterfrom
mstre123:task2

Conversation

@mstre123
Copy link
Copy Markdown
Contributor

Remove default in orc8r database storage

Summary

Add a new MustGetEnv function in orc8r/lib/go/definitions/env.go
Set SQL driver and DB source in orc8r/cloud/go/storage/storage.go with MustGetEnv instead of the "with default" getter
Fix tests

Test Plan

./build.py -t

Additional Information

#4086

@mstre123 mstre123 requested review from a team and emakeev June 11, 2021 00:13
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines. label Jun 11, 2021
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for opening a PR! 💯 Please note that all commits must be signed off. This is enforced by the DCO check.

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

Copy link
Copy Markdown
Contributor

@hcgatewood hcgatewood left a comment

Choose a reason for hiding this comment

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

Thanks for the change! Couple small details then ready to go

func GetSharedMemoryDB() (*sql.DB, error) {
var err error
once.Do(func() { instance, err = sqorc.Open(storage2.SQLDriver, ":memory:") })
once.Do(func() { instance, err = sqorc.Open("sqlite3", ":memory:") })
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's a const for this somewhere in the codebase. If not, let's add one -- I think there's one for postgres you could look for to emulate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

couldn't find the postgres const so I moved it to the definitions const file

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 11, 2021

Codecov Report

Merging #7484 (e62da5d) into master (ed336cf) will increase coverage by 0.00%.
The diff coverage is 33.33%.

❗ Current head e62da5d differs from pull request most recent head 40a85c1. Consider uploading reports for the commit 40a85c1 to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7484   +/-   ##
=======================================
  Coverage   64.43%   64.43%           
=======================================
  Files         679      679           
  Lines       46973    46975    +2     
  Branches     1320     1320           
=======================================
+ Hits        30265    30268    +3     
  Misses      13259    13259           
+ Partials     3449     3448    -1     
Flag Coverage Δ
cloud_lint 65.70% <33.33%> (+<0.01%) ⬆️
feg-lint 56.38% <ø> (ø)
lte-test 72.60% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
orc8r/cloud/go/storage/storage.go 38.88% <0.00%> (-2.29%) ⬇️
orc8r/cloud/go/test_utils/test_db.go 50.00% <100.00%> (ø)
...oud/go/services/state/indexer/reindex/reindexer.go 68.62% <0.00%> (+1.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed336cf...40a85c1. Read the comment docs.

Move SQLDriver and DatabaseSource from global vars to getter funcs.
Signed-off-by: Eli Sutton <[email protected]>
@mstre123 mstre123 requested a review from a team June 15, 2021 20:32
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines. and removed size/S Denotes a PR that changes 10-29 lines. labels Jun 15, 2021
@magmabot magmabot added the component: agw Access gateway-related issue label Jun 15, 2021
Copy link
Copy Markdown
Contributor

@hcgatewood hcgatewood left a comment

Choose a reason for hiding this comment

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

Looks good, couple notes

Signed-off-by: Eli Sutton <[email protected]>
Copy link
Copy Markdown
Contributor

@hcgatewood hcgatewood left a comment

Choose a reason for hiding this comment

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

One last aesthetic fix then am ready to merge

Signed-off-by: Eli Sutton <[email protected]>
Copy link
Copy Markdown
Contributor

@hcgatewood hcgatewood left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for the fix!

You'll need to re-push (e.g. force-push a noop commit or amend the head commit) to re-kick off the failed flaky cirlceci job

}

// MustGetEnv returns the string value of the environment variable,
// panics it doesn't exist
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit

Suggested change
// panics it doesn't exist
// panics it doesn't exist.

@hcgatewood hcgatewood enabled auto-merge (squash) June 23, 2021 21:49
Copy link
Copy Markdown
Member

@themarwhal themarwhal left a comment

Choose a reason for hiding this comment

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

feg changes looks good!

@hcgatewood hcgatewood merged commit 1b78449 into magma:master Jun 23, 2021
rmeleromira pushed a commit to rmeleromira/magma that referenced this pull request Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported-v1.6 component: agw Access gateway-related issue size/M Denotes a PR that changes 30-99 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants