-
Notifications
You must be signed in to change notification settings - Fork 26
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: alert rule and tests association #168
Conversation
Co-authored-by: Jack Browne <[email protected]>
bb62dcf
to
03f213c
Compare
@@ -0,0 +1,34 @@ | |||
data "thousandeyes_agent" "amsterdam" { | |||
agent_name = "Amsterdam, Netherlands" |
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.
nice, more ATs for this repo! 💪
}, | ||
checkUpdateFunc: []resource.TestCheckFunc{ | ||
resource.TestCheckResourceAttr(alertRuleResourceName, "rounds_violating_required", "4"), | ||
resource.TestCheckResourceAttr(alertRuleResourceName, "test_ids.#", "1"), |
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.
We may want to start adding some comments to these Acceptance tests - the ones that I created also do not have them and they should!
It's not immediate to understand that here we are making sure that if an alertRule
is updated, them the tests
associated with it are not cleared. Can you add a comment?
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.
tried to reflect that in the test name but i guess i failed miserably 😅
i've added the comments, take another look when possible
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.
TIL: didn't knew about this computed
terraform attribute! This can come in handy in some edge case scenarios, such as this one
cf60211
to
08e1aab
Compare
fixes #158
This issue is happening because we currently allow the alert rule <-> test association to be established from both perspectives. From the alert rule update perspective, it will clear any test association if the list of testIds is not sent in the request.
This PR changes the alert rule
test_ids
schema attribute to be computed so that it is not considered in the TF plan but it's still retrieved from the alert rule get by id operation and passed along the alert rule update request.Also, since the alert rule returns a field
tests
when getting by id and receives a fieldtestIds
when updating the alert rule, had to implement a map from the GenericTest to get only the testId.One drawback of this approach (not a huge one IMO) is that the state may not always be accurate. This is because a test <-> alert rules association can be changed from the test perspective and not get reflected on the alert rule perspective. Anyways, it will eventually update the state when the next alert rule update is performed.