{ "info": { "author": "Nir Soffer", "author_email": "nirsof@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Testing" ], "description": "# userstorage\n\nHelper for setting up storage for tests.\n\n\n## Overview\n\nSome tests need more than a temporary directory on the local file\nsystem. One example is testing block device with 4k sector size, or\ntesting a filesystem on top of such a block device.\n\nYou can create storage using loop devices and mounts in test fixtures,\nbut creating devices and mounts requires root. Do you really want to run\nall your tests as root, when the code under test should not run as root?\n\nThe userstorage tool solves this problem by creating storage for tests\nbefore running the tests, and making the storage available to the\ncurrent user. Once you created the storage, you can run the tests\nquickly as yourself directly from your editor.\n\n## Requirements\n\nOn Fedora / CentOS you need to install these packages:\n\n dnf install \\\n e2fsprogs \\\n sudo \\\n systemd-udev \\\n util-linux \\\n xfsprogs\n\nSome packages are typically installed on your machine, but you may need\nto add them to CI environment or container.\n\n\n## Installing\n\nUse pip:\n\n python3 -m pip install --user userstorage\n\nUse python2 if you need to run on a distribution without python3.\n\n\n## Creating configuration file\n\nThe userstorage tool creates storage based on configuration file that\nyou must provide.\n\nThe configuration module is used both by the userstorage tool to\nprovision the storage, and by the tests consuming the storage.\n\nThe configuration module typically starts by importing the required\nbackends:\n\n from userstorage import File\n\nThe configuration module must define these names:\n\n # Where storage is provisioned.\n BASE_DIR = \"/path/to/my/storage\"\n\n # Storage configurations needed by the tests.\n BACKENDS = {}\n\nSee [example_config.py](https://raw.githubusercontent.com/nirs/userstorage/master/example_config.py)\nfor example configuration used by the tests for this project.\n\n\n## Creating storage\n\nTo create the storage described in example_config.py, run:\n\n userstorage create example_config.py\n\nThis can be run once when creating a development environment, and must\nbe run again after rebooting the host.\n\nIf you want to delete the storage, run:\n\n userstorage delete example_config.py\n\nThere is no need to delete the storage normally. The loop devices are\nbacked up by sparse files and do not consume much resources.\n\n\n## Consuming the storage in your tests\n\nSee test/consume_test.py for example test module consuming storage\nset up by userstorage tool, and the example_config.py module.\n\nNote that some storage may not be available on some systems. Your tests\ncan check if a storage is available and skip or mark the test as xfail\nif needed.\n\n\n## Ensuring test isolation\n\nReusing the same storage for all tests introduce the problem of old test\ndata breaking other tests, or causing test to pass when they should\nfail.\n\nTo avoid this issues, you should call backend's setup() methods before\nusing the storage in a test, and teardown() after running the tests.\nThis ensures that old data from other tests will not be seen by this\ntest.\n\n\n## How it works?\n\nThe userstorage tool creates this directory layout in the BASE_DIR\ndefined in the configuration module:\n\n $ tree /var/tmp/example-storage/\n /var/tmp/example-storage/\n \u251c\u2500\u2500 block-4k-backing\n \u251c\u2500\u2500 block-4k-loop -> /dev/loop2\n \u251c\u2500\u2500 block-512-backing\n \u251c\u2500\u2500 block-512-loop -> /dev/loop3\n \u251c\u2500\u2500 file-4k-backing\n \u251c\u2500\u2500 file-4k-loop -> /dev/loop4\n \u251c\u2500\u2500 file-4k-mount\n \u2502\u00a0\u00a0 \u251c\u2500\u2500 file\n \u2502\u00a0\u00a0 \u2514\u2500\u2500 lost+found [error opening dir]\n \u251c\u2500\u2500 file-512-backing\n \u251c\u2500\u2500 file-512-loop -> /dev/loop5\n \u2514\u2500\u2500 file-512-mount\n \u251c\u2500\u2500 file\n \u2514\u2500\u2500 lost+found [error opening dir]\n\nThe symbolic links (e.g. file-4k-loop) link to the loop devices created\nby the tool (/dev/loop4), and used to delete the storage later.\n\nThe actual file used for the tests are created inside the mounted\nfilesystem (/var/tmp/example-storage/file-4k-mount/file).\n\n\n## Projects using userstorage\n\n- [ovirt-imageio](https://github.com/oVirt/ovirt-imageio)\n- [vdsm](https://github.com/oVirt/vdsm) - embers a more recent version\n- [sanlock](https://pagure.io/sanlock) - embeds a very early version\n\n(Please add your project here)\n\n\n## Contributing\n\nIf you found a bug, please open an issue.\n\nIf you have an idea for improving this tool, please open an issue to\ndiscuss the idea.\n\nFor trivial changes please send a pull request.\n\n\n## Running the tests\n\nTo run the tests you need to install tox. You can use tox from your\ndistribution (python2-tox or python3-tox on Fedora), or install it using\npip.\n\nBefore running the tests, create the example storage:\n\n python3 -m userstorage create example_config.py\n\nTo run the tests:\n\n tox\n\nIf you want to change storage layout, best delete the example storage:\n\n python3 -m userstorage delete example_config.py\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nirs/userstorage", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "userstorage", "package_url": "https://pypi.org/project/userstorage/", "platform": "", "project_url": "https://pypi.org/project/userstorage/", "project_urls": { "Homepage": "https://github.com/nirs/userstorage" }, "release_url": "https://pypi.org/project/userstorage/0.4/", "requires_dist": null, "requires_python": "", "summary": "Create storage for tests", "version": "0.4" }, "last_serial": 5957411, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "50ad7ab9ad457d303c2c16af3656830d", "sha256": "a36ef858b032d5b42a02ed6077cdfd0588ff736fee4986673531298e70913c9f" }, "downloads": -1, "filename": "userstorage-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "50ad7ab9ad457d303c2c16af3656830d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16175, "upload_time": "2019-07-17T18:53:42", "url": "https://files.pythonhosted.org/packages/fe/06/7b455b5b7c4b1d82b63171d19b9671a002f339419e410ccf98cc052cd4e1/userstorage-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "755e25f85927b0b5918c910cd0581f7e", "sha256": "a68166e7e88a0618097c2eedce961404c8b68d25221fa9ab924c469eb987ce63" }, "downloads": -1, "filename": "userstorage-0.1.tar.gz", "has_sig": false, "md5_digest": "755e25f85927b0b5918c910cd0581f7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6992, "upload_time": "2019-07-17T18:53:45", "url": "https://files.pythonhosted.org/packages/40/b6/f6eb8845dd706cfe497652bf4e368f56d04f753baa473d45ee016b9915ac/userstorage-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "ebb0188c5fdbd6442c1891c63eda38bb", "sha256": "9c6efeb907400b94d054c026a5a0f99aaf8f2330fcc32ca3abad598a2a878cb3" }, "downloads": -1, "filename": "userstorage-0.2-py2-none-any.whl", "has_sig": false, "md5_digest": "ebb0188c5fdbd6442c1891c63eda38bb", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 16525, "upload_time": "2019-07-24T17:02:33", "url": "https://files.pythonhosted.org/packages/00/b1/4297784feba65720bf09e89b2b5625c1e1a5165f51cd8ace45bd134f0adf/userstorage-0.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c64df3d46ab249f754fbe422c210ea59", "sha256": "eab3ad535d242b093921f1320386e5ef94d7a46d00f3decc66158ab5a6aeacb3" }, "downloads": -1, "filename": "userstorage-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c64df3d46ab249f754fbe422c210ea59", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16523, "upload_time": "2019-07-24T17:02:35", "url": "https://files.pythonhosted.org/packages/4e/69/ef01a18c74ce898c5c7ea1ac28d9796c832aa9a60576dab2c11555e90093/userstorage-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c256f76d7942d88a76476c2aba2471d5", "sha256": "938e39f3ae86f48a8013843db628880d80bc11aec7fdbf118ea47d18ea79e5c5" }, "downloads": -1, "filename": "userstorage-0.2.tar.gz", "has_sig": false, "md5_digest": "c256f76d7942d88a76476c2aba2471d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7291, "upload_time": "2019-07-24T17:02:36", "url": "https://files.pythonhosted.org/packages/86/85/76f8603c8beb2e6ca993390cb6b95e238ac5ea37616384468703aae9c908/userstorage-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "859bfb5463d05c3bc65347bfb56e2bfa", "sha256": "07f0a3041b4327f92398f55b38e8a16c6f7448f13f0c9e170dea7caceed7662f" }, "downloads": -1, "filename": "userstorage-0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "859bfb5463d05c3bc65347bfb56e2bfa", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16660, "upload_time": "2019-10-09T19:06:57", "url": "https://files.pythonhosted.org/packages/84/4f/956025dad0a46b5273f2d81c750c297bcee154fbc50eb768de7bddeb778f/userstorage-0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e9e37374d6faf9db57f9bf6a13dcb7f1", "sha256": "ef64c7cb51a3dc8cbaf85bd26cb4c8963562c79d94b8c060e6622fc916279f46" }, "downloads": -1, "filename": "userstorage-0.3.tar.gz", "has_sig": false, "md5_digest": "e9e37374d6faf9db57f9bf6a13dcb7f1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9141, "upload_time": "2019-10-09T19:06:58", "url": "https://files.pythonhosted.org/packages/af/f8/6ae7bfd7b875188836a9d62583b871b5d78cb14ea5f5a2f4ac64338845a7/userstorage-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "c4ce3a76e1259be2193a0b07b3e463db", "sha256": "890825ddaa6ffe9875e9a666f96b8264b7fb2a9ad3eec2e925de120bfea48d49" }, "downloads": -1, "filename": "userstorage-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "c4ce3a76e1259be2193a0b07b3e463db", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16795, "upload_time": "2019-10-10T22:43:30", "url": "https://files.pythonhosted.org/packages/66/1a/329b1d8994af4cd7462167728d5886e66a562705c978296019db987d9606/userstorage-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "73251cbe8f7dd562965bb2441bafcdb5", "sha256": "78944e0b5b71a538b318a9d39712c41a17b98db56dc552a711284804286b7d70" }, "downloads": -1, "filename": "userstorage-0.4.tar.gz", "has_sig": false, "md5_digest": "73251cbe8f7dd562965bb2441bafcdb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9272, "upload_time": "2019-10-10T22:43:31", "url": "https://files.pythonhosted.org/packages/bd/50/4ba9de01a523bf2e36418cc76c019930231002fd0de0f71d301fa0f846f9/userstorage-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c4ce3a76e1259be2193a0b07b3e463db", "sha256": "890825ddaa6ffe9875e9a666f96b8264b7fb2a9ad3eec2e925de120bfea48d49" }, "downloads": -1, "filename": "userstorage-0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "c4ce3a76e1259be2193a0b07b3e463db", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 16795, "upload_time": "2019-10-10T22:43:30", "url": "https://files.pythonhosted.org/packages/66/1a/329b1d8994af4cd7462167728d5886e66a562705c978296019db987d9606/userstorage-0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "73251cbe8f7dd562965bb2441bafcdb5", "sha256": "78944e0b5b71a538b318a9d39712c41a17b98db56dc552a711284804286b7d70" }, "downloads": -1, "filename": "userstorage-0.4.tar.gz", "has_sig": false, "md5_digest": "73251cbe8f7dd562965bb2441bafcdb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9272, "upload_time": "2019-10-10T22:43:31", "url": "https://files.pythonhosted.org/packages/bd/50/4ba9de01a523bf2e36418cc76c019930231002fd0de0f71d301fa0f846f9/userstorage-0.4.tar.gz" } ] }