{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/65259128","id":65259128,"diff_hunk":"@@ -0,0 +1,178 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.elasticsearch.bwcompat;\n+\n+import org.elasticsearch.common.io.FileTestUtils;\n+import org.elasticsearch.common.settings.Settings;\n+import org.elasticsearch.common.util.set.Sets;\n+import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;\n+import org.elasticsearch.snapshots.SnapshotId;\n+import org.elasticsearch.snapshots.SnapshotInfo;\n+import org.elasticsearch.test.ESIntegTestCase;\n+\n+import java.nio.file.DirectoryStream;\n+import java.nio.file.Files;\n+import java.nio.file.Path;\n+import java.util.ArrayList;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.Set;\n+\n+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;\n+import static org.hamcrest.Matchers.equalTo;\n+\n+/**\n+ * Tests that a repository can handle snapshots of the new (5.0) and old (pre 5.0) formats,\n+ * as blob names and repository blobs have changed between the snapshot versions.\n+ */\n+@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)\n+public class MixedRepositoryInteroperabilityIT extends AbstractSnapshotIntegTestCase {\n+\n+    /**\n+     * This tests that a repository can inter-operate with snapshots that both have and don't have a UUID,\n+     * namely when a repository was created in a pre 5.0 release with snapshots created in the old format\n+     * (only snapshot name, no UUID) and then the repository is loaded into newer versions where subsequent\n+     * snapshots have a name and a UUID.\n+     */\n+    public void testRepositoryWorksWithCrossVersions() throws Exception {\n+        final List<String> repoVersions = listRepoVersions();\n+        // run the test for each supported version\n+        for (final String version : repoVersions) {\n+            final String repoName = \"test-repo-\" + version;\n+            logger.info(\"-->  creating repository [{}] for version [{}]\", repoName, version);\n+            createRepository(version, repoName);\n+\n+            logger.info(\"--> get the snapshots\");\n+            final String originalIndex = \"index-\" + version;\n+            final Set<String> indices = Sets.newHashSet(originalIndex);\n+            final Set<SnapshotInfo> snapshotInfos = Sets.newHashSet(getSnapshots(repoName));\n+            assertThat(snapshotInfos.size(), equalTo(1));\n+            SnapshotInfo originalSnapshot = snapshotInfos.iterator().next();\n+            assertThat(originalSnapshot.snapshotId(), equalTo(new SnapshotId(\"test_1\", SnapshotId.UNASSIGNED_UUID)));\n+            assertThat(Sets.newHashSet(originalSnapshot.indices()), equalTo(indices));\n+\n+            logger.info(\"--> restore the original snapshot\");\n+            final Set<String> restoredIndices = Sets.newHashSet(\n+                restoreSnapshot(repoName, originalSnapshot.snapshotId().getName())\n+            );\n+            assertThat(restoredIndices, equalTo(indices));\n+\n+            final String snapshotName2 = \"test_2\";\n+            logger.info(\"--> take a new snapshot of the old index\");\n+            for (int i = 0; i < 10; i++) {\n+                index(originalIndex, \"doc\", Integer.toString(i), \"foo\", \"new-bar-\" + i);\n+            }\n+            refresh();\n+            snapshotInfos.add(createSnapshot(repoName, snapshotName2));\n+\n+            logger.info(\"--> get the snapshots with the newly created snapshot [{}]\", snapshotName2);\n+            Set<SnapshotInfo> snapshotInfosFromRepo = Sets.newHashSet(getSnapshots(repoName));\n+            assertThat(snapshotInfosFromRepo, equalTo(snapshotInfos));\n+            snapshotInfosFromRepo.forEach(snapshotInfo -> {\n+                assertThat(Sets.newHashSet(snapshotInfo.indices()), equalTo(indices));\n+            });\n+\n+            final String snapshotName3 = \"test_3\";\n+            final String indexName2 = \"index2\";\n+            logger.info(\"--> take a new snapshot with a new index\");\n+            createIndex(indexName2);\n+            indices.add(indexName2);\n+            for (int i = 0; i < 10; i++) {\n+                index(indexName2, \"doc\", Integer.toString(i), \"foo\", \"new-bar-\" + i);\n+            }\n+            refresh();\n+            snapshotInfos.add(createSnapshot(repoName, snapshotName3));\n+\n+            logger.info(\"--> get the snapshots with the newly created snapshot [{}]\", snapshotName3);\n+            snapshotInfosFromRepo = Sets.newHashSet(getSnapshots(repoName));\n+            assertThat(snapshotInfosFromRepo, equalTo(snapshotInfos));\n+            snapshotInfosFromRepo.forEach(snapshotInfo -> {\n+                if (snapshotInfo.snapshotId().getName().equals(snapshotName3)) {\n+                    // only the last snapshot has all the indices\n+                    assertThat(Sets.newHashSet(snapshotInfo.indices()), equalTo(indices));","path":"core/src/test/java/org/elasticsearch/bwcompat/MixedRepositoryInteroperabilityIT.java","position":109,"original_position":109,"commit_id":"d973e652a47f5a481de49d99744661f98568eea5","original_commit_id":"d973e652a47f5a481de49d99744661f98568eea5","user":{"login":"imotov","id":655851,"avatar_url":"https://avatars.githubusercontent.com/u/655851?v=3","gravatar_id":"","url":"https://api.github.com/users/imotov","html_url":"https://github.com/imotov","followers_url":"https://api.github.com/users/imotov/followers","following_url":"https://api.github.com/users/imotov/following{/other_user}","gists_url":"https://api.github.com/users/imotov/gists{/gist_id}","starred_url":"https://api.github.com/users/imotov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imotov/subscriptions","organizations_url":"https://api.github.com/users/imotov/orgs","repos_url":"https://api.github.com/users/imotov/repos","events_url":"https://api.github.com/users/imotov/events{/privacy}","received_events_url":"https://api.github.com/users/imotov/received_events","type":"User","site_admin":false},"body":"It looks like we only check that snapshot command returned us the index name as a result of the snapshot. I think it might be better to test that we still can restore the old snapshot as well as the new snapshot. ","created_at":"2016-05-31T20:44:13Z","updated_at":"2016-05-31T20:44:13Z","html_url":"https://github.com/elastic/elasticsearch/pull/18228#discussion_r65259128","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/65259128"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/18228#discussion_r65259128"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228","id":69443826,"html_url":"https://github.com/elastic/elasticsearch/pull/18228","diff_url":"https://github.com/elastic/elasticsearch/pull/18228.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/18228.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18228","number":18228,"state":"open","locked":false,"title":"Adds UUIDs to snapshots","user":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"body":"This commit adds a UUID for each snapshot, in addition to the already\r\nexisting repository and snapshot name. The addition of UUIDs will enable\r\nmore robust handling of the deletion of previous snapshots and lingering\r\nfiles from partially failed delete operations, on top of being able to\r\nuniquely track each snapshot.\r\n\r\nRelates #18156","created_at":"2016-05-10T03:24:13Z","updated_at":"2016-05-31T20:44:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54e80b117f75216adcd2ce1929b9c9a0677d6b5e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18228/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/d973e652a47f5a481de49d99744661f98568eea5","head":{"label":"abeyad:snapshot-uuid","ref":"snapshot-uuid","sha":"d973e652a47f5a481de49d99744661f98568eea5","user":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"repo":{"id":48216890,"name":"elasticsearch","full_name":"abeyad/elasticsearch","owner":{"login":"abeyad","id":1631297,"avatar_url":"https://avatars.githubusercontent.com/u/1631297?v=3","gravatar_id":"","url":"https://api.github.com/users/abeyad","html_url":"https://github.com/abeyad","followers_url":"https://api.github.com/users/abeyad/followers","following_url":"https://api.github.com/users/abeyad/following{/other_user}","gists_url":"https://api.github.com/users/abeyad/gists{/gist_id}","starred_url":"https://api.github.com/users/abeyad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abeyad/subscriptions","organizations_url":"https://api.github.com/users/abeyad/orgs","repos_url":"https://api.github.com/users/abeyad/repos","events_url":"https://api.github.com/users/abeyad/events{/privacy}","received_events_url":"https://api.github.com/users/abeyad/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abeyad/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/abeyad/elasticsearch","forks_url":"https://api.github.com/repos/abeyad/elasticsearch/forks","keys_url":"https://api.github.com/repos/abeyad/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abeyad/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abeyad/elasticsearch/teams","hooks_url":"https://api.github.com/repos/abeyad/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/abeyad/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/abeyad/elasticsearch/events","assignees_url":"https://api.github.com/repos/abeyad/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/abeyad/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/abeyad/elasticsearch/tags","blobs_url":"https://api.github.com/repos/abeyad/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abeyad/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abeyad/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/abeyad/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abeyad/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/abeyad/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/abeyad/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/abeyad/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/abeyad/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/abeyad/elasticsearch/subscription","commits_url":"https://api.github.com/repos/abeyad/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/abeyad/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/abeyad/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/abeyad/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/abeyad/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/abeyad/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abeyad/elasticsearch/merges","archive_url":"https://api.github.com/repos/abeyad/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abeyad/elasticsearch/downloads","issues_url":"https://api.github.com/repos/abeyad/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/abeyad/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/abeyad/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/abeyad/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abeyad/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/abeyad/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/abeyad/elasticsearch/deployments","created_at":"2015-12-18T05:46:26Z","updated_at":"2015-12-18T05:46:48Z","pushed_at":"2016-05-31T01:36:16Z","git_url":"git://github.com/abeyad/elasticsearch.git","ssh_url":"git@github.com:abeyad/elasticsearch.git","clone_url":"https://github.com/abeyad/elasticsearch.git","svn_url":"https://github.com/abeyad/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":220581,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"38bee27b112b62cfd227a86eb330a0349958f190","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/elasticsearch/deployments","created_at":"2010-02-08T13:20:56Z","updated_at":"2016-05-31T19:02:00Z","pushed_at":"2016-05-31T20:21:54Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":320772,"stargazers_count":16745,"watchers_count":16745,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5652,"mirror_url":null,"open_issues_count":1064,"forks":5652,"open_issues":1064,"watchers":16745,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/18228"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/18228"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/18228/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/18228/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/d973e652a47f5a481de49d99744661f98568eea5"}}}}
{"actor":{"display_login":"imotov"}}