Skip to content

Commit 7842f47

Browse files
authored
Prebuild support for C (#206)
1 parent 8f3ba09 commit 7842f47

13 files changed

Lines changed: 86 additions & 45 deletions

File tree

environment/aws/topology_setup/test_server_platforms/c_register.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@
4444
)
4545
from environment.aws.common.output import header
4646
from environment.aws.topology_setup.cbl_library_downloader import CBLLibraryDownloader
47-
from environment.aws.topology_setup.test_server import (
48-
TEST_SERVER_DIR,
49-
TestServer,
50-
copy_dataset,
51-
)
47+
from environment.aws.topology_setup.test_server import TEST_SERVER_DIR, TestServer
5248

5349
from .android_bridge import AndroidBridge
5450
from .exe_bridge import ExeBridge
@@ -80,9 +76,6 @@ def __init__(self, version: str):
8076
def cbl_filename(self, version: str) -> str:
8177
pass
8278

83-
def _copy_dataset(self) -> None:
84-
copy_dataset(C_TEST_SERVER_DIR / "assets")
85-
8679

8780
class CTestServer_Desktop(CTestServer):
8881
def _download_cbl(self) -> None:
@@ -115,7 +108,6 @@ def build(self) -> None:
115108
"""
116109
Build the C test server.
117110
"""
118-
self._copy_dataset()
119111
shutil.rmtree(LIB_DIR, ignore_errors=True)
120112
self._download_cbl()
121113
header("Building C test server")
@@ -219,7 +211,6 @@ def _download_cbl(self):
219211

220212
def build(self):
221213
self._download_cbl()
222-
self._copy_dataset()
223214
header("Building")
224215
env = os.environ.copy()
225216
env["LANG"] = "en_US.UTF-8"
@@ -275,12 +266,14 @@ def create_bridge(self) -> PlatformBridge:
275266
Returns:
276267
PlatformBridge: The platform bridge.
277268
"""
278-
path = (
279-
IOS_BUILD_DIR / "Build" / "Products" / "Release-iphoneos" / "TestServer.app"
269+
prefix = (
270+
TEST_SERVER_DIR / "downloaded" / self.platform / self.version
271+
if self._downloaded
272+
else IOS_BUILD_DIR / "Build" / "Products" / "Release-iphoneos"
280273
)
281274

282275
return iOSBridge(
283-
str(path),
276+
str(prefix / "TestServer.app"),
284277
"com.couchbase.CBLTestServer",
285278
)
286279

@@ -370,7 +363,6 @@ def build(self) -> None:
370363
Build the C test server.
371364
"""
372365
self._download_cbl()
373-
self._copy_dataset()
374366
gradle_path = C_TEST_SERVER_DIR / "platforms" / "android" / "gradlew"
375367
if platform.system() == "Windows":
376368
gradle_path = gradle_path.with_suffix(".bat")
@@ -405,7 +397,13 @@ def create_bridge(self) -> PlatformBridge:
405397
PlatformBridge: The platform bridge.
406398
"""
407399
path = (
408-
C_TEST_SERVER_DIR
400+
TEST_SERVER_DIR
401+
/ "downloaded"
402+
/ self.platform
403+
/ self.version
404+
/ "testserver_android.apk"
405+
if self._downloaded
406+
else C_TEST_SERVER_DIR
409407
/ "platforms"
410408
/ "android"
411409
/ "app"
@@ -500,9 +498,12 @@ def create_bridge(self) -> PlatformBridge:
500498
Returns:
501499
PlatformBridge: The platform bridge.
502500
"""
503-
return ExeBridge(
504-
str(BUILD_DIR / "out" / "bin" / "testserver.exe"),
501+
prefix = (
502+
TEST_SERVER_DIR / "downloaded" / self.platform / self.version
503+
if self._downloaded
504+
else BUILD_DIR / "out" / "bin"
505505
)
506+
return ExeBridge(str(prefix / "testserver.exe"))
506507

507508
def compress_package(self) -> str:
508509
"""
@@ -561,9 +562,12 @@ def create_bridge(self) -> PlatformBridge:
561562
Returns:
562563
PlatformBridge: The platform bridge.
563564
"""
564-
return ExeBridge(
565-
str(BUILD_DIR / "out" / "bin" / "testserver"),
565+
prefix = (
566+
TEST_SERVER_DIR / "downloaded" / self.platform / self.version
567+
if self._downloaded
568+
else BUILD_DIR / "out" / "bin"
566569
)
570+
return ExeBridge(str(prefix / "testserver"))
567571

568572
def compress_package(self) -> str:
569573
"""
@@ -622,9 +626,12 @@ def create_bridge(self) -> PlatformBridge:
622626
Returns:
623627
PlatformBridge: The platform bridge.
624628
"""
625-
return ExeBridge(
626-
str(BUILD_DIR / "out" / "bin" / "testserver"),
629+
prefix = (
630+
TEST_SERVER_DIR / "downloaded" / self.platform / self.version
631+
if self._downloaded
632+
else BUILD_DIR / "out" / "bin"
627633
)
634+
return ExeBridge(str(prefix / "testserver"))
628635

629636
def compress_package(self) -> str:
630637
"""

jenkins/pipelines/dev_e2e/c/Jenkinsfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,32 @@ pipeline {
2323
}
2424
}
2525
}
26+
stage('Prebuild Servers') {
27+
steps {
28+
script {
29+
def platforms = [
30+
'c_windows', 'c_ios', 'c_android', 'c_macos', 'c_linux_x86_64'
31+
]
32+
def parallelBuilds = [:]
33+
for(p in platforms) {
34+
// Groovy stupidness. Need to set a local variable here
35+
// to avoid late binding (all jobs use dotnet_macos).
36+
def platform = p
37+
parallelBuilds[platform] = {
38+
build job: 'prebuild-test-server',
39+
parameters: [
40+
string(name: 'TS_PLATFORM', value: platform),
41+
string(name: 'CBL_VERSION', value: params.CBL_VERSION),
42+
string(name: 'CBL_BUILD', value: params.CBL_BUILD)
43+
],
44+
wait: true,
45+
propagate: true
46+
}
47+
}
48+
parallel parallelBuilds
49+
}
50+
}
51+
}
2652
stage('Run Tests') {
2753
parallel {
2854
stage('macOS') {

jenkins/pipelines/dev_e2e/c/run_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ stop_venv
3333
create_venv venv
3434
source venv/bin/activate
3535
trap stop_venv EXIT
36-
pip install -r $AWS_ENVIRONMENT_DIR/requirements.txt
36+
uv pip install -r $AWS_ENVIRONMENT_DIR/requirements.txt
3737
if [ -n "$private_key_path" ]; then
3838
python3 $SCRIPT_DIR/setup_test.py $platform $cbl_version $dataset_version $sgw_version --private_key $private_key_path
3939
else
4040
python3 $SCRIPT_DIR/setup_test.py $platform $cbl_version $dataset_version $sgw_version
4141
fi
4242

4343
pushd $DEV_E2E_TESTS_DIR
44-
pip install -r requirements.txt
44+
uv pip install -r requirements.txt
4545
pytest -v --no-header -W ignore::DeprecationWarning --config config.json
4646
deactivate

jenkins/pipelines/dev_e2e/c/topologies/topology_single_android.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"platform": "c_android",
66
"cbl_version": "{{version}}",
77
"dataset_version": "{{dataset_version}}",
8-
"location": "1BCACS00001MX3"
8+
"location": "1BCACS00001MX3",
9+
"download": true
910
}
1011
],
1112
"include": "../../../../../environment/aws/topology_setup/default_topology.json"

jenkins/pipelines/dev_e2e/c/topologies/topology_single_ios.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"platform": "c_ios",
66
"cbl_version": "{{version}}",
77
"dataset_version": "{{dataset_version}}",
8-
"location": "00008110-000A48A63E10401E"
8+
"location": "00008110-000A48A63E10401E",
9+
"download": true
910
}
1011
],
1112
"include": "../../../../../environment/aws/topology_setup/default_topology.json"

jenkins/pipelines/dev_e2e/c/topologies/topology_single_linux_x86_64.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"platform": "c_linux_x86_64",
66
"cbl_version": "{{version}}",
77
"dataset_version": "{{dataset_version}}",
8-
"location": "localhost"
8+
"location": "localhost",
9+
"download": true
910
}
1011
],
1112
"include": "../../../../../environment/aws/topology_setup/default_topology.json"

jenkins/pipelines/dev_e2e/c/topologies/topology_single_macos.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"platform": "c_macos",
66
"cbl_version": "{{version}}",
77
"dataset_version": "{{dataset_version}}",
8-
"location": "localhost"
8+
"location": "localhost",
9+
"download": true
910
}
1011
],
1112
"include": "../../../../../environment/aws/topology_setup/default_topology.json"

jenkins/pipelines/dev_e2e/c/topologies/topology_single_windows.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"platform": "c_windows",
66
"cbl_version": "{{version}}",
77
"dataset_version": "{{dataset_version}}",
8-
"location": "localhost"
8+
"location": "localhost",
9+
"download": true
910
}
1011
],
1112
"include": "../../../../../environment/aws/topology_setup/default_topology.json"

jenkins/pipelines/shared/config.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ function create_venv() {
77
fi
88

99
REQUIRED_VERSION="${2:-3.10}"
10+
if [[ "$(uname -s)" == "Linux" ]]; then
11+
# Linux doesn't allow systemwide pip installs, and
12+
# doesn't have a uv apt package so I am forced to
13+
# install it like this
14+
if ! command -v uv >/dev/null 2>&1; then
15+
curl -LsSf https://astral.sh/uv/install.sh | sh
16+
source $HOME/.local/bin/env
17+
fi
18+
19+
uv venv --python $REQUIRED_VERSION $1
20+
else
21+
python3 -m pip install uv
22+
python3 -m uv venv --python $REQUIRED_VERSION $1
23+
fi
1024

11-
python3 -m pip install uv
12-
python3 -m uv venv --python $REQUIRED_VERSION $1
1325
source "$1/bin/activate"
1426
python -m ensurepip --upgrade
1527
python -m pip install --upgrade pip

servers/c/CMakeLists.txt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ if(MSVC)
132132
)
133133
endif()
134134

135-
file(COPY assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
136-
137135
install(
138136
TARGETS testserver
139137
RUNTIME DESTINATION bin
@@ -145,12 +143,4 @@ file(GLOB CBLITE_FILES "${CBLITE_PARENT_DIR}/*cblite*")
145143
install(
146144
FILES ${CBLITE_FILES}
147145
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
148-
)
149-
150-
install(
151-
DIRECTORY assets
152-
DESTINATION ${CMAKE_INSTALL_PREFIX}
153-
FILES_MATCHING
154-
PATTERN "*"
155-
PATTERN ".gitkeep" EXCLUDE
156146
)

0 commit comments

Comments
 (0)