CLI tests: more testing and Python 3 fixes
- when downloading the internal job binaries, compare it with the original file; - simplify the string matching for the error messages in negative testing (job binary and node group templates). The returned string is a bit different when using python 3 (few \n remainings, maybe there is an interaction between string and byte arrays.) - run the API v2 tests using Python 3. Python 3 and API v2 tests have been both added in Stein. - define few data strings used for testing as bytes, so that they can work with both Python 2 and Python 3. Change-Id: I1924239659072ec8f1ea67df8d3d5b9a2264beb8
This commit is contained in:
parent
3333341a72
commit
4c1d1645de
10
.zuul.yaml
10
.zuul.yaml
|
@ -80,18 +80,26 @@
|
|||
- job:
|
||||
name: sahara-tests-tempest-v2
|
||||
description: |
|
||||
Run Tempest tests from the Sahara plugin against Sahara APIv2.
|
||||
Run Tempest tests from the Sahara plugin against Sahara APIv2
|
||||
and Python 3.
|
||||
parent: sahara-tests-tempest
|
||||
required-projects:
|
||||
- openstack/python-saharaclient
|
||||
branches: master
|
||||
vars:
|
||||
devstack_localrc:
|
||||
USE_PYTHON3: 'True'
|
||||
devstack_local_conf:
|
||||
test-config:
|
||||
$TEMPEST_CONFIG:
|
||||
data-processing:
|
||||
api_version_saharaclient: '2'
|
||||
use_api_v2: 'True'
|
||||
devstack_services:
|
||||
s-account: false
|
||||
s-container: false
|
||||
s-object: false
|
||||
s-proxy: false
|
||||
|
||||
# variant for pre-Rocky branches (no S3)
|
||||
- job:
|
||||
|
|
|
@ -188,18 +188,15 @@ class ClientTestBase(base.ClientTestBase):
|
|||
except exc.CommandFailed as e:
|
||||
# lower() is required because "result" string could
|
||||
# have the first letter capitalized.
|
||||
output_msg = str(e).splitlines()
|
||||
for msg in output_msg:
|
||||
if msg.lower() == error_message.lower():
|
||||
self.assertEqual(error_message.lower(), msg.lower())
|
||||
msg_exist = True
|
||||
if error_message.lower() in str(e).lower():
|
||||
msg_exist = True
|
||||
if not msg_exist:
|
||||
raise exc.TempestException('%s is not a part of output of '
|
||||
'executed command %s'
|
||||
% (error_message, cmd))
|
||||
raise exc.TempestException('"%s" is not a part of output of '
|
||||
'executed command "%s" (%s)'
|
||||
% (error_message, cmd, output_msg))
|
||||
else:
|
||||
raise exc.TempestException('%s %s in negative scenarios have been '
|
||||
'executed without any errors'
|
||||
raise exc.TempestException('"%s %s" in negative scenarios has '
|
||||
'been executed without any errors'
|
||||
% (cmd, name))
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from filecmp import cmp
|
||||
from os import fdopen
|
||||
from os import path
|
||||
from os import remove
|
||||
|
@ -31,6 +32,7 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
|||
|
||||
def openstack_job_binary_create(self, job_internal=True):
|
||||
job_binary_name = data_utils.rand_name('job-fake')
|
||||
script_name = ''
|
||||
if job_internal:
|
||||
fd, script_name = tempfile.mkstemp()
|
||||
with fdopen(fd, 'w+') as jb:
|
||||
|
@ -48,11 +50,10 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
|||
'Field',
|
||||
'Value'
|
||||
])
|
||||
if job_internal:
|
||||
remove(script_name)
|
||||
return job_binary_name
|
||||
return job_binary_name, script_name
|
||||
|
||||
def openstack_job_binary_download(self, job_binary_name):
|
||||
def openstack_job_binary_download(self, job_binary_name,
|
||||
original_file=None):
|
||||
if path.exists(job_binary_name):
|
||||
remove(job_binary_name)
|
||||
|
||||
|
@ -60,6 +61,9 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
|||
params=job_binary_name)
|
||||
|
||||
self.assertTrue(path.exists(job_binary_name))
|
||||
if original_file:
|
||||
self.assertTrue(cmp(job_binary_name, original_file))
|
||||
remove(original_file)
|
||||
remove(job_binary_name)
|
||||
|
||||
def openstack_job_binary_show(self, job_binary_name):
|
||||
|
|
|
@ -159,13 +159,13 @@ class Scenario(images.SaharaImageCLITest,
|
|||
@testtools.skipIf(TEMPEST_CONF.data_processing.api_version_saharaclient !=
|
||||
'1.1', "Full job binaries testing requires API v1.1")
|
||||
def test_job_binary_cli(self):
|
||||
job_binary_name = self.openstack_job_binary_create()
|
||||
job_binary_name, original_file = self.openstack_job_binary_create()
|
||||
self.addCleanup(self.delete_resource, 'job binary', job_binary_name)
|
||||
|
||||
self.openstack_job_binary_list()
|
||||
self.openstack_job_binary_show(job_binary_name)
|
||||
self.openstack_job_binary_update(job_binary_name, flag='description')
|
||||
self.openstack_job_binary_download(job_binary_name)
|
||||
self.openstack_job_binary_download(job_binary_name, original_file)
|
||||
self.filter_job_binaries_in_list()
|
||||
self.negative_try_to_update_protected_jb(job_binary_name)
|
||||
self.openstack_job_binary_update(job_binary_name, flag='unprotected')
|
||||
|
@ -173,7 +173,8 @@ class Scenario(images.SaharaImageCLITest,
|
|||
self.negative_delete_removed_job_binary(job_binary_name)
|
||||
|
||||
def test_job_template_cli(self):
|
||||
job_binary_name = self.openstack_job_binary_create(job_internal=False)
|
||||
job_binary_name, _ = self.openstack_job_binary_create(
|
||||
job_internal=False)
|
||||
self.addCleanup(self.delete_resource, 'job binary', job_binary_name)
|
||||
|
||||
job_template_name = self.openstack_job_template_create(job_binary_name)
|
||||
|
|
|
@ -85,7 +85,7 @@ class JobBinariesTest(base.BaseDataProcessingTest):
|
|||
|
||||
def _check_internal_db_job_binary_create(self):
|
||||
name = data_utils.rand_name('sahara-internal-job-binary')
|
||||
self.job_binary_data = 'Some data'
|
||||
self.job_binary_data = b'Some data'
|
||||
job_binary_internal = (
|
||||
self.create_job_binary_internal(name, self.job_binary_data))
|
||||
self.internal_db_binary_with_extra = {
|
||||
|
|
|
@ -31,7 +31,7 @@ class JobBinaryInternalsTest(base.BaseDataProcessingTest):
|
|||
|
||||
def _check_job_binary_internal_create(self):
|
||||
name = data_utils.rand_name('sahara-internal-job-binary')
|
||||
self.job_binary_data = 'Some data'
|
||||
self.job_binary_data = b'Some data'
|
||||
# create job binary internal
|
||||
resp_body = self.create_job_binary_internal(name, self.job_binary_data)
|
||||
# check that job_binary_internal created successfully
|
||||
|
|
Loading…
Reference in New Issue