Browse Source

Functional test for creating execution with function version

Other changes in order to make this patch pass CI jobs:
- Incease default runtime replicas to 5
- Decrease tempest concurrency number to 2

Change-Id: If2186013c3c49f1d99ab0ca9b623a339f01680f6
Story: 2001829
Task: 14456
changes/30/564730/3
Lingxian Kong 3 years ago
parent
commit
6ee16cee26
5 changed files with 50 additions and 5 deletions
  1. +4
    -3
      .zuul.yaml
  2. +3
    -0
      devstack/plugin.sh
  3. +7
    -2
      qinling_tempest_plugin/services/qinling_client.py
  4. +22
    -0
      qinling_tempest_plugin/tests/api/test_executions.py
  5. +14
    -0
      qinling_tempest_plugin/tests/base.py

+ 4
- 3
.zuul.yaml View File

@ -54,9 +54,10 @@
TEMPEST_PLUGINS: '/opt/stack/qinling'
tox_envlist: all-plugin
tempest_test_regex: '^(qinling_tempest_plugin.)'
# Set tempest concurrency to qinling's default number of replicas in a
# deployment to avoid tests failing of no avaliable pod.
tempest_concurrency: 3
# Qinling's default replicas number is 3, some test cases need
# 2 workers, set concurrency to 2 to avoid
# "Not enough workers available" error.
tempest_concurrency: 2
- job:
name: qinling-tempest-centos7


+ 3
- 0
devstack/plugin.sh View File

@ -1,3 +1,4 @@
#!/usr/bin/env bash
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set -o xtrace
@ -119,6 +120,8 @@ function configure_qinling {
else
iniset $QINLING_CONF_FILE kubernetes use_api_certificate False
fi
iniset $QINLING_CONF_FILE kubernetes replicas 5
}


+ 7
- 2
qinling_tempest_plugin/services/qinling_client.py View File

@ -115,8 +115,13 @@ class QinlingClient(client_base.QinlingClientBase):
None,
headers={})
def create_execution(self, function_id, input=None, sync=True):
req_body = {'function_id': function_id, 'sync': sync, 'input': input}
def create_execution(self, function_id, input=None, sync=True, version=0):
req_body = {
'function_id': function_id,
'function_version': version,
'sync': sync,
'input': input
}
resp, body = self.post_json('executions', req_body)
return resp, body


+ 22
- 0
qinling_tempest_plugin/tests/api/test_executions.py View File

@ -95,6 +95,28 @@ class ExecutionsTest(base.BaseQinlingTest):
context.resp_body.get('faultstring')
)
@decorators.idempotent_id('794cdfb2-0a27-4e56-86e8-be18eee9400f')
def test_create_with_function_version(self):
function_id = self.create_function()
execution_id = self.create_execution(function_id)
resp, body = self.client.get_execution_log(execution_id)
self.assertEqual(200, resp.status)
self.assertIn('Hello, World', body)
version_1 = self.create_function_version(function_id)
execution_id = self.create_execution(function_id, version=version_1)
resp, body = self.client.get_execution_log(execution_id)
self.assertEqual(200, resp.status)
self.assertIn('Hello, World', body)
self.update_function_package(function_id,
"python/test_python_sleep.py")
version_2 = self.create_function_version(function_id)
execution_id = self.create_execution(function_id, version=version_2)
resp, body = self.client.get_execution_log(execution_id)
self.assertEqual(200, resp.status)
self.assertNotIn('Hello, World', body)
@decorators.idempotent_id('8096cc52-64d2-4660-a657-9ac0bdd743ae')
def test_execution_async(self):
function_id = self.create_function()


+ 14
- 0
qinling_tempest_plugin/tests/base.py View File

@ -192,3 +192,17 @@ class BaseQinlingTest(test.BaseTestCase):
version, ignore_notfound=True)
return version
def create_execution(self, function_id, version=0, input=None):
resp, body = self.client.create_execution(function_id, version=version,
input=input)
self.assertEqual(201, resp.status)
execution_id = body['id']
self.addCleanup(self.client.delete_resource, 'executions',
execution_id, ignore_notfound=True)
self.assertEqual('success', body['status'])
return execution_id

Loading…
Cancel
Save