1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4: 3 #ident "$Id$" 4 /*====== 5 This file is part of PerconaFT. 6 7 8 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. 9 10 PerconaFT is free software: you can redistribute it and/or modify 11 it under the terms of the GNU General Public License, version 2, 12 as published by the Free Software Foundation. 13 14 PerconaFT is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. 21 22 ---------------------------------------- 23 24 PerconaFT is free software: you can redistribute it and/or modify 25 it under the terms of the GNU Affero General Public License, version 3, 26 as published by the Free Software Foundation. 27 28 PerconaFT is distributed in the hope that it will be useful, 29 but WITHOUT ANY WARRANTY; without even the implied warranty of 30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 31 GNU Affero General Public License for more details. 32 33 You should have received a copy of the GNU Affero General Public License 34 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>. 35 ======= */ 36 37 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved." 38 39 #pragma once 40 41 #include "test.h" 42 #include "locktree_unit_test.h" 43 44 #include "lock_request.h" 45 46 namespace toku { 47 48 class lock_request_unit_test { 49 public: 50 // create and set the object's internals, destroy should not crash. 51 void test_create_destroy(void); 52 53 // make setting keys and getting them back works properly. 54 // at a high level, we want to make sure keys are copied 55 // when appropriate and plays nice with +/- infinity. 56 void test_get_set_keys(void); 57 58 // starting a lock request without immediate success should get 59 // stored in the lock request set as pending. 60 void test_start_pending(void); 61 62 // make sure deadlocks are detected when a lock request starts 63 void test_start_deadlock(void); 64 65 // test that the get_wait_time callback works 66 void test_wait_time_callback(void); 67 68 private: 69 // releases a single range lock and retries all lock requests. 70 // this is kind of like what the ydb layer does, except that 71 // the ydb layer releases all of a txn's locks at once using 72 // lt->release_locks(), not individually using lt->remove_overlapping_locks_for_txnid). release_lock_and_retry_requests(locktree * lt,TXNID txnid,const DBT * left_key,const DBT * right_key)73 void release_lock_and_retry_requests(locktree *lt, 74 TXNID txnid, const DBT *left_key, const DBT * right_key) { 75 locktree_unit_test::locktree_test_release_lock(lt, txnid, left_key, right_key); 76 lock_request::retry_all_lock_requests(lt); 77 } 78 }; 79 80 } 81