]> git-server-git.apps.pok.os.sepia.ceph.com Git - ragweed.git/commitdiff
ragweed: switch to pytest framework
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 31 Jan 2023 16:56:18 +0000 (11:56 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 20 Feb 2023 14:37:50 +0000 (09:37 -0500)
due to deprecation of nose

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 8fedfb579fe2bca916922e9b33517ca3c7e1b824)

README.rst [new file with mode: 0644]
bootstrap
pytest.ini [new file with mode: 0644]
ragweed/framework.py
requirements.txt

diff --git a/README.rst b/README.rst
new file mode 100644 (file)
index 0000000..5cb6545
--- /dev/null
@@ -0,0 +1,66 @@
+===============
+ Ragweed Tests
+===============
+
+This is a set of test that verify functionality for the RGW, and the way it is represented in rados.
+
+This can be used to verify functionality between upgrades.
+
+Tests are run in two phases. In the first phase, (possibly when running against the old version) data is prepared.
+
+In the second phase the representation of that data is then tested (possibly after an upgrade). 
+
+Each of these phases can be executed separately.
+
+For more information on the background of the tests visit: https://www.spinics.net/lists/ceph-devel/msg34636.html
+
+The tests use the pytest test framework. To get started, ensure you have
+the ``virtualenv`` software installed; e.g. on Debian/Ubuntu::
+
+       sudo apt-get install python-virtualenv
+
+on Fedora/RHEL::
+
+       sudo yum install python3-virtualenv
+
+and then run::
+
+       ./bootstrap
+
+You will need to create a configuration file with the location of the
+service and two different credentials. A sample configuration file named
+``ragweed-example.conf`` has been provided in this repo. 
+
+Once you have that file copied and edited, you can run the tests with::
+
+       RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/pytest -v
+
+The phase(s) of the tests are set via ``RAGWEED_STAGES``. The options for ``RAGWEED_STAGES``  are ``prepare`` and ``check``. ``test`` can be used instead of ``check``.
+
+=====================================
+Running Ragweed Tests with vstart.sh
+=====================================
+
+Note: This example assumes the path to the ceph source code is $HOME/ceph.
+
+The ``ragweed-example.conf`` file provided can be can be used to run the ragweed tests on a Ceph cluster started with vstart.
+
+Before the ragweed tests are run a system user must be created on the cluster first. From the ``ceph/build`` directory run::
+
+         $HOME/ceph/build/bin/radosgw-admin -c ceph.conf user create --uid=admin_user --display-name="Admin User" --access-key=accesskey2 --secret-key=secretkey2 --admin
+
+If the system user created is different than the one created above the ``[user system]`` section in the ragweed.conf file much match the created user.
+
+Then run ``$HOME/ceph/build/vstart_environment.sh`` or export the ``LD_LIBRARY_PATH`` and ``PYTHONPATH`` generated in the file ``$HOME/ceph/build/vstart_environment.sh``::
+
+        chmod 775 $HOME/ceph/build/vstart_environment.sh
+        $HOME/ceph/build/vstart_environment.sh
+
+OR::
+
+        export PYTHONPATH=$HOME/ceph/master/src/pybind:$HOME/ceph/master/build/lib/cython_modules/lib.3:$HOME/ceph/master/src/python-common:$PYTHONPATH
+        export LD_LIBRARY_PATH=$HOME/ceph/master/build/lib:$LD_LIBRARY_PATH
+
+Finally run the ragweed tests::
+
+       RAGWEED_CONF=ragweed.conf RAGWEED_STAGES=prepare,check ./virtualenv/bin/pytest -v
index a70fea25d44ed8d62076679292cc46397ea7cc4a..186f6b7159894b71336ac863bfdbeefc5d559312 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -35,7 +35,7 @@ virtualenv -p python3 --system-site-packages --download virtualenv
 
 # work-around change in pip 1.5
 ./virtualenv/bin/pip install six
-./virtualenv/bin/pip install -I nose
+./virtualenv/bin/pip install -U pytest
 ./virtualenv/bin/pip install setuptools
 
 ./virtualenv/bin/pip install -U -r requirements.txt
diff --git a/pytest.ini b/pytest.ini
new file mode 100644 (file)
index 0000000..48f2cbe
--- /dev/null
@@ -0,0 +1,3 @@
+[pytest]
+python_classes = r_test
+python_files = test*.py
index 3dfb3e403596018402dd7b96a85c30c0e85da540..a02d18ec8c69703545adf5f15ad745f60e359a64 100644 (file)
@@ -15,6 +15,8 @@ import rados
 
 from .reqs import _make_admin_request
 
+import pytest
+
 ragweed_env = None
 suite = None
 
@@ -287,7 +289,7 @@ class RZone:
 
 
 class RTest:
-    def __init__(self):
+    def setup_method(self):
         self._name = self.__class__.__name__
         self.r_buckets = []
         self.init()
@@ -445,6 +447,7 @@ class RagweedEnv:
                 'ceph_conf is missing under the [rados] section in ' + os.environ['RAGWEED_CONF']
                 )
 
+        print('conf=' + str(self.ceph_conf))
         self.rados = rados.Rados(conffile=self.ceph_conf)
         self.rados.connect()
 
@@ -459,3 +462,8 @@ def setup_module():
 
     ragweed_env = RagweedEnv()
     suite = ragweed_env.suite
+
+@pytest.fixture(scope="package", autouse=True)
+def setup_teardown():
+    setup_module()
+    yield
index 178ef67966ca8e5a98545a2621664c745472c90a..b196d563f3cff12fbd6d4c4b0b4471146681ad26 100644 (file)
@@ -1,5 +1,5 @@
 PyYAML
-nose >=1.0.0
+pytest
 boto >=2.6.0, != 2.46.0
 munch >=1.0.0
 gevent >=1.0