canonical / mysql-operator

Machine charm for MySQL following the operator framework
https://charmhub.io/mysql
Apache License 2.0
7 stars 10 forks source link

Stabilize integration tests; avoid using equality for comparison of units and compare unit names instead #508

Closed shayancanonical closed 4 weeks ago

shayancanonical commented 4 weeks ago

Issue

Network cut test: https://github.com/canonical/mysql-operator/actions/runs/10397182320/job/28792633963 Replicate data on restart test: https://github.com/canonical/mysql-operator/actions/runs/10397182320/job/28792634154#step:28:425

Both of the above tests fail on retrieving a cluster primary when the old primary is stopped or cut from the network. The reason for this, I believe, is the usage of == to compare units. Despite the unit and unit_excluded is the same, the unit is not excluded (the condition does not hold true). This is why the tests above fail to get primary from the "old primary unit" which does not have a running mysqld.

Solution

Compare unit names instead