Skip to content

Commit

Permalink
Merge pull request juju#18715 from nvinuesa/fix_relation_departing_ci
Browse files Browse the repository at this point in the history
juju#18715

This patch fixes the relation departing unit CI test that was failing only on AWS.
The reason is that after the patch
juju#18614 the logs are no longer received for the removed unit, making the check on logs impossible for the test to succeed.
The fix was therefore to check the values of the `related-units` field in the yaml output of juju show-unit.

## QA steps

Run (on AWS):

```
$ ./main.sh -c aws relations test_relation_departing_unit
```

## Links


**Jira card:** JUJU-7486
  • Loading branch information
jujubot authored Jan 24, 2025
2 parents b4194cf + c6e39d5 commit 5994301
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions tests/suites/relations/relation_departing_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,30 @@ run_relation_departing_unit() {

echo "Deploy 2 departer instances"
juju deploy ./testcharms/charms/departer -n 2

wait_for "departer" "$(idle_condition "departer" 0 0)"
wait_for "departer" "$(idle_condition "departer" 0 1)"

check_contains "$(juju show-unit departer/0 | yq '.departer/0.relation-info[0].related-units')" 'departer/1'
check_contains "$(juju show-unit departer/1 | yq '.departer/1.relation-info[0].related-units')" 'departer/0'

echo "Remove departer/1"
juju remove-unit departer/1

attempt=10
while [[ ${attempt} -gt 0 ]]; do
attempt=$((attempt - 1))
sleep 10

echo "Check departer/1 is departing the relation"
got=$(juju debug-log --replay --include unit-departer-0 | grep 'Remote unit departer/1 is departing the relation' || true)
if [ -z "${got}" ]; then
# shellcheck disable=SC2046
echo $(red "expected departer/0 to be notified that departer/1 went away")
if [[ ${attempt} -eq 0 ]]; then
exit 1
else
continue
fi
fi
got=$(juju debug-log --replay --include unit-departer-1 | grep 'Local unit is departing the relation' || true)
if [ -z "${got}" ]; then
got=$(juju show-unit departer/0 | yq '.departer/0.relation-info[0].related-units' || true)
if [ "${got}" != null ]; then
# shellcheck disable=SC2046
echo $(red "expected departer/1 to be notified that it is going away")
echo $(red "expected departer/1 to be removed from departer/0 related-units")
if [[ ${attempt} -eq 0 ]]; then
exit 1
else
continue
fi
fi
break
sleep 2
done

destroy_model "${model_name}"
Expand Down

0 comments on commit 5994301

Please sign in to comment.