|
5 | 5 |
|
6 | 6 |
|
7 | 7 | class BuildPlugin(Command): |
8 | | - # package_type: "RPM" or "DEB" -- the -D flag run.cmake expects. |
9 | | - def __init__(self, package_type: str, workdir: PurePath = PurePath(".")): |
| 8 | + # Pass package_type ("RPM" or "DEB") for the -D flag run.cmake expects, |
| 9 | + # or cmake_prefix_path (exclusive of package_type) to instead link |
| 10 | + # against an unpacked MariaDB server bintar via -DCMAKE_PREFIX_PATH -- |
| 11 | + # omitting -DRPM/-DDEB entirely is what makes run.cmake produce a plain |
| 12 | + # bintar tarball for the plugin instead of a package. |
| 13 | + def __init__( |
| 14 | + self, |
| 15 | + package_type: str = None, |
| 16 | + cmake_prefix_path: str = None, |
| 17 | + workdir: PurePath = PurePath("."), |
| 18 | + ): |
| 19 | + assert (package_type is None) != (cmake_prefix_path is None), ( |
| 20 | + "BuildPlugin takes exactly one of package_type or cmake_prefix_path" |
| 21 | + ) |
10 | 22 | self.package_type = package_type |
11 | | - super().__init__(name=f"Build plugin ({package_type})", workdir=workdir) |
| 23 | + self.cmake_prefix_path = cmake_prefix_path |
| 24 | + super().__init__( |
| 25 | + name=f"Build plugin ({package_type or 'bintar'})", workdir=workdir |
| 26 | + ) |
12 | 27 |
|
13 | 28 | def as_cmd_arg(self) -> list[str]: |
| 29 | + cmake_define = ( |
| 30 | + f"-DCMAKE_PREFIX_PATH={self.cmake_prefix_path} " |
| 31 | + if self.cmake_prefix_path |
| 32 | + else f"-D{self.package_type}=1 " |
| 33 | + ) |
14 | 34 | return [ |
15 | 35 | "bash", |
16 | 36 | "-exc", |
17 | | - util.Interpolate(f"cmake -D{self.package_type}=1 -P run.cmake %(prop:plugin)s"), |
| 37 | + util.Interpolate(f"cmake {cmake_define}-P run.cmake %(prop:plugin)s"), |
18 | 38 | ] |
19 | 39 |
|
20 | 40 |
|
@@ -53,6 +73,87 @@ def as_cmd_arg(self) -> list[str]: |
53 | 73 | return ["bash", "-exc", f"set -euo pipefail\n{script}"] |
54 | 74 |
|
55 | 75 |
|
| 76 | +class DownloadServerBintar(Command): |
| 77 | + # Foundry bintar plugin builds link against a matching MariaDB server |
| 78 | + # bintar instead of installed -devel packages. ci_builder is the |
| 79 | + # production buildbot builder on ci.mariadb.org that publishes it for |
| 80 | + # this OS (e.g. "amd64-centos-7-bintar") -- the exact tarball filename |
| 81 | + # varies by version/build, so it's discovered from the directory |
| 82 | + # listing rather than assumed. Emits the extracted directory's absolute |
| 83 | + # path on stdout, for capture into a property (e.g. via |
| 84 | + # PropFromShellStep) and use as BuildPlugin's cmake_prefix_path. |
| 85 | + def __init__(self, ci_builder: str, workdir: PurePath = PurePath(".")): |
| 86 | + self.ci_builder = ci_builder |
| 87 | + super().__init__(name="Download server bintar", workdir=workdir) |
| 88 | + |
| 89 | + def as_cmd_arg(self) -> list[str]: |
| 90 | + return [ |
| 91 | + "bash", |
| 92 | + "-exc", |
| 93 | + util.Interpolate( |
| 94 | + f""" |
| 95 | +set -euo pipefail |
| 96 | +
|
| 97 | +base_url="https://ci.mariadb.org/%(prop:tarbuildnum)s/{self.ci_builder}" |
| 98 | +filename=$(curl -fsSL "$base_url/" | grep -oE 'href="mariadb-[^"]*-linux[^"]*\\.tar\\.gz"' | head -1 | sed -E 's/^href="(.*)"$/\\1/') |
| 99 | +if [ -z "$filename" ]; then |
| 100 | + echo "Could not find a server bintar under $base_url" >&2 |
| 101 | + exit 1 |
| 102 | +fi |
| 103 | +
|
| 104 | +mkdir -p /home/buildbot/bintar |
| 105 | +curl -fsSL "$base_url/$filename" -o "/home/buildbot/bintar/$filename" |
| 106 | +tar -xzf "/home/buildbot/bintar/$filename" -C /home/buildbot/bintar |
| 107 | +
|
| 108 | +dirname=$(tar -tzf "/home/buildbot/bintar/$filename" | head -1 | cut -d/ -f1) |
| 109 | +echo "/home/buildbot/bintar/$dirname" |
| 110 | +""" |
| 111 | + ), |
| 112 | + ] |
| 113 | + |
| 114 | + |
| 115 | +class ExtractPluginBintarIntoServerBintar(Command): |
| 116 | + # The plugin's own MTR suite is only visible to MTR once its bintar is |
| 117 | + # unpacked directly into the server bintar tree it was built against -- |
| 118 | + # --strip-components=1 drops the plugin tarball's own top-level |
| 119 | + # directory so its plugin/<name>/ contents land alongside the server |
| 120 | + # bintar's own plugin/, mysql-test/, etc. |
| 121 | + # |
| 122 | + # The server bintar ships its own bundled plugin suites (rocksdb, |
| 123 | + # columnstore, ...) under that same plugin/*/*/suite.pm layout, so once |
| 124 | + # extraction is done there's no way to tell "ours" apart from those by |
| 125 | + # just re-scanning the merged tree. Emit the suite name(s) contributed |
| 126 | + # by *this* plugin's tarball -- read off its own listing, before it gets |
| 127 | + # merged in -- on stdout, for capture into a property (e.g. via |
| 128 | + # PropFromShellStep) and use as RunPluginMTRSuiteFromBintar's suites arg. |
| 129 | + def __init__(self, server_bintar_dir: str, workdir: PurePath = PurePath(".")): |
| 130 | + self.server_bintar_dir = server_bintar_dir |
| 131 | + super().__init__( |
| 132 | + name="Extract plugin bintar into server bintar", workdir=workdir |
| 133 | + ) |
| 134 | + |
| 135 | + def as_cmd_arg(self) -> list[str]: |
| 136 | + return [ |
| 137 | + "bash", |
| 138 | + "-exc", |
| 139 | + util.Interpolate( |
| 140 | + f""" |
| 141 | +set -euo pipefail |
| 142 | +
|
| 143 | +suites="" |
| 144 | +for f in ./mariadb-plugin-*.tar.gz; do |
| 145 | + tar -xf "$f" -C "{self.server_bintar_dir}" --strip-components=1 |
| 146 | + for name in $(tar -tzf "$f" | grep -oE '^[^/]+/plugin/[^/]+/[^/]+/suite\\.pm$' | awk -F/ '{{print $4}}' || true); do |
| 147 | + suites="$suites,$name" |
| 148 | + done |
| 149 | +done |
| 150 | +suites=$(echo "$suites" | sed 's/^,//') |
| 151 | +echo "$suites" |
| 152 | +""" |
| 153 | + ), |
| 154 | + ] |
| 155 | + |
| 156 | + |
56 | 157 | class RunPluginMTRSuite(Command): |
57 | 158 | # MARIADB_ADD_PLUGIN's INSTALL_MYSQL_TEST (cmake/plugin.cmake) installs |
58 | 159 | # a plugin's mysql-test suite(s) under <mtr_base_dir>/plugin/<X>/<name>/, |
@@ -111,3 +212,41 @@ def as_cmd_arg(self) -> list[str]: |
111 | 212 | """ |
112 | 213 | ), |
113 | 214 | ] |
| 215 | + |
| 216 | + |
| 217 | +class RunPluginMTRSuiteFromBintar(Command): |
| 218 | + # Runs the suite(s) contributed by the plugin we just built and unpacked |
| 219 | + # into a server bintar tree. Unlike RunPluginMTRSuite, suites isn't |
| 220 | + # (re)discovered here -- the server bintar bundles its own plugin |
| 221 | + # suites (rocksdb, columnstore, ...) under the same plugin/*/*/suite.pm |
| 222 | + # layout, so re-scanning the merged tree can't tell those apart from |
| 223 | + # ours. Instead suites comes straight from |
| 224 | + # ExtractPluginBintarIntoServerBintar, which read it off the plugin's |
| 225 | + # own tarball listing before merging. mariadb-test-run.pl (wrapped by |
| 226 | + # ./mtr) lives at a known path inside the tree, so there's no package |
| 227 | + # manager to query either. |
| 228 | + def __init__( |
| 229 | + self, server_bintar_dir: str, suites: str, workdir: PurePath = PurePath(".") |
| 230 | + ): |
| 231 | + self.server_bintar_dir = server_bintar_dir |
| 232 | + self.suites = suites |
| 233 | + super().__init__(name="Run plugin MTR suite", workdir=workdir) |
| 234 | + |
| 235 | + def as_cmd_arg(self) -> list[str]: |
| 236 | + return [ |
| 237 | + "bash", |
| 238 | + "-exc", |
| 239 | + util.Interpolate( |
| 240 | + f""" |
| 241 | +set -euo pipefail |
| 242 | +
|
| 243 | +suites="{self.suites}" |
| 244 | +if [ -z "$suites" ]; then |
| 245 | + echo "No MTR suite found for plugin %(prop:plugin)s -- skipping" |
| 246 | + exit 0 |
| 247 | +fi |
| 248 | +
|
| 249 | +cd "{self.server_bintar_dir}/mariadb-test" && ./mtr --force --max-test-fail=20 --suite="$suites" |
| 250 | +""" |
| 251 | + ), |
| 252 | + ] |
0 commit comments