fix order dependent test related to migration

If the order in which tests are executed is changed then test fails.
This commit ensures that all migrations are run before ensuring that
there are no pending migration.
Merge pull request #11634 from neerajdotname/fix_order_dependent_test_for_migration

fix order dependent test related to migration