ut/blob: recreate bs on each create_snapshot power fail UT
blob_create_snapshot_power_failure() test always attempted snapshot creation until the snapshot did open. Which meant that on bs reload after dirty shutdown, the original blob might be in unrecoverable state. UT did not verify create call beyond that point. Next patch will stop after snapshot is possible to be opened, AND the spdk_bs_create_snapshot() returned success. This patch makes it easier to recreate same starting conditions after snapshot did not open. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I1901b29a8319b2203a855e7879821ed3850f4917 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1261 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
0f5157377f
commit
2eada474ba
@ -5320,6 +5320,7 @@ static void
|
||||
blob_create_snapshot_power_failure(void)
|
||||
{
|
||||
struct spdk_blob_store *bs = g_bs;
|
||||
struct spdk_bs_dev *dev;
|
||||
struct spdk_blob_opts opts;
|
||||
struct spdk_blob *blob, *snapshot;
|
||||
struct spdk_power_failure_thresholds thresholds = {};
|
||||
@ -5331,20 +5332,28 @@ blob_create_snapshot_power_failure(void)
|
||||
int rc;
|
||||
bool created = false;
|
||||
|
||||
/* Create blob */
|
||||
ut_spdk_blob_opts_init(&opts);
|
||||
opts.num_clusters = 10;
|
||||
|
||||
spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL);
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID);
|
||||
blobid = g_blobid;
|
||||
SPDK_CU_ASSERT_FATAL(spdk_bit_array_get(bs->used_clusters, 1));
|
||||
SPDK_CU_ASSERT_FATAL(!spdk_bit_array_get(bs->used_clusters, 11));
|
||||
|
||||
thresholds.general_threshold = 1;
|
||||
while (!created) {
|
||||
dev = init_dev();
|
||||
|
||||
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
SPDK_CU_ASSERT_FATAL(g_bs != NULL);
|
||||
bs = g_bs;
|
||||
|
||||
/* Create blob */
|
||||
ut_spdk_blob_opts_init(&opts);
|
||||
opts.num_clusters = 10;
|
||||
|
||||
spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL);
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID);
|
||||
blobid = g_blobid;
|
||||
SPDK_CU_ASSERT_FATAL(spdk_bit_array_get(bs->used_clusters, 1));
|
||||
SPDK_CU_ASSERT_FATAL(!spdk_bit_array_get(bs->used_clusters, 11));
|
||||
|
||||
dev_set_power_failure_thresholds(thresholds);
|
||||
|
||||
/* Create snapshot */
|
||||
@ -5400,11 +5409,9 @@ blob_create_snapshot_power_failure(void)
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
/* Reload blobstore to have the same starting conditions (as the previous blobstore load
|
||||
* may trigger cleanup after power failure or may not) */
|
||||
ut_bs_reload(&bs, NULL);
|
||||
SPDK_CU_ASSERT_FATAL(spdk_bit_array_get(bs->used_clusters, 1));
|
||||
SPDK_CU_ASSERT_FATAL(!spdk_bit_array_get(bs->used_clusters, 11));
|
||||
spdk_bs_unload(bs, bs_op_complete, NULL);
|
||||
poll_threads();
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
thresholds.general_threshold++;
|
||||
}
|
||||
@ -6548,7 +6555,7 @@ int main(int argc, char **argv)
|
||||
CU_ADD_TEST(suite, blob_relations);
|
||||
CU_ADD_TEST(suite, blob_relations2);
|
||||
CU_ADD_TEST(suite, blob_delete_snapshot_power_failure);
|
||||
CU_ADD_TEST(suite_bs, blob_create_snapshot_power_failure);
|
||||
CU_ADD_TEST(suite, blob_create_snapshot_power_failure);
|
||||
CU_ADD_TEST(suite_bs, blob_inflate_rw);
|
||||
CU_ADD_TEST(suite_bs, blob_snapshot_freeze_io);
|
||||
CU_ADD_TEST(suite_bs, blob_operation_split_rw);
|
||||
|
Loading…
Reference in New Issue
Block a user