Length limitation on cluster name removed

For removing limitation on cluster name length we use DB TEXT field

Change-Id: I5b1ff0644097452da3efaf476f4d73288feeaf64
Closes-Bug: #1467988
This commit is contained in:
Alexander Kislitsky 2015-07-01 19:24:27 +03:00
parent 087f14e450
commit b5aed0bdbc
4 changed files with 28 additions and 2 deletions

View File

@ -77,6 +77,7 @@ def upgrade():
op.create_unique_constraint(
'oswl_stats_cluster_id_created_date_resource_type_unique_key',
'oswl_stats', ['cluster_id', 'created_date', 'resource_type'])
op.alter_column('clusters', 'name', type_=sa.TEXT())
extend_ip_addrs_model_upgrade()
extend_node_model_upgrade()
@ -103,6 +104,8 @@ def downgrade():
downgrade_task_names()
vms_conf_downgrade()
op.execute('UPDATE clusters SET name=LEFT(name, 50)')
op.alter_column('clusters', 'name', type_=sa.VARCHAR(50))
op.drop_constraint(
'oswl_stats_cluster_id_created_date_resource_type_unique_key',
'oswl_stats', type_='unique')

View File

@ -20,7 +20,7 @@ from sqlalchemy import Enum
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import Text
from sqlalchemy import Unicode
from sqlalchemy import UnicodeText
from sqlalchemy.orm import backref
from sqlalchemy.orm import relationship
@ -71,7 +71,7 @@ class Cluster(Base):
nullable=False,
server_default='{"view_mode": "standard", "grouping": "roles"}'
)
name = Column(Unicode(50), unique=True, nullable=False)
name = Column(UnicodeText, unique=True, nullable=False)
release_id = Column(Integer, ForeignKey('releases.id'), nullable=False)
pending_release_id = Column(Integer, ForeignKey('releases.id'))
nodes = relationship(

View File

@ -202,3 +202,16 @@ class TestHandlers(BaseIntegrationTest):
)
self.assertEqual(get_resp.status_code, 200)
self.datadiff(get_resp.json_body, cluster.attributes.generated)
def test_cluster_name_length(self):
long_name = u'ю' * 2048
cluster = self.env.create_cluster(api=False)
resp = self.app.put(
reverse('ClusterHandler', kwargs={'obj_id': cluster.id}),
jsonutils.dumps({'name': long_name}),
headers=self.default_headers
)
self.assertEqual(resp.status_code, 200)
self.db.refresh(cluster)
self.assertEqual(long_name, cluster.name)

View File

@ -53,6 +53,16 @@ class TestDbModels(BaseTestCase):
Release(version=version).environment_version,
enviroment_version)
def test_cluster_name_length(self):
cluster_data = {
'name': u'ю' * 2048,
'fuel_version': '',
'release_id': self.env.create_release(api=False).id
}
cluster = Cluster(**cluster_data)
self.db.add(cluster)
self.db.commit()
class TestNodeInterfacesDbModels(BaseTestCase):
sample_nic_interface_data = {