Wait for cluster safe state before running query
Merge pull request #4211 from ajermakovics/maint/query-basic-test-4200

QueryBasicTest. Wait for cluster safe state before running query (backport)