diff options
author | Inam Soomro <inam@att.com> | 2018-10-01 16:51:20 -0400 |
---|---|---|
committer | Soomro, Inam(is076r) <inam@att.com> | 2018-10-02 15:48:17 -0400 |
commit | 83ce3c1d86d650f467b77b679a02fab30bc12bea (patch) | |
tree | 16606fabc63a382b5c9fbb664a4cdcf5b3d03ec0 /conductor | |
parent | 30d9e916b1591ca4af8bbf56433b65858010f7d8 (diff) |
Unit test case fixed for index_create.
Fixed for the table create index on plans table.
Fixed comments section for index create from creates table.
Issue-ID: OPTFRA-359
Change-Id: I8cd85e18c3b9dce04c2f3f571976544c16a00972
Signed-off-by: Soomro, Inam(is076r) <inam@att.com>
Diffstat (limited to 'conductor')
-rw-r--r-- | conductor/conductor/common/models/plan.py | 8 | ||||
-rw-r--r-- | conductor/conductor/common/music/api.py | 21 | ||||
-rw-r--r-- | conductor/conductor/common/music/model/base.py | 13 |
3 files changed, 42 insertions, 0 deletions
diff --git a/conductor/conductor/common/models/plan.py b/conductor/conductor/common/models/plan.py index 1c293c0..de5af5b 100644 --- a/conductor/conductor/common/models/plan.py +++ b/conductor/conductor/common/models/plan.py @@ -115,6 +115,14 @@ class Plan(base.Base): return schema @classmethod + def indexes(cls): + """Return indexes """ + indexes = [ + 'status' + ] + return indexes + + @classmethod def atomic(cls): """Use atomic operations""" return False diff --git a/conductor/conductor/common/music/api.py b/conductor/conductor/common/music/api.py index c212a29..dc351c6 100644 --- a/conductor/conductor/common/music/api.py +++ b/conductor/conductor/common/music/api.py @@ -473,6 +473,17 @@ class MusicAPI(object): response = self.rest.request(method='post', path=path, data=data) return response + def index_create(self, keyspace, table, index): + + """Create indexes for a particular table""" + + path = '/keyspaces/%(keyspace)s/tables/%(table)s/index/%(field)s' % { + 'keyspace': keyspace, + 'table': table, + 'field': index + } + response = self.rest.request(method='post', path=path) + return response def row_complex_field_update(self, keyspace, table, pk_name, pk_value, plan_id, updated_fields, values): @@ -580,6 +591,9 @@ class MockAPI(object): def _set_table(self, keyspace, table): self._keyspaces[keyspace][table] = {} + def _set_index(self, keyspace, table): + self._keyspaces[keyspace][table] = {} + def _unset_table(self, keyspace, table): self._keyspaces[keyspace].pop(table) @@ -653,6 +667,13 @@ class MockAPI(object): self._set_table(keyspace, table) return True + def index_create(self, keyspace, table, index=None): + """Creates a index.""" + if CONF.music_api.debug: + LOG.debug("Creating index {}, keyspace {}".format(table, keyspace)) + self._set_index(keyspace, table) + return True + def table_delete(self, keyspace, table): """Creates a table.""" if CONF.music_api.debug: diff --git a/conductor/conductor/common/music/model/base.py b/conductor/conductor/common/music/model/base.py index 0b6f638..9e8205f 100644 --- a/conductor/conductor/common/music/model/base.py +++ b/conductor/conductor/common/music/model/base.py @@ -69,6 +69,13 @@ class Base(object): kwargs['schema'] = cls.schema() api.MUSIC_API.table_create(**kwargs) + # Create indexes for the table + del kwargs['schema'] + if cls.indexes(): + for index in cls.indexes(): + kwargs['index'] = index + api.MUSIC_API.index_create(**kwargs) + @abstractclassmethod def atomic(cls): """Use atomic operations""" @@ -79,6 +86,12 @@ class Base(object): """Return schema""" return cls() + @classmethod + def indexes(cls): + """Return Indexes""" + pass + # return cls() + @abstractclassmethod def pk_name(cls): """Primary key name""" |