From 6ee16cee269a3bf33b5687c76785106b8ae15ea2 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Fri, 27 Apr 2018 22:50:32 +1200 Subject: [PATCH] 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 --- .zuul.yaml | 7 +++--- devstack/plugin.sh | 3 +++ .../services/qinling_client.py | 9 ++++++-- .../tests/api/test_executions.py | 22 +++++++++++++++++++ qinling_tempest_plugin/tests/base.py | 14 ++++++++++++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 4ba688f6..6bfd0e72 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/devstack/plugin.sh b/devstack/plugin.sh index ba90269b..8da7598a 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -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 } diff --git a/qinling_tempest_plugin/services/qinling_client.py b/qinling_tempest_plugin/services/qinling_client.py index 75d581c0..622ecc33 100644 --- a/qinling_tempest_plugin/services/qinling_client.py +++ b/qinling_tempest_plugin/services/qinling_client.py @@ -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 diff --git a/qinling_tempest_plugin/tests/api/test_executions.py b/qinling_tempest_plugin/tests/api/test_executions.py index 85624a59..64de807f 100644 --- a/qinling_tempest_plugin/tests/api/test_executions.py +++ b/qinling_tempest_plugin/tests/api/test_executions.py @@ -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() diff --git a/qinling_tempest_plugin/tests/base.py b/qinling_tempest_plugin/tests/base.py index 0de54f8d..bc323426 100644 --- a/qinling_tempest_plugin/tests/base.py +++ b/qinling_tempest_plugin/tests/base.py @@ -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