Skip to content

Commit

Permalink
[TEST] Better snapshot/repo clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Sep 15, 2016
1 parent 054ebed commit cc3a40d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/Elasticsearch/Tests/YamlRunnerTest.php
Expand Up @@ -826,6 +826,46 @@ private function clean()
$response = curl_exec($ch);
curl_close($ch);

$ch = curl_init($host."/_snapshot/_all");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

$response = curl_exec($ch);
curl_close($ch);
if ($response != "{}") {
$response = json_decode($response, true);
foreach ($response as $repo => $settings) {
if ($settings['type'] == 'fs') {
$ch = curl_init($host."/_snapshot/$repo/_all?ignore_unavailable");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

$snapshots = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($snapshots['snapshots'] as $snapshot) {
$snapshotName = $snapshot['snapshot'];
$ch = curl_init($host."/_snapshot/$repo/$snapshotName");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

$response = curl_exec($ch);
curl_close($ch);
}
$ch = curl_init($host."/_snapshot/$repo");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

$response = curl_exec($ch);
curl_close($ch);

}
}
}

// TODO ewwww...
shell_exec('rm -rf /tmp/test_repo_create_1_loc');
shell_exec('rm -rf /tmp/test_repo_restore_1_loc');
Expand Down

0 comments on commit cc3a40d

Please sign in to comment.