Get python3 tempest tests job to pass

* Switch to file backend if python35 is enabled because the default
  backend is swift that hasn't migrate to py35 yet.
* Safe decode bytes string of response body.

Depends-On: Ib222bf2e84f4b06b0dc3981fc3554510658d4ef0
Partial-Implements: blueprint support-python-35
Change-Id: I2d9a95dda8ead16421186116118badfce1de7ba6
This commit is contained in:
Hongbin Lu 2017-07-31 22:30:31 +00:00
parent 548325b74f
commit ffb5762344
2 changed files with 17 additions and 11 deletions

View File

@ -158,6 +158,11 @@ function configure_zun {
if [ "$ZUN_USE_MOD_WSGI" == "True" ]; then
_config_zun_apache_wsgi
fi
if [[ "$USE_PYTHON3" = "True" ]]; then
# Switch off glance->swift communication as swift fails under py3.x
iniset /etc/glance/glance-api.conf glance_store default_store file
fi
}
# upload_sandbox_image() - Upload sandbox image to glance

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import encodeutils
from tempest.lib import decorators
from zun.tests.tempest.api import clients
@ -222,7 +223,7 @@ class TestContainer(base.BaseZunTest):
image="myrepo", image_driver="glance", command=command)
resp, body = self.container_client.logs_container(model.uuid)
self.assertEqual(200, resp.status)
self.assertTrue('hello' in body)
self.assertTrue('hello' in encodeutils.safe_decode(body))
finally:
try:
response = self.images_client.list_images()
@ -308,7 +309,7 @@ class TestContainer(base.BaseZunTest):
resp, body = self.container_client.exec_container(model.uuid,
command='echo hello')
self.assertEqual(200, resp.status)
self.assertTrue('hello' in body)
self.assertTrue('hello' in encodeutils.safe_decode(body))
@decorators.idempotent_id('a912ca23-14e7-442f-ab15-e05aaa315204')
def test_logs_container(self):
@ -316,7 +317,7 @@ class TestContainer(base.BaseZunTest):
command="/bin/sh -c 'echo hello;sleep 1000000'")
resp, body = self.container_client.logs_container(model.uuid)
self.assertEqual(200, resp.status)
self.assertTrue('hello' in body)
self.assertTrue('hello' in encodeutils.safe_decode(body))
@decorators.idempotent_id('d383f359-3ebd-40ef-9dc5-d36922790230')
def test_update_container(self):
@ -351,20 +352,20 @@ class TestContainer(base.BaseZunTest):
command="/bin/sh -c 'sleep 1000000'")
resp, body = self.container_client.top_container(model.uuid)
self.assertEqual(200, resp.status)
self.assertTrue('sleep 1000000' in body)
self.assertTrue('sleep 1000000' in encodeutils.safe_decode(body))
@decorators.idempotent_id('09638306-b501-4803-aafa-7e8025632cef')
def test_stats_container(self):
_, model = self._run_container()
resp, body = self.container_client.stats_container(model.uuid)
self.assertEqual(200, resp.status)
self.assertTrue('NET I/O(B)' in body)
self.assertTrue('CONTAINER' in body)
self.assertTrue('MEM LIMIT(MiB)' in body)
self.assertTrue('CPU %' in body)
self.assertTrue('MEM USAGE(MiB)' in body)
self.assertTrue('MEM %' in body)
self.assertTrue('BLOCK I/O(B)' in body)
self.assertTrue('NET I/O(B)' in encodeutils.safe_decode(body))
self.assertTrue('CONTAINER' in encodeutils.safe_decode(body))
self.assertTrue('MEM LIMIT(MiB)' in encodeutils.safe_decode(body))
self.assertTrue('CPU %' in encodeutils.safe_decode(body))
self.assertTrue('MEM USAGE(MiB)' in encodeutils.safe_decode(body))
self.assertTrue('MEM %' in encodeutils.safe_decode(body))
self.assertTrue('BLOCK I/O(B)' in encodeutils.safe_decode(body))
def _assert_resource_constraints(self, container, cpu=None, memory=None):
if cpu is not None: