Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 11 additions & 8 deletions client/src/cbltest/api/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,9 @@ async def configure_dataset(

current_span.add_event("Handle HTTP 412")
await self.__sync_gateway.delete_database(dataset_name)
if self.sync_gateway.using_rosmar:
raise CblTestError(
f"Database {dataset_name} already exists on Sync Gateway and cannot be deleted when "
"using rosmar until CBG-5213 is implemented. To work around, restart a Sync Gateway to "
"delete the rosmar buckets."
)
else:
self.__couchbase_server.drop_bucket(db_payload.bucket)
await self.drop_bucket(db_payload.bucket)
await self.__sync_gateway.wait_for_no_databases(db_payload.bucket)
if not self.sync_gateway.using_rosmar:
Comment thread
torcolvin marked this conversation as resolved.
self.__couchbase_server.create_bucket(db_payload.bucket)
self._create_collections(db_payload)

Expand All @@ -163,3 +158,11 @@ async def configure_dataset(
)

await self.__sync_gateway.load_dataset(dataset_name, data_filepath)

async def drop_bucket(self, bucket_name: str, *, wait_for_deleted=False):
"""Drop the bucket from the backing cluster. This is an asynchronous operation unless wait_for_deleted is set to True."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it? I don't see anywhere that it is consulted....

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of a subsequent PR, and the code was buggy so I removed it.

if self.sync_gateway.using_rosmar:
await self.sync_gateway._send_request("delete", f"/_rosmar/{bucket_name}")
else:
self.couchbase_server.drop_bucket(bucket_name)
await self.couchbase_server.wait_for_bucket_deleted(bucket_name)
21 changes: 19 additions & 2 deletions client/src/cbltest/api/syncgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from urllib.parse import urljoin

import requests
import tenacity
from aiohttp import BasicAuth, ClientError, ClientSession, ClientTimeout, TCPConnector
from aiohttp.client_exceptions import ClientConnectorError
from opentelemetry.trace import get_tracer
Expand All @@ -17,7 +18,7 @@
from cbltest.assertions import _assert_not_null
from cbltest.httplog import get_next_writer
from cbltest.jsonhelper import _get_typed_required
from cbltest.logging import cbl_error, cbl_info, cbl_warning
from cbltest.logging import cbl_error, cbl_info, cbl_trace, cbl_warning
from cbltest.utils import assert_not_null
from cbltest.version import VERSION

Expand Down Expand Up @@ -659,7 +660,7 @@ async def get_version(self) -> CouchbaseVersion:

def tls_cert(self) -> str | None:
if not self.secure:
cbl_warning(
cbl_trace(
"Sync Gateway instance not using TLS, returning empty tls_cert..."
)
return None
Expand Down Expand Up @@ -1874,6 +1875,22 @@ async def start(self, config_name: str = "bootstrap") -> None:
# Wait a bit for SGW to fully initialize
await asyncio.sleep(5)

@tenacity.retry(
wait=tenacity.wait_fixed(0.1),
# Sync Gateway polling time is 10s, so wait 60s for polling time + any additional work
Comment thread
torcolvin marked this conversation as resolved.
Outdated
stop=tenacity.stop_after_delay(60),
reraise=True,
retry=tenacity.retry_if_exception_type(AssertionError),
)
async def wait_for_no_databases(self, bucket_name: str):
with self._tracer.start_as_current_span("get_all_dbs"):
resp = await self._send_request("get", "/_all_dbs?verbose=true")
assert isinstance(resp, list), resp
for db in resp:
assert db["bucket"] != bucket_name, (
f"Database {db=} is still backed by bucket {bucket_name}"
)
Comment thread
torcolvin marked this conversation as resolved.

async def wait_for_db_gone_clusterwide(
self,
sync_gateways: list["SyncGateway"],
Expand Down
1 change: 1 addition & 0 deletions environment/local/run_sync_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def main(start, stop, server):
if stop:
bridge.stop("localhost")
else:
bridge.stop("localhost")
Comment thread
torcolvin marked this conversation as resolved.
Outdated
bridge.run("localhost")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"log_level": "debug",
"log_keys": ["*"]
}
},
"unsupported": {
"rosmar_bucket_management": true
}
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies = [
"paramiko==3.5.0",
"psutil==7.0.0",
"pyyaml==6.0.2",
"tenacity==9.1.4",
"tqdm==4.67.1",
]

Expand Down
11 changes: 11 additions & 0 deletions uv.lock

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

Loading