Fixed a bug regarding workbooks namespace in postgresql

dropped (name, project_id) unique_constraint from the workbooks_v2
table.

Change-Id: I61acaed1658d291798e10229e81136259fcdb627
Closes-Bug: 1858394
Signed-off-by: ali <ali.abdelal@nokia.com>
This commit is contained in:
ali 2020-01-06 08:18:52 +00:00 committed by ali abdelal
parent 6e9a70db25
commit 8991a20e19
2 changed files with 60 additions and 4 deletions

View File

@ -0,0 +1,44 @@
# Copyright 2020 Nokia Software.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""namespace support for workbooks table postgresql
Revision ID: 036
Revises: 035
Create Date: 2020-1-6 9:49:20
"""
# revision identifiers, used by Alembic.
from alembic import op
from sqlalchemy.engine import reflection
revision = '036'
down_revision = '035'
def upgrade():
inspect = reflection.Inspector.from_engine(op.get_bind())
unique_constraints = [
unique_constraint['name'] for unique_constraint in
inspect.get_unique_constraints('workbooks_v2')
]
if 'workbooks_v2_name_project_id_key' in unique_constraints:
op.drop_constraint('workbooks_v2_name_project_id_key',
table_name='workbooks_v2')

View File

@ -19,12 +19,10 @@ from mistral.lang import parser as spec_parser
from mistral.services import workbooks as wb_service
from mistral.tests.unit import base
# Use the set_default method to set value otherwise in certain test cases
# the change in value is not permanent.
cfg.CONF.set_default('auth_enable', False, group='pecan')
WORKBOOK = """
---
version: '2.0'
@ -94,7 +92,6 @@ WORKBOOK_WF2_DEFINITION = """wf2:
result: "The result of subworkflow is '{$.final_result}'"
"""
UPDATED_WORKBOOK = """
---
version: '2.0'
@ -160,7 +157,6 @@ UPDATED_WORKBOOK_WF2_DEFINITION = """wf2:
result: "{$}"
"""
ACTION_DEFINITION = """concat:
base: std.echo
base-input:
@ -220,6 +216,22 @@ class WorkbookServiceTest(base.DbTestCase):
self.assertEqual(namespace, wf2_db.namespace)
self.assertEqual(WORKBOOK_WF2_DEFINITION, wf2_db.definition)
def test_create_same_workbook_in_different_namespaces(self):
first_namespace = 'first_namespace'
second_namespace = 'second_namespace'
first_wb = wb_service.create_workbook_v2(WORKBOOK,
namespace=first_namespace)
self.assertIsNotNone(first_wb)
self.assertEqual('my_wb', first_wb.name)
self.assertEqual(first_namespace, first_wb.namespace)
second_wb = wb_service.create_workbook_v2(WORKBOOK,
namespace=second_namespace)
self.assertIsNotNone(second_wb)
self.assertEqual('my_wb', second_wb.name)
self.assertEqual(second_namespace, second_wb.namespace)
def test_create_workbook_with_default_namespace(self):
wb_db = wb_service.create_workbook_v2(WORKBOOK)