Skip to content

Commit 69c2c36

Browse files
committed
Backport: Fixed the Yaml tests + updated wipeCluster
1 parent a456313 commit 69c2c36

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

tests/Utility.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ private static function ensureNoInitializingShards(Client $client): void
192192
'level' => 'shards'
193193
]);
194194
}
195+
/**
196+
* Determines whether the system feature reset API should be invoked between tests. The default implementation is to reset
197+
* all feature states, deleting system indices, system associated indices, and system data streams.
198+
*
199+
* @see https://github.com/elastic/elasticsearch/blob/main/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java#L546
200+
*/
201+
202+
private static function resetFeaturesStates(Client $client): bool
203+
{
204+
return self::$hasMl || version_compare(self::getVersion($client), '8.6.99') > 0;
205+
}
195206

196207
/**
197208
* Delete the cluster
@@ -212,6 +223,9 @@ private static function wipeCluster(Client $client): void
212223
}
213224

214225
self::wipeSnapshots($client);
226+
if (self::resetFeaturesStates($client)) {
227+
$client->features()->resetFeatures();
228+
}
215229
self::wipeDataStreams($client);
216230
self::wipeAllIndices($client);
217231

util/YamlTests.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ class YamlTests
3737
// use of _internal APIs
3838
'free/cluster.desired_nodes/10_basic.yml',
3939
'free/cluster.desired_nodes/20_dry_run.yml',
40-
'free/health/'
40+
'free/health/',
41+
'free/cluster.desired_balance/10_basic.yml',
42+
'free/cluster.prevalidate_node_removal/10_basic.yml'
4143
];
4244

4345
const SKIPPED_TEST_OSS = [
46+
'Aggregations\_HistogramTest::HistogramProfiler' => "[histogram] field doesn't support values of type: VALUE_BOOLEAN",
47+
'Aggregations\_Percentiles_BucketTest::*' => 'Array index with float',
48+
'Aggregations\_Time_SeriesTest::BasicTest' => 'Unknown aggregation type [time_series]',
4449
'Cat\Nodeattrs\_10_BasicTest::TestCatNodesAttrsOutput' => 'Regexp error, it seems not compatible with PHP',
4550
'Cat\Shards\_10_BasicTest::TestCatShardsOutput' => 'Regexp error, it seems not compatible with PHP',
4651
'Cat\Templates\_10_BasicTest::FilteredTemplates' => 'regex mismatch',
@@ -51,7 +56,6 @@ class YamlTests
5156
'Indices\PutTemplate\_10_BasicTest::PutTemplateCreate' => 'index_template [test] already exists',
5257
'Indices\Refresh\_10_BasicTest::IndicesRefreshTestEmptyArray' => 'empty array?',
5358
'Indices\SimulateIndexTemplate\_10_BasicTest::SimulateIndexTemplateWithIndexNotMatchingAnyTemplate' => 'Bool mismatch',
54-
'Search\Aggregation\_10_HistogramTest::HistogramProfiler' => "Error reading 'n' field from YAML",
5559
'Snapshot\Create\_10_BasicTest::CreateASnapshot' => 'Invalid snapshot name [test_snapshot]',
5660
'Snapshot\Create\_10_BasicTest::CreateASnapshotAndCleanUpRepository' => 'Invalid snapshot name [test_snapshot]',
5761
];
@@ -60,12 +64,8 @@ class YamlTests
6064
'ApiKey\_10_BasicTest::TestGetApiKey' => 'Mismatch values',
6165
'ApiKey\_20_QueryTest::TestQueryApiKey' => 'Mismatch values',
6266
'DataStream\_80_Resolve_Index_Data_StreamsTest::*' => 'Skipped all tests',
63-
'License\_20_Put_LicenseTest::CurrentLicenseIsTrialMeansNotEligleToStartTrial' => 'License issue',
64-
'License\_20_Put_LicenseTest::MustAcknowledgeToStartBasic' => 'License issue',
65-
'License\_20_Put_LicenseTest::InstallingAndGettingLicenseWorks' => 'Invalid license',
66-
'License\_20_Put_LicenseTest::ShouldInstallAFeatureTypeLicense' => 'Invalid license',
67-
'License\_20_Put_LicenseTest::CanStartBasicLicenseIfDoNotAlreadyHaveBasic' => 'Invalid license',
68-
'License\_30_Enterprise_LicenseTest::InstallingEnterpriseLicense' => 'Invalid license',
67+
'License\_20_Put_LicenseTest::*' => 'License issue',
68+
'License\_30_Enterprise_LicenseTest::*' => 'Invalid license',
6969
'Ml\_Jobs_CrudTest::TestPutJobWithModel_memory_limitAsStringAndLazyOpen' => 'Memory limit',
7070
'Ml\_Data_Frame_Analytics_CrudTest::TestPutClassificationGivenNum_top_classesIsLessThanZero' => 'No error catched',
7171
'Ml\_Set_Upgrade_ModeTest::*' => 'Skipped all tests',
@@ -89,7 +89,8 @@ class YamlTests
8989
'RuntimeFields\_40_DateTest::GetMapping' => 'String mismatch',
9090
'RuntimeFields\_50_IpTest::GetMapping' => 'String mismatch',
9191
'RuntimeFields\_60_BooleanTest::GetMapping' => 'String mismatch',
92-
'SearchableSnapshots\_10_UsageTest::TestsSearchableSnapshotsUsageStatsWithFull_copyAndShared_cacheIndices' => 'Mismatch values',
92+
'SearchableSnapshots\_10_UsageTest::*' => 'Mismatch values',
93+
'SearchableSnapshots\_20_Synthetic_SourceTest::*' => 'no_shard_available_action_exception',
9394
'ServiceAccounts\_10_BasicTest::TestServiceAccountTokens' => 'Count mismatch',
9495
'Snapshot\_10_BasicTest::CreateASourceOnlySnapshotAndThenRestoreIt' => 'Snapshot name already exists',
9596
'Snapshot\_20_Operator_Privileges_DisabledTest::OperatorOnlySettingsCanBeSetAndRestoredByNonoperatorUserWhenOperatorPrivilegesIsDisabled' => 'Count mismatch',
@@ -163,7 +164,8 @@ private function getAllTests(string $dir): array
163164
continue;
164165
}
165166
$content = file_get_contents($file->getPathname());
166-
$content = str_replace(' y: ', " 'y': ", $content); // replace "y:" with "'y':" due the y/true conversion in YAML 1.1
167+
$content = str_replace(' y:', " 'y':", $content); // replace y: with 'y': due the y/true conversion in YAML 1.1
168+
$content = str_replace(' n:', " 'n':", $content); // replace n: with 'n': due the n/false conversion in YAML 1.1
167169
try {
168170
$test = yaml_parse($content, -1, $ndocs, [
169171
YAML_MAP_TAG => function($value, $tag, $flags) {

util/template/test/unit-test-xpack

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,18 @@ use stdClass;
3030
*/
3131
class :test-name extends TestCase
3232
{
33-
public static function setUpBeforeClass(): void
34-
{
35-
Utility::initYamlXPackUsers(Utility::getClient());
36-
}
37-
38-
public static function tearDownAfterClass(): void
39-
{
40-
Utility::removeYamlXPackUsers(Utility::getClient());
41-
}
42-
4333
protected function setUp(): void
4434
{
4535
$this->client = Utility::getClient();
36+
Utility::initYamlXPackUsers($this->client);
4637
$this->yamlSetup();
4738
}
4839

4940
protected function tearDown(): void
5041
{
5142
$this->client = Utility::getClient();
5243
$this->yamlTearDown();
44+
Utility::removeYamlXPackUsers($this->client);
5345
Utility::cleanUpCluster($this->client);
5446
}
5547

0 commit comments

Comments
 (0)