Skip to content

Commit

Permalink
[fix][client] Fix authentication not update after changing the servic…
Browse files Browse the repository at this point in the history
…eUrl (apache#19510)
  • Loading branch information
hangc0276 authored Feb 14, 2023
1 parent aa63a55 commit 0f025f3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void updateServiceUrl(String target,
}

pulsarClient.updateServiceUrl(target);
pulsarClient.reloadLookUp();
currentPulsarServiceUrl = target;
} catch (IOException e) {
log.error("Current Pulsar service is {}, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void initialize(PulsarClient client) {
}

pulsarClient.updateServiceUrl(serviceUrl);
pulsarClient.reloadLookUp();
currentPulsarServiceUrl = serviceUrl;
currentControlledConfiguration = controlledConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,14 @@ public void testAutoClusterFailoverSwitchWithAuthentication() throws IOException
autoClusterFailover.initialize(pulsarClient);

Awaitility.await().untilAsserted(() -> assertEquals(autoClusterFailover.getServiceUrl(), secondary));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateTlsTrustCertsFilePath(secondaryTlsTrustCertsFilePath);
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateAuthentication(secondaryAuthentication);

// primary cluster came back
Mockito.doReturn(true).when(autoClusterFailover).probeAvailable(primary);
Awaitility.await().untilAsserted(() -> assertEquals(autoClusterFailover.getServiceUrl(), primary));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateTlsTrustCertsFilePath(primaryTlsTrustCertsFilePath);
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateAuthentication(primaryAuthentication);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void testControlledClusterFailoverSwitch() throws IOException {

Awaitility.await().untilAsserted(() ->
Assert.assertEquals(backupServiceUrlV1, controlledClusterFailover.getServiceUrl()));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateServiceUrl(backupServiceUrlV1);
Mockito.verify(pulsarClient, Mockito.atLeastOnce())
.updateTlsTrustCertsFilePath(tlsTrustCertsFilePathV1);
Expand Down

0 comments on commit 0f025f3

Please sign in to comment.