ceph-csi/internal
Niels de Vos d42814dfb9 util: fix unit-test for GetClusterMappingInfo()
Unit-testing often fails due to a race condition while writing the
clusterMappingConfigFile from multiple go-routines at the same time.
Failures from `make containerized-test` look like this:

    === CONT  TestGetClusterMappingInfo/site2-storage_cluster-id_mapping
        cluster_mapping_test.go:153: GetClusterMappingInfo() = <nil>, expected data &[{map[site1-storage:site2-storage] [map[1:3]] [map[11:5]]} {map[site3-storage:site2-storage] [map[8:3]] [map[10:5]]}]
    === CONT  TestGetClusterMappingInfo/site3-storage_cluster-id_mapping
        cluster_mapping_test.go:153: GetClusterMappingInfo() = <nil>, expected data &[{map[site3-storage:site2-storage] [map[8:3]] [map[10:5]]}]
    --- FAIL: TestGetClusterMappingInfo (0.01s)
        --- PASS: TestGetClusterMappingInfo/mapping_file_not_found (0.00s)
        --- PASS: TestGetClusterMappingInfo/mapping_file_found_with_empty_data (0.00s)
        --- PASS: TestGetClusterMappingInfo/cluster-id_mapping_not_found (0.00s)
        --- FAIL: TestGetClusterMappingInfo/site2-storage_cluster-id_mapping (0.00s)
        --- FAIL: TestGetClusterMappingInfo/site3-storage_cluster-id_mapping (0.00s)
        --- PASS: TestGetClusterMappingInfo/site1-storage_cluster-id_mapping (0.00s)

By splitting the public GetClusterMappingInfo() function into an
internal getClusterMappingInfo() that takes a filename, unit-testing can
use different files for each go-routine, and testing becomes more
predictable.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit 8b71671b42665789fac4a4aa1453b0b107f475c6)
2021-09-01 09:40:24 +00:00
..
cephfs cephfs: support selinux mount options 2021-08-05 08:37:52 +00:00
controller rbd: refractor RegenerateJournal() to take in volumeAttributes 2021-08-11 09:50:10 +00:00
csi-common cleanup: resolve nlreturn linter issues 2021-07-22 06:05:01 +00:00
journal cleanup: resolve nlreturn linter issues 2021-07-22 06:05:01 +00:00
liveness cleanup: resolve nlreturn linter issues 2021-07-22 06:05:01 +00:00
rbd rbd: Cleanup OMAP data for secondary image 2021-08-17 04:36:04 +00:00
util util: fix unit-test for GetClusterMappingInfo() 2021-09-01 09:40:24 +00:00