Skip to content

Commit 18c7bd8

Browse files
fix plugin mtr suite discovery
1 parent 4c96cd7 commit 18c7bd8

2 files changed

Lines changed: 74 additions & 19 deletions

File tree

configuration/builders/sequences/foundry/autobake.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from configuration.steps.commands.download import GitInitFromCommit
1010
from configuration.steps.commands.foundry import (
1111
BuildPlugin,
12+
DiscoverPluginMTRSuites,
1213
DownloadServerBintar,
1314
ExtractPluginBintarIntoServerBintar,
1415
InstallBuiltPackages,
@@ -104,6 +105,15 @@ def deb(config: DockerConfig, repo_file_url: str):
104105
docker_environment=config,
105106
)
106107
)
108+
sequence.add_step(
109+
InContainer(
110+
PropFromShellStep(
111+
command=DiscoverPluginMTRSuites("DEB"),
112+
property="plugin_suites",
113+
),
114+
docker_environment=config,
115+
)
116+
)
107117
sequence.add_step(
108118
InContainer(
109119
ShellStep(command=InstallBuiltPackages("DEB")),
@@ -124,7 +134,7 @@ def deb(config: DockerConfig, repo_file_url: str):
124134
sequence.add_step(
125135
InContainer(
126136
ShellStep(
127-
command=RunPluginMTRSuite("DEB")
137+
command=RunPluginMTRSuite("DEB", "%(prop:plugin_suites)s")
128138
),
129139
docker_environment=config,
130140
)
@@ -156,6 +166,15 @@ def rpm(config: DockerConfig, repo_file_url: str):
156166
docker_environment=config,
157167
)
158168
)
169+
sequence.add_step(
170+
InContainer(
171+
PropFromShellStep(
172+
command=DiscoverPluginMTRSuites("RPM"),
173+
property="plugin_suites",
174+
),
175+
docker_environment=config,
176+
)
177+
)
159178
sequence.add_step(
160179
InContainer(
161180
ShellStep(command=InstallBuiltPackages("RPM")),
@@ -176,7 +195,7 @@ def rpm(config: DockerConfig, repo_file_url: str):
176195
sequence.add_step(
177196
InContainer(
178197
ShellStep(
179-
command=RunPluginMTRSuite("RPM")
198+
command=RunPluginMTRSuite("RPM", "%(prop:plugin_suites)s")
180199
),
181200
docker_environment=config,
182201
)

configuration/steps/commands/foundry.py

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,64 @@ def as_cmd_arg(self) -> list[str]:
154154
]
155155

156156

157-
class RunPluginMTRSuite(Command):
157+
class DiscoverPluginMTRSuites(Command):
158158
# MARIADB_ADD_PLUGIN's INSTALL_MYSQL_TEST (cmake/plugin.cmake) installs
159159
# a plugin's mysql-test suite(s) under <mtr_base_dir>/plugin/<X>/<name>/,
160160
# e.g. plugin/rocksdb/rocksdb/suite.pm or
161-
# plugin/columnstore/columnstore/suite.pm. <X> is the plugin's own CMake
162-
# project/target name, which isn't always the same as the Foundry
163-
# "plugin" property (e.g. tidesql's CMake target is actually "tidesdb"),
164-
# so rather than guess it, discover whatever actually landed under
165-
# plugin/*/*/suite.pm -- exactly one plugin gets installed per build.
161+
# plugin/columnstore/columnstore/suite.pm -- the same layout MariaDB-test
162+
# itself uses for the suites it bundles for its own plugins (rocksdb,
163+
# columnstore, auth_gssapi, ...). Once MariaDB-test is installed
164+
# alongside our plugin there's no way to tell "ours" apart by re-scanning
165+
# the merged plugin/ directory -- doing that picked up every bundled
166+
# suite as well as (or instead of) the plugin actually under test.
167+
# Read the suite name(s) straight off the plugin's own just-built
168+
# package listing instead, before MariaDB-test ever gets installed. <X>
169+
# is the plugin's own CMake project/target name, which isn't always the
170+
# same as the Foundry "plugin" property (e.g. tidesql's CMake target is
171+
# actually "tidesdb"), so this discovers whatever actually landed under
172+
# plugin/*/*/suite.pm rather than guessing it. Emits comma-separated
173+
# suite name(s) on stdout for capture into a property (e.g. via
174+
# PropFromShellStep) and use as RunPluginMTRSuite's suites arg.
175+
def __init__(self, package_type: str, workdir: PurePath = PurePath(".")):
176+
self.package_type = package_type
177+
super().__init__(name="Discover plugin MTR suite", workdir=workdir)
178+
179+
def as_cmd_arg(self) -> list[str]:
180+
if self.package_type == "RPM":
181+
list_files_cmd = "rpm -qlp ./*.rpm"
182+
else:
183+
list_files_cmd = "dpkg-deb -c ./*.deb | awk '{print $NF}'"
184+
return [
185+
"bash",
186+
"-exc",
187+
util.Interpolate(
188+
f"""
189+
set -euo pipefail
190+
191+
suites=""
192+
for name in $({list_files_cmd} | grep -oE '/plugin/[^/]+/[^/]+/suite\\.pm$' | awk -F/ '{{print $(NF-1)}}' | sort -u); do
193+
suites="$suites,$name"
194+
done
195+
suites=$(echo "$suites" | sed 's/^,//')
196+
echo "$suites"
197+
"""
198+
),
199+
]
200+
201+
202+
class RunPluginMTRSuite(Command):
166203
# mtr_cases.pm resolves a bare suite name (e.g. "rocksdb") by searching
167204
# under plugin/*/ itself, so passing just the suite's short name is
168-
# enough -- no need to spell out the plugin/<X>/ prefix. A plugin with no
169-
# suite.pm anywhere under it is skipped rather than failing the build.
170-
def __init__(self, package_type: str, workdir: PurePath = PurePath(".")):
205+
# enough -- no need to spell out the plugin/<X>/ prefix. suites is
206+
# discovered up front by DiscoverPluginMTRSuites, before MariaDB-test
207+
# gets installed -- see that class for why re-discovering it here, after
208+
# install, doesn't work. No suite for the plugin under test is skipped
209+
# rather than failing the build.
210+
def __init__(
211+
self, package_type: str, suites: str, workdir: PurePath = PurePath(".")
212+
):
171213
self.package_type = package_type
214+
self.suites = suites
172215
super().__init__(name="Run plugin MTR suite", workdir=workdir, user="root")
173216

174217
def as_cmd_arg(self) -> list[str]:
@@ -195,14 +238,7 @@ def as_cmd_arg(self) -> list[str]:
195238
fi
196239
mtr_base_dir=$(dirname "$mtr_script")
197240
198-
suites=""
199-
for suite_pm in "$mtr_base_dir"/plugin/*/*/suite.pm; do
200-
[ -f "$suite_pm" ] || continue
201-
name=$(basename "$(dirname "$suite_pm")")
202-
suites="$suites,$name"
203-
done
204-
suites=$(echo "$suites" | sed 's/^,//')
205-
241+
suites="{self.suites}"
206242
if [ -z "$suites" ]; then
207243
echo "No MTR suite found for plugin %(prop:plugin)s -- skipping"
208244
exit 0

0 commit comments

Comments
 (0)