|
|
|
@ -12,9 +12,11 @@
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
import os
|
|
|
|
|
import pkg_resources
|
|
|
|
|
import tempfile
|
|
|
|
|
import zipfile
|
|
|
|
|
|
|
|
|
|
from oslo_serialization import jsonutils
|
|
|
|
|
from tempest.lib.common.utils import data_utils
|
|
|
|
|
from tempest.lib import decorators
|
|
|
|
|
|
|
|
|
@ -48,19 +50,10 @@ class ExecutionsTest(base.BaseQinlingTest):
|
|
|
|
|
|
|
|
|
|
super(ExecutionsTest, cls).resource_cleanup()
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
super(ExecutionsTest, self).setUp()
|
|
|
|
|
|
|
|
|
|
# Wait until runtime is available
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
|
|
|
|
|
python_file_path = os.path.abspath(
|
|
|
|
|
os.path.join(
|
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
|
os.pardir,
|
|
|
|
|
os.pardir,
|
|
|
|
|
'functions/python_test.py'
|
|
|
|
|
)
|
|
|
|
|
def _create_function(self, name='python_test.py'):
|
|
|
|
|
python_file_path = pkg_resources.resource_filename(
|
|
|
|
|
'qinling_tempest_plugin',
|
|
|
|
|
"functions/%s" % name
|
|
|
|
|
)
|
|
|
|
|
base_name, extention = os.path.splitext(python_file_path)
|
|
|
|
|
self.base_name = os.path.basename(base_name)
|
|
|
|
@ -96,9 +89,13 @@ class ExecutionsTest(base.BaseQinlingTest):
|
|
|
|
|
|
|
|
|
|
self.addCleanup(self.client.delete_resource, 'functions',
|
|
|
|
|
self.function_id, ignore_notfound=True)
|
|
|
|
|
self.addCleanup(os.remove, self.python_zip_file)
|
|
|
|
|
|
|
|
|
|
@decorators.idempotent_id('2a93fab0-2dae-4748-b0d4-f06b735ff451')
|
|
|
|
|
def test_crud_execution(self):
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
self._create_function()
|
|
|
|
|
|
|
|
|
|
resp, body = self.client.create_execution(self.function_id,
|
|
|
|
|
input={'name': 'Qinling'})
|
|
|
|
|
|
|
|
|
@ -125,6 +122,9 @@ class ExecutionsTest(base.BaseQinlingTest):
|
|
|
|
|
|
|
|
|
|
@decorators.idempotent_id('8096cc52-64d2-4660-a657-9ac0bdd743ae')
|
|
|
|
|
def test_execution_async(self):
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
self._create_function()
|
|
|
|
|
|
|
|
|
|
resp, body = self.client.create_execution(self.function_id, sync=False)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(201, resp.status)
|
|
|
|
@ -138,6 +138,9 @@ class ExecutionsTest(base.BaseQinlingTest):
|
|
|
|
|
|
|
|
|
|
@decorators.idempotent_id('6cb47b1d-a8c6-48f2-a92f-c4f613c33d1c')
|
|
|
|
|
def test_execution_log(self):
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
self._create_function()
|
|
|
|
|
|
|
|
|
|
resp, body = self.client.create_execution(self.function_id,
|
|
|
|
|
input={'name': 'OpenStack'})
|
|
|
|
|
|
|
|
|
@ -153,3 +156,31 @@ class ExecutionsTest(base.BaseQinlingTest):
|
|
|
|
|
|
|
|
|
|
self.assertEqual(200, resp.status)
|
|
|
|
|
self.assertIn('Hello, OpenStack', body)
|
|
|
|
|
|
|
|
|
|
def test_python_execution_file_limit(self):
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
self._create_function(name='test_python_file_limit.py')
|
|
|
|
|
|
|
|
|
|
resp, body = self.client.create_execution(self.function_id)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(201, resp.status)
|
|
|
|
|
self.assertEqual('failed', body['status'])
|
|
|
|
|
|
|
|
|
|
output = jsonutils.loads(body['output'])
|
|
|
|
|
self.assertIn(
|
|
|
|
|
'Too many open files', output['output']
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_python_execution_process_number(self):
|
|
|
|
|
self.await_runtime_available(self.runtime_id)
|
|
|
|
|
self._create_function(name='test_python_process_limit.py')
|
|
|
|
|
|
|
|
|
|
resp, body = self.client.create_execution(self.function_id)
|
|
|
|
|
|
|
|
|
|
self.assertEqual(201, resp.status)
|
|
|
|
|
self.assertEqual('failed', body['status'])
|
|
|
|
|
|
|
|
|
|
output = jsonutils.loads(body['output'])
|
|
|
|
|
self.assertIn(
|
|
|
|
|
'too much resource consumption', output['output']
|
|
|
|
|
)
|
|
|
|
|