Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
* Added server errors handling
* Added workload description and external link to docs
* 0.3.2: Backend dependencies are bumped
* 0.3.3: Removed limit of returned DB objects in DB List API
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cloudblueconnect/connect-extension-runner:27.19
FROM cloudblueconnect/connect-extension-runner:27.21

COPY pyproject.toml /install_temp/.
COPY poetry.* /install_temp/.
Expand Down
6 changes: 3 additions & 3 deletions dbaas/extension.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "DBaaS",
"description": "On-demand provisioning of cloud-based database storages as a service.",
"version": "0.3.2",
"version": "0.3.3",
"audience": ["reseller", "distributor", "vendor"],
"readme_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.2/README.md",
"changelog_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.2/CHANGELOG.md",
"readme_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.3/README.md",
"changelog_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.3/CHANGELOG.md",
"icon": "googleExtensionBaseline"
}
12 changes: 9 additions & 3 deletions dbaas/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
class DB:
COLLECTION = Collections.DB
MAX_ID_GENERATION_RETRIES = 3
LIST_STEP_LENGTH = 20

@classmethod
async def list(cls, db: AsyncIOMotorDatabase, context: Context) -> list[dict]:
Expand All @@ -43,9 +44,14 @@ async def list(cls, db: AsyncIOMotorDatabase, context: Context) -> list[dict]:
).sort('events.created.at', pymongo.DESCENDING)

results = []
for db_document in await cursor.to_list(length=20):
doc = cls._db_document_repr(db_document)
results.append(doc)

docs = await cursor.to_list(length=cls.LIST_STEP_LENGTH)
while docs:
for db_document in docs:
doc = cls._db_document_repr(db_document)
results.append(doc)

docs = await cursor.to_list(length=cls.LIST_STEP_LENGTH)

return results

Expand Down
30 changes: 15 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/services/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ async def test_list_several_account_dbs(db, admin_context):
assert [r['id'] for r in results] == [db['id'] for db in (db3, db2, other_account_db, db1)]


@pytest.mark.asyncio
async def test_list_number_of_dbs_gt_than_cursor_length(db):
account_id = 'PA-456'

dbs = DBFactory.create_batch(size=25, account_id=account_id)
await db[Collections.DB].insert_many(dbs)

results = await DB.list(db, Context(account_id=account_id))
assert len(results) == 25
assert len({r['id'] for r in results}) == 25


@pytest.mark.asyncio
async def test_retrieve_is_empty(db):
result = await DB.retrieve('any', db, Context(account_id='VA-123-456'))
Expand Down