Skip to content

Commit 9426a60

Browse files
torcolvinborrrden
andauthored
Support building linux c test server locally (#379)
Co-authored-by: Jim Borden <jim.borden@couchbase.com>
1 parent bcc9df2 commit 9426a60

5 files changed

Lines changed: 45 additions & 8 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ http_log
2020
servers/downloaded
2121
.version
2222

23+
servers/*/CMakeFiles
24+
servers/*/_deps
25+
servers/*/download
26+
2327
# Temp files
24-
.tmp
28+
.tmp

environment/aws/download_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def download_cbbackupmgr(version: str):
119119
location.unlink(missing_ok=True)
120120

121121
dest_dir.mkdir(parents=True, exist_ok=True)
122-
url = f"https://latestbuilds.service.couchbase.com/builds/releases/{version}/couchbase-server-admin-tools-{version}-{os}_{arch}.{ext}"
122+
url = f"https://packages.couchbase.com/releases/{version}/couchbase-server-dev-tools-{version}-{os}_{arch}.{ext}"
123123
download = requests.get(url, stream=True)
124124
download.raise_for_status()
125125
tmp_file = TMP_LOCATION / f"download.{ext}"

environment/aws/topology_setup/cbl_library_downloader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def download(self, location: Path) -> None:
1818
Download the CBL library from the latest builds server.
1919
"""
2020
if self.__build == 0:
21-
download_url = f"https://releases.service.couchbase.com/builds/releases/mobile/{self.__project}/{self.__version}/{self.__file}"
21+
download_url = f"https://packages.couchbase.com/releases/{self.__project}/{self.__version}/{self.__file}"
2222
else:
2323
download_url = f"https://latestbuilds.service.couchbase.com/builds/latestbuilds/{self.__project}/{self.__version}/{self.__build}/{self.__file}"
2424

environment/aws/topology_setup/test_server.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def __init__(self, version: str) -> None:
114114

115115
def __normalize_version(self, version: str) -> str:
116116
if "-" in version:
117+
if version.split("-")[1] == "0":
118+
return version.split("-")[0]
119+
117120
return version
118121

119122
click.secho(
@@ -123,14 +126,29 @@ def __normalize_version(self, version: str) -> str:
123126

124127
if version in self.__build_no_cache[self.product]:
125128
build_no = self.__build_no_cache[self.product][version]
129+
if build_no == "0":
130+
click.secho(
131+
f"Version {version} is a release version [CACHED]", fg="blue"
132+
)
133+
return version
134+
126135
click.secho(f"Found latest good build: {build_no} [CACHED]", fg="blue")
127136
return f"{version}-{build_no}"
128137

129138
resp = requests.get(
130139
f"http://proget.build.couchbase.com:8080/api/get_version?product={self.product}&version={version}"
131140
)
132141
resp.raise_for_status()
133-
build_no = resp.json()["BuildNumber"]
142+
resp_body = resp.json()
143+
if resp_body["IsRelease"] is True:
144+
click.secho(
145+
f"Version {version} is a release version, no build number needed",
146+
fg="green",
147+
)
148+
self.__build_no_cache[self.product][version] = "0"
149+
return version
150+
151+
build_no = resp_body["BuildNumber"]
134152
click.secho(f"Found latest good build: {build_no}", fg="green")
135153
self.__build_no_cache[self.product][version] = build_no
136154
return f"{version}-{build_no}"
@@ -191,7 +209,9 @@ def create(cls, name: str, version: str) -> TestServer:
191209
cls.initialize()
192210

193211
if name not in cls.__registry:
194-
raise ValueError(f"Unknown test server type: {name}")
212+
raise ValueError(
213+
f"Unknown test server type: {name}. Valid names {cls.__registry.keys()}"
214+
)
195215

196216
return cls.__registry[name](version)
197217

environment/local/start_local.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import pathlib
2323
import sys
2424

25+
import click
2526
import requests
2627

2728
SCRIPT_DIR = pathlib.Path(__file__).parent
@@ -34,14 +35,26 @@
3435
TOPOLOGY_CONFIG = SCRIPT_DIR / "topology.json"
3536

3637

37-
def main():
38+
@click.command()
39+
@click.option(
40+
"--build-testserver",
41+
help="Build the test server from source rather than downloading it. Takes a version string (e.g., 4.0.3).",
42+
)
43+
def main(build_testserver: str | None):
44+
if build_testserver:
45+
cbl_version = f"{build_testserver}-0"
46+
download = False
47+
else:
48+
cbl_version = get_latest_released_cbl_c_version()
49+
download = True
50+
3851
config = {
3952
"test_servers": [
4053
{
4154
"location": "localhost",
42-
"download": True,
55+
"download": download,
4356
"platform": get_cbl_platform(),
44-
"cbl_version": get_latest_released_cbl_c_version(),
57+
"cbl_version": cbl_version,
4558
}
4659
],
4760
}

0 commit comments

Comments
 (0)