Skip to content

Commit 2230a58

Browse files
committed
BUG#35696649 ADD TLS SUPPORT FOR REMAINING TESTS AND TOOLS
Adds TLS support for ndb tests and test tools that do not use yet Ndb_cluster_connection from test-wide NDBT_Context. Change-Id: If403f21d17c245875370cad57a289ed8072ceef4
1 parent d16608e commit 2230a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+170
-23
lines changed

storage/ndb/test/crund/schema_driven_load_unfinished/tws_cpp/NdbApiTwsDriver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ NdbApiTwsDriver::initConnection() {
820820
cout << "creating cluster connection ..." << flush;
821821
assert(!mgmdConnect.empty());
822822
mgmd = new Ndb_cluster_connection(mgmdConnect.c_str());
823+
mgmd->configure_tls(opt_tls_search_path, opt_mgm_tls);
823824
cout << " [ok]" << endl; // no useful mgmd->string conversion
824825

825826
// connect to cluster management node (ndb_mgmd)

storage/ndb/test/crund/src/cpp/NdbapiAB.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ NdbapiAB::init() {
265265
cout << "creating cluster connection ..." << flush;
266266
assert(!mgmdConnect.empty());
267267
mgmd = new Ndb_cluster_connection(mgmdConnect.c_str());
268+
mgmd->configure_tls(opt_tls_search_path, opt_mgm_tls);
268269
cout << " [ok: mgmd@" << mgmdConnect << "]" << endl;
269270
}
270271

storage/ndb/test/crund/src/cpp/NdbapiTwsDriver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ NdbapiTwsDriver::initConnection() {
761761
cout << "creating cluster connection ..." << flush;
762762
assert(!mgmdConnect.empty());
763763
mgmd = new Ndb_cluster_connection(mgmdConnect.c_str());
764+
mgmd->configure_tls(opt_tls_search_path, opt_mgm_tls);
764765
cout << " [ok: mgmd@" << mgmdConnect << "]" << endl;
765766

766767
// connect to cluster management node (ndb_mgmd)

storage/ndb/test/include/NDBT.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
*
3333
*/
3434

35+
// ndb_opts.h contains declaration of opt_tls_search_path and opt_mgm_tls
36+
// including this file will help to enable TLS support in test programs
37+
#include <ndb_opts.h>
38+
3539
#include "NDBT_ReturnCodes.h"
3640

3741
#ifdef __cplusplus

storage/ndb/test/include/NdbMgmd.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <InputStream.hpp>
4343

4444
#include "NdbSleep.h"
45+
#include "util/TlsKeyManager.hpp"
4546

4647
class NdbMgmd {
4748
BaseString m_connect_str;
@@ -148,14 +149,20 @@ class NdbMgmd {
148149
}
149150

150151
bool connect(const char* connect_string = NULL,
151-
int num_retries = 12, int retry_delay_in_seconds = 5) {
152+
int num_retries = 12, int retry_delay_in_seconds = 5, bool use_tls=true) {
152153
require(m_handle == NULL);
154+
155+
TlsKeyManager tlsKeyManager;
156+
extern const char* opt_tls_search_path;
157+
extern unsigned long long opt_mgm_tls;
158+
153159
m_handle= ndb_mgm_create_handle();
154160
if (!m_handle){
155161
error("connect: ndb_mgm_create_handle failed");
156162
return false;
157163
}
158164

165+
159166
if (ndb_mgm_set_connectstring(m_handle,
160167
connect_string ?
161168
connect_string : getConnectString()) != 0){
@@ -169,7 +176,16 @@ class NdbMgmd {
169176
return false;
170177
}
171178

172-
if (ndb_mgm_connect(m_handle,num_retries,retry_delay_in_seconds,0) != 0){
179+
int connect_status = -1;
180+
if(use_tls) {
181+
tlsKeyManager.init_mgm_client(opt_tls_search_path);
182+
ndb_mgm_set_ssl_ctx(m_handle, tlsKeyManager.ctx());
183+
connect_status = ndb_mgm_connect_tls(m_handle,num_retries,retry_delay_in_seconds,0,opt_mgm_tls);
184+
} else {
185+
connect_status = ndb_mgm_connect(m_handle,num_retries,retry_delay_in_seconds,0);
186+
}
187+
188+
if (connect_status != 0){
173189
error("connect: ndb_mgm_connect failed");
174190
return false;
175191
}

storage/ndb/test/include/NdbRestarter.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "mgmcommon/NdbMgm.hpp"
3030
#include <Vector.hpp>
3131
#include <BaseString.hpp>
32+
#include "util/TlsKeyManager.hpp"
3233

3334
#define NDBT_NO_NODE_GROUP_ID (int(-256))
3435

@@ -143,7 +144,8 @@ class NdbRestarter {
143144
*/
144145
Vector<Vector<int> > splitNodes();
145146

146-
NdbMgmHandle handle;
147+
NdbMgmHandle handle;
148+
TlsKeyManager tlsKeyManager;
147149

148150
enum NodeSelector
149151
{

storage/ndb/test/include/NdbTest.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
*
3434
*/
3535

36+
// ndb_opts.h contains declaration of opt_tls_search_path and opt_mgm_tls
37+
// including this file will help to enable TLS support in test programs
38+
#include <ndb_opts.h>
39+
3640
#include "NDBT_ReturnCodes.h"
3741

3842
#ifdef __cplusplus

storage/ndb/test/ndbapi/bank/bankCreator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ int main(int argc, const char** argv){
5757
}
5858

5959
Ndb_cluster_connection con;
60+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
6061
if(con.connect(12, 5, 1) != 0)
6162
{
6263
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bank/bankMakeGL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int main(int argc, const char** argv){
5353
}
5454

5555
Ndb_cluster_connection con;
56+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5657
if(con.connect(12, 5, 1) != 0)
5758
{
5859
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bank/bankSumAccounts.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ int main(int argc, const char** argv){
5353
}
5454

5555
Ndb_cluster_connection con;
56+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5657
if(con.connect(12, 5, 1) != 0)
5758
{
5859
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bank/bankTimer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(int argc, const char** argv){
5656
}
5757

5858
Ndb_cluster_connection con;
59+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5960
if(con.connect(12, 5, 1) != 0)
6061
{
6162
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bank/bankTransactionMaker.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int main(int argc, const char** argv){
5656
}
5757

5858
Ndb_cluster_connection con;
59+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5960
if(con.connect(12, 5, 1) != 0)
6061
{
6162
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bank/bankValidateAllGLs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ int main(int argc, const char** argv){
5454
}
5555

5656
Ndb_cluster_connection con;
57+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5758
if(con.connect(12, 5, 1) != 0)
5859
{
5960
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/bench/userInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ UserHandle*
554554
userDbConnect(uint32 createDb, const char *dbName)
555555
{
556556
Ndb_cluster_connection *con= new Ndb_cluster_connection();
557+
con->configure_tls(opt_tls_search_path, opt_mgm_tls);
557558
if(con->connect(12, 5, 1) != 0)
558559
{
559560
ndbout << "Unable to connect to management server." << endl;

storage/ndb/test/ndbapi/create_all_tabs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ int main(int argc, const char** argv){
5757

5858
// Connect to Ndb
5959
Ndb_cluster_connection con;
60+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
6061
if(con.connect(12, 5, 1) != 0)
6162
{
6263
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/create_tab.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ int main(int argc, const char** argv){
115115

116116
// Connect to Ndb
117117
Ndb_cluster_connection con(_connectstr);
118+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
118119
if(con.connect(12, 5, 1) != 0)
119120
{
120121
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/drop_all_tabs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int main(int argc, const char** argv){
5050

5151
// Connect to Ndb
5252
Ndb_cluster_connection con;
53+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
5354
if(con.connect(12, 5, 1) != 0)
5455
{
5556
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/flexAsynch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ int main(int argc, char** argv)
351351
for (int i = 0; i < tConnections; i++)
352352
{
353353
g_cluster_connection[i] = new Ndb_cluster_connection();
354+
g_cluster_connection[i]->configure_tls(opt_tls_search_path, opt_mgm_tls);
354355
ndbout_c("CPU for this connection: %u", receiveCPUArray[i]);
355356
}
356357
for (int i = 0; i < tConnections; i++)

storage/ndb/test/ndbapi/flexBench.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ int main(int argc, char** argv)
340340
NdbThread_SetConcurrencyLevel(tNoOfThreads + 2);
341341

342342
Ndb_cluster_connection con;
343+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
343344
if(con.connect(12, 5, 1) != 0)
344345
{
345346
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/flexHammer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Revision history:
6565
#include <NdbTick.h>
6666
#include <NdbOut.hpp>
6767
#include <NdbTimer.hpp>
68-
#include <NdbTick.h>
6968
#include <NdbTest.hpp>
7069
#include <NDBT_Error.hpp>
7170
#include <NdbSchemaCon.hpp>
@@ -233,6 +232,7 @@ int main(int argc, char** argv)
233232
}
234233
// Create and init Ndb object
235234
Ndb_cluster_connection con;
235+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
236236
if(con.connect(12, 5, 1) != 0)
237237
{
238238
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/flexTT.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ int main(int argc, char** argv)
244244
setTableNames();
245245

246246
Ndb_cluster_connection con;
247+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
247248
if(con.connect(12, 5, 1) != 0)
248249
{
249250
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/slow_select.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <NdbApi.hpp>
2929
#include <NdbOut.hpp>
3030
#include <NdbTick.h>
31+
#include <ndb_opts.h>
3132

3233
struct
3334
S_Scan {
@@ -69,6 +70,7 @@ main(void){
6970
ndb_init();
7071

7172
Ndb_cluster_connection con;
73+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
7274
if(con.connect(12, 5, 1) != 0)
7375
{
7476
return 1;

storage/ndb/test/ndbapi/testBitfield.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ main(int argc, char** argv){
6868
}
6969

7070
Ndb_cluster_connection con(opt_ndb_connectstring, opt_ndb_nodeid);
71+
extern const char* opt_tls_search_path;
72+
extern unsigned long long opt_mgm_tls;
73+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
7174
if(con.connect(12, 5, 1))
7275
{
7376
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/testBlobs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6327,6 +6327,7 @@ int main(int argc, char** argv)
63276327
}
63286328
ndbout << cmdline << endl;
63296329
g_ncc = new Ndb_cluster_connection();
6330+
g_ncc->configure_tls(opt_tls_search_path, opt_mgm_tls);
63306331
if (g_ncc->connect(30) != 0 || testmain() == -1 || testperf() == -1) {
63316332
ndbout << "line " << __LINE__ << " FAIL loop=" << g_loop << endl;
63326333
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/testDataBuffers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ int main(int argc, char** argv)
628628
unsigned ok = true;
629629

630630
Ndb_cluster_connection con;
631+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
631632
if(con.connect(12, 5, 1))
632633
{
633634
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/testDeadlock.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ int main(int argc, char** argv)
513513
}
514514

515515
Ndb_cluster_connection con;
516+
con.configure_tls(opt_tls_search_path, opt_mgm_tls);
516517
if(con.connect(12, 5, 1) != 0)
517518
{
518519
return NDBT_ProgramExit(NDBT_FAILED);

storage/ndb/test/ndbapi/testIndex.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <NdbSqlUtil.hpp>
3636
#include <BlockNumbers.h>
3737
#include "portlib/NdbSleep.h"
38+
#include "util/TlsKeyManager.hpp"
3839

3940
#define CHECK(b) if (!(b)) { \
4041
g_err << "ERR: "<< step->getName() \
@@ -2687,6 +2688,9 @@ runBug56829(NDBT_Context* ctx, NDBT_Step* step)
26872688
const int rows = ctx->getNumRecords();
26882689
const char* mgm = 0;//XXX ctx->getRemoteMgm();
26892690

2691+
TlsKeyManager tlsKeyManager;
2692+
tlsKeyManager.init_mgm_client(opt_tls_search_path);
2693+
26902694
char tabname[100];
26912695
strcpy(tabname, tab.getName());
26922696
char indname[100];
@@ -2711,7 +2715,8 @@ runBug56829(NDBT_Context* ctx, NDBT_Step* step)
27112715
{
27122716
CHECK2((h = ndb_mgm_create_handle()) != 0, "mgm: failed to create handle");
27132717
CHECK2(ndb_mgm_set_connectstring(h, mgm) == 0, ndb_mgm_get_latest_error_msg(h));
2714-
CHECK2(ndb_mgm_connect(h, 0, 0, 0) == 0, ndb_mgm_get_latest_error_msg(h));
2718+
ndb_mgm_set_ssl_ctx(h, tlsKeyManager.ctx());
2719+
CHECK2(ndb_mgm_connect_tls(h, 0, 0, 0, opt_mgm_tls) == 0, ndb_mgm_get_latest_error_msg(h));
27152720
g_info << "mgm: connected to " << (mgm ? mgm : "default") << endl;
27162721

27172722
// make bitmask of DB nodes

storage/ndb/test/ndbapi/testIndexStat.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,6 +2144,7 @@ doconnect()
21442144
{
21452145
g_ncc = new Ndb_cluster_connection();
21462146
require(g_ncc != 0);
2147+
g_ncc->configure_tls(opt_tls_search_path, opt_mgm_tls);
21472148
chkdb(g_ncc->connect(30) == 0);
21482149
g_ndb = new Ndb(g_ncc, "TEST_DB");
21492150
require(g_ndb != 0);

storage/ndb/test/ndbapi/testLcp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ static int parse_args(int argc, char** argv)
271271
static int connect_ndb()
272272
{
273273
g_cluster_connection = new Ndb_cluster_connection();
274+
g_cluster_connection->configure_tls(opt_tls_search_path, opt_mgm_tls);
274275
if(g_cluster_connection->connect(12, 5, 1) != 0)
275276
{
276277
return 1;

0 commit comments

Comments
 (0)