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:
|
- job:
|
||||||
name: sahara-tests-tempest-v2
|
name: sahara-tests-tempest-v2
|
||||||
description: |
|
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
|
parent: sahara-tests-tempest
|
||||||
required-projects:
|
required-projects:
|
||||||
- openstack/python-saharaclient
|
- openstack/python-saharaclient
|
||||||
branches: master
|
branches: master
|
||||||
vars:
|
vars:
|
||||||
|
devstack_localrc:
|
||||||
|
USE_PYTHON3: 'True'
|
||||||
devstack_local_conf:
|
devstack_local_conf:
|
||||||
test-config:
|
test-config:
|
||||||
$TEMPEST_CONFIG:
|
$TEMPEST_CONFIG:
|
||||||
data-processing:
|
data-processing:
|
||||||
api_version_saharaclient: '2'
|
api_version_saharaclient: '2'
|
||||||
use_api_v2: 'True'
|
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)
|
# variant for pre-Rocky branches (no S3)
|
||||||
- job:
|
- job:
|
||||||
|
|
|
@ -188,18 +188,15 @@ class ClientTestBase(base.ClientTestBase):
|
||||||
except exc.CommandFailed as e:
|
except exc.CommandFailed as e:
|
||||||
# lower() is required because "result" string could
|
# lower() is required because "result" string could
|
||||||
# have the first letter capitalized.
|
# have the first letter capitalized.
|
||||||
output_msg = str(e).splitlines()
|
if error_message.lower() in str(e).lower():
|
||||||
for msg in output_msg:
|
msg_exist = True
|
||||||
if msg.lower() == error_message.lower():
|
|
||||||
self.assertEqual(error_message.lower(), msg.lower())
|
|
||||||
msg_exist = True
|
|
||||||
if not msg_exist:
|
if not msg_exist:
|
||||||
raise exc.TempestException('%s is not a part of output of '
|
raise exc.TempestException('"%s" is not a part of output of '
|
||||||
'executed command %s'
|
'executed command "%s" (%s)'
|
||||||
% (error_message, cmd))
|
% (error_message, cmd, output_msg))
|
||||||
else:
|
else:
|
||||||
raise exc.TempestException('%s %s in negative scenarios have been '
|
raise exc.TempestException('"%s %s" in negative scenarios has '
|
||||||
'executed without any errors'
|
'been executed without any errors'
|
||||||
% (cmd, name))
|
% (cmd, name))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from filecmp import cmp
|
||||||
from os import fdopen
|
from os import fdopen
|
||||||
from os import path
|
from os import path
|
||||||
from os import remove
|
from os import remove
|
||||||
|
@ -31,6 +32,7 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
||||||
|
|
||||||
def openstack_job_binary_create(self, job_internal=True):
|
def openstack_job_binary_create(self, job_internal=True):
|
||||||
job_binary_name = data_utils.rand_name('job-fake')
|
job_binary_name = data_utils.rand_name('job-fake')
|
||||||
|
script_name = ''
|
||||||
if job_internal:
|
if job_internal:
|
||||||
fd, script_name = tempfile.mkstemp()
|
fd, script_name = tempfile.mkstemp()
|
||||||
with fdopen(fd, 'w+') as jb:
|
with fdopen(fd, 'w+') as jb:
|
||||||
|
@ -48,11 +50,10 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
||||||
'Field',
|
'Field',
|
||||||
'Value'
|
'Value'
|
||||||
])
|
])
|
||||||
if job_internal:
|
return job_binary_name, script_name
|
||||||
remove(script_name)
|
|
||||||
return job_binary_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):
|
if path.exists(job_binary_name):
|
||||||
remove(job_binary_name)
|
remove(job_binary_name)
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ class SaharaJobBinaryCLITest(base.ClientTestBase):
|
||||||
params=job_binary_name)
|
params=job_binary_name)
|
||||||
|
|
||||||
self.assertTrue(path.exists(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)
|
remove(job_binary_name)
|
||||||
|
|
||||||
def openstack_job_binary_show(self, 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 !=
|
@testtools.skipIf(TEMPEST_CONF.data_processing.api_version_saharaclient !=
|
||||||
'1.1', "Full job binaries testing requires API v1.1")
|
'1.1', "Full job binaries testing requires API v1.1")
|
||||||
def test_job_binary_cli(self):
|
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.addCleanup(self.delete_resource, 'job binary', job_binary_name)
|
||||||
|
|
||||||
self.openstack_job_binary_list()
|
self.openstack_job_binary_list()
|
||||||
self.openstack_job_binary_show(job_binary_name)
|
self.openstack_job_binary_show(job_binary_name)
|
||||||
self.openstack_job_binary_update(job_binary_name, flag='description')
|
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.filter_job_binaries_in_list()
|
||||||
self.negative_try_to_update_protected_jb(job_binary_name)
|
self.negative_try_to_update_protected_jb(job_binary_name)
|
||||||
self.openstack_job_binary_update(job_binary_name, flag='unprotected')
|
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)
|
self.negative_delete_removed_job_binary(job_binary_name)
|
||||||
|
|
||||||
def test_job_template_cli(self):
|
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)
|
self.addCleanup(self.delete_resource, 'job binary', job_binary_name)
|
||||||
|
|
||||||
job_template_name = self.openstack_job_template_create(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):
|
def _check_internal_db_job_binary_create(self):
|
||||||
name = data_utils.rand_name('sahara-internal-job-binary')
|
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 = (
|
job_binary_internal = (
|
||||||
self.create_job_binary_internal(name, self.job_binary_data))
|
self.create_job_binary_internal(name, self.job_binary_data))
|
||||||
self.internal_db_binary_with_extra = {
|
self.internal_db_binary_with_extra = {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class JobBinaryInternalsTest(base.BaseDataProcessingTest):
|
||||||
|
|
||||||
def _check_job_binary_internal_create(self):
|
def _check_job_binary_internal_create(self):
|
||||||
name = data_utils.rand_name('sahara-internal-job-binary')
|
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
|
# create job binary internal
|
||||||
resp_body = self.create_job_binary_internal(name, self.job_binary_data)
|
resp_body = self.create_job_binary_internal(name, self.job_binary_data)
|
||||||
# check that job_binary_internal created successfully
|
# check that job_binary_internal created successfully
|
||||||
|
|
Loading…
Reference in New Issue