Replace nose to nose2

because nose is in deprecation[1] so we need to
use nose2, or pytests instead. This commit
suggests to use nose2 and fix some import errors
on slow attribute according to the docs [2]

1: https://nose.readthedocs.io/en/latest/#note-to-users
2: https://docs.nose2.io/en/latest/plugins/attrib.html
Change-Id: Idc0c8c146a9ac7fa7ffd90793211422571852d82
This commit is contained in:
Kota Tsuyuzaki 2022-10-18 16:49:18 +09:00 committed by Takashi Kajinami
parent e9187da3ea
commit 02e4f40ec9
11 changed files with 22 additions and 19 deletions

View File

@ -19,7 +19,7 @@ ant build_storlets
SRC_DIR=$(cd $(dirname $0); pwd)
cd ${SRC_DIR}/tests/functional
if [ "$FLAVOR" == "jenkins" ]; then
nosetests --exe -v ${@:2}
nose2 -v ${@:2}
else
nosetests --exe -v -a '!slow' ${@:2}
nose2 -v -A '!slow' ${@:2}
fi

View File

@ -4,7 +4,7 @@ With that user just do:
::
sudo apt-get update
sudo apt-get install python-tox python-nose git
sudo apt-get install python-tox git
git clone https://opendev.org/openstack/storlets.git
cd storlets
./s2aio.sh install

2
nose2.cfg Normal file
View File

@ -0,0 +1,2 @@
[unittest]
plugins = nose2.plugins.attrib

View File

@ -6,7 +6,6 @@
with_items:
- python3
- python3-venv
- python3-nose
- python3-pip
become: yes

View File

@ -5,7 +5,7 @@
hacking>=3.0.1,<3.1.0 # Apache-2.0
coverage>=3.6
nose
nose2
pexpect
python-subunit>=0.0.18
oslotest>=1.2.0 # Apache-2.0

View File

@ -19,7 +19,6 @@ import os
import random
import string
from swiftclient import client as c
from nose.plugins.attrib import attr
from tests.functional.java import StorletJavaFunctionalTest
import unittest
@ -139,7 +138,6 @@ class TestSLO(StorletJavaFunctionalTest):
f.close()
self.ssertEqual(chunk, aux_content)
@attr('slow')
def test_get_SLO(self):
headers = {'X-Run-Storlet': self.storlet_name}
headers.update(self.additional_headers)
@ -152,6 +150,8 @@ class TestSLO(StorletJavaFunctionalTest):
headers=headers)
self.compare_slo_to_chunks(body)
test_get_SLO.slo = 1
class TestSloOnProxy(TestSLO):
def setUp(self):

View File

@ -18,7 +18,6 @@ import os
import random
import string
from swiftclient import client as c
from nose.plugins.attrib import attr
from contextlib import contextmanager
from tests.functional.java import StorletJavaFunctionalTest
import unittest
@ -127,7 +126,6 @@ class TestIdentityStorlet(StorletJavaFunctionalTest):
except Exception:
pass
@attr('slow')
def test_put_10MB_file(self):
gf_file_path = '/tmp/10MB_file'
with self._filecontext(gf_file_path):
@ -149,6 +147,8 @@ class TestIdentityStorlet(StorletJavaFunctionalTest):
status = response.get('status')
self.assertIn(status, [200, 201])
test_put_10MB_file.slow = 1
def test_put(self):
self.invoke_storlet('PUT')

View File

@ -17,7 +17,6 @@
import threading
from swiftclient import client as swift_client
from swiftclient import ClientException
from nose.plugins.attrib import attr
from storlets.tools.utils import get_member_auth
from tests.functional.java import StorletJavaFunctionalTest
import unittest
@ -100,10 +99,11 @@ class TestTestStorlet(StorletJavaFunctionalTest):
def test_crash(self):
self.invokeTestStorlet("crash")
@attr('slow')
def test_hold(self):
self.invokeTestStorlet("hold")
test_hold.slow = 1
def invokeTestStorletinParallel(self):
mythreads = []
@ -117,10 +117,11 @@ class TestTestStorlet(StorletJavaFunctionalTest):
for t in mythreads:
t.join()
@attr('slow')
def test_parallel_print(self):
self.invokeTestStorletinParallel()
test_parallel_print.slow = 1
def test_storlet_acl_get_fail(self):
headers = {'X-Run-Storlet': self.storlet_name}
headers.update(self.additional_headers)

View File

@ -17,7 +17,6 @@ import json
import random
import string
from swiftclient import client
from nose.plugins.attrib import attr
from tests.functional.python import StorletPythonFunctionalTest
import unittest
@ -104,7 +103,6 @@ class TestSLO(StorletPythonFunctionalTest):
aux_content += f.read()
self.asertEqual(chunk, aux_content)
@attr('slow')
def test_get_SLO(self):
headers = {'X-Run-Storlet': self.storlet_name}
headers.update(self.additional_headers)
@ -117,6 +115,8 @@ class TestSLO(StorletPythonFunctionalTest):
headers=headers)
self.compare_slo_to_chunks(body)
test_get_SLO.slow = 1
class TestSLOOnProxy(TestSLO):
def setUp(self):

View File

@ -16,7 +16,6 @@
import os
import tempfile
from swiftclient import client
from nose.plugins.attrib import attr
from tests.functional.python import StorletPythonFunctionalTest
import unittest
from urllib.request import Request, urlopen
@ -79,7 +78,6 @@ class TestSimpleStorlet(StorletPythonFunctionalTest):
response_dict=resp)
self.assertEqual(204, resp['status'])
@attr('slow')
def test_put_10MB_file(self):
with tempfile.NamedTemporaryFile() as f:
with open(f.name, 'wb') as wf:
@ -99,6 +97,8 @@ class TestSimpleStorlet(StorletPythonFunctionalTest):
status = response.get('status')
self.assertEqual(201, status)
test_put_10MB_file.slow = 1
def test_copy_from(self):
resp = dict()
objname = self.storlet_file + '-copy'

View File

@ -16,7 +16,6 @@
import threading
from swiftclient import client as swift_client
from swiftclient import ClientException
from nose.plugins.attrib import attr
from storlets.tools.utils import get_member_auth
from tests.functional.python import StorletPythonFunctionalTest
import unittest
@ -89,10 +88,11 @@ class TestTestStorlet(StorletPythonFunctionalTest):
def test_crash(self):
self.invoke_storlet("crash")
@attr('slow')
def test_hold(self):
self.invoke_storlet("hold")
test_hold.slow = 1
def invoke_storlet_in_parallel(self):
mythreads = []
@ -106,10 +106,11 @@ class TestTestStorlet(StorletPythonFunctionalTest):
for t in mythreads:
t.join()
@attr('slow')
def test_parallel_print(self):
self.invoke_storlet_in_parallel()
test_parallel_print.slow = 1
def test_storlet_acl_get_fail(self):
headers = {'X-Run-Storlet': self.storlet_name}
headers.update(self.additional_headers)