/* * The contents of this file are subject to the terms of the Common Development and * Distribution License (the License). You may not use this file except in compliance with the * License. * * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the * specific language governing permission and limitations under the License. * * When distributing Covered Software, include this CDDL Header Notice in each file and include * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL * Header, with the fields enclosed by brackets [] replaced by your own identifying * information: "Portions copyright [year] [name of copyright owner]". * * Copyright 2026 3A Systems, LLC. */ package org.opends.server.replication; import static org.assertj.core.api.Assertions.assertThat; import static org.opends.messages.ReplicationMessages.*; import java.util.List; import org.forgerock.opendj.ldap.DN; import org.opends.server.TestCaseUtils; import org.opends.server.replication.common.ServerState; import org.opends.server.replication.plugin.DomainFakeCfg; import org.opends.server.replication.plugin.DummyReplicationDomain; import org.opends.server.replication.service.ReplicationBroker; import org.testng.annotations.Test; /** * Tests what a directory server logs when it cannot connect to any replication server. */ @SuppressWarnings("javadoc") public class ReplicationBrokerConnectFailureTest extends ReplicationTestCase { /** * Tests that a directory server which reaches no replication server at all names the * reason it reached none. *
* The cause is built for every replication server contacted, but it used to be logged
* only for the elected one, and no server is ever elected when none of them answers: a
* rejected certificate, a refused connection and a wrong port then all read as "unable
* to connect to any replication servers".
*/
@Test
public void aBrokerWhichReachesNoReplicationServerNamesTheCause() throws Exception
{
TestCaseUtils.startServer();
final DN baseDN = DN.valueOf(TestCaseUtils.TEST_ROOT_DN_STRING);
final int serverId = 4021;
// Free, and left free: nothing must listen on it for this test to be about a failure.
final int deadPort = TestCaseUtils.findFreePorts(1)[0];
final String deadServer = "127.0.0.1:" + deadPort;
final DomainFakeCfg config = newFakeCfg(baseDN, serverId, deadPort);
final ReplicationBroker broker = new ReplicationBroker(
new DummyReplicationDomain(0), new ServerState(), config, getReplSessionSecurity());
try
{
final List