|
14 | 14 | use Elasticsearch\Common\Exceptions\ServerErrorResponseException;
|
15 | 15 | use Elasticsearch\Common\Exceptions\RoutingMissingException;
|
16 | 16 | use GuzzleHttp\Ring\Future\FutureArrayInterface;
|
| 17 | +use RecursiveDirectoryIterator; |
| 18 | +use RecursiveIteratorIterator; |
17 | 19 | use Symfony\Component\Finder\Finder;
|
18 | 20 | use Symfony\Component\Finder\SplFileInfo;
|
19 | 21 | use Symfony\Component\Yaml\Exception\ParseException;
|
@@ -669,7 +671,7 @@ public function operationSkip($operation, $lastOperationResult, $testName)
|
669 | 671 | $version[1] = PHP_INT_MAX;
|
670 | 672 | }
|
671 | 673 |
|
672 |
| - if (version_compare(static::$esVersion, $version[0], '>=') && version_compare(static::$esVersion, $version[1], '<=')) { |
| 674 | + if (version_compare(static::$esVersion, (string)$version[0], '>=') && version_compare(static::$esVersion, (string)$version[1], '<=')) { |
673 | 675 | static::markTestSkipped(sprintf('Skip test "%s", as version %s should be skipped (%s)', $testName, static::$esVersion, $operation->reason));
|
674 | 676 | }
|
675 | 677 | }
|
@@ -862,7 +864,8 @@ private function formatRegex($regex)
|
862 | 864 | */
|
863 | 865 | private function splitDocument($file, $path, $filter = null)
|
864 | 866 | {
|
865 |
| - $fileContent = file_get_contents($file); |
| 867 | + |
| 868 | + $fileContent = $file->getContents(); |
866 | 869 | // cleanup some bad comments
|
867 | 870 | $fileContent = str_replace('"#', '" #', $fileContent);
|
868 | 871 |
|
@@ -999,16 +1002,32 @@ private function clean()
|
999 | 1002 | }
|
1000 | 1003 | }
|
1001 | 1004 |
|
1002 |
| - // TODO ewwww... |
1003 |
| - shell_exec('rm -rf /tmp/test_repo_create_1_loc'); |
1004 |
| - shell_exec('rm -rf /tmp/test_repo_restore_1_loc'); |
1005 |
| - shell_exec('rm -rf /tmp/test_cat_repo_1_loc'); |
1006 |
| - shell_exec('rm -rf /tmp/test_cat_repo_2_loc'); |
1007 |
| - shell_exec('rm -rf /tmp/test_cat_snapshots_1_loc'); |
| 1005 | + $this->rmDirRecursively('/tmp/test_repo_create_1_loc'); |
| 1006 | + $this->rmDirRecursively('/tmp/test_repo_restore_1_loc'); |
| 1007 | + $this->rmDirRecursively('/tmp/test_cat_repo_1_loc'); |
| 1008 | + $this->rmDirRecursively('/tmp/test_cat_repo_2_loc'); |
| 1009 | + $this->rmDirRecursively('/tmp/test_cat_snapshots_1_loc'); |
1008 | 1010 |
|
1009 | 1011 | $this->waitForYellow();
|
1010 | 1012 | }
|
1011 | 1013 |
|
| 1014 | + private function rmDirRecursively($dir) { |
| 1015 | + if (!is_dir($dir )) { |
| 1016 | + return; |
| 1017 | + } |
| 1018 | + $files = new RecursiveIteratorIterator( |
| 1019 | + new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), |
| 1020 | + RecursiveIteratorIterator::CHILD_FIRST |
| 1021 | + ); |
| 1022 | + |
| 1023 | + foreach ($files as $fileinfo) { |
| 1024 | + $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink'); |
| 1025 | + $todo($fileinfo->getRealPath()); |
| 1026 | + } |
| 1027 | + |
| 1028 | + rmdir($dir); |
| 1029 | + } |
| 1030 | + |
1012 | 1031 | /**
|
1013 | 1032 | * Wait for cluster to be in a "YELLOW" state
|
1014 | 1033 | */
|
|
0 commit comments