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

fix(harness): don't error out when attempting attaching storage before begin #1150

Merged

Conversation

tonyandrewmeyer
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer commented Mar 13, 2024

One minor fix to the storage metadata: charmcraft.yaml and metadata.yaml support a multiple.range value in the form <n>+ - this would previously error out when we attempted to read the metadata. We now support this (as an alias for <n>-, which is an open-ended range rather than "n or less", and have a test for it.

Adds a minor clarification in the API docs when Harness.add_storage will emit a storage-attached event.

In begin_with_initial_hooks, if the storage has already been attached, then don't try to attach it a second time, but do emit the storage-attached event, since that will not have been done previously.

Make the _storage_attach method safe to call multiple times. This appears to have been the intention based on comments in the code, but, in practice, attempting to symlink the mount would fail. Now, if the symlink already exists (and has the same target) then we continue.

Adds a variety of tests for Harness add_storage and attach_storage behaviour.

Fixes #1127

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Great, thanks for this. Nit and comment about test structure.

ops/testing.py Outdated Show resolved Hide resolved
test/test_testing.py Outdated Show resolved Hide resolved
@IronCore864
Copy link
Contributor

Great test cases, I've learned a lot :)

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Very clean, thanks!

@tonyandrewmeyer tonyandrewmeyer merged commit 9fcb04a into canonical:main Mar 18, 2024
28 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the add-storage-clearer-use-1127 branch March 18, 2024 08:30
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.

Using Harness.add_storage(..., attach=True) before begin_with_initial_hooks gives confusing error
3 participants