Skip to content

Commit e5d5c2b

Browse files
committed
PROTON-2916: Speed up c++ reconnect test
We were using bad names to make name lookup fail - these were valid top level domains and caused the full name lookup timeout for them to fail. Changing these absent names to use the .invalid domain which is reverved for non existent names makes the test run much faster.
1 parent 8888889 commit e5d5c2b

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

cpp/src/reconnect_test.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class stop_reconnect_tester : public proton::messaging_handler {
273273

274274
void on_container_start(proton::container &c) override {
275275
proton::reconnect_options reconnect_options;
276-
c.connect("this-is-not-going-to work.com", proton::connection_options().reconnect(reconnect_options));
276+
c.connect("this-is-not-going-to work.invalid", proton::connection_options().reconnect(reconnect_options));
277277
c.schedule(proton::duration::SECOND, proton::make_work(&stop_reconnect_tester::deferred_stop, this));
278278
}
279279

@@ -381,32 +381,32 @@ class test_reconnect_url : public proton::messaging_handler {
381381
void on_container_start(proton::container &c) override {
382382
// Never actually connects, keeps re-trying to bogus hostnames with
383383
// changing options.
384-
c.connect("nosuchhost0",
384+
c.connect("nosuchhost0.invalid",
385385
copts()
386386
.reconnect(ropts())
387387
.virtual_host("vhost0")
388388
.user("user0")
389-
.reconnect_url("hahaha1"));
389+
.reconnect_url("hahaha1.invalid"));
390390
}
391391

392392
void on_transport_error(proton::transport &t) override {
393393
switch (++errors_) {
394394
case 1:
395-
ASSERT_SUBSTRING("nosuchhost0", t.error().what()); // First failure
395+
ASSERT_SUBSTRING("nosuchhost0.invalid", t.error().what()); // First failure
396396
break;
397397
case 2: {
398-
ASSERT_SUBSTRING("hahaha1",t.error().what()); // Second failure
398+
ASSERT_SUBSTRING("hahaha1.invalid",t.error().what()); // Second failure
399399
ASSERT_EQUAL("user0", t.connection().user());
400400
break;
401401
}
402402
case 3:
403-
ASSERT_SUBSTRING("hahaha1", t.error().what()); // Still trying reconnect url
404-
t.connection().update_options(copts().reconnect_url("nosuchhost1"));
403+
ASSERT_SUBSTRING("hahaha1.invalid", t.error().what()); // Still trying reconnect url
404+
t.connection().update_options(copts().reconnect_url("nosuchhost1.invalid"));
405405
// Verify changing reconnect options does not affect other options.
406406
ASSERT_EQUAL("user0", t.connection().user());
407407
break;
408408
case 4:
409-
ASSERT_SUBSTRING("nosuchhost1", t.error().what()); // Re-try new reconnect url
409+
ASSERT_SUBSTRING("nosuchhost1.invalid", t.error().what()); // Re-try new reconnect url
410410
break;
411411
default:
412412
t.connection().container().stop();
@@ -436,35 +436,35 @@ class test_reconnect_update_failover : public proton::messaging_handler {
436436
void on_container_start(proton::container &c) override {
437437
// Never actually connects, keeps re-trying to bogus hostnames with
438438
// changing options.
439-
c.connect("nosuchhost0", copts().reconnect(ropts()).virtual_host("vhost0").user("user0"));
439+
c.connect("nosuchhost0.invalid", copts().reconnect(ropts()).virtual_host("vhost0").user("user0"));
440440
}
441441

442442
void on_transport_error(proton::transport &t) override {
443443
switch (++errors_) {
444444
case 1:
445-
ASSERT_SUBSTRING("nosuchhost0", t.error().what()); // First failure
445+
ASSERT_SUBSTRING("nosuchhost0.invalid", t.error().what()); // First failure
446446
break;
447447
case 2: {
448-
ASSERT_SUBSTRING("nosuchhost0",t.error().what()); // Second failure
448+
ASSERT_SUBSTRING("nosuchhost0.invalid",t.error().what()); // Second failure
449449
std::vector<std::string> urls;
450-
urls.push_back("nosuchhost1");
450+
urls.push_back("nosuchhost1.invalid");
451451
// Update the failover list
452452
t.connection().update_options(copts().failover_urls(urls));
453453
// Verify changing reconnect options does not affect other options.
454454
ASSERT_EQUAL("user0", t.connection().user());
455455
break;
456456
}
457457
case 3:
458-
ASSERT_SUBSTRING("nosuchhost1", t.error().what()); // Using failover host
458+
ASSERT_SUBSTRING("nosuchhost1.invalid", t.error().what()); // Using failover host
459459
// Change a non-reconnect option should not affect reconnect
460460
t.connection().update_options(copts().user("user1"));
461461
break;
462462
case 4:
463-
ASSERT_SUBSTRING("nosuchhost0", t.error().what()); // Back to original url
463+
ASSERT_SUBSTRING("nosuchhost0.invalid", t.error().what()); // Back to original url
464464
ASSERT_EQUAL("user1", t.connection().user());
465465
break;
466466
case 5:
467-
ASSERT_SUBSTRING("nosuchhost1", t.error().what()); // Still have failover
467+
ASSERT_SUBSTRING("nosuchhost1.invalid", t.error().what()); // Still have failover
468468
break;
469469
default:
470470
t.connection().container().stop();
@@ -493,40 +493,40 @@ class test_reconnect_update_simple : public proton::messaging_handler {
493493
void on_container_start(proton::container &c) override {
494494
// Never actually connects, keeps re-trying to bogus hostnames with
495495
// changing options.
496-
c.connect("nosuchhost0", copts().reconnect(ropts()).virtual_host("vhost0").user("user0"));
496+
c.connect("nosuchhost0.invalid", copts().reconnect(ropts()).virtual_host("vhost0").user("user0"));
497497
}
498498

499499
void on_transport_error(proton::transport &t) override {
500500
switch (++errors_) {
501501
case 1:
502-
ASSERT_SUBSTRING("nosuchhost0", t.error().what()); // First failure
502+
ASSERT_SUBSTRING("nosuchhost0.invalid", t.error().what()); // First failure
503503
break;
504504
case 2: {
505-
ASSERT_SUBSTRING("nosuchhost0",t.error().what()); // Second failure
506-
t.connection().update_options(copts().reconnect_url("nosuchhost1"));
505+
ASSERT_SUBSTRING("nosuchhost0.invalid",t.error().what()); // Second failure
506+
t.connection().update_options(copts().reconnect_url("nosuchhost1.invalid"));
507507
// Verify changing reconnect options does not affect other options.
508508
ASSERT_EQUAL("user0", t.connection().user());
509509
break;
510510
}
511511
case 3:
512-
ASSERT_SUBSTRING("nosuchhost1", t.error().what()); // Re-try original
513-
t.connection().update_options(copts().reconnect_url("notsuchahostatall"));
512+
ASSERT_SUBSTRING("nosuchhost1.invalid", t.error().what()); // Re-try original
513+
t.connection().update_options(copts().reconnect_url("notsuchahostatall.invalid"));
514514
break;
515515
case 4:
516-
ASSERT_SUBSTRING("notsuchahostatall", t.error().what()); // Re-try new reconnect url
516+
ASSERT_SUBSTRING("notsuchahostatall.invalid", t.error().what()); // Re-try new reconnect url
517517
break;
518518
case 5:
519-
ASSERT_SUBSTRING("notsuchahostatall", t.error().what()); // Re-try new reconnect url
519+
ASSERT_SUBSTRING("notsuchahostatall.invalid", t.error().what()); // Re-try new reconnect url
520520
// Change a non-reconnect option should not affect reconnect
521521
t.connection().update_options(copts().user("user1"));
522522
break;
523523
case 6:
524-
ASSERT_SUBSTRING("notsuchahostatall", t.error().what()); // Same reconnect url
524+
ASSERT_SUBSTRING("notsuchahostatall.invalid", t.error().what()); // Same reconnect url
525525
ASSERT_EQUAL("user1", t.connection().user());
526-
t.connection().update_options(copts().reconnect_url("nosuchhost1"));
526+
t.connection().update_options(copts().reconnect_url("nosuchhost1.invalid"));
527527
break;
528528
case 7:
529-
ASSERT_SUBSTRING("nosuchhost1", t.error().what());
529+
ASSERT_SUBSTRING("nosuchhost1.invalid", t.error().what());
530530
break;
531531
default:
532532
t.connection().container().stop();

0 commit comments

Comments
 (0)