|
1 | 1 | /*
|
2 |
| - Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | 3 |
|
4 | 4 | This program is free software; you can redistribute it and/or modify
|
5 | 5 | it under the terms of the GNU General Public License as published by
|
@@ -8714,6 +8714,181 @@ int runTestStartNode(NDBT_Context* ctx, NDBT_Step* step){
|
8714 | 8714 | return NDBT_OK;
|
8715 | 8715 | }
|
8716 | 8716 |
|
| 8717 | +int run_PLCP_I1(NDBT_Context *ctx, NDBT_Step *step) |
| 8718 | +{ |
| 8719 | + Ndb *pNdb = GETNDB(step); |
| 8720 | + int i = 0; |
| 8721 | + int result = NDBT_OK; |
| 8722 | + int loops = ctx->getNumLoops(); |
| 8723 | + int records = ctx->getNumRecords(); |
| 8724 | + NdbRestarter restarter; |
| 8725 | + const Uint32 nodeCount = restarter.getNumDbNodes(); |
| 8726 | + int nodeId = restarter.getRandomNotMasterNodeId(rand()); |
| 8727 | + HugoTransactions hugoTrans(*ctx->getTab()); |
| 8728 | + |
| 8729 | + if (nodeCount < 2) |
| 8730 | + { |
| 8731 | + return NDBT_OK; /* Requires at least 2 nodes to run */ |
| 8732 | + } |
| 8733 | + g_err << "Executing " << loops << " loops" << endl; |
| 8734 | + while(++i <= loops && result != NDBT_FAILED) |
| 8735 | + { |
| 8736 | + g_err << "Start loop " << i << endl; |
| 8737 | + g_err << "Loading " << records << " records..." << endl; |
| 8738 | + if (hugoTrans.loadTable(pNdb, records) != NDBT_OK) |
| 8739 | + { |
| 8740 | + g_err << "Failed to load table" << endl; |
| 8741 | + return NDBT_FAILED; |
| 8742 | + } |
| 8743 | + if (restarter.restartOneDbNode(nodeId, |
| 8744 | + true, /* initial */ |
| 8745 | + true, /* nostart */ |
| 8746 | + false, /* abort */ |
| 8747 | + false /* force */) != 0) |
| 8748 | + { |
| 8749 | + g_err << "Restart failed" << endl; |
| 8750 | + return NDBT_FAILED; |
| 8751 | + } |
| 8752 | + ndbout << "Wait for NoStart state" << endl; |
| 8753 | + restarter.waitNodesNoStart(&nodeId, 1); |
| 8754 | + ndbout << "Start node" << endl; |
| 8755 | + if (restarter.startNodes(&nodeId, 1) != 0) |
| 8756 | + { |
| 8757 | + g_err << "Start failed" << endl; |
| 8758 | + return NDBT_FAILED; |
| 8759 | + } |
| 8760 | + ndbout << "Delete records" << endl; |
| 8761 | + |
| 8762 | + Uint32 row_step = 10; |
| 8763 | + Uint32 num_deleted_records = records / 10; |
| 8764 | + Uint32 batch = 1; |
| 8765 | + |
| 8766 | + for (Uint32 start = 0; start < 10; start++) |
| 8767 | + { |
| 8768 | + CHECK((hugoTrans.pkDelRecords(pNdb, |
| 8769 | + num_deleted_records, |
| 8770 | + batch, |
| 8771 | + true, |
| 8772 | + 0, |
| 8773 | + start, |
| 8774 | + row_step) == 0), ""); |
| 8775 | + if (result == NDBT_FAILED) |
| 8776 | + return result; |
| 8777 | + NdbSleep_SecSleep(1); |
| 8778 | + } |
| 8779 | + ndbout << "Wait for initial node restart to complete" << endl; |
| 8780 | + if (restarter.waitNodesStarted(&nodeId, 1) != 0) |
| 8781 | + { |
| 8782 | + g_err << "Wait node start failed" << endl; |
| 8783 | + return NDBT_FAILED; |
| 8784 | + } |
| 8785 | + } |
| 8786 | + return NDBT_OK; |
| 8787 | +} |
| 8788 | + |
| 8789 | +int run_PLCP_I2(NDBT_Context *ctx, NDBT_Step *step) |
| 8790 | +{ |
| 8791 | + Ndb *pNdb = GETNDB(step); |
| 8792 | + int i = 0; |
| 8793 | + int result = NDBT_OK; |
| 8794 | + int loops = ctx->getNumLoops(); |
| 8795 | + int records = ctx->getNumRecords(); |
| 8796 | + NdbRestarter restarter; |
| 8797 | + const Uint32 nodeCount = restarter.getNumDbNodes(); |
| 8798 | + int nodeId = restarter.getRandomNotMasterNodeId(rand()); |
| 8799 | + HugoTransactions hugoTrans(*ctx->getTab()); |
| 8800 | + |
| 8801 | + if (nodeCount < 2) |
| 8802 | + { |
| 8803 | + return NDBT_OK; /* Requires at least 2 nodes to run */ |
| 8804 | + } |
| 8805 | + g_err << "Executing " << loops << " loops" << endl; |
| 8806 | + while(++i <= loops && result != NDBT_FAILED) |
| 8807 | + { |
| 8808 | + g_err << "Start loop " << i << endl; |
| 8809 | + g_err << "Loading " << records << " records..." << endl; |
| 8810 | + if (hugoTrans.loadTable(pNdb, records) != NDBT_OK) |
| 8811 | + { |
| 8812 | + g_err << "Failed to load table" << endl; |
| 8813 | + return NDBT_FAILED; |
| 8814 | + } |
| 8815 | + if (restarter.restartOneDbNode(nodeId, |
| 8816 | + true, /* initial */ |
| 8817 | + true, /* nostart */ |
| 8818 | + false, /* abort */ |
| 8819 | + false /* force */) != 0) |
| 8820 | + { |
| 8821 | + g_err << "Restart failed" << endl; |
| 8822 | + return NDBT_FAILED; |
| 8823 | + } |
| 8824 | + ndbout << "Wait for NoStart state" << endl; |
| 8825 | + restarter.waitNodesNoStart(&nodeId, 1); |
| 8826 | + ndbout << "Start node" << endl; |
| 8827 | + if (restarter.startNodes(&nodeId, 1) != 0) |
| 8828 | + { |
| 8829 | + g_err << "Start failed" << endl; |
| 8830 | + return NDBT_FAILED; |
| 8831 | + } |
| 8832 | + ndbout << "Delete 10% of records" << endl; |
| 8833 | + |
| 8834 | + Uint32 row_step = 1; |
| 8835 | + Uint32 start = 0; |
| 8836 | + Uint32 num_deleted_records = records / 10; |
| 8837 | + Uint32 batch = 1; |
| 8838 | + |
| 8839 | + CHECK((hugoTrans.pkDelRecords(pNdb, |
| 8840 | + num_deleted_records, |
| 8841 | + batch, |
| 8842 | + true, |
| 8843 | + 0, |
| 8844 | + start, |
| 8845 | + row_step) == 0), ""); |
| 8846 | + if (result == NDBT_FAILED) |
| 8847 | + return result; |
| 8848 | + ndbout << "Start an LCP" << endl; |
| 8849 | + { |
| 8850 | + int val = DumpStateOrd::DihStartLcpImmediately; |
| 8851 | + if(restarter.dumpStateAllNodes(&val, 1) != 0) |
| 8852 | + { |
| 8853 | + g_err << "ERR: "<< step->getName() |
| 8854 | + << " failed on line " << __LINE__ << endl; |
| 8855 | + return NDBT_FAILED; |
| 8856 | + } |
| 8857 | + } |
| 8858 | + ndbout << "Delete 80% of the records" << endl; |
| 8859 | + for (Uint32 i = 2; i < 10; i++) |
| 8860 | + { |
| 8861 | + start += num_deleted_records; |
| 8862 | + CHECK((hugoTrans.pkDelRecords(pNdb, |
| 8863 | + num_deleted_records, |
| 8864 | + batch, |
| 8865 | + true, |
| 8866 | + 0, |
| 8867 | + start, |
| 8868 | + row_step) == 0), ""); |
| 8869 | + if (result == NDBT_FAILED) |
| 8870 | + return result; |
| 8871 | + } |
| 8872 | + ndbout << "Wait for initial node restart to complete" << endl; |
| 8873 | + if (restarter.waitNodesStarted(&nodeId, 1) != 0) |
| 8874 | + { |
| 8875 | + g_err << "Wait node start failed" << endl; |
| 8876 | + return NDBT_FAILED; |
| 8877 | + } |
| 8878 | + ndbout << "Delete remaining records" << endl; |
| 8879 | + start += num_deleted_records; |
| 8880 | + CHECK((hugoTrans.pkDelRecords(pNdb, |
| 8881 | + num_deleted_records, |
| 8882 | + batch, |
| 8883 | + true, |
| 8884 | + 0, |
| 8885 | + start, |
| 8886 | + row_step) == 0), ""); |
| 8887 | + if (result == NDBT_FAILED) |
| 8888 | + return result; |
| 8889 | + } |
| 8890 | + return NDBT_OK; |
| 8891 | +} |
8717 | 8892 |
|
8718 | 8893 | NDBT_TESTSUITE(testNodeRestart);
|
8719 | 8894 | TESTCASE("NoLoad",
|
@@ -9410,6 +9585,16 @@ TESTCASE("MultiCrashTest",
|
9410 | 9585 | STEP(runMultiCrashTest);
|
9411 | 9586 | FINALIZER(runClearTable);
|
9412 | 9587 | }
|
| 9588 | +TESTCASE("PLCP_I1", |
| 9589 | + "Initial node restart while deleting rows") |
| 9590 | +{ |
| 9591 | + INITIALIZER(run_PLCP_I1); |
| 9592 | +} |
| 9593 | +TESTCASE("PLCP_I2", |
| 9594 | + "Initial node restart while deleting rows") |
| 9595 | +{ |
| 9596 | + INITIALIZER(run_PLCP_I2); |
| 9597 | +} |
9413 | 9598 | TESTCASE("ArbitrationWithApiNodeFailure",
|
9414 | 9599 | "Check that arbitration do not fail with non arbitrator api node "
|
9415 | 9600 | "failure.");
|
|
0 commit comments