Skip to content

Commit

Permalink
Generated Ml Namespace Endpoints Using OpenSearch API Specifications
Browse files Browse the repository at this point in the history
Signed-off-by: saimedhi <saimedhi@amazon.com>
  • Loading branch information
saimedhi committed Jul 15, 2024
1 parent b4f3a4b commit ef7c3d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/Endpoints/MlNamespaceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testRegisterModelGroup()
{
$client = Utility::getClient();

if (!Utility::isOpenSearchVersionAtLeast($client, '2.8.0')) {
if (!Utility::isOpenSearchVersionAtLeast($client, '2.8.0') || !Utility::isOpenSearchVersionAtmost($client, '2.x')) {
$this->markTestSkipped('Ml plugin tests require OpenSearch >= 2.8.0');
}

Expand All @@ -47,7 +47,7 @@ public function testgetModels()
{
$client = Utility::getClient();

if (!Utility::isOpenSearchVersionAtLeast($client, '2.12.0')) {
if (!Utility::isOpenSearchVersionAtLeast($client, '2.12.0') || !Utility::isOpenSearchVersionAtmost($client, '2.x')) {
$this->markTestSkipped('Ml plugin tests require OpenSearch >= 2.12.0');
}

Expand All @@ -59,7 +59,7 @@ public function testsearchModels()
{
$client = Utility::getClient();

if (!Utility::isOpenSearchVersionAtLeast($client, '2.12.0')) {
if (!Utility::isOpenSearchVersionAtLeast($client, '2.12.0') || !Utility::isOpenSearchVersionAtmost($client, '2.x')) {
$this->markTestSkipped('Ml plugin tests require OpenSearch >= 2.12.0');
}

Expand Down
14 changes: 14 additions & 0 deletions tests/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ public static function isOpenSearchVersionAtLeast(Client $client, string $versio
return version_compare($versionNumber, $version) >= 0;
}

/**
* Check if cluster is OpenSearch and version is less than the specified version.
*/
public static function isOpenSearchVersionAtMost(Client $client, string $version): bool
{
$versionInfo = self::getVersion($client);
$distribution = $versionInfo['distribution'] ?? null;
if ($distribution !== 'opensearch') {
return false;
}
$versionNumber = $versionInfo['number'];
return version_compare($versionNumber, $version, '<');
}

/**
* Check if cluster is Elasticsearch and version is greater than or equal to specified version.
*/
Expand Down

0 comments on commit ef7c3d3

Please sign in to comment.