Skip to content

Commit

Permalink
[TEST] test tweaks to appease stricter types
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Aug 10, 2017
1 parent 5f83b52 commit 51f189e
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Elasticsearch\Common\Exceptions\ServerErrorResponseException;
use Elasticsearch\Common\Exceptions\RoutingMissingException;
use GuzzleHttp\Ring\Future\FutureArrayInterface;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\Yaml\Exception\ParseException;
Expand Down Expand Up @@ -669,7 +671,7 @@ public function operationSkip($operation, $lastOperationResult, $testName)
$version[1] = PHP_INT_MAX;
}

if (version_compare(static::$esVersion, $version[0], '>=') && version_compare(static::$esVersion, $version[1], '<=')) {
if (version_compare(static::$esVersion, (string)$version[0], '>=') && version_compare(static::$esVersion, (string)$version[1], '<=')) {
static::markTestSkipped(sprintf('Skip test "%s", as version %s should be skipped (%s)', $testName, static::$esVersion, $operation->reason));
}
}
Expand Down Expand Up @@ -862,7 +864,8 @@ private function formatRegex($regex)
*/
private function splitDocument($file, $path, $filter = null)
{
$fileContent = file_get_contents($file);

$fileContent = $file->getContents();
// cleanup some bad comments
$fileContent = str_replace('"#', '" #', $fileContent);

Expand Down Expand Up @@ -999,16 +1002,32 @@ private function clean()
}
}

// TODO ewwww...
shell_exec('rm -rf /tmp/test_repo_create_1_loc');
shell_exec('rm -rf /tmp/test_repo_restore_1_loc');
shell_exec('rm -rf /tmp/test_cat_repo_1_loc');
shell_exec('rm -rf /tmp/test_cat_repo_2_loc');
shell_exec('rm -rf /tmp/test_cat_snapshots_1_loc');
$this->rmDirRecursively('/tmp/test_repo_create_1_loc');
$this->rmDirRecursively('/tmp/test_repo_restore_1_loc');
$this->rmDirRecursively('/tmp/test_cat_repo_1_loc');
$this->rmDirRecursively('/tmp/test_cat_repo_2_loc');
$this->rmDirRecursively('/tmp/test_cat_snapshots_1_loc');

$this->waitForYellow();
}

private function rmDirRecursively($dir) {
if (!is_dir($dir )) {
return;
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);

foreach ($files as $fileinfo) {
$todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
$todo($fileinfo->getRealPath());
}

rmdir($dir);
}

/**
* Wait for cluster to be in a "YELLOW" state
*/
Expand Down

0 comments on commit 51f189e

Please sign in to comment.