{"action":"created","comment":{"url":"https://api.github.com/repos/basho/leveldb/pulls/comments/77553700","id":77553700,"diff_hunk":"@@ -0,0 +1,600 @@\n+// -------------------------------------------------------------------\n+//\n+// hot_backup_test.cc\n+//\n+// Copyright (c) 2016 Basho Technologies, Inc. All Rights Reserved.\n+//\n+// This file is provided to you under the Apache License,\n+// Version 2.0 (the \"License\"); you may not use this file\n+// except in compliance with the License.  You may obtain\n+// 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+\n+#include <fcntl.h>\n+#include <libgen.h>\n+#include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+#include \"leveldb/db.h\"\n+#include \"util/testharness.h\"\n+#include \"util/testutil.h\"\n+\n+#include \"db/dbformat.h\"\n+#include \"db/db_impl.h\"\n+#include \"db/filename.h\"\n+#include \"util/hot_backup.h\"\n+\n+\n+/**\n+ * Execution routine\n+ */\n+int main(int argc, char** argv)\n+{\n+    int ret_val;\n+\n+    ret_val=leveldb::test::RunAllTests();\n+\n+    return(ret_val);\n+}   // main\n+\n+\n+namespace leveldb {\n+\n+\n+/**\n+ * Wrapper class for tests.  Holds working variables\n+ * and helper functions.\n+ */\n+class HotBackupTester : public HotBackup\n+{\n+public:\n+    std::string m_DBName;\n+    std::string m_Trigger;\n+\n+    HotBackupTester()\n+    {\n+        m_DBName = test::TmpDir() + \"/hot_backup\";\n+        m_Trigger = test::TmpDir() + \"/trigger\";\n+        gHotBackup=this;\n+    };\n+\n+    virtual ~HotBackupTester()\n+    {\n+        ResetHotBackupObject();\n+    };\n+\n+    virtual const char * GetTriggerPath() {return(m_Trigger.c_str());};\n+\n+    void ClearAllBackups(\n+        Options & InOptions)\n+    {\n+        int loop;\n+        Options options;\n+\n+        // clear old if exists\n+        for (loop=0; loop<=config::kNumBackups; ++loop)\n+        {\n+            options=InOptions;\n+\n+            SetBackupPaths(options, loop);\n+            DestroyDB(\"\", options);\n+        }   // if\n+\n+        options.tiered_slow_level=4;\n+        options.tiered_fast_prefix=m_DBName + \"/fast\";\n+        options.tiered_slow_prefix=m_DBName + \"/slow\";\n+        DestroyDB(\"\", options);\n+    }   // ClearAllBackups\n+\n+};  // class HotBackupTester\n+\n+\n+/**\n+ * Initial code used the existance of /etc/riak/hot_backup file\n+ *  as flag to start a backup.\n+ */\n+TEST(HotBackupTester, FileTriggerTest)\n+{\n+    char * dup_path, *path;\n+    int ret_val;\n+    bool ret_flag;\n+    uint64_t perf_before, perf_after;\n+\n+    perf_before=gPerfCounters->Value(ePerfSyslogWrite);\n+\n+    // cleanup anything existing, likely fails\n+    ///  hmm, should there be a way to move this trigger\n+    ///  to a \"safe\" area like /tmp?\n+    unlink(GetTriggerPath());\n+\n+    // does parent path exist?\n+    //  bypass test if it does not ... Travis CI and\n+    //  other users might not be able to access /etc/riak\n+    dup_path=strdup(GetTriggerPath());\n+    path=dirname(dup_path);\n+    ret_val=access(path, R_OK | W_OK);\n+    ASSERT_TRUE(-1!=ret_val);\n+\n+    // is a trigger seen (hope not)\n+    ret_flag=HotBackup::IsTriggerSet();\n+    ASSERT_TRUE(!ret_flag);\n+\n+    // make a trigger\n+    ret_val=open(GetTriggerPath(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);\n+    ASSERT_TRUE(-1!=ret_val);\n+    close(ret_val);\n+\n+    // test the trigger\n+    ret_flag=HotBackup::IsTriggerSet();\n+    ASSERT_TRUE(ret_flag);\n+\n+    // pretend to be back process\n+    /// schedule twice\n+    HotBackup::HotBackupScheduled();\n+    HotBackup::HotBackupScheduled();\n+\n+    // trigger still there?\n+    ret_flag=HotBackup::IsTriggerSet();\n+    ASSERT_TRUE(ret_flag);\n+\n+    // release one, trigger goes away\n+    HotBackup::HotBackupFinished();\n+    ret_flag=HotBackup::IsTriggerSet();\n+    ASSERT_TRUE(!ret_flag);\n+\n+    // did our simulation create a syslog entry?\n+    //  (bonus if you manually check /var/log/syslog for actual entries)\n+    perf_after=gPerfCounters->Value(ePerfSyslogWrite) - perf_before;\n+    ASSERT_TRUE( 1==perf_after );\n+\n+    // clean up second count.\n+    HotBackupFinished();","path":"util/hot_backup_test.cc","position":163,"original_position":163,"commit_id":"2f0610ef1a2d843155fcaabacf0cba57b2722848","original_commit_id":"9b58e117f4249df583516a6ca3539826525b4b93","user":{"login":"matthewvon","id":225681,"avatar_url":"https://avatars.githubusercontent.com/u/225681?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewvon","html_url":"https://github.com/matthewvon","followers_url":"https://api.github.com/users/matthewvon/followers","following_url":"https://api.github.com/users/matthewvon/following{/other_user}","gists_url":"https://api.github.com/users/matthewvon/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewvon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewvon/subscriptions","organizations_url":"https://api.github.com/users/matthewvon/orgs","repos_url":"https://api.github.com/users/matthewvon/repos","events_url":"https://api.github.com/users/matthewvon/events{/privacy}","received_events_url":"https://api.github.com/users/matthewvon/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2016-09-05T20:08:45Z","updated_at":"2016-09-05T20:08:45Z","html_url":"https://github.com/basho/leveldb/pull/202#discussion_r77553700","pull_request_url":"https://api.github.com/repos/basho/leveldb/pulls/202","_links":{"self":{"href":"https://api.github.com/repos/basho/leveldb/pulls/comments/77553700"},"html":{"href":"https://github.com/basho/leveldb/pull/202#discussion_r77553700"},"pull_request":{"href":"https://api.github.com/repos/basho/leveldb/pulls/202"}}},"pull_request":{"url":"https://api.github.com/repos/basho/leveldb/pulls/202","id":79965069,"html_url":"https://github.com/basho/leveldb/pull/202","diff_url":"https://github.com/basho/leveldb/pull/202.diff","patch_url":"https://github.com/basho/leveldb/pull/202.patch","issue_url":"https://api.github.com/repos/basho/leveldb/issues/202","number":202,"state":"open","locked":false,"title":"Mv hot backup [JIRA: RIAK-2784]","user":{"login":"matthewvon","id":225681,"avatar_url":"https://avatars.githubusercontent.com/u/225681?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewvon","html_url":"https://github.com/matthewvon","followers_url":"https://api.github.com/users/matthewvon/followers","following_url":"https://api.github.com/users/matthewvon/following{/other_user}","gists_url":"https://api.github.com/users/matthewvon/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewvon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewvon/subscriptions","organizations_url":"https://api.github.com/users/matthewvon/orgs","repos_url":"https://api.github.com/users/matthewvon/repos","events_url":"https://api.github.com/users/matthewvon/events{/privacy}","received_events_url":"https://api.github.com/users/matthewvon/received_events","type":"User","site_admin":false},"body":"Hot Backup allows an external trigger file, /etc/riak/hot_backup, to cause all open leveldb databases on a server to create a backup image, live.  The leveldb process does not the user to stop or pause data operations.  Hot backup will maintain up to five backup snapshots in a rolling fashion if the user does not wish to copy and erase after each backup.\r\n\r\nEach backup snapshot is \"ready to run\".  Previous Basho and 3rd party solutions required a database \"repair\" or similar lengthy process to guarantee state before using their backup.\r\n\r\nUsage and code details are here:  https://github.com/basho/leveldb/wiki/mv-hot-backup","created_at":"2016-08-03T19:34:35Z","updated_at":"2016-09-05T20:08:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7f160916f49adeca74d8ec6efce85085bf6f647","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/basho/leveldb/pulls/202/commits","review_comments_url":"https://api.github.com/repos/basho/leveldb/pulls/202/comments","review_comment_url":"https://api.github.com/repos/basho/leveldb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/basho/leveldb/issues/202/comments","statuses_url":"https://api.github.com/repos/basho/leveldb/statuses/2f0610ef1a2d843155fcaabacf0cba57b2722848","head":{"label":"basho:mv-hot-backup","ref":"mv-hot-backup","sha":"2f0610ef1a2d843155fcaabacf0cba57b2722848","user":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"repo":{"id":3280270,"name":"leveldb","full_name":"basho/leveldb","owner":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/basho/leveldb","description":"Clone of http://code.google.com/p/leveldb/","fork":false,"url":"https://api.github.com/repos/basho/leveldb","forks_url":"https://api.github.com/repos/basho/leveldb/forks","keys_url":"https://api.github.com/repos/basho/leveldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/basho/leveldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/basho/leveldb/teams","hooks_url":"https://api.github.com/repos/basho/leveldb/hooks","issue_events_url":"https://api.github.com/repos/basho/leveldb/issues/events{/number}","events_url":"https://api.github.com/repos/basho/leveldb/events","assignees_url":"https://api.github.com/repos/basho/leveldb/assignees{/user}","branches_url":"https://api.github.com/repos/basho/leveldb/branches{/branch}","tags_url":"https://api.github.com/repos/basho/leveldb/tags","blobs_url":"https://api.github.com/repos/basho/leveldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/basho/leveldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/basho/leveldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/basho/leveldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/basho/leveldb/statuses/{sha}","languages_url":"https://api.github.com/repos/basho/leveldb/languages","stargazers_url":"https://api.github.com/repos/basho/leveldb/stargazers","contributors_url":"https://api.github.com/repos/basho/leveldb/contributors","subscribers_url":"https://api.github.com/repos/basho/leveldb/subscribers","subscription_url":"https://api.github.com/repos/basho/leveldb/subscription","commits_url":"https://api.github.com/repos/basho/leveldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/basho/leveldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/basho/leveldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/basho/leveldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/basho/leveldb/contents/{+path}","compare_url":"https://api.github.com/repos/basho/leveldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/basho/leveldb/merges","archive_url":"https://api.github.com/repos/basho/leveldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/basho/leveldb/downloads","issues_url":"https://api.github.com/repos/basho/leveldb/issues{/number}","pulls_url":"https://api.github.com/repos/basho/leveldb/pulls{/number}","milestones_url":"https://api.github.com/repos/basho/leveldb/milestones{/number}","notifications_url":"https://api.github.com/repos/basho/leveldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/basho/leveldb/labels{/name}","releases_url":"https://api.github.com/repos/basho/leveldb/releases{/id}","deployments_url":"https://api.github.com/repos/basho/leveldb/deployments","created_at":"2012-01-27T04:49:26Z","updated_at":"2016-09-01T11:00:52Z","pushed_at":"2016-09-05T19:54:40Z","git_url":"git://github.com/basho/leveldb.git","ssh_url":"git@github.com:basho/leveldb.git","clone_url":"https://github.com/basho/leveldb.git","svn_url":"https://github.com/basho/leveldb","homepage":"","size":5865,"stargazers_count":391,"watchers_count":391,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":22,"forks":156,"open_issues":22,"watchers":391,"default_branch":"develop"}},"base":{"label":"basho:develop","ref":"develop","sha":"04a60dbaba2d25bcf94e45f6c5f24f43d8ef733a","user":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"repo":{"id":3280270,"name":"leveldb","full_name":"basho/leveldb","owner":{"login":"basho","id":176293,"avatar_url":"https://avatars.githubusercontent.com/u/176293?v=3","gravatar_id":"","url":"https://api.github.com/users/basho","html_url":"https://github.com/basho","followers_url":"https://api.github.com/users/basho/followers","following_url":"https://api.github.com/users/basho/following{/other_user}","gists_url":"https://api.github.com/users/basho/gists{/gist_id}","starred_url":"https://api.github.com/users/basho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basho/subscriptions","organizations_url":"https://api.github.com/users/basho/orgs","repos_url":"https://api.github.com/users/basho/repos","events_url":"https://api.github.com/users/basho/events{/privacy}","received_events_url":"https://api.github.com/users/basho/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/basho/leveldb","description":"Clone of http://code.google.com/p/leveldb/","fork":false,"url":"https://api.github.com/repos/basho/leveldb","forks_url":"https://api.github.com/repos/basho/leveldb/forks","keys_url":"https://api.github.com/repos/basho/leveldb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/basho/leveldb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/basho/leveldb/teams","hooks_url":"https://api.github.com/repos/basho/leveldb/hooks","issue_events_url":"https://api.github.com/repos/basho/leveldb/issues/events{/number}","events_url":"https://api.github.com/repos/basho/leveldb/events","assignees_url":"https://api.github.com/repos/basho/leveldb/assignees{/user}","branches_url":"https://api.github.com/repos/basho/leveldb/branches{/branch}","tags_url":"https://api.github.com/repos/basho/leveldb/tags","blobs_url":"https://api.github.com/repos/basho/leveldb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/basho/leveldb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/basho/leveldb/git/refs{/sha}","trees_url":"https://api.github.com/repos/basho/leveldb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/basho/leveldb/statuses/{sha}","languages_url":"https://api.github.com/repos/basho/leveldb/languages","stargazers_url":"https://api.github.com/repos/basho/leveldb/stargazers","contributors_url":"https://api.github.com/repos/basho/leveldb/contributors","subscribers_url":"https://api.github.com/repos/basho/leveldb/subscribers","subscription_url":"https://api.github.com/repos/basho/leveldb/subscription","commits_url":"https://api.github.com/repos/basho/leveldb/commits{/sha}","git_commits_url":"https://api.github.com/repos/basho/leveldb/git/commits{/sha}","comments_url":"https://api.github.com/repos/basho/leveldb/comments{/number}","issue_comment_url":"https://api.github.com/repos/basho/leveldb/issues/comments{/number}","contents_url":"https://api.github.com/repos/basho/leveldb/contents/{+path}","compare_url":"https://api.github.com/repos/basho/leveldb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/basho/leveldb/merges","archive_url":"https://api.github.com/repos/basho/leveldb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/basho/leveldb/downloads","issues_url":"https://api.github.com/repos/basho/leveldb/issues{/number}","pulls_url":"https://api.github.com/repos/basho/leveldb/pulls{/number}","milestones_url":"https://api.github.com/repos/basho/leveldb/milestones{/number}","notifications_url":"https://api.github.com/repos/basho/leveldb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/basho/leveldb/labels{/name}","releases_url":"https://api.github.com/repos/basho/leveldb/releases{/id}","deployments_url":"https://api.github.com/repos/basho/leveldb/deployments","created_at":"2012-01-27T04:49:26Z","updated_at":"2016-09-01T11:00:52Z","pushed_at":"2016-09-05T19:54:40Z","git_url":"git://github.com/basho/leveldb.git","ssh_url":"git@github.com:basho/leveldb.git","clone_url":"https://github.com/basho/leveldb.git","svn_url":"https://github.com/basho/leveldb","homepage":"","size":5865,"stargazers_count":391,"watchers_count":391,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":22,"forks":156,"open_issues":22,"watchers":391,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/basho/leveldb/pulls/202"},"html":{"href":"https://github.com/basho/leveldb/pull/202"},"issue":{"href":"https://api.github.com/repos/basho/leveldb/issues/202"},"comments":{"href":"https://api.github.com/repos/basho/leveldb/issues/202/comments"},"review_comments":{"href":"https://api.github.com/repos/basho/leveldb/pulls/202/comments"},"review_comment":{"href":"https://api.github.com/repos/basho/leveldb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/basho/leveldb/pulls/202/commits"},"statuses":{"href":"https://api.github.com/repos/basho/leveldb/statuses/2f0610ef1a2d843155fcaabacf0cba57b2722848"}}}}
{"actor":{"display_login":"matthewvon"}}