Skip to content

Commit

Permalink
Merge pull request #15662 from hpidcock/fix-relation-departing-test
Browse files Browse the repository at this point in the history
#15662

Fixes 5s sleep being inadequate. Instead polls debug-log up to 10 times with 10s delay.

## QA steps

Apply this patch
```
diff --git a/testcharms/charms/departer/hooks/self-relation-departed b/testcharms/charms/departer/hooks/self-relation-departed
index 241c4f724d..b04dd07dc8 100644
--- a/testcharms/charms/departer/hooks/self-relation-departed
+++ b/testcharms/charms/departer/hooks/self-relation-departed
@@ -1,6 +1,8 @@
 #!/bin/sh
 echo $0

+sleep 30
+
 remote_unit=$(echo $JUJU_REMOTE_UNIT)
 departing_unit=$(echo $JUJU_DEPARTING_UNIT)
```

Run the test
```
./main.sh -v -s '"test_relation_data_exchange,test_relation_list_app"' relations test_relation_departing_unit`
```

## Documentation changes

N/A

## Bug reference

https://jenkins.juju.canonical.com/job/test-relations-test-relation-departing-unit-lxd/591/consoleText
  • Loading branch information
jujubot committed May 26, 2023
2 parents f639f09 + c75361d commit 68ef945
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
3 changes: 0 additions & 3 deletions testcharms/charms/departer/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ peers:
self:
interface: dummy
series:
- xenial
- bionic
- focal
- jammy
43 changes: 28 additions & 15 deletions tests/suites/relations/relation_departing_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,34 @@ run_relation_departing_unit() {

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

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")
exit 1
fi
got=$(juju debug-log --replay --include unit-departer-1 | grep 'Local unit is departing the relation' || true)
if [ -z "${got}" ]; then
# shellcheck disable=SC2046
echo $(red "expected departer/1 to be notified that it is going away")
exit 1
fi

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
# shellcheck disable=SC2046
echo $(red "expected departer/1 to be notified that it is going away")
if [[ ${attempt} -eq 0 ]]; then
exit 1
else
continue
fi
fi
break
done

destroy_model "${model_name}"
}
Expand Down

0 comments on commit 68ef945

Please sign in to comment.