@@ -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]:
195238fi
196239mtr_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 } "
206242if [ -z "$suites" ]; then
207243 echo "No MTR suite found for plugin %(prop:plugin)s -- skipping"
208244 exit 0
0 commit comments