-
Notifications
You must be signed in to change notification settings - Fork 123
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: add checks and log_targets to ops.testing #1268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. The structure is very good, but there are a few minor issues with the types and the merging logic.
[misunderstood smth, yanked comment] |
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good now, approving! Just a couple of nit issues in the tests. I'll also ask another Charm Tech team member to review.
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
off topic: Why the PR title validation fails if I change it to "fix: add checks and log_targets to ops.testing"? |
@amandahla Must have been a glitch -- I just changed it back to that now, and it ran fine. We'll keep an eye on it. |
@amandahla We require two reviews for PRs on this repo, so I've asked one more Charm Tech reviewer to review this (probably in the next couple of days), but it's looking good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of small suggestions, but looks great, thanks!
client.add_layer( | ||
'foo', | ||
pebble.Layer("""\ | ||
log-targets: | ||
baz: | ||
override: replace | ||
type: loki | ||
location: https://example123.com:3100/loki/api/v1/push | ||
services: | ||
- foo | ||
labels: | ||
key1: value1 | ||
"""), | ||
combine=True, | ||
) | ||
plan = client.get_plan() | ||
assert ( | ||
textwrap.dedent("""\ | ||
log-targets: | ||
baz: | ||
labels: | ||
key1: value1 | ||
location: https://example123.com:3100/loki/api/v1/push | ||
override: replace | ||
services: | ||
- foo | ||
type: loki | ||
""") | ||
== plan.to_yaml() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is asserting that the plan is equal to the second layer, right? Because override: replace
was used.
I think the test would be clearer (and more resilient) if it made that explicit. Something like (untested):
client.add_layer( | |
'foo', | |
pebble.Layer("""\ | |
log-targets: | |
baz: | |
override: replace | |
type: loki | |
location: https://example123.com:3100/loki/api/v1/push | |
services: | |
- foo | |
labels: | |
key1: value1 | |
"""), | |
combine=True, | |
) | |
plan = client.get_plan() | |
assert ( | |
textwrap.dedent("""\ | |
log-targets: | |
baz: | |
labels: | |
key1: value1 | |
location: https://example123.com:3100/loki/api/v1/push | |
override: replace | |
services: | |
- foo | |
type: loki | |
""") | |
== plan.to_yaml() | |
) | |
layer = pebble.Layer("""\ | |
log-targets: | |
baz: | |
override: replace | |
type: loki | |
location: https://example123.com:3100/loki/api/v1/push | |
services: | |
- foo | |
labels: | |
key1: value1 | |
""" | |
) | |
client.add_layer( | |
'foo', | |
layer, | |
combine=True, | |
) | |
plan = client.get_plan() | |
assert layer.to_yaml() == plan.to_yaml() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont have a strong opinion about it so I don't mind changing it but to me the existing code looks explicit too :)
I follow the pattern in the test_add_layer_combine_override_replace. I'm afraid that changing just one of them would look confusing.
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
Presumption that next time will be ops 2.15.0 :)
Add checks and log_targets to ops.testing add_layer so it is possible to test it via Harness.
Fixes #1112