From 0d916d8c837ccb464f3357220b85c6cfac8088ad Mon Sep 17 00:00:00 2001 From: Enrico Zimuel Date: Wed, 12 Jun 2024 18:39:18 +0200 Subject: [PATCH] Added the requires in Yaml tests --- util/ActionTest.php | 48 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/util/ActionTest.php b/util/ActionTest.php index 67bdda131..79b32ce1c 100644 --- a/util/ActionTest.php +++ b/util/ActionTest.php @@ -336,6 +336,38 @@ private function length(array $actions) ]); } + private function requires(array $requires) + { + if (isset($requires['test_runner_features'])) { + if (is_string($requires['test_runner_features'])) { + $requires['test_runner_features'] = [$requires['test_runner_features']]; + } + foreach ($requires['test_runner_features'] as $req) { + if (!in_array($requires['test_runner_features'], self::SUPPORTED_FEATURES)) { + return YamlTests::render(self::TEMPLATE_SKIP_FEATURE, [ + ':testname' => "__CLASS__ . '::' . __FUNCTION__", + ':feature' => sprintf("'%s'", $req) + ]); + } + } + } + if (isset($requires['cluster_features'])) { + if (is_string($requires['cluster_features'])) { + $part = explode('_', $requires['cluster_features']); + if ($part[0] === 'gte') { + $version = str_replace ('v','', $part[1]); + if (version_compare(YamlTests::$esVersion, $version, '<')) { + return YamlTests::render(self::TEMPLATE_SKIP_VERSION, [ + ':testname' => "__CLASS__ . '::' . __FUNCTION__", + ':esversion' => sprintf("'%s'", YamlTests::$esVersion), + ':reason' => sprintf("'%s'", $requires['reason'] ?? '') + ]); + } + } + } + } + } + private function skip(array $actions) { if (isset($actions['version']) && isset($actions['reason'])) { @@ -388,7 +420,21 @@ private function skip(array $actions) break; } } - + } + if (isset($actions['cluster_features'])) { + if (is_string($actions['cluster_features'])) { + $part = explode('_', $actions['cluster_features']); + if ($part[0] === 'gte') { + $version = str_replace ('v','', $part[1]); + if (version_compare(YamlTests::$esVersion, $version, '>=')) { + return YamlTests::render(self::TEMPLATE_SKIP_VERSION, [ + ':testname' => "__CLASS__ . '::' . __FUNCTION__", + ':esversion' => sprintf("'%s'", YamlTests::$esVersion), + ':reason' => sprintf("'%s'", $actions['reason'] ?? '') + ]); + } + } + } } }