Adam Litke has uploaded a new change for review.
Change subject: tests: Use make_uuid in storage tests ......................................................................
tests: Use make_uuid in storage tests
Change-Id: Ie86551f26d5cdd12e66516af3b069344c99588e8 Signed-off-by: Adam Litke alitke@redhat.com --- M tests/storageMailboxTests.py M tests/storage_hsm_test.py M tests/storage_sdm_copy_data_test.py M tests/storage_sdm_create_volume_test.py M tests/storage_volume_artifacts_test.py M tests/storage_volume_metadata_test.py M tests/storage_workarounds_test.py M tests/storagetestlib.py M tests/storagetestlibTests.py 9 files changed, 49 insertions(+), 50 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/64943/1
diff --git a/tests/storageMailboxTests.py b/tests/storageMailboxTests.py index 1d5b45a..5de9652 100644 --- a/tests/storageMailboxTests.py +++ b/tests/storageMailboxTests.py @@ -18,11 +18,11 @@ # Refer to the README and COPYING files for full details of the license #
-from uuid import uuid4 import threading import os import shutil
+from testlib import make_uuid from testlib import VdsmTestCase as TestCaseBase
import storage.storage_mailbox as sm @@ -33,7 +33,7 @@
class StoragePoolStub(object): def __init__(self): - self.spUUID = str(uuid4()) + self.spUUID = make_uuid() self.storage_repository = tempfile.mkdtemp(dir='/var/tmp') self.__masterDir = os.path.join(self.storage_repository, self.spUUID, "mastersd", DOMAIN_META_DATA) diff --git a/tests/storage_hsm_test.py b/tests/storage_hsm_test.py index e9e0448..b7e0e28 100644 --- a/tests/storage_hsm_test.py +++ b/tests/storage_hsm_test.py @@ -18,11 +18,11 @@ # Refer to the README and COPYING files for full details of the license #
-import uuid from contextlib import contextmanager
from monkeypatch import MonkeyPatchScope from testlib import make_config +from testlib import make_uuid from testlib import VdsmTestCase from testlib import permutations, expandPermutations from storagetestlib import fake_file_env @@ -112,8 +112,8 @@ @contextmanager def fake_volume(self, vol_fmt): with fake_file_env() as env: - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() make_file_volume(env.sd_manifest, self.SIZE, img_id, vol_id, vol_format=vol_fmt) yield env.sd_manifest.produceVolume(img_id, vol_id) diff --git a/tests/storage_sdm_copy_data_test.py b/tests/storage_sdm_copy_data_test.py index c0ec533..e770b7f 100644 --- a/tests/storage_sdm_copy_data_test.py +++ b/tests/storage_sdm_copy_data_test.py @@ -19,7 +19,6 @@ # from __future__ import absolute_import
-import uuid from contextlib import contextmanager
from fakelib import FakeScheduler @@ -28,6 +27,7 @@ from storagetestlib import fake_env from storagetestlib import make_qemu_chain, write_qemu_chain, verify_qemu_chain from storagetestlib import ChainVerificationError +from testlib import make_uuid from testlib import VdsmTestCase, expandPermutations, permutations from testlib import wait_for_job
@@ -130,7 +130,7 @@ def test_intra_domain_copy(self, env_type, src_fmt, dst_fmt): src_fmt = sc.name2type(src_fmt) dst_fmt = sc.name2type(dst_fmt) - job_id = str(uuid.uuid4()) + job_id = make_uuid()
with self.get_vols(env_type, src_fmt, dst_fmt) as (src_chain, dst_chain): @@ -173,7 +173,7 @@ dst_chain): write_qemu_chain(src_chain) for index in copy_seq: - job_id = str(uuid.uuid4()) + job_id = make_uuid() src_vol = src_chain[index] dst_vol = dst_chain[index] source = dict(endpoint_type='div', sd_id=src_vol.sdUUID, @@ -193,7 +193,7 @@ volume format may be set incorrectly due to an old bug. Check that the workaround we have in place allows the copy to proceed without error. """ - job_id = str(uuid.uuid4()) + job_id = make_uuid() vm_conf_size = workarounds.VM_CONF_SIZE_BLK * sc.BLOCK_SIZE vm_conf_data = "VM Configuration"
diff --git a/tests/storage_sdm_create_volume_test.py b/tests/storage_sdm_create_volume_test.py index ebc2db0..f62f325 100644 --- a/tests/storage_sdm_create_volume_test.py +++ b/tests/storage_sdm_create_volume_test.py @@ -20,10 +20,10 @@ from __future__ import absolute_import
from contextlib import contextmanager -import uuid
from monkeypatch import MonkeyPatchScope from storagefakelib import FakeResourceManager +from testlib import make_uuid from testlib import VdsmTestCase, recorded, expandPermutations, permutations from testlib import wait_for_job
@@ -84,17 +84,17 @@
def _get_vol_info(): - return dict(sd_id=str(uuid.uuid4()), img_id=str(uuid.uuid4()), - vol_id=str(uuid.uuid4()), virtual_size=2048, + return dict(sd_id=make_uuid(), img_id=make_uuid(), + vol_id=make_uuid(), virtual_size=2048, vol_format='RAW', disk_type='SYSTEM')
class CreateVolumeTests(VdsmTestCase):
def _get_args(self): - job_id = str(uuid.uuid4()) + job_id = make_uuid() host_id = 1 - sd_manifest = FakeDomainManifest(str(uuid.uuid4())) + sd_manifest = FakeDomainManifest(make_uuid()) vol_info = _get_vol_info() vol_info_obj = storage.sdm.api.create_volume.CreateVolumeInfo(vol_info) return dict(job_id=job_id, host_id=host_id, sd_manifest=sd_manifest, diff --git a/tests/storage_volume_artifacts_test.py b/tests/storage_volume_artifacts_test.py index 36ea004..ee044f0 100644 --- a/tests/storage_volume_artifacts_test.py +++ b/tests/storage_volume_artifacts_test.py @@ -19,9 +19,9 @@ #
import os -import uuid
from monkeypatch import MonkeyPatchScope +from testlib import make_uuid from testlib import VdsmTestCase from testlib import permutations, expandPermutations from testValidation import brokentest @@ -62,8 +62,8 @@ class VolumeArtifactsTestsMixin(object):
def setUp(self): - self.img_id = str(uuid.uuid4()) - self.vol_id = str(uuid.uuid4()) + self.img_id = make_uuid() + self.vol_id = make_uuid()
def test_state_missing(self): with self.fake_env() as env: @@ -107,7 +107,7 @@ first.create(*BASE_PARAMS[sc.RAW_FORMAT]) first.commit() second = env.sd_manifest.get_volume_artifacts( - self.img_id, str(uuid.uuid4())) + self.img_id, make_uuid()) self.assertRaises(se.InvalidParameterException, second.create, *BASE_PARAMS[sc.COW_FORMAT])
@@ -118,7 +118,7 @@ first.create(*BASE_PARAMS[sc.RAW_FORMAT]) first.commit() second = env.sd_manifest.get_volume_artifacts( - self.img_id, str(uuid.uuid4())) + self.img_id, make_uuid()) self.assertRaises(se.InvalidParameterException, second.create, *BASE_PARAMS[sc.RAW_FORMAT])
@@ -329,8 +329,8 @@ class FileVolumeArtifactVisibilityTests(VdsmTestCase):
def setUp(self): - self.img_id = str(uuid.uuid4()) - self.vol_id = str(uuid.uuid4()) + self.img_id = make_uuid() + self.vol_id = make_uuid()
def test_getallimages(self): # The current behavior of getAllImages is to report garbage image @@ -563,8 +563,8 @@ class BlockVolumeArtifactVisibilityTests(VdsmTestCase):
def setUp(self): - self.img_id = str(uuid.uuid4()) - self.vol_id = str(uuid.uuid4()) + self.img_id = make_uuid() + self.vol_id = make_uuid()
def test_getallimages(self): # The current behavior of getAllImages for block domains does not diff --git a/tests/storage_volume_metadata_test.py b/tests/storage_volume_metadata_test.py index b8f5873..86222ef 100644 --- a/tests/storage_volume_metadata_test.py +++ b/tests/storage_volume_metadata_test.py @@ -19,8 +19,8 @@
import textwrap import time -import uuid
+from testlib import make_uuid from testlib import VdsmTestCase, permutations, expandPermutations from monkeypatch import MonkeyPatchScope
@@ -35,9 +35,9 @@
def make_init_params(**kwargs): res = dict( - domain=str(uuid.uuid4()), - image=str(uuid.uuid4()), - puuid=str(uuid.uuid4()), + domain=make_uuid(), + image=make_uuid(), + puuid=make_uuid(), size=1024 * MB, format=sc.type2name(sc.RAW_FORMAT), type=sc.type2name(sc.SPARSE_VOL), diff --git a/tests/storage_workarounds_test.py b/tests/storage_workarounds_test.py index 47728b4..fd659e5 100644 --- a/tests/storage_workarounds_test.py +++ b/tests/storage_workarounds_test.py @@ -19,8 +19,8 @@ #
from __future__ import absolute_import -import uuid
+from testlib import make_uuid from testlib import VdsmTestCase from storagetestlib import fake_file_env
@@ -35,8 +35,8 @@
def make_volume(env, size, md_fmt, real_fmt): - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() env.make_volume(size, img_id, vol_id, vol_format=md_formats[md_fmt]) vol = env.sd_manifest.produceVolume(img_id, vol_id) qemuimg.create(vol.getVolumePath(), size, qemu_formats[real_fmt]) diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py index 81b575c..24cd27e 100644 --- a/tests/storagetestlib.py +++ b/tests/storagetestlib.py @@ -17,10 +17,9 @@ # Refer to the README and COPYING files for full details of the license # import os -import uuid from contextlib import contextmanager
-from testlib import make_file, namedTemporaryDir +from testlib import make_file, make_uuid, namedTemporaryDir from storagefakelib import FakeLVM from storagefakelib import FakeStorageDomainCache from monkeypatch import MonkeyPatchScope @@ -139,16 +138,16 @@ md[sd.DMDK_SDUUID] = sduuid md[sd.DMDK_VERSION] = version md[sd.DMDK_CLASS] = dom_class - md[sd.DMDK_POOLS] = pools if pools is not None else [str(uuid.uuid4())] + md[sd.DMDK_POOLS] = pools if pools is not None else [make_uuid()] return md
def make_blocksd_manifest(tmpdir, fake_lvm, sduuid=None, devices=None): if sduuid is None: - sduuid = str(uuid.uuid4()) + sduuid = make_uuid() if devices is None: devices = get_random_devices() - spuuid = str(uuid.uuid4()) + spuuid = make_uuid()
fake_lvm.createVG(sduuid, devices, blockSD.STORAGE_DOMAIN_TAG, blockSD.VG_METADATASIZE) @@ -188,8 +187,8 @@
def make_filesd_manifest(tmpdir): - spuuid = str(uuid.uuid4()) - sduuid = str(uuid.uuid4()) + spuuid = make_uuid() + sduuid = make_uuid()
domain_path = os.path.join(tmpdir, spuuid, sduuid) metafile = get_metafile_path(domain_path) @@ -340,11 +339,11 @@
def make_qemu_chain(env, size, base_vol_fmt, chain_len): vol_list = [] - img_id = str(uuid.uuid4()) + img_id = make_uuid() parent_vol_id = sc.BLANK_UUID vol_fmt = base_vol_fmt for i in range(chain_len): - vol_id = str(uuid.uuid4()) + vol_id = make_uuid() if parent_vol_id != sc.BLANK_UUID: vol_fmt = sc.COW_FORMAT env.make_volume(size, img_id, vol_id, diff --git a/tests/storagetestlibTests.py b/tests/storagetestlibTests.py index addf340..a7d6a2c 100644 --- a/tests/storagetestlibTests.py +++ b/tests/storagetestlibTests.py @@ -18,9 +18,9 @@ #
import os -import uuid
from testlib import expandPermutations, permutations +from testlib import make_uuid from testlib import namedTemporaryDir from testlib import VdsmTestCase from testlib import TEMPDIR @@ -72,8 +72,8 @@
def test_volume_structure(self): with fake_file_env() as env: - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() make_file_volume(env.sd_manifest, 0, img_id, vol_id) image_dir = env.sd_manifest.getImagePath(img_id) files = (vol_id, vol_id + sc.LEASE_FILEEXT, @@ -85,8 +85,8 @@ def test_volume_metadata_io(self): with fake_file_env() as env: size = 1 * MB - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() make_file_volume(env.sd_manifest, size, img_id, vol_id) vol = env.sd_manifest.produceVolume(img_id, vol_id) desc = 'foo' @@ -144,8 +144,8 @@ def test_volume_size_alignment(self, size_param): with fake_block_env() as env: sd_id = env.sd_manifest.sdUUID - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() make_block_volume(env.lvm, env.sd_manifest, size_param, img_id, vol_id) vol = env.sd_manifest.produceVolume(img_id, vol_id) @@ -161,8 +161,8 @@ def test_volume_metadata_io(self): with fake_block_env() as env: sd_id = env.sd_manifest.sdUUID - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() size_mb = sc.VG_EXTENT_SIZE_MB size = size_mb * MB size_blk = size_mb * MB / sc.BLOCK_SIZE @@ -182,8 +182,8 @@ def test_volume_accessibility(self): with fake_block_env() as env: sd_id = env.sd_manifest.sdUUID - img_id = str(uuid.uuid4()) - vol_id = str(uuid.uuid4()) + img_id = make_uuid() + vol_id = make_uuid() make_block_volume(env.lvm, env.sd_manifest, 1 * MB, img_id, vol_id)
self.assertTrue(os.path.isfile(env.lvm.lvPath(sd_id, vol_id)))
gerrit-hooks has posted comments on this change.
Change subject: tests: Use make_uuid in storage tests ......................................................................
Patch Set 1:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Nir Soffer has posted comments on this change.
Change subject: tests: Use make_uuid in storage tests ......................................................................
Patch Set 1: Code-Review+2
Nir Soffer has posted comments on this change.
Change subject: tests: Use make_uuid in storage tests ......................................................................
Patch Set 1: Verified+1
Verified by the tests.
Nir Soffer has submitted this change and it was merged.
Change subject: tests: Use make_uuid in storage tests ......................................................................
tests: Use make_uuid in storage tests
Change-Id: Ie86551f26d5cdd12e66516af3b069344c99588e8 Signed-off-by: Adam Litke alitke@redhat.com Reviewed-on: https://gerrit.ovirt.org/64943 Reviewed-by: Nir Soffer nsoffer@redhat.com Continuous-Integration: Jenkins CI Tested-by: Nir Soffer nsoffer@redhat.com --- M tests/storageMailboxTests.py M tests/storage_hsm_test.py M tests/storage_sdm_copy_data_test.py M tests/storage_sdm_create_volume_test.py M tests/storage_volume_artifacts_test.py M tests/storage_volume_metadata_test.py M tests/storage_workarounds_test.py M tests/storagetestlib.py M tests/storagetestlibTests.py 9 files changed, 49 insertions(+), 50 deletions(-)
Approvals: Nir Soffer: Verified; Looks good to me, approved Jenkins CI: Passed CI tests
gerrit-hooks has posted comments on this change.
Change subject: tests: Use make_uuid in storage tests ......................................................................
Patch Set 2:
* #64943::Update tracker: OK * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org