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

[wip] facade charm #152

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

[wip] facade charm #152

wants to merge 23 commits into from

Conversation

PietroPasotti
Copy link
Contributor

@PietroPasotti PietroPasotti commented Jun 6, 2024

This PR adds a facade charm to this repository.
The facade charm is a 'universal prorgrammable relation interface mocking charm'.

Charmcraft.yaml is dynamically generated, and to help people remember that they should regenerate it on each use, it's generated by tox -e pack and deleted afterwards.

The idea is:

  • you can relate it to anything, as a provider or as a requirer
  • you can manually populate the databags of any relation and insert whatever you like

Purpose:

  • manual testing during the development of relation interfaces
  • generic integration testing tester charm (it could potentially replace many of our bespoke tester charms)

See it in action:
https://github.com/canonical/tempo-k8s-operator/pull/127/files#diff-0b4ff0c5a367926f20bde3d63ac17e8a1b14a6459e6a05e2ec6a0e2c654c1e3c

facade-charm/src/charm.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dimaqq dimaqq left a comment

Choose a reason for hiding this comment

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

I think it would help to see how this code is used to properly evaluate this idea.

It could be an integration (?) test where the programmable charm is used.

(Arguably that's no longer an integration test, rather a functional test perhaps?)

facade-charm/src/charm.py Outdated Show resolved Hide resolved
facade-charm/tests/integration/test_charm.py Outdated Show resolved Hide resolved
facade-charm/tests/unit/test_charm.py Outdated Show resolved Hide resolved
@PietroPasotti
Copy link
Contributor Author

I think it would help to see how this code is used to properly evaluate this idea.

Here you go: https://github.com/canonical/tempo-k8s-operator/pull/127/files#diff-0b4ff0c5a367926f20bde3d63ac17e8a1b14a6459e6a05e2ec6a0e2c654c1e3c

@PietroPasotti
Copy link
Contributor Author

it's somewhat similar to https://github.com/canonical/any-charm but less focused on programming the charm itself and more focus on the interfaces

Copy link
Contributor

@gruyaume gruyaume left a comment

Choose a reason for hiding this comment

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

Can you please add in the PR description how this charm will be used in the context of the charm-relation-interfaces project? We are adding this charm under facade_charm but nothing else refers to it or uses it.

@@ -0,0 +1,239 @@
interfaces:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably add a comment to mention that this file is automatically generated and should not be modified.

@@ -0,0 +1,15 @@
# Copyright 2024 pietro
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2024 pietro
# Copyright 2024 Canonical Ltd.

facade_charm/src/charm.py Outdated Show resolved Hide resolved
Co-authored-by: Guillaume Belanger <[email protected]>
Comment on lines +21 to +22
resp = requests.get("https://charmhub.io/packages.json")
return resp.json()['packages']
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding resp.raise_for_status();

or possibly configuring the client to automatically raise for bab status values.

Copy link
Contributor

@dimaqq dimaqq Aug 21, 2024

Choose a reason for hiding this comment

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

OT: this gives me exactly 360 charms packages.

I wonder if that's all there is, or is it some kind of server limit?



async def get_all_integrations(charms_pkg_info):
async with aiohttp.ClientSession() as session:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
async with aiohttp.ClientSession() as session:
async with aiohttp.ClientSession(raise_for_status=True) as session:

I would also include a base URL, it's pretty handy.

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.

5 participants