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

Make consume respect the controller name in the url #1038

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

Aflynn50
Copy link
Contributor

@Aflynn50 Aflynn50 commented Mar 27, 2024

Description

consume takes a controller_name argument. This is not needed and should be automatically generated from the offer url. A deprecation warning is logged and the variable is not used.

Also update offer and consume integration tests to no longer be skipped.

This helps avoid #1031

QA Steps

juju bootstrap lxd c1
juju add-model offerer
juju deploy juju-qa-dummy-source dummy-source
juju offer dummy-source:sink
juju bootstrap lxd c2
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("c1:admin/offerer.dummy-source")

# Exit REPL
juju status
# Confirm SAAS exists
juju remove-saas dummy-source
# Confirm removal
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("admin/offerer.dummy-source", controller_name="c1")

# Exit REPL
juju status
# Confirm SAAS exists
juju remove-saas dummy-source
# Confirm removal
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("c1:admin/offerer.dummy-source", controller_name="c1")

All CI tests need to pass.

@Aflynn50 Aflynn50 requested a review from cderici March 27, 2024 21:20
@Aflynn50 Aflynn50 force-pushed the fix-consume branch 2 times, most recently from 2d7b6b7 to a844ec9 Compare March 28, 2024 18:00
Copy link
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

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

Code looks good. Could you please check if there's a test with a controller name in the endpoint url? If not we should add that (for parse_offer_url, or _get_source_api) I'd be ok if it's a mocked test within tests/unit if coming up with a sensible integration test is hard. We just need to ensure the capability is there for future. Hope that makes sense.

Also looks like we need a rebase.

tests/integration/test_crossmodel.py Outdated Show resolved Hide resolved
consume takes a controller_name argument. This is not needed and should
be automatically generated from the offer url. A deprecation warning is
logged and the variable is not used.

Also update offer and consume integration tests to no longer be skipped.
@Aflynn50 Aflynn50 force-pushed the fix-consume branch 3 times, most recently from 5cb9a8e to 74c847c Compare April 2, 2024 11:56
@Aflynn50
Copy link
Contributor Author

Aflynn50 commented Apr 2, 2024

Code looks good. Could you please check if there's a test with a controller name in the endpoint url? If not we should add that (for parse_offer_url, or _get_source_api) I'd be ok if it's a mocked test within tests/unit if coming up with a sensible integration test is hard. We just need to ensure the capability is there for future. Hope that makes sense.

Also looks like we need a rebase.

I've added a unit test which checks the consume behavior, though its uses a lot of mocks.

I've also changed it so you can use the controller_name argument as expected, just to ensure that we don't break anything with this.

@Aflynn50 Aflynn50 requested a review from cderici April 2, 2024 11:57
Copy link
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

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

Yeah this looks good 👍 mocking is fine as we can't bootstrap, the purpose of the test is just to protect the api in the future.

tests/unit/test_offerendpoint.py Outdated Show resolved Hide resolved
@Aflynn50
Copy link
Contributor Author

Aflynn50 commented Apr 3, 2024

/merge

@jujubot jujubot merged commit 3c57a0c into juju:master Apr 3, 2024
7 of 9 checks passed
jujubot added a commit that referenced this pull request May 31, 2024
#1056

## What's Changed
* Make consume respect the controller name in the url by @Aflynn50 in #1038
* Fix multiline description in textarea in bug template GH workflow by @cderici in #1041
* Fix issue with microk8s proxy by @Aflynn50 in #1044
* add missing "revision" parameter to addModel step. by @Thanhphan1147 in #1043
* Add user api to pylibjuju documentation by @cderici in #1049

## New Contributors
* @Thanhphan1147 made their first contribution in #1043

**Full Changelog**: 3.4.0.0...3.5.0.0
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