Commit 2eada474 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

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: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1901b29a8319b2203a855e7879821ed3850f4917
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1261


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 0f515737
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -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,6 +5332,16 @@ blob_create_snapshot_power_failure(void)
	int rc;
	bool created = false;

	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;
@@ -5343,8 +5354,6 @@ blob_create_snapshot_power_failure(void)
		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_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);